#( This example draws a rotating rectangle that follows the mouse cursor. The size changes when the left mouse button is held, and the color changes when space is pressed. ) ([1]import* love math time array) ([20]def #(cycle colors when space is pressed) fill-color ([21]switch ([22]key-presses "space") [0.3 0 0.9] [0 0.9 0.3] [0.9 0.3 0] [0.3 0.9 0] [0 0.3 0.9] [0.9 0 0.3]) #(smooth out rgb channels individually) smooth-color ([36]map fill-color ([32]fn (i) ([33]smooth 0.1 i)))) ([2]draw ([3]->> ([8]rectangle 'fill' 100 100) ([14]color smooth-color) ([15]scale ([34]smooth 0.2 ([16]switch ([17]mouse-down? 1) 0.5 1))) ([5]rotate ([9]ramp 2 tau)) #(rotate tau (2*PI) every 2 seconds) ([4]translate ([10]mouse-pos)) #(move to mouse cursor) ))