diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2018-11-06 05:55:32 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2018-11-06 05:57:09 +0000 |
| commit | 5be83254486bef58f85f43dba719b674f0c3bc92 (patch) | |
| tree | 519608d655497a60e47202504aaed6bd98655717 /root/animations/twisted | |
| parent | mmm.component fix (diff) | |
| download | mmm-5be83254486bef58f85f43dba719b674f0c3bc92.tar.gz mmm-5be83254486bef58f85f43dba719b674f0c3bc92.zip | |
implement mmmfs on real fs
Diffstat (limited to 'root/animations/twisted')
| -rw-r--r-- | root/animations/twisted/description: text$plain | 1 | ||||
| -rw-r--r-- | root/animations/twisted/text$moonscript -> mmm$component.moon | 43 |
2 files changed, 44 insertions, 0 deletions
diff --git a/root/animations/twisted/description: text$plain b/root/animations/twisted/description: text$plain new file mode 100644 index 0000000..bbd63be --- /dev/null +++ b/root/animations/twisted/description: text$plain @@ -0,0 +1 @@ +pseudo-3d twisting pyramid diff --git a/root/animations/twisted/text$moonscript -> mmm$component.moon b/root/animations/twisted/text$moonscript -> mmm$component.moon new file mode 100644 index 0000000..3fd11b0 --- /dev/null +++ b/root/animations/twisted/text$moonscript -> mmm$component.moon @@ -0,0 +1,43 @@ +assert MODE == 'CLIENT', '[nossr]' +import CanvasApp from require 'mmm.canvasapp' +import hsl from require 'mmm.color' + +Math = window.Math + +class TwistedDemo extends CanvasApp + width: 500 + height: 400 + length: math.pi * 4 + new: (preview) => + if preview + @width, @height = 120, 120 + super false, true + else + super true + @background = {Math.random!, Math.random!/3+.2, Math.random!/4} + hue = Math.random! + @shades = setmetatable {}, __index: (key) => + with val = { hue, .7, key * .3 + .1} do rawset @, key, val + + draw: => + @ctx.fillStyle = hsl @background + @ctx\fillRect 0, 0, @width, @height + @ctx\translate @width/2, @height/2 + 70 + + draw = (i) -> + @ctx\save! + @ctx\translate 0, -120*i + s = 1 - 0.1 * math.sin @time + i*2 + s *= 0.8 - i * .4 * math.cos @time + @ctx\scale s, s/2 + @ctx\rotate @time/4 + i * .6 * math.cos @time + @ctx.fillStyle = hsl table.unpack @shades[i] + @ctx\fillRect -80, -80, 160, 160 + @ctx\restore! + + for i=0,1,1/(20 + 19 * math.sin(@time / 2)) + draw i + draw 1 + +-- .props['preview: fn -> mmm/component'] = => TwistedDemo true +TwistedDemo! |
