mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Improve several examples.
This commit is contained in:
parent
2dfe491212
commit
ace2e3e13b
4 changed files with 33 additions and 23 deletions
|
@ -6,15 +6,23 @@
|
|||
<link rel="stylesheet" href="../css/style.css">
|
||||
<script type="text/javascript" src="../../dist/paper.js"></script>
|
||||
<script type="text/paperscript" canvas="canvas">
|
||||
var redPath = new Path.Circle(view.center, 10);
|
||||
redPath.fillColor = 'red';
|
||||
var redPath = new Path.Circle({
|
||||
center: view.center,
|
||||
radius: 5,
|
||||
fillColor: 'red'
|
||||
});
|
||||
|
||||
var whitePath = new Path.Circle(view.center, 10);
|
||||
whitePath.fillColor = 'white';
|
||||
var whitePath = new Path.Circle({
|
||||
center: view.center,
|
||||
radius: 5,
|
||||
fillColor: 'white'
|
||||
});
|
||||
|
||||
var text = new PointText();
|
||||
text.content = 'Resize your window';
|
||||
text.justification = 'center';
|
||||
var text = new PointText({
|
||||
content: 'Resize your window',
|
||||
justification: 'center',
|
||||
point: view.center
|
||||
});
|
||||
|
||||
function onResize(event) {
|
||||
// Resize the red circle to fill the bounds of the view:
|
||||
|
|
|
@ -7,14 +7,17 @@
|
|||
<script type="text/javascript" src="../../dist/paper.js"></script>
|
||||
<script type="text/paperscript" canvas="canvas">
|
||||
var path;
|
||||
var rect = new Rectangle([150, 150], [300, 300]);
|
||||
project.currentStyle.fillColor = 'black';
|
||||
|
||||
function onFrame(event) {
|
||||
if (path)
|
||||
path.remove();
|
||||
var size = Math.abs(Math.sin(event.count / 40)) * 150 + 10;
|
||||
path = new Path.RoundRectangle(rect, size);
|
||||
path = new Path.RoundRectangle({
|
||||
radius: Math.abs(Math.sin(event.count / 40)) * 150 + 10,
|
||||
rectangle: {
|
||||
size: [300, 300]
|
||||
},
|
||||
fillColor: 'black'
|
||||
});
|
||||
path.position = view.center;
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -6,20 +6,18 @@
|
|||
<link rel="stylesheet" href="../css/style.css">
|
||||
<script type="text/javascript" src="../../dist/paper.js"></script>
|
||||
<script type="text/paperscript" canvas="canvas">
|
||||
// All newly created items will receive
|
||||
// these style properties:
|
||||
project.currentStyle = {
|
||||
fillColor: 'white',
|
||||
strokeColor: 'black'
|
||||
};
|
||||
|
||||
var path;
|
||||
function onMouseDrag(event) {
|
||||
// The radius is the distance between the position
|
||||
// where the user clicked and the current position
|
||||
// of the mouse.
|
||||
var radius = (event.downPoint - event.point).length;
|
||||
path = new Path.Circle(event.downPoint, radius);
|
||||
var path = new Path.Circle({
|
||||
center: event.downPoint,
|
||||
radius: (event.downPoint - event.point).length,
|
||||
fillColor: 'white',
|
||||
strokeColor: 'black'
|
||||
});
|
||||
|
||||
// Remove this path on the next drag event:
|
||||
path.removeOnDrag();
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
if (event.delta.length > minSize) {
|
||||
// If there is no path, make one:
|
||||
if (!path) {
|
||||
path = new Path();
|
||||
path.fillColor = 'black';
|
||||
path = new Path({
|
||||
fillColor: 'black'
|
||||
});
|
||||
path.add(event.lastPoint);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue