mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
366122cd33
3 changed files with 38 additions and 22 deletions
|
@ -7,24 +7,35 @@
|
|||
<script type="text/javascript">var root = '../../'</script>
|
||||
<script type="text/javascript" src="../../src/load.js"></script>
|
||||
<script type="text/paperscript" canvas="canvas">
|
||||
document.currentStyle.fillColor = 'black';
|
||||
var raster = new Raster('lenna');
|
||||
var raster = new Raster('lenna'),
|
||||
size = new Size(50, 50),
|
||||
colSize = raster.size / size * 1.5,
|
||||
fullSize = size * colSize;
|
||||
|
||||
raster.hidden = true;
|
||||
var size = new Size(50, 50);
|
||||
var colSize = raster.size / size * 1.5;
|
||||
raster.size = size;
|
||||
for (var x = 0; x < size.width; x++) {
|
||||
for (var y = 0; y < size.height; y++) {
|
||||
var gray = raster.getPixel(x, y).gray * 0.9;
|
||||
var color = raster.getPixel(x, y),
|
||||
gray = color.gray * 0.9;
|
||||
if (gray > 0.1) {
|
||||
var pos = new Point(x, y) * colSize + colSize / 2;
|
||||
var rectSize = gray * colSize.width;
|
||||
var path = new Path.Rectangle([0, 0], [rectSize, rectSize]);
|
||||
var pos = new Point(x, y) * colSize + colSize / 2,
|
||||
rectSize = gray * colSize.width,
|
||||
path = new Path.Rectangle([0, 0], [rectSize, rectSize]);
|
||||
path.fillColor = color;
|
||||
path.position = pos;
|
||||
path.rotate(gray * 180);
|
||||
}
|
||||
}
|
||||
}
|
||||
document.activeLayer.position = document.bounds.center;
|
||||
|
||||
// Reposition the paths whenever the window is resized:
|
||||
DomEvent.add(window, {
|
||||
resize: function(event) {
|
||||
document.activeLayer.position = document.bounds.center;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -458,14 +458,16 @@ var Item = this.Item = Base.extend({
|
|||
y1 = x1,
|
||||
y2 = x2;
|
||||
for (var i = 0, l = children.length; i < l; i++) {
|
||||
var child = children[i],
|
||||
rect = includeStroke
|
||||
? child.getStrokeBounds()
|
||||
: child.getBounds();
|
||||
x1 = Math.min(rect.x, x1);
|
||||
y1 = Math.min(rect.y, y1);
|
||||
x2 = Math.max(rect.x + rect.width, x2);
|
||||
y2 = Math.max(rect.y + rect.height, y2);
|
||||
var child = children[i];
|
||||
if (child.visible) {
|
||||
var rect = includeStroke
|
||||
? child.getStrokeBounds()
|
||||
: child.getBounds();
|
||||
x1 = Math.min(rect.x, x1);
|
||||
y1 = Math.min(rect.y, y1);
|
||||
x2 = Math.max(rect.x + rect.width, x2);
|
||||
y2 = Math.max(rect.y + rect.height, y2);
|
||||
}
|
||||
}
|
||||
return includeStroke
|
||||
? Rectangle.create(x1, y1, x2 - x1, y2 - y1)
|
||||
|
|
|
@ -154,15 +154,18 @@ var PaperScript = this.PaperScript = new function() {
|
|||
DomEvent.requestAnimationFrame(frame, doc && doc.canvas);
|
||||
onFrame();
|
||||
// Automatically redraw document each frame.
|
||||
doc && doc.redraw();
|
||||
}
|
||||
DomEvent.requestAnimationFrame(frame, doc && doc.canvas);
|
||||
if (doc)
|
||||
doc.redraw();
|
||||
};
|
||||
// Call the onFrame handler and redraw the document:
|
||||
frame();
|
||||
} else {
|
||||
// Automatically redraw document at the end.
|
||||
if (doc)
|
||||
doc.redraw();
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
// Automatically redraw document at the end.
|
||||
if (doc)
|
||||
doc.redraw();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue