mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Replace new Size(x, y) calls with internal Size.create(x, y).
This commit is contained in:
parent
26210fb95b
commit
b5e46971f0
3 changed files with 11 additions and 11 deletions
|
@ -1897,7 +1897,7 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
: rectangle.height / bounds.height,
|
: rectangle.height / bounds.height,
|
||||||
delta = rectangle.getCenter().subtract(bounds.getCenter()),
|
delta = rectangle.getCenter().subtract(bounds.getCenter()),
|
||||||
newBounds = new Rectangle(new Point(),
|
newBounds = new Rectangle(new Point(),
|
||||||
new Size(bounds.width * scale, bounds.height * scale));
|
Size.create(bounds.width * scale, bounds.height * scale));
|
||||||
newBounds.setCenter(rectangle.getCenter());
|
newBounds.setCenter(rectangle.getCenter());
|
||||||
this.setBounds(newBounds);
|
this.setBounds(newBounds);
|
||||||
},
|
},
|
||||||
|
@ -1940,9 +1940,9 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
// If the item has a blendMode or is defining an opacity, draw it on
|
// If the item has a blendMode or is defining an opacity, draw it on
|
||||||
// a temporary canvas first and composite the canvas afterwards.
|
// a temporary canvas first and composite the canvas afterwards.
|
||||||
// Paths with an opacity < 1 that both define a fillColor
|
// Paths with an opacity < 1 that both define a fillColor
|
||||||
// and strokeColor also need to be drawn on a temporary canvas first,
|
// and strokeColor also need to be drawn on a temporary canvas
|
||||||
// since otherwise their stroke is drawn half transparent over their
|
// first, since otherwise their stroke is drawn half transparent
|
||||||
// fill.
|
// over their fill.
|
||||||
if (item._blendMode !== 'normal'
|
if (item._blendMode !== 'normal'
|
||||||
|| item._opacity < 1
|
|| item._opacity < 1
|
||||||
&& !(item._segments && (!item.getFillColor()
|
&& !(item._segments && (!item.getFillColor()
|
||||||
|
@ -1953,7 +1953,7 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
// Floor the offset and ceil the size, so we don't cut off any
|
// Floor the offset and ceil the size, so we don't cut off any
|
||||||
// antialiased pixels when drawing onto the temporary canvas.
|
// antialiased pixels when drawing onto the temporary canvas.
|
||||||
var itemOffset = bounds.getTopLeft().floor(),
|
var itemOffset = bounds.getTopLeft().floor(),
|
||||||
size = bounds.getSize().ceil().add(new Size(1, 1));
|
size = bounds.getSize().ceil().add(Size.create(1, 1));
|
||||||
tempCanvas = CanvasProvider.getCanvas(size);
|
tempCanvas = CanvasProvider.getCanvas(size);
|
||||||
// Save the parent context, so we can draw onto it later
|
// Save the parent context, so we can draw onto it later
|
||||||
parentCtx = ctx;
|
parentCtx = ctx;
|
||||||
|
|
|
@ -120,7 +120,7 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{
|
||||||
orig = new Point(0, 0).transform(matrix),
|
orig = new Point(0, 0).transform(matrix),
|
||||||
u = new Point(1, 0).transform(matrix).subtract(orig),
|
u = new Point(1, 0).transform(matrix).subtract(orig),
|
||||||
v = new Point(0, 1).transform(matrix).subtract(orig);
|
v = new Point(0, 1).transform(matrix).subtract(orig);
|
||||||
return new Size(
|
return Size.create(
|
||||||
72 / u.getLength(),
|
72 / u.getLength(),
|
||||||
72 / v.getLength()
|
72 / v.getLength()
|
||||||
);
|
);
|
||||||
|
@ -160,7 +160,7 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{
|
||||||
if (this._canvas)
|
if (this._canvas)
|
||||||
CanvasProvider.returnCanvas(this._canvas);
|
CanvasProvider.returnCanvas(this._canvas);
|
||||||
this._canvas = canvas;
|
this._canvas = canvas;
|
||||||
this._size = new Size(canvas.width, canvas.height);
|
this._size = Size.create(canvas.width, canvas.height);
|
||||||
this._image = null;
|
this._image = null;
|
||||||
this._context = null;
|
this._context = null;
|
||||||
this._changed(Change.GEOMETRY);
|
this._changed(Change.GEOMETRY);
|
||||||
|
@ -182,9 +182,9 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{
|
||||||
CanvasProvider.returnCanvas(this._canvas);
|
CanvasProvider.returnCanvas(this._canvas);
|
||||||
this._image = image;
|
this._image = image;
|
||||||
/*#*/ if (options.browser) {
|
/*#*/ if (options.browser) {
|
||||||
this._size = new Size(image.naturalWidth, image.naturalHeight);
|
this._size = Size.create(image.naturalWidth, image.naturalHeight);
|
||||||
/*#*/ } else if (options.server) {
|
/*#*/ } else if (options.server) {
|
||||||
this._size = new Size(image.width, image.height);
|
this._size = Size.create(image.width, image.height);
|
||||||
/*#*/ } // options.server
|
/*#*/ } // options.server
|
||||||
this._canvas = null;
|
this._canvas = null;
|
||||||
this._context = null;
|
this._context = null;
|
||||||
|
@ -252,7 +252,7 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{
|
||||||
var ctx = Raster._sampleContext;
|
var ctx = Raster._sampleContext;
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
ctx = Raster._sampleContext = CanvasProvider.getCanvas(
|
ctx = Raster._sampleContext = CanvasProvider.getCanvas(
|
||||||
new Size(sampleSize)).getContext('2d');
|
sampleSize.clone()).getContext('2d');
|
||||||
} else {
|
} else {
|
||||||
// Clear the sample canvas:
|
// Clear the sample canvas:
|
||||||
ctx.clearRect(0, 0, sampleSize, sampleSize);
|
ctx.clearRect(0, 0, sampleSize, sampleSize);
|
||||||
|
|
|
@ -32,7 +32,7 @@ var CanvasView = View.extend(/** @lends CanvasView# */{
|
||||||
// 2nd argument onwards could be view size, otherwise use default:
|
// 2nd argument onwards could be view size, otherwise use default:
|
||||||
var size = Size.read(arguments, 1);
|
var size = Size.read(arguments, 1);
|
||||||
if (size.isZero())
|
if (size.isZero())
|
||||||
size = new Size(1024, 768);
|
size = Size.create(1024, 768);
|
||||||
canvas = CanvasProvider.getCanvas(size);
|
canvas = CanvasProvider.getCanvas(size);
|
||||||
}
|
}
|
||||||
this._context = canvas.getContext('2d');
|
this._context = canvas.getContext('2d');
|
||||||
|
|
Loading…
Reference in a new issue