mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-08-13 06:29:11 -04:00
Improve several examples.
This commit is contained in:
parent
2dfe491212
commit
ace2e3e13b
4 changed files with 33 additions and 23 deletions
examples/Scripts
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue