mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-28 17:02:24 -05:00
Add Layer & Group script tags to Examples
This commit is contained in:
parent
62409a18d4
commit
538bda6a09
18 changed files with 63 additions and 27 deletions
|
@ -14,6 +14,8 @@
|
|||
<script type="text/javascript" src="../../src/PathItem.js"></script>
|
||||
<script type="text/javascript" src="../../src/Path.js"></script>
|
||||
<script type="text/javascript" src="../../src/Doc.js"></script>
|
||||
<script type="text/javascript" src="../../src/Layer.js"></script>
|
||||
<script type="text/javascript" src="../../src/Group.js"></script>
|
||||
<script>
|
||||
var canvas, doc;
|
||||
var count = 0;
|
||||
|
@ -25,7 +27,7 @@
|
|||
|
||||
function draw() {
|
||||
count++;
|
||||
doc.children = [];
|
||||
doc.activeLayer.children = [];
|
||||
var point = new Point(1024, 768).divide(2);
|
||||
for(var i = 0; i < 35; i++) {
|
||||
var vector = new Point(20 + 10 * i, 0).rotate(i * (360 / 35 * 2) * Math.sin(count / 150));
|
||||
|
@ -40,9 +42,9 @@
|
|||
path.add(newPoint);
|
||||
}
|
||||
path.smooth();
|
||||
doc.children.push(path);
|
||||
doc.activeLayer.appendTop(path);
|
||||
}
|
||||
doc.children.reverse();
|
||||
doc.activeLayer.children.reverse();
|
||||
doc.redraw();
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<script type="text/javascript" src="../../src/PathItem.js"></script>
|
||||
<script type="text/javascript" src="../../src/Path.js"></script>
|
||||
<script type="text/javascript" src="../../src/Doc.js"></script>
|
||||
<script type="text/javascript" src="../../src/Layer.js"></script>
|
||||
<script type="text/javascript" src="../../src/Group.js"></script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
var canvas = document.getElementById('canvas');
|
||||
|
@ -34,9 +36,9 @@
|
|||
path.arcTo(point.add(vector), true);
|
||||
}
|
||||
}
|
||||
doc.children.push(path);
|
||||
doc.activeLayer.appendTop(path);
|
||||
}
|
||||
doc.children.reverse();
|
||||
doc.activeLayer.children.reverse();
|
||||
|
||||
doc.redraw();
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<script type="text/javascript" src="../../src/PathItem.js"></script>
|
||||
<script type="text/javascript" src="../../src/Path.js"></script>
|
||||
<script type="text/javascript" src="../../src/Doc.js"></script>
|
||||
<script type="text/javascript" src="../../src/Layer.js"></script>
|
||||
<script type="text/javascript" src="../../src/Group.js"></script>
|
||||
<script>
|
||||
var count = 0;
|
||||
var doc;
|
||||
|
@ -24,7 +26,7 @@
|
|||
for(var i = 0; i < 70; i++) {
|
||||
var path = new Path.Circle(center, i * 5);
|
||||
path.strokeColor = 'black';
|
||||
doc.children.push(path);
|
||||
doc.activeLayer.appendTop(path);
|
||||
}
|
||||
doc.redraw();
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<script type="text/javascript" src="../../src/PathItem.js"></script>
|
||||
<script type="text/javascript" src="../../src/Path.js"></script>
|
||||
<script type="text/javascript" src="../../src/Doc.js"></script>
|
||||
<script type="text/javascript" src="../../src/Layer.js"></script>
|
||||
<script type="text/javascript" src="../../src/Group.js"></script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
var canvas = document.getElementById('canvas');
|
||||
|
@ -36,7 +38,7 @@
|
|||
new Segment(new Point(56.984375, 286.0546875), new Point(10.03076171875, 6.6875))
|
||||
);
|
||||
letterPath.fillColor = 'black';
|
||||
doc.children.push(letterPath);
|
||||
doc.activeLayer.appendTop(letterPath);
|
||||
doc.redraw();
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<script type="text/javascript" src="../../src/PathItem.js"></script>
|
||||
<script type="text/javascript" src="../../src/Path.js"></script>
|
||||
<script type="text/javascript" src="../../src/Doc.js"></script>
|
||||
<script type="text/javascript" src="../../src/Layer.js"></script>
|
||||
<script type="text/javascript" src="../../src/Group.js"></script>
|
||||
<script>
|
||||
var count = 0;
|
||||
var doc;
|
||||
|
@ -25,13 +27,13 @@
|
|||
|
||||
function draw() {
|
||||
count++;
|
||||
doc.children = [];
|
||||
doc.activeLayer.children = [];
|
||||
var point = new Point(1024, 768).divide(2);
|
||||
var vector = new Point(100, 0);
|
||||
for(var i = 0; i < 180; i++) {
|
||||
var path = new Path.Line(point.add(vector.rotate(i * 2).normalize(30)), point.add(vector.rotate(i * 2).normalize(30 + Math.abs(Math.sin((i + count / 20)) * 300))));
|
||||
path.strokeColor = i % 4 ? 'black' : 'red';
|
||||
doc.children.push(path);
|
||||
doc.activeLayer.appendTop(path);
|
||||
}
|
||||
doc.redraw();
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<script type="text/javascript" src="../../src/PathItem.js"></script>
|
||||
<script type="text/javascript" src="../../src/Path.js"></script>
|
||||
<script type="text/javascript" src="../../src/Doc.js"></script>
|
||||
<script type="text/javascript" src="../../src/Layer.js"></script>
|
||||
<script type="text/javascript" src="../../src/Group.js"></script>
|
||||
<script>
|
||||
var count = 0;
|
||||
var doc;
|
||||
|
@ -23,7 +25,7 @@
|
|||
var path = new Path.Rectangle([50, 50], [100, 100]);
|
||||
path.strokeColor = 'black';
|
||||
console.log(path);
|
||||
doc.children.push(path);
|
||||
doc.activeLayer.appendTop(path);
|
||||
doc.redraw();
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<script type="text/javascript" src="../../src/PathItem.js"></script>
|
||||
<script type="text/javascript" src="../../src/Path.js"></script>
|
||||
<script type="text/javascript" src="../../src/Doc.js"></script>
|
||||
<script type="text/javascript" src="../../src/Layer.js"></script>
|
||||
<script type="text/javascript" src="../../src/Group.js"></script>
|
||||
<script>
|
||||
var count = 0;
|
||||
var doc;
|
||||
|
@ -24,12 +26,12 @@
|
|||
}
|
||||
function draw() {
|
||||
count++;
|
||||
doc.children = [];
|
||||
doc.activeLayer.children = [];
|
||||
var rect = new Rectangle([150, 150], [300, 300]);
|
||||
var size = Math.abs(Math.sin(count / 40)) * 150 + 10;
|
||||
var path = new Path.RoundRectangle(rect, size);
|
||||
path.fillColor = 'black';
|
||||
doc.children.push(path);
|
||||
doc.activeLayer.appendTop(path);
|
||||
doc.redraw();
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<script type="text/javascript" src="../../src/PathItem.js"></script>
|
||||
<script type="text/javascript" src="../../src/Path.js"></script>
|
||||
<script type="text/javascript" src="../../src/Doc.js"></script>
|
||||
<script type="text/javascript" src="../../src/Layer.js"></script>
|
||||
<script type="text/javascript" src="../../src/Group.js"></script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
var canvas = document.getElementById('canvas');
|
||||
|
@ -33,9 +35,9 @@
|
|||
path.add(newPoint);
|
||||
}
|
||||
path.smooth();
|
||||
doc.children.push(path);
|
||||
doc.activeLayer.appendTop(path);
|
||||
}
|
||||
doc.children.reverse();
|
||||
doc.activeLayer.children.reverse();
|
||||
doc.redraw();
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<script type="text/javascript" src="../../src/PathItem.js"></script>
|
||||
<script type="text/javascript" src="../../src/Path.js"></script>
|
||||
<script type="text/javascript" src="../../src/Doc.js"></script>
|
||||
<script type="text/javascript" src="../../src/Layer.js"></script>
|
||||
<script type="text/javascript" src="../../src/Group.js"></script>
|
||||
<script>
|
||||
var count = 0;
|
||||
var doc;
|
||||
|
@ -24,7 +26,7 @@
|
|||
path.strokeColor = 'black';
|
||||
path.strokeWidth = 30;
|
||||
path.strokeJoin = 'bevel';
|
||||
doc.children.push(path);
|
||||
doc.activeLayer.appendTop(path);
|
||||
doc.redraw();
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<script type="text/javascript" src="../../src/PathItem.js"></script>
|
||||
<script type="text/javascript" src="../../src/Path.js"></script>
|
||||
<script type="text/javascript" src="../../src/Doc.js"></script>
|
||||
<script type="text/javascript" src="../../src/Layer.js"></script>
|
||||
<script type="text/javascript" src="../../src/Group.js"></script>
|
||||
<script>
|
||||
var count = 0;
|
||||
var doc;
|
||||
|
@ -27,11 +29,11 @@
|
|||
// var path = new Path.RoundRectangle(rect, 200);
|
||||
// path.strokeColor = 'black';
|
||||
// console.log(path);
|
||||
// doc.children.push(path);
|
||||
// doc.activeLayer.appendTop(path);
|
||||
//
|
||||
// // var path = new Path.Rectangle(rect);
|
||||
// // path.strokeColor = 'black';
|
||||
// // doc.children.push(path);
|
||||
// // doc.activeLayer.appendTop(path);
|
||||
// doc.redraw();
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<script type="text/javascript" src="../../src/PathItem.js"></script>
|
||||
<script type="text/javascript" src="../../src/Path.js"></script>
|
||||
<script type="text/javascript" src="../../src/Doc.js"></script>
|
||||
<script type="text/javascript" src="../../src/Layer.js"></script>
|
||||
<script type="text/javascript" src="../../src/Group.js"></script>
|
||||
<script type="text/javascript" src="../../src/ToolEvent.js"></script>
|
||||
<script type="text/javascript" src="../../src/ToolHandler.js"></script>
|
||||
<script type="text/javascript" src="../../src/Tool.js"></script>
|
||||
|
@ -25,12 +27,12 @@
|
|||
var tool = new Tool({
|
||||
onMouseDrag: function(event) {
|
||||
if(event.count != 1)
|
||||
doc.children.pop();
|
||||
doc.activeLayer.children.pop();
|
||||
var distance = event.downPoint.subtract(event.point).length;
|
||||
var path = new Path.Circle(event.downPoint, distance);
|
||||
path.strokeColor = 'black';
|
||||
path.fillColor = 'white';
|
||||
doc.children.push(path);
|
||||
doc.activeLayer.appendTop(path);
|
||||
}
|
||||
});
|
||||
tool.document = doc;
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<script type="text/javascript" src="../../src/PathItem.js"></script>
|
||||
<script type="text/javascript" src="../../src/Path.js"></script>
|
||||
<script type="text/javascript" src="../../src/Doc.js"></script>
|
||||
<script type="text/javascript" src="../../src/Layer.js"></script>
|
||||
<script type="text/javascript" src="../../src/Group.js"></script>
|
||||
<script type="text/javascript" src="../../src/ToolEvent.js"></script>
|
||||
<script type="text/javascript" src="../../src/ToolHandler.js"></script>
|
||||
<script type="text/javascript" src="../../src/Tool.js"></script>
|
||||
|
@ -30,7 +32,7 @@
|
|||
path.strokeJoin = 'round';
|
||||
path.strokeCap = 'round';
|
||||
path.add(event.point);
|
||||
doc.children.push(path);
|
||||
doc.activeLayer.appendTop(path);
|
||||
},
|
||||
onMouseDrag: function(event) {
|
||||
path.arcTo(event.point, true);
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<script type="text/javascript" src="../../src/PathItem.js"></script>
|
||||
<script type="text/javascript" src="../../src/Path.js"></script>
|
||||
<script type="text/javascript" src="../../src/Doc.js"></script>
|
||||
<script type="text/javascript" src="../../src/Layer.js"></script>
|
||||
<script type="text/javascript" src="../../src/Group.js"></script>
|
||||
<script type="text/javascript" src="../../src/ToolEvent.js"></script>
|
||||
<script type="text/javascript" src="../../src/ToolHandler.js"></script>
|
||||
<script type="text/javascript" src="../../src/Tool.js"></script>
|
||||
|
@ -38,7 +40,7 @@
|
|||
path = new Path();
|
||||
path.fillColor = 'black';
|
||||
path.add(event.lastPoint);
|
||||
doc.children.push(path);
|
||||
doc.activeLayer.appendTop(path);
|
||||
}
|
||||
|
||||
var step = event.delta.divide(2);
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<script type="text/javascript" src="../../src/PathItem.js"></script>
|
||||
<script type="text/javascript" src="../../src/Path.js"></script>
|
||||
<script type="text/javascript" src="../../src/Doc.js"></script>
|
||||
<script type="text/javascript" src="../../src/Layer.js"></script>
|
||||
<script type="text/javascript" src="../../src/Group.js"></script>
|
||||
<script type="text/javascript" src="../../src/ToolEvent.js"></script>
|
||||
<script type="text/javascript" src="../../src/ToolHandler.js"></script>
|
||||
<script type="text/javascript" src="../../src/Tool.js"></script>
|
||||
|
@ -34,7 +36,7 @@
|
|||
onMouseDown: function(event) {
|
||||
path = new Path();
|
||||
path.fillColor = event.count % 2 ? 'red' : 'black';
|
||||
doc.children.push(path);
|
||||
doc.activeLayer.appendTop(path);
|
||||
},
|
||||
|
||||
onMouseDrag: function(event) {
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<script type="text/javascript" src="../../src/PathItem.js"></script>
|
||||
<script type="text/javascript" src="../../src/Path.js"></script>
|
||||
<script type="text/javascript" src="../../src/Doc.js"></script>
|
||||
<script type="text/javascript" src="../../src/Layer.js"></script>
|
||||
<script type="text/javascript" src="../../src/Group.js"></script>
|
||||
<script type="text/javascript" src="../../src/ToolEvent.js"></script>
|
||||
<script type="text/javascript" src="../../src/ToolHandler.js"></script>
|
||||
<script type="text/javascript" src="../../src/Tool.js"></script>
|
||||
|
@ -37,7 +39,7 @@
|
|||
path = new Path();
|
||||
path.strokeColor = 'black';
|
||||
path.add(point);
|
||||
doc.children.push(path);
|
||||
doc.activeLayer.appendTop(path);
|
||||
},
|
||||
onMouseDrag: function(event) {
|
||||
var p = getPos(event.point);
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<script type="text/javascript" src="../../src/PathItem.js"></script>
|
||||
<script type="text/javascript" src="../../src/Path.js"></script>
|
||||
<script type="text/javascript" src="../../src/Doc.js"></script>
|
||||
<script type="text/javascript" src="../../src/Layer.js"></script>
|
||||
<script type="text/javascript" src="../../src/Group.js"></script>
|
||||
<script type="text/javascript" src="../../src/ToolEvent.js"></script>
|
||||
<script type="text/javascript" src="../../src/ToolHandler.js"></script>
|
||||
<script type="text/javascript" src="../../src/Tool.js"></script>
|
||||
|
@ -35,7 +37,7 @@
|
|||
for (var i = 0; i < values.lines; i++) {
|
||||
var path = new Path();
|
||||
path.strokeColor = '#000000';
|
||||
doc.children.push(path);
|
||||
doc.activeLayer.appendTop(path);
|
||||
paths.push(path);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<script type="text/javascript" src="../../src/PathItem.js"></script>
|
||||
<script type="text/javascript" src="../../src/Path.js"></script>
|
||||
<script type="text/javascript" src="../../src/Doc.js"></script>
|
||||
<script type="text/javascript" src="../../src/Layer.js"></script>
|
||||
<script type="text/javascript" src="../../src/Group.js"></script>
|
||||
<script type="text/javascript" src="../../src/ToolEvent.js"></script>
|
||||
<script type="text/javascript" src="../../src/ToolHandler.js"></script>
|
||||
<script type="text/javascript" src="../../src/Tool.js"></script>
|
||||
|
@ -35,7 +37,7 @@
|
|||
onMouseDown: function(event) {
|
||||
path = new Path();
|
||||
path.strokeColor = 'black';
|
||||
doc.children.push(path);
|
||||
doc.activeLayer.appendTop(path);
|
||||
},
|
||||
|
||||
onMouseDrag: function(event) {
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<script type="text/javascript" src="../../src/PathItem.js"></script>
|
||||
<script type="text/javascript" src="../../src/Path.js"></script>
|
||||
<script type="text/javascript" src="../../src/Doc.js"></script>
|
||||
<script type="text/javascript" src="../../src/Layer.js"></script>
|
||||
<script type="text/javascript" src="../../src/Group.js"></script>
|
||||
<script type="text/javascript" src="../../src/ToolEvent.js"></script>
|
||||
<script type="text/javascript" src="../../src/ToolHandler.js"></script>
|
||||
<script type="text/javascript" src="../../src/Tool.js"></script>
|
||||
|
@ -38,7 +40,7 @@
|
|||
worm.fillColor = '#ffffff';
|
||||
worm.strokeColor = '#000000';
|
||||
worm.add(event.point);
|
||||
doc.children.push(worm);
|
||||
doc.activeLayer.appendTop(worm);
|
||||
},
|
||||
|
||||
onMouseDrag: function(event) {
|
||||
|
@ -75,7 +77,7 @@
|
|||
// make a new line path from top to bottom
|
||||
var line = new Path.Line(top, bottom);
|
||||
line.strokeColor = '#000000';
|
||||
doc.children.push(line);
|
||||
doc.activeLayer.appendTop(line);
|
||||
|
||||
// smooth the segments of the path
|
||||
worm.smooth();
|
||||
|
|
Loading…
Reference in a new issue