2011-06-30 21:20:09 -04:00
|
|
|
<!DOCTYPE html>
|
2011-06-18 21:32:07 -04:00
|
|
|
<html>
|
|
|
|
<head>
|
2014-08-16 13:24:54 -04:00
|
|
|
<meta charset="UTF-8">
|
|
|
|
<title>Division Raster</title>
|
|
|
|
<link rel="stylesheet" href="../css/style.css">
|
|
|
|
<script type="text/javascript" src="../../dist/paper-full.js"></script>
|
|
|
|
<script type="text/paperscript" canvas="canvas">
|
2011-06-19 09:18:17 -04:00
|
|
|
// Based on 'JPEG Raster' by Jonathan Puckey:
|
|
|
|
// http://www.flickr.com/photos/puckey/3179779686/in/photostream/
|
|
|
|
|
2015-05-31 04:50:04 -04:00
|
|
|
// Create a raster item using the image with id='mona'
|
2011-06-19 09:18:17 -04:00
|
|
|
var raster = new Raster('mona');
|
|
|
|
|
|
|
|
// Make the raster invisible:
|
|
|
|
raster.visible = false;
|
|
|
|
|
2013-03-09 12:51:04 -05:00
|
|
|
var lastPos = view.center;
|
|
|
|
function moveHandler(event) {
|
2014-08-16 13:24:54 -04:00
|
|
|
if (lastPos.getDistance(event.point) < 10)
|
|
|
|
return;
|
|
|
|
lastPos = event.point;
|
2011-06-19 09:18:17 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
var size = this.bounds.size.clone();
|
|
|
|
var isLandscape = size.width > size.height;
|
2011-06-19 09:18:17 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
// If the path is in landscape orientation, we're going to
|
|
|
|
// split the path horizontally, otherwise vertically:
|
2011-06-19 09:18:17 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
size /= isLandscape ? [2, 1] : [1, 2];
|
2011-06-19 09:18:17 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
var path = new Path.Rectangle({
|
|
|
|
point: this.bounds.topLeft.floor(),
|
|
|
|
size: size.ceil(),
|
|
|
|
onMouseMove: moveHandler
|
|
|
|
});
|
|
|
|
path.fillColor = raster.getAverageColor(path);
|
2011-06-19 09:18:17 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
var path = new Path.Rectangle({
|
|
|
|
point: isLandscape
|
|
|
|
? this.bounds.topCenter.ceil()
|
|
|
|
: this.bounds.leftCenter.ceil(),
|
|
|
|
size: size.floor(),
|
|
|
|
onMouseMove: moveHandler
|
|
|
|
});
|
|
|
|
path.fillColor = raster.getAverageColor(path);
|
2011-06-19 09:18:17 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
this.remove();
|
2011-06-19 09:18:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function onResize(event) {
|
2014-08-16 13:24:54 -04:00
|
|
|
project.activeLayer.removeChildren();
|
2011-06-19 09:18:17 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
// Transform the raster so that it fills the bounding rectangle
|
|
|
|
// of the view:
|
|
|
|
raster.fitBounds(view.bounds, true);
|
2011-06-19 09:18:17 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
// Create a path that fills the view, and fill it with
|
|
|
|
// the average color of the raster:
|
|
|
|
new Path.Rectangle({
|
|
|
|
rectangle: view.bounds,
|
|
|
|
fillColor: raster.getAverageColor(view.bounds),
|
|
|
|
onMouseMove: moveHandler
|
|
|
|
});
|
2011-06-19 09:18:17 -04:00
|
|
|
}
|
2014-08-16 13:24:54 -04:00
|
|
|
</script>
|
2011-06-18 21:32:07 -04:00
|
|
|
</head>
|
|
|
|
<body>
|
2014-08-16 13:24:54 -04:00
|
|
|
<canvas id="canvas" resize></canvas>
|
|
|
|
<img width="512" height="512" id="mona" style="display: none;" src="data:image/jpeg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAAATAAD/4QMraHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8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