mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-04 03:45:58 -05:00
Use faster Array construction.
This commit is contained in:
parent
49cf3201f8
commit
d3bb68d0e0
3 changed files with 3 additions and 3 deletions
|
@ -84,7 +84,7 @@ var Color = this.Color = Base.extend(new function() {
|
|||
function hexToRgb(string) {
|
||||
var hex = string.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
|
||||
if (hex.length >= 4) {
|
||||
var components = new Array(3);
|
||||
var components = [0, 0, 0];
|
||||
for (var i = 0; i < 3; i++) {
|
||||
var value = hex[i + 1];
|
||||
components[i] = parseInt(value.length == 1
|
||||
|
|
|
@ -444,7 +444,7 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{
|
|||
getPixel: function(point) {
|
||||
point = Point.read(arguments);
|
||||
var pixels = this.getContext().getImageData(point.x, point.y, 1, 1).data,
|
||||
components = new Array(4);
|
||||
components = [0, 0, 0, 0];
|
||||
for (var i = 0; i < 4; i++)
|
||||
components[i] = pixels[i] / 255;
|
||||
return Color.create('rgb', components);
|
||||
|
|
|
@ -580,7 +580,7 @@ statics: {
|
|||
getBounds: function(v) {
|
||||
var min = v.slice(0, 2), // Start with values of point1
|
||||
max = min.slice(), // clone
|
||||
roots = new Array(2);
|
||||
roots = [0, 0];
|
||||
for (var i = 0; i < 2; i++)
|
||||
Curve._addBounds(v[i], v[i + 2], v[i + 4], v[i + 6],
|
||||
i, 0, min, max, roots);
|
||||
|
|
Loading…
Reference in a new issue