git.s-ol.nu alive / d2027cd
examples: more smoothing in love example :) s-ol 6 months ago
1 changed file(s) with 11 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
22 The size changes when the left mouse button is held, and the color
33 changes when space is pressed.
44 )
5 ([1]import* love math time)
5 ([1]import* love math time array-)
66
7 ([32]trace ([33]mouse-releases))
8
9 #(cycle colors when space is prssed)
10 ([20]def fill-color
11 ([21]switch ([22]key-presses "space")
7 ([20]def
8 #(cycle colors when space is pressed)
9 fill-color ([21]switch ([22]key-presses "space")
1210 ([23]array 0.3 0 0.9)
1311 ([24]array 0 0.9 0.3)
1412 ([27]array 0.9 0.3 0)
1513 ([28]array 0.3 0.9 0)
1614 ([30]array 0 0.3 0.9)
17 ([31]array 0.9 0 0.3)))
15 ([31]array 0.9 0 0.3))
16
17 #(smooth out rgb channels individually)
18 smooth-color ([36]map fill-color
19 ([32]fn (i) ([33]smooth 0.1 i))))
1820
1921 ([2]draw ([3]->>
2022 ([8]rectangle 'fill' 100 100)
21 ([14]color fill-color)
22 ([15]scale ([16]switch ([17]mouse-down? 1) 0.5 1))
23 ([14]color smooth-color)
24 ([15]scale ([34]smooth 0.2 ([16]switch ([17]mouse-down? 1) 0.5 1)))
2325 ([5]rotate ([9]ramp 2 tau)) #(rotate tau (2*PI) every 2 seconds)
2426 ([4]translate ([10]mouse-pos) #(move to mouse cursor)
2527 )))