From faf9b453d16b39e387277d2bfd09a72e91d4ba68 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Sun, 19 Jun 2011 03:43:47 +0200 Subject: [PATCH] Clean up the PhyllotaxisRaster example and use Item#fitBounds instead of stretching the image. --- examples/Scripts/PhyllotaxisRaster.html | 28 ++++++++++--------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/examples/Scripts/PhyllotaxisRaster.html b/examples/Scripts/PhyllotaxisRaster.html index 2817c4f5..246c9784 100644 --- a/examples/Scripts/PhyllotaxisRaster.html +++ b/examples/Scripts/PhyllotaxisRaster.html @@ -17,25 +17,19 @@ amount: 200 }; // Create a raster object, using the image - var originalRaster = new Raster('sunflower'); - // Stretch the image to fit exactly into the view - originalRaster.bounds = view.bounds; - originalRaster.visible = false; - rasterizeImage(); + var raster = new Raster('sunflower'); + + // Transform the raster so it fills the bounding rectangle + // of the view: + raster.fitBounds(view.bounds, true); + + // Hide the raster: + raster.visible = false; // Create the group of circle shaped paths and scale it up a bit: var group = createPhyllotaxis(values.amount); group.scale(3); - function rasterizeImage() { - // Stretch the image to fit exactly into the view - originalRaster.bounds = view.bounds; - if (raster) - raster.remove(); - raster = originalRaster.rasterize(); - raster.visible = false; - } - function createPhyllotaxis(amount) { var group = new Group(); // The Golden Angle (http://en.wikipedia.org/wiki/Golden_angle) @@ -71,10 +65,10 @@ position = event.point; } - // Whenever the window is resized, - // we need to rerasterize the image: + // Whenever the window is resized, we need to fit the raster + // in the bounding rectangle of the view again: function onResize() { - rasterizeImage(); + raster.fitBounds(view.bounds, true); } function onFrame(event) {