aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2018-10-27 12:56:46 +0000
committers-ol <s-ol@users.noreply.github.com>2018-10-27 12:56:46 +0000
commit29a3ad9c26017b1578062706b6da9282977b6ad2 (patch)
tree8e7b51e9564a0ccd0b83e0cf3607c0b2501a9517
parentmmmfs browser etc (diff)
downloadmmm-29a3ad9c26017b1578062706b6da9282977b6ad2.tar.gz
mmm-29a3ad9c26017b1578062706b6da9282977b6ad2.zip
pause twisted preview
-rw-r--r--app/mmmfs/tree.moon6
-rw-r--r--app/mmmfs/twisted.moon15
-rw-r--r--lib/canvasapp.client.moon9
3 files changed, 19 insertions, 11 deletions
diff --git a/app/mmmfs/tree.moon b/app/mmmfs/tree.moon
index b90d8cd..e058b85 100644
--- a/app/mmmfs/tree.moon
+++ b/app/mmmfs/tree.moon
@@ -242,9 +242,5 @@ and some bold **text** and `code tags` with me.",
}
-- if we are on client (mmm.s-ol.nu/?client=mmmfs), throw in twisted as a child
- if MODE == 'CLIENT' then Fileder {
- 'name: alpha': 'twisted',
- 'title: text/plain': "canvas animation that doesn't quite fit",
- 'preview: moon -> mmm/component': => require '.twisted'
- }
+ if MODE == 'CLIENT' then require '.twisted'
}
diff --git a/app/mmmfs/twisted.moon b/app/mmmfs/twisted.moon
index c2f805b..ec3fa83 100644
--- a/app/mmmfs/twisted.moon
+++ b/app/mmmfs/twisted.moon
@@ -7,8 +7,12 @@ class TwistedDemo extends CanvasApp
width: 500
height: 400
length: math.pi * 4
- new: =>
- super true
+ 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) =>
@@ -35,3 +39,10 @@ class TwistedDemo extends CanvasApp
draw 1
TwistedDemo!
+
+Fileder {
+ 'name: alpha': 'twisted',
+ 'title: text/plain': "canvas animation with static preview",
+ 'preview: moon -> mmm/component': => TwistedDemo true
+ 'moon -> mmm/component': => TwistedDemo!
+}
diff --git a/lib/canvasapp.client.moon b/lib/canvasapp.client.moon
index a6467f2..38cc307 100644
--- a/lib/canvasapp.client.moon
+++ b/lib/canvasapp.client.moon
@@ -19,14 +19,15 @@ class CanvasApp
lastMillis = window.performance\now!
animationFrame = (_, millis) ->
+ @update (millis - lastMillis) / 1000
+ @ctx\resetTransform!
+ @draw!
+ lastMillis = millis
+
if not @paused
- @update (millis - lastMillis) / 1000
- @ctx\resetTransform!
- @draw!
window\setTimeout (->
window\requestAnimationFrame animationFrame
), 0
- lastMillis = millis
window\requestAnimationFrame animationFrame
@node = if show_menu