Skip to content

Instantly share code, notes, and snippets.

@rebolek
Last active February 23, 2018 17:03
Show Gist options
  • Save rebolek/efc2f02a2636b20421aef49c62f1aa00 to your computer and use it in GitHub Desktop.
Save rebolek/efc2f02a2636b20421aef49c62f1aa00 to your computer and use it in GitHub Desktop.
Live logo
Red[]
frames: [
[
pen 238.172.41
fill-pen 238.172.41 polygon 100x2 86x56 72x42
fill-pen 188.130.45 polygon 100x2 86x56 128x42
pen 212.28.24
fill-pen 212.28.24 polygon 82x72 68x128 36x96 64x54
fill-pen 129.31.34 polygon 82x72 68x128 163x96 136x54
pen 212.28.24
fill-pen 212.28.24 polygon 64x143 50x199 0x147 28x107
fill-pen 129.31.34 polygon 64x143 50x199 199x147 172x107
][
pen 238.172.41
fill-pen 238.172.41 polygon 100x2 114x56 72x42
fill-pen 188.130.45 polygon 100x2 114x56 128x42
pen 212.28.24
fill-pen 212.28.24 polygon 118x72 132x128 36x96 64x54
fill-pen 129.31.34 polygon 118x72 132x128 163x96 136x54
pen 212.28.24
fill-pen 212.28.24 polygon 136x143 150x199 0x147 28x107
fill-pen 129.31.34 polygon 136x143 150x199 199x147 172x107
]
]
anim: [
rate 30
frame frames/1 morph to frame frames/2 in 0:0:1
]
parse-anim: func [
face
dialect
/local value stack
rate-rule
morph-rule
][
stack: copy []
rate-rule: ['rate set value integer! (face/rate: value)]
frame-rule: ['frame set value [block! | word! | path!]]
push-frame: [(
unless block? value [value: get value]
append/only stack value
)]
morph-rule: [
frame-rule
'morph
opt 'to
push-frame
frame-rule
push-frame
'in set value time!
(
frames: face/rate * to integer! value
; create script for morph
repeat index frames [
append/only face/extra/actions bind compose/deep [
face/draw: morph [(stack/1)] [(stack/2)] (frames) (index)
face/extra/action: take face/extra/actions
] face
]
; setup first frame
face/extra/action: take face/extra/actions
)
]
parse dialect [
some [
rate-rule
| morph-rule
]
]
; be nice and stop anim after last frame
append/only face/extra/actions [face/rate: none]
]
src: [
pen 238.172.41
fill-pen 238.172.41 polygon 100x2 86x56 72x42
fill-pen 188.130.45 polygon 100x2 86x56 128x42
pen 212.28.24
fill-pen 212.28.24 polygon 82x72 68x128 36x96 64x54
fill-pen 129.31.34 polygon 82x72 68x128 163x96 136x54
pen 212.28.24
fill-pen 212.28.24 polygon 64x143 50x199 0x147 28x107
fill-pen 129.31.34 polygon 64x143 50x199 199x147 172x107
]
change-pair: func [
source
dest
coef
][
as-pair
dest/x - source/x * coef + source/x
dest/y - source/y * coef + source/y
]
morph: func [
source
dest
steps
step
/local coef out rule mark
][
coef: step / to float! steps
out: copy/deep source
parse out rule: [
some [
ahead block! into rule
| mark: pair! (mark/1: change-pair mark/1 pick dest index? mark coef)
| skip
]
]
out
]
old-time: [
face/extra/step: face/extra/step + 1
if face/extra/step > face/extra/steps [
tmp: src
src: dst
dst: tmp
face/extra/step: 0
]
face/draw: morph src dst face/extra/steps face/extra/step
]
view/no-wait [
canvas: base 200x200 white
on-create [
face/extra: context [
steps: 40
step: 0
actions: copy []
action: none
]
]
on-time [
do reduce [func [face] face/extra/action face]
]
]
parse-anim canvas anim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment