mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Small change to Flock example.
This commit is contained in:
parent
de466edc23
commit
3751dd0a38
1 changed files with 5 additions and 3 deletions
|
@ -20,6 +20,8 @@
|
||||||
head.strokeColor = null;
|
head.strokeColor = null;
|
||||||
var headSymbol = new Symbol(head);
|
var headSymbol = new Symbol(head);
|
||||||
|
|
||||||
|
var size = document.size;
|
||||||
|
|
||||||
var Boid = Base.extend({
|
var Boid = Base.extend({
|
||||||
initialize: function(position, maxSpeed, maxForce) {
|
initialize: function(position, maxSpeed, maxForce) {
|
||||||
var strength = Math.random() * 0.5;
|
var strength = Math.random() * 0.5;
|
||||||
|
@ -129,8 +131,8 @@
|
||||||
var loc = this.loc,
|
var loc = this.loc,
|
||||||
r = this.r,
|
r = this.r,
|
||||||
oldLoc = this.loc.clone(),
|
oldLoc = this.loc.clone(),
|
||||||
width = document.size.width,
|
width = size.width,
|
||||||
height = document.size.height;
|
height = size.height;
|
||||||
if (loc.x < -r) loc.x = width + r;
|
if (loc.x < -r) loc.x = width + r;
|
||||||
if (loc.y < -r) loc.y = height + r;
|
if (loc.y < -r) loc.y = height + r;
|
||||||
if (loc.x > width + r) loc.x = -r;
|
if (loc.x > width + r) loc.x = -r;
|
||||||
|
@ -281,7 +283,7 @@
|
||||||
|
|
||||||
// Resize the document, whenever the window is resized,
|
// Resize the document, whenever the window is resized,
|
||||||
window.onresize = function(event) {
|
window.onresize = function(event) {
|
||||||
document.size = [window.innerWidth, window.innerHeight];
|
size = document.size = [window.innerWidth, window.innerHeight];
|
||||||
heartPath.position = document.bounds.center;
|
heartPath.position = document.bounds.center;
|
||||||
document.redraw();
|
document.redraw();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue