Scandinavian floor rugs
Posted: Sun Apr 01, 2018 7:26 am
Code: Select all
graphics ! graphics clear 1,1,1
get screen size w,h ! cx=w/2 ! cy=h/2
'
t=20 ' thickness of the fabric
dhue=6 ' speed of color change
'
hue=rnd(360)
draw size t ! dtet=0.01
R=5 ! x=cx ! y=cy ! draw to cx,cy
for tet=0 to 2300/t step dtet
R=5+tet*t/6.2
hue+=rnd(dhue)-dhue/2 ! if hue<0 then hue+=360
pal(hue) ! draw color pal.r,pal.g,pal.b
x=cx+R*cos(tet) ! y=cy+R*sin(tet)
draw line to x,y
next tet
end
' Simple color definition function, based on HSV system
' only HUE factor (h) is required (-> restricted color range)
'
def pal(h)
r=0 ! g=0 ! b=0 ! h%=360
if h<120 or h>240 then r=palsub(abs(h-360*floor(h/240)))
if h<240 then g=palsub(abs(h-120))
if h>120 then b=palsub(abs(h-240))
end def
def palsub(e)
f=.7 ' 0<=f<=1 better balance between prim. and sec. colors
if e<60 then c=1 else ! x=(120-e)/60 ! c=x*(1+f-f*x) ! end if
return c
end def