mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Clean up Future Splash example a bit.
This commit is contained in:
parent
1d6b5e23c8
commit
7ee7895d57
1 changed files with 12 additions and 13 deletions
|
@ -31,7 +31,7 @@
|
||||||
this.strength = param.strength ? param.strength : 0.55;
|
this.strength = param.strength ? param.strength : 0.55;
|
||||||
this.mamb = values.invMass * values.invMass;
|
this.mamb = values.invMass * values.invMass;
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function() {
|
update: function() {
|
||||||
var delta = this.b - this.a;
|
var delta = this.b - this.a;
|
||||||
var dist = delta.length;
|
var dist = delta.length;
|
||||||
|
@ -47,15 +47,6 @@
|
||||||
|
|
||||||
onResize();
|
onResize();
|
||||||
|
|
||||||
function onResize() {
|
|
||||||
values.count = 0;
|
|
||||||
if (path) {
|
|
||||||
path.remove();
|
|
||||||
}
|
|
||||||
size = view.bounds.size * [2, 1];
|
|
||||||
path = createPath(0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
function createPath(strength) {
|
function createPath(strength) {
|
||||||
var path = new Path();
|
var path = new Path();
|
||||||
path.data = {};
|
path.data = {};
|
||||||
|
@ -81,10 +72,18 @@
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onResize() {
|
||||||
|
values.count = 0;
|
||||||
|
if (path) {
|
||||||
|
path.remove();
|
||||||
|
}
|
||||||
|
size = view.bounds.size * [2, 1];
|
||||||
|
path = createPath(0.1);
|
||||||
|
}
|
||||||
|
|
||||||
function onMouseMove(event) {
|
function onMouseMove(event) {
|
||||||
var segments = path.segments;
|
var segments = path.segments;
|
||||||
var index = Math.floor((event.point.x + size.width / 4)
|
var index = Math.floor((event.point.x + size.width / 4) * segments.length / size.width);
|
||||||
* segments.length / size.width);
|
|
||||||
var y = event.point.y;
|
var y = event.point.y;
|
||||||
var range = size.height / 4;
|
var range = size.height / 4;
|
||||||
var segment = segments[index];
|
var segment = segments[index];
|
||||||
|
@ -130,7 +129,7 @@
|
||||||
path.insert(0, new Point(0, size.height));
|
path.insert(0, new Point(0, size.height));
|
||||||
path.add(new Point(size));
|
path.add(new Point(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
function onKeyDown(event) {
|
function onKeyDown(event) {
|
||||||
if (event.key == 'space')
|
if (event.key == 'space')
|
||||||
path.fullySelected = !path.fullySelected;
|
path.fullySelected = !path.fullySelected;
|
||||||
|
|
Loading…
Reference in a new issue