Add missing semicolons
This commit is contained in:
parent
5dff1b2fd7
commit
8470f696de
24
js/magic.js
24
js/magic.js
@ -1,5 +1,5 @@
|
|||||||
var Magic = function (options) {
|
var Magic = function (options) {
|
||||||
options = options || {}
|
options = options || {};
|
||||||
// Array to hold all active spells being drawn
|
// Array to hold all active spells being drawn
|
||||||
this.spells = [];
|
this.spells = [];
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ var Magic = function (options) {
|
|||||||
|
|
||||||
// Save this query here now that the page is loaded
|
// Save this query here now that the page is loaded
|
||||||
this.canvas = document.getElementById("magic");
|
this.canvas = document.getElementById("magic");
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Get the height and width of full document. To avoid browser
|
/* Get the height and width of full document. To avoid browser
|
||||||
@ -53,7 +53,7 @@ Magic.prototype.getDocumentDimensions = function () {
|
|||||||
html.offsetWidth);
|
html.offsetWidth);
|
||||||
|
|
||||||
return {"height": height, "width": width};
|
return {"height": height, "width": width};
|
||||||
}
|
};
|
||||||
|
|
||||||
/* Specifies what will be added to the red, green, and blue values of the
|
/* Specifies what will be added to the red, green, and blue values of the
|
||||||
* color at each interval. */
|
* color at each interval. */
|
||||||
@ -67,7 +67,7 @@ Magic.prototype.pickGradient = function () {
|
|||||||
magnitudes[Math.floor(Math.random() * 3)],
|
magnitudes[Math.floor(Math.random() * 3)],
|
||||||
"b": directions[Math.floor(Math.random() * 3)] *
|
"b": directions[Math.floor(Math.random() * 3)] *
|
||||||
magnitudes[Math.floor(Math.random() * 3)]};
|
magnitudes[Math.floor(Math.random() * 3)]};
|
||||||
}
|
};
|
||||||
|
|
||||||
/* Alters the given color by the given gradient and returns both.
|
/* Alters the given color by the given gradient and returns both.
|
||||||
|
|
||||||
@ -96,14 +96,14 @@ Magic.prototype.nextColor = function(color, gradient) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {"color": color, "gradient": gradient};
|
return {"color": color, "gradient": gradient};
|
||||||
}
|
};
|
||||||
|
|
||||||
/* Choose a random RGB color to begin the color gradient with */
|
/* Choose a random RGB color to begin the color gradient with */
|
||||||
Magic.prototype.pickRandomColor = function() {
|
Magic.prototype.pickRandomColor = function() {
|
||||||
return {"r": Math.floor(Math.random() * (255 + 1)),
|
return {"r": Math.floor(Math.random() * (255 + 1)),
|
||||||
"g": Math.floor(Math.random() * (255 + 1)),
|
"g": Math.floor(Math.random() * (255 + 1)),
|
||||||
"b": Math.floor(Math.random() * (255 + 1))};
|
"b": Math.floor(Math.random() * (255 + 1))};
|
||||||
}
|
};
|
||||||
|
|
||||||
Magic.prototype.drawSplineSegment = function(branch, context) {
|
Magic.prototype.drawSplineSegment = function(branch, context) {
|
||||||
var ax = (-branch.points[0].x + 3*branch.points[1].x - 3*branch.points[2].x + branch.points[3].x) / 6;
|
var ax = (-branch.points[0].x + 3*branch.points[1].x - 3*branch.points[2].x + branch.points[3].x) / 6;
|
||||||
@ -123,7 +123,7 @@ Magic.prototype.drawSplineSegment = function(branch, context) {
|
|||||||
ay*Math.pow(branch.t+this.step, 3) + by*Math.pow(branch.t+this.step, 2) + cy*(branch.t+this.step) + dy
|
ay*Math.pow(branch.t+this.step, 3) + by*Math.pow(branch.t+this.step, 2) + cy*(branch.t+this.step) + dy
|
||||||
);
|
);
|
||||||
branch.t += this.step;
|
branch.t += this.step;
|
||||||
}
|
};
|
||||||
|
|
||||||
Magic.prototype.splitBranch = function(branch) {
|
Magic.prototype.splitBranch = function(branch) {
|
||||||
var newBranches = [];
|
var newBranches = [];
|
||||||
@ -154,7 +154,7 @@ Magic.prototype.splitBranch = function(branch) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
return newBranches;
|
return newBranches;
|
||||||
}
|
};
|
||||||
|
|
||||||
Magic.prototype.cast = function(x, y, angle, chain) {
|
Magic.prototype.cast = function(x, y, angle, chain) {
|
||||||
// Find random position if not defined
|
// Find random position if not defined
|
||||||
@ -182,7 +182,7 @@ Magic.prototype.cast = function(x, y, angle, chain) {
|
|||||||
duration:Math.floor(Math.random() * (this.maxDuration - this.minDuration + 1)) + 50,
|
duration:Math.floor(Math.random() * (this.maxDuration - this.minDuration + 1)) + 50,
|
||||||
chain:chain,
|
chain:chain,
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/* Most of this funtion is provided by Maissan Inc. in their tutorial:
|
/* Most of this funtion is provided by Maissan Inc. in their tutorial:
|
||||||
http://www.maissan.net/articles/simulating-vines */
|
http://www.maissan.net/articles/simulating-vines */
|
||||||
@ -268,14 +268,14 @@ Magic.prototype.cast = function(x, y, angle, chain) {
|
|||||||
// Drawing interval
|
// Drawing interval
|
||||||
var frameId = animationFrame.request(animate);
|
var frameId = animationFrame.request(animate);
|
||||||
return frameId;
|
return frameId;
|
||||||
}
|
};
|
||||||
|
|
||||||
Magic.prototype.canvasClickHandler = function(event) {
|
Magic.prototype.canvasClickHandler = function(event) {
|
||||||
var x = event.pageX;
|
var x = event.pageX;
|
||||||
var y = event.pageY;
|
var y = event.pageY;
|
||||||
|
|
||||||
this.cast(x, y, undefined, false);
|
this.cast(x, y, undefined, false);
|
||||||
}
|
};
|
||||||
|
|
||||||
Magic.prototype.draw = function() {
|
Magic.prototype.draw = function() {
|
||||||
var interval_time = 2000;
|
var interval_time = 2000;
|
||||||
@ -295,4 +295,4 @@ Magic.prototype.draw = function() {
|
|||||||
// Cast magic spells
|
// Cast magic spells
|
||||||
var frameId = this.drawSpells(context, false, true, true);
|
var frameId = this.drawSpells(context, false, true, true);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user