2011-03-06 09:11:18 -05:00
|
|
|
<!-- <!DOCTYPE html> -->
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
|
<title>Example</title>
|
2011-05-05 11:25:17 -04:00
|
|
|
<link rel="stylesheet" href="../css/style.css">
|
2011-06-12 14:03:18 -04:00
|
|
|
<script type="text/javascript" src="../../dist/paper.js"></script>
|
2011-03-06 09:11:18 -05:00
|
|
|
<script type="text/paperscript" canvas="canvas">
|
2011-05-15 06:36:10 -04:00
|
|
|
var raster = new Raster('lenna');
|
|
|
|
var size = new Size(50, 50);
|
|
|
|
var colSize = raster.size / size * 1.5;
|
|
|
|
var fullSize = size * colSize;
|
2011-05-08 12:20:23 -04:00
|
|
|
|
2011-05-19 16:55:51 -04:00
|
|
|
raster.visible = false;
|
2011-03-06 09:11:18 -05:00
|
|
|
raster.size = size;
|
|
|
|
for (var x = 0; x < size.width; x++) {
|
|
|
|
for (var y = 0; y < size.height; y++) {
|
2011-05-15 06:36:10 -04:00
|
|
|
var color = raster.getPixel(x, y);
|
|
|
|
var gray = color.gray * 0.9;
|
2011-05-03 03:55:01 -04:00
|
|
|
if (gray > 0.1) {
|
2011-05-15 06:36:10 -04:00
|
|
|
var pos = new Point(x, y) * colSize + colSize / 2;
|
|
|
|
var rectSize = gray * colSize.width;
|
|
|
|
var path = new Path.Rectangle([0, 0], [rectSize, rectSize]);
|
2011-05-08 12:20:23 -04:00
|
|
|
path.fillColor = color;
|
2011-03-06 09:11:18 -05:00
|
|
|
path.position = pos;
|
|
|
|
path.rotate(gray * 180);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-05-16 08:33:15 -04:00
|
|
|
project.activeLayer.position = view.center;
|
2011-05-08 12:20:23 -04:00
|
|
|
|
|
|
|
// Reposition the paths whenever the window is resized:
|
2011-05-16 07:51:20 -04:00
|
|
|
function onResize(event) {
|
2011-05-16 08:33:15 -04:00
|
|
|
project.activeLayer.position = view.center;
|
2011-05-16 07:51:20 -04:00
|
|
|
}
|
2011-03-06 09:11:18 -05:00
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
2011-06-29 07:44:06 -04:00
|
|
|
<canvas id="canvas" resize></canvas>
|
2011-05-14 06:04:02 -04:00
|
|
|
<img width="512" height="512" id="lenna" style="display: none;" src="data:image/jpeg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAAAXAAD/4QMraHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjAtYzA2MCA2MS4xMzQ3NzcsIDIwMTAvMDIvMTItMTc6MzI6MDAgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCBDUzUgTWFjaW50b3NoIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOkUxMDE3MzA5NDAwODExRTBCQjkwRDlDMzRBOTRBODAyIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOkUxMDE3MzBBNDAwODExRTBCQjkwRDl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