Here are some spare snowflakes, plenty of them in Sweden!
Something very similar was written in n6 many years ago.
Something very similar was written in n6 many years ago.
Code:
' Snowflakes
' ----------
include "list.n7"
#win32
constant BG_R = 16, BG_G = 24, BG_B = 64
set window "Snowflakes", 480*screenw()/screenh(), 480, true
set redraw off
snowflakeImage = loadimage("snowflake.png")
stars = List()
for i = 1 to 200 stars.Add([x: rnd()*2 - 1, y: rnd()*2 - 1, z: 0.1 + rnd()*0.9])
set color BG_R, BG_G, BG_B
cls
do
for i = 0 to stars.size - 1
s = stars[i]
s.z = s.z - 0.01
if s.z < 0.1
s.z = s.z + 0.9
s.x = rnd()*2 - 1
s.y = rnd()*2 - 1
endif
next
stars.Sort(function(a, b)
return b.z - a.z
endfunc)
set color BG_R, BG_G, BG_B, 96
cls
wp = width(primary)/2
hp = height(primary)/2
for i = 0 to stars.size - 1
s = stars[i]
x = wp + s.x*wp/s.z*0.75
y = hp + s.y*hp/s.z*0.75
size = 16/s.z
set color BG_R, BG_G, BG_B, s.z*255
DrawScaledImage(snowflakeImage, x - size/2, y - size/2, size, size)
next
fwait 60
redraw
until keydown(KEY_ESCAPE) or mousebutton(0)
function DrawScaledImage(img, x, y, w, h)
du = 1/w
u = 0
for dx = 0 to w - 1
draw vraster img, x + dx, y, y + h - 1, u, 0, u, 1
u = u + du
next
endfunc