Skip to content

Instantly share code, notes, and snippets.

@toomasv
Created February 20, 2018 04:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toomasv/801e0d27372174b55866a2c0451291e9 to your computer and use it in GitHub Desktop.
Save toomasv/801e0d27372174b55866a2c0451291e9 to your computer and use it in GitHub Desktop.
Exercise in curve animation
Red [
Author: "Toomas Vooglaid"
Purpose: "Exercise in animation"
Date: 2018-2-19
]
system/view/auto-sync?: off
t: 0
view/tight [
box 200x200 all-over cursor hand
draw [crv: curve 100x50 100x125 100x200 flr: translate 0x0 [rotate 0 100x50 fill-pen red polygon 100x50 95x48 90x35 97x40 100x30 103x40 110x35 105x48]]
all-over
on-down [
face/rate: none
show face
]
on-over [
if event/down? [
crv/2: event/offset
flr/2: event/offset - 100x50 ;
diff: crv/2 - crv/3
flr/3/2: 180 / pi * (arctangent2 diff/y diff/x) + 90
]
show face
]
on-up [
d: 100x50 - crv/2
dst: max absolute d/x absolute d/y
face/rate: 25 show face
]
on-time [
d: 100x50 - crv/2
crv/2/x: crv/2/x + dx: round/to d/x / to-float dst 1
crv/2/y: crv/2/y + dy: round/to d/y / to-float dst 1
flr/2/x: flr/2/x + dx
flr/2/y: flr/2/y + dy
diff: crv/2 - crv/3
flr/3/2: 180 / pi * (arctangent2 diff/y diff/x) + 90
dst: dst - 1
if dst = 0 [face/rate: none]
show face
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment