Liberty BASIC Community Forum
« Paper Snowflake »

Welcome Guest. Please Login or Register.
Aug 16th, 2017, 10:47pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1 2  Notify Send Topic Print
 hotthread  Author  Topic: Paper Snowflake  (Read 751 times)
tsh73
Moderator
ImageImageImageImageImage


member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1680
xx Re: Paper Snowflake
« Reply #7 on: Nov 29th, 2015, 08:48am »

Quote:
Anatoly and John are both teachers.

You just blew our cover!
*ROTFL*

EDIT
quoter from my colleague:
"You should not annoy me, your teacher [that much]. If I bite you you will became teachers yourself!"
(No, I wasn't bitten by a teacher in my youth. Or was I? How could I be sure?!)
« Last Edit: Nov 29th, 2015, 08:51am by tsh73 » User IP Logged

damned Dog in the Manger
Joseph
Board Moderator

member is offline

Avatar

Hello, World!


PM

Gender: Male
Posts: 854
xx Re: Paper Snowflake
« Reply #8 on: Nov 30th, 2015, 05:05am »

Wow, this is incredible. Good job, guys!
User IP Logged

My Personal LB Project Page
Twitter GitHub
My App
Alyce Watson
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Female
Posts: 14915
xx Re: Paper Snowflake
« Reply #9 on: Dec 1st, 2015, 04:52am »

on Nov 29th, 2015, 08:48am, tsh73 wrote:
You just blew our cover!
*ROTFL*

EDIT
quoter from my colleague:
"You should not annoy me, your teacher [that much]. If I bite you you will became teachers yourself!"
(No, I wasn't bitten by a teacher in my youth. Or was I? How could I be sure?!)


Anatoly, as we say in the US, "It takes one to know one." (Retired teacher, here. wink )

This challenge has spawned imaginative graphics programs, both on this thread and on the graphics board. Thanks so much for creating it!
User IP Logged

Alyce
Liberty BASIC Workshop - a complete IDE for Liberty BASIC


Alyce's Restaurant
for Liberty BASIC code, tools and references
tsh73
Moderator
ImageImageImageImageImage


member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1680
xx Re: Paper Snowflake
« Reply #10 on: Dec 1st, 2015, 05:14am »

Quote:
as we say in the US, "It takes one to know one."

Russian is "Fisherman recognizes other Fishermen from afar"
(versed as
rybak rybaka
vidit izdaleka
)
EDIT proverbs could not be translated 100% accurately
sad
Layers of meaning and history makes that impossible.
« Last Edit: Dec 1st, 2015, 05:23am by tsh73 » User IP Logged

damned Dog in the Manger
tenochtitlanuk
Board Moderator

member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1160
xx Re: Paper Snowflake
« Reply #11 on: Dec 1st, 2015, 08:30am »

...and it so happens my surname is 'Fisher'!!
Like Russians, we have lots of names like Smith (Kuznetsov) that come from ancient occupations, but don't have patronymics. That we can compare proverbs is a bit like 'convergence' in evolution. We're all the same 'under the skin'.
User IP Logged

tsh73
Moderator
ImageImageImageImageImage


member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1680
xx Re: Paper Snowflake
« Reply #12 on: Dec 10th, 2015, 2:14pm »

What? No takers?
Here is modification of first one - when I'll need bunch of flakes I'll use this...
Code:
nomainwin
open "Paper Snowflake" for graphics_nsb_nf as #gr
#gr "trapclose [quit]"
#gr "fill black; down; color white"
#gr "size 10"

a=0
' repeat 6 times
for i = 1 to 6
    #gr "home; north; turn ";a
    'draw single "arm" from center
    #gr "go 40"
    #gr "turn 120"
    #gr "go 40"
    #gr "go -40"    'you can go back like this
    #gr "turn -240"
    #gr "go 40"
    #gr "go -40"
    #gr "turn 120"
    #gr "go 40"
    #gr "turn 60"
    #gr "go 40"
    #gr "go -40"    'you can go back like this
    #gr "turn -120"
    #gr "go 40"
    #gr "go -40"
    #gr "turn 60"   'make sure drawing direction is aligned right then you draw further
    #gr "go 40"
    a=a+60  'each arm turned 60 degrees more
next

#gr "flush"
wait

[quit]
close #gr
 

and nice recursive one
Code:
nomainwin
open "Paper Snowflake" for graphics_nsb_nf as #gr
#gr "trapclose [quit]"
#gr "fill black; down; color white"
'#gr "size 15"
#gr "home; posxy cx cy"

call flake cx, cy, 100

#gr "flush"
wait

sub flake cx, cy, r
    if r <1 then exit sub
    ' repeat 6 times
    for i = 0 to 5
        #gr "place ";cx;" ";cy
        #gr "north; turn ";i*60 'recustion breaks current angle, so had to start with North each time
        #gr "go ";r
        #gr "posxy cx1 cy1"
        call flake cx1, cy1, r/3
    next
end sub

[quit]
    close #gr
 
« Last Edit: Dec 10th, 2015, 2:51pm by tsh73 » User IP Logged

damned Dog in the Manger
tsh73
Moderator
ImageImageImageImageImage


member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1680
xx Re: Paper Snowflake
« Reply #13 on: Dec 10th, 2015, 2:54pm »

Quote:
>>when I'll need bunch of flakes

Yeah.
Problems:
1) it takes a lot of CPU - I better use sprites
2) XOR doesn't work with "go 40; go -40" kind of thing
3) they scale really weird :(
Code:
nomainwin
gosub [getSlack]

h=400
w=600
WindowHeight=h+slackY
WindowWidth =w+slackX

UpperLeftX = (DisplayWidth-WindowWidth)/2
UpperLeftY = (DisplayHeight-WindowHeight)/2

open "Snow Lissajous" for graphics_nsb_nf as #gr
#gr "trapclose [quit]"
#gr "down; fill black"
#gr "backcolor black"
#gr "color white"

'call flake 150,150,30
'wait

t=0
dt=0.02
a=7
b=6
n=15
#gr "rule ";_R2_XORPEN
dim x(n), y(n)
timer 150, [nxt]
while 1
    for i = 0 to n
        'draw
        if t >0 then 'clear prevoius
            x=w/2.2*cos(a*(t+i*dt-dt))+w/2
            y=h/2.2*sin(b*(t+i*dt-dt))+h/2
            call flake int(x),int(y),i*1.5
        end if
        'clear with XOR
        x=w/2.2*cos(a*(t+i*dt))+w/2
        y=h/2.2*sin(b*(t+i*dt))+h/2
        call flake int(x),int(y),i*1.5
    next
    wait
[nxt]
    'change t
    t=t+dt
    #gr "discard"
    '#gr "fill black"
wend

#gr "flush"


wait

[quit]
    timer 0
    close #gr
end

[getSlack]
    WindowWidth=200:WindowHeight=200
    open "" for graphics_nsb as #t:#t,"home;posxy x y":close#t
    slackX=WindowWidth-2*x:slackY=WindowHeight-2*y
return

sub flake x0,y0,rr
'#gr "color black"
'#gr "place ";x0;" ";y0;"; circlefilled "; rr+2
'#gr "color white"
a=0
r=int(rr/3)
' repeat 6 times
for i = 1 to 6
    #gr "place ";x0;" ";y0
    #gr "north; turn ";a
    'draw single "arm" from center
    #gr "go ";r
    #gr "posxy x y" 'store point
    #gr "turn 120"
    #gr "go ";r
    #gr "place ";x;" ";y    'restore point
    #gr "turn -120"
    #gr "go ";r
    #gr "posxy x y" 'store point
    #gr "turn 60"
    #gr "go ";r
    #gr "place ";x;" ";y    'restore point
    #gr "turn -120"
    #gr "go ";r
    #gr "place ";x;" ";y    'restore point
    #gr "turn 60"   'make sure drawing direction is aligned right then you draw further
    #gr "go ";r
    a=a+60  'each arm turned 60 degrees more
next
end sub
 
« Last Edit: Dec 10th, 2015, 2:58pm by tsh73 » User IP Logged

damned Dog in the Manger
tsh73
Moderator
ImageImageImageImageImage


member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1680
xx Re: Paper Snowflake
« Reply #14 on: Dec 11th, 2015, 07:30am »

better scaling
Code:
nomainwin
gosub [getSlack]

h=400
w=600
WindowHeight=h+slackY
WindowWidth =w+slackX

UpperLeftX = (DisplayWidth-WindowWidth)/2
UpperLeftY = (DisplayHeight-WindowHeight)/2

open "Snow Lissajous" for graphics_nsb_nf as #gr
#gr "trapclose [quit]"
#gr "down; fill black"
#gr "backcolor black"
#gr "color white"
#gr "rule ";_R2_XORPEN

'for i = 1 to 15
'    call flake 20+(15-i)*40,150,i*1.5
'next
'for i = 1 to 15
'    call flake2 20+(15-i)*40,200,i*1.5
'next
'#gr "flush"
'wait

t=0
dt=0.02
a=7
b=6
n=15
dim x(n), y(n)
timer 150, [nxt]
while 1
    for i = 0 to n
        'draw
        if t >0 then 'clear prevoius
            x=w/2.2*cos(a*(t+i*dt-dt))+w/2
            y=h/2.2*sin(b*(t+i*dt-dt))+h/2
            call flake int(x),int(y),i*1.5
        end if
        'clear with XOR
        x=w/2.2*cos(a*(t+i*dt))+w/2
        y=h/2.2*sin(b*(t+i*dt))+h/2
        call flake int(x),int(y),i*1.5
    next
    wait
[nxt]
    'change t
    t=t+dt
    #gr "discard"
    '#gr "fill black"
wend

#gr "flush"


wait

[quit]
    timer 0
    close #gr
end

[getSlack]
    WindowWidth=200:WindowHeight=200
    open "" for graphics_nsb as #t:#t,"home;posxy x y":close#t
    slackX=WindowWidth-2*x:slackY=WindowHeight-2*y
return

sub flake x0,y0,rr
'#gr "color black"
'#gr "place ";x0;" ";y0;"; circlefilled "; rr+2
'#gr "color white"
'if rr < 5 then call flake2 x0,y0,rr: exit sub
a=0
r=int(rr/3)
' repeat 6 times
    #gr "place ";x0;" ";y0
    #gr "circle ";r+1
for i = 1 to 6
    'draw single "arm" from center
    #gr "place ";x0;" ";y0
    #gr "north; turn ";a
    #gr "up; go ";int(2/3*rr)
    #gr "posxy x y" 'store point
    #gr "turn 60"
    #gr "down; go ";r
    #gr "place ";x;" ";y    'restore point
    #gr "turn -120"
    #gr "go ";r
    #gr "place ";x0;" ";y0
    #gr "north; turn ";a
    #gr "go ";rr

    a=a+60  'each arm turned 60 degrees more
next
end sub

sub flake2 x0,y0,rr
'#gr "color black"
'#gr "place ";x0;" ";y0;"; circlefilled "; rr+2
'#gr "color white"
a=0
' repeat 6 times
for i = 1 to 6
    #gr "place ";x0;" ";y0
    #gr "north; turn ";a
    'draw single "arm" from center
    #gr "go ";rr
    a=a+60  'each arm turned 60 degrees more
next
#gr "set ";x0;" ";y0
end sub
 
User IP Logged

damned Dog in the Manger
tenochtitlanuk
Board Moderator

member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1160
xx Re: Paper Snowflake
« Reply #15 on: Dec 19th, 2015, 5:58pm »

If anyone else chances on this thread, you could find some fantastic snowflake resources via the Evil Mad Scientists website.
http://www.evilmadscientist.com/2008/vector-snowflake-application/
User Image
It would be a good programming exercise to copy/improve some of the ideas in the programs linked from there.

Merry Xmas everyone.

PS Scientists are not usually mad or evil- at least at the start of their careers!

PPS outputting as a vector file means you can run the output into a CNC foam-sheet cutter, router or w.h.y.
« Last Edit: Dec 19th, 2015, 5:59pm by tenochtitlanuk » User IP Logged

tsh73
Moderator
ImageImageImageImageImage


member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1680
xx Re: Paper Snowflake
« Reply #16 on: Jan 22nd, 2016, 01:08am »

today (Dec 21 2016) Kevin & Kell
User Image wink
User IP Logged

damned Dog in the Manger
tenochtitlanuk
Board Moderator

member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1160
xx Re: Paper Snowflake
« Reply #17 on: Jan 22nd, 2016, 04:08am »

Love that, Anatoly!
Have a great New Year- I really enjoy all your contributions. Snowflakes triggered me off in all sorts of directions.
User IP Logged

tsh73
Moderator
ImageImageImageImageImage


member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1680
xx Re: Paper Snowflake
« Reply #18 on: Jan 22nd, 2016, 06:23am »

I was fiddling with graphical IDE
It started from reply#7 at BEHOLD !! 1st Graphics IDE.. TURTLE STYLE EDIT and evolved a bit on other basic forum.
Anyway, now it reads this
Code:
north
repeat 6
  home
  go 100
  repeat 6
    go 30
    repeat 6
      go 10
      go -10
      turn 60
    loop
    go -30
    turn 60
  loop
  turn 60
loop
 

and produces that:
User Image
User IP Logged

damned Dog in the Manger
tenochtitlanuk
Board Moderator

member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1160
xx Re: Paper Snowflake
« Reply #19 on: Jan 23rd, 2016, 11:12am »

From my other interest- Raspberry Pi and Python!
User Image
User IP Logged

Pages: 1 2  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls