From 49510f78fc2fff6f4a34b26755a27ed91e55d5b7 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Thu, 5 May 2011 18:40:10 +0100 Subject: [PATCH] Adjust examples to work nicely when the browser window is resized. --- examples/Animated/Flock.html | 2 +- examples/Animated/RadialRainbows.html | 17 ++++++++++--- examples/Animated/Smoothing.html | 36 +++++++++++++++++++-------- examples/Animated/animatedStar.html | 12 ++++++--- 4 files changed, 50 insertions(+), 17 deletions(-) diff --git a/examples/Animated/Flock.html b/examples/Animated/Flock.html index 165ec8bd..01e9dafe 100644 --- a/examples/Animated/Flock.html +++ b/examples/Animated/Flock.html @@ -10,7 +10,7 @@ // Adapted from Flocking Processing example by Daniel Schiffman: // http://processing.org/learning/topics/flocking.html - // Resize the document, whenever the window is resized, + // Reposition the heart path whenever the window is resized: Event.add(window, { resize: function(event) { size = document.size; diff --git a/examples/Animated/RadialRainbows.html b/examples/Animated/RadialRainbows.html index 1abe9f96..2a97b3ce 100644 --- a/examples/Animated/RadialRainbows.html +++ b/examples/Animated/RadialRainbows.html @@ -7,7 +7,6 @@ diff --git a/examples/Animated/Smoothing.html b/examples/Animated/Smoothing.html index b60c0c4a..45aa605c 100644 --- a/examples/Animated/Smoothing.html +++ b/examples/Animated/Smoothing.html @@ -7,22 +7,29 @@ diff --git a/examples/Animated/animatedStar.html b/examples/Animated/animatedStar.html index c7011639..6ce446d0 100644 --- a/examples/Animated/animatedStar.html +++ b/examples/Animated/animatedStar.html @@ -12,20 +12,19 @@ var values = { count: 34, points: 32 - } + }; var center = new Point(document.size) / 2; for (var i = 0; i < values.count; i++) { var offset = new Point(20 + 10 * i, 0); var path = new Path(); path.fillColor = i % 2 ? 'red' : 'black'; - //console.log('color', path.fillColor); path.closed = true; var l = offset.length; for (var j = 0; j < values.points * 2; j++) { offset.angle += 360 / values.points; - var vector = offset.clone() + var vector = offset.clone(); vector.length = l * (j % 2 ? 0.1 : -0.1); path.add(offset + vector); } @@ -44,6 +43,13 @@ item.rotate(angle); } } + + // Reposition the paths whenever the window is resized: + Event.add(window, { + resize: function(event) { + document.activeLayer.position = document.bounds.center; + } + });