mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
More beans related refactoring.
This commit is contained in:
parent
b06bf88aed
commit
836ee492ae
5 changed files with 28 additions and 24 deletions
|
@ -342,6 +342,7 @@ var Matrix = this.Matrix = Base.extend({
|
|||
// away
|
||||
// If a size is provided, assume it's defining a rectangle centered on
|
||||
// the origin, as required by Matrix and PlacedSymbol
|
||||
// TODO: Find a better way to handle this, as it is too specific for here.
|
||||
if (bounds instanceof Size) {
|
||||
bounds = new Rectangle(-bounds.width / 2, -bounds.height / 2,
|
||||
bounds.width, bounds.height);
|
||||
|
|
|
@ -35,7 +35,7 @@ var GradientColor = this.GradientColor = Color.extend({
|
|||
setHilite: function() {
|
||||
var hilite = Point.read(arguments);
|
||||
var vector = hilite.subtract(this._origin);
|
||||
if (vector.length > this._radius) {
|
||||
if (vector.getLength() > this._radius) {
|
||||
this._hilite = this._origin.add(vector.normalize(
|
||||
this._radius - 0.1));
|
||||
} else {
|
||||
|
|
|
@ -609,7 +609,8 @@ var Item = this.Item = Base.extend({
|
|||
// fill.
|
||||
if (item.blendMode !== 'normal'
|
||||
|| item.opacity < 1
|
||||
&& !(item.segments && (!item.getFillColor() || !item.getStrokeColor()))) {
|
||||
&& !(item.segments && (!item.getFillColor()
|
||||
|| !item.getStrokeColor()))) {
|
||||
var bounds = item.getStrokeBounds() || item.getBounds();
|
||||
if (!bounds.width || !bounds.height)
|
||||
return;
|
||||
|
@ -702,9 +703,9 @@ var Item = this.Item = Base.extend({
|
|||
/**
|
||||
* {@grouptitle Hierarchy Operations}
|
||||
*
|
||||
* Inserts the specified item as a child of the item by appending it to the
|
||||
* list of children and moving it above all other children. You can use this
|
||||
* function for groups, compound paths and layers.
|
||||
* Inserts the specified item as a child of the item by appending it to
|
||||
* the list of children and moving it above all other children. You can
|
||||
* use this function for groups, compound paths and layers.
|
||||
*
|
||||
* Sample code:
|
||||
* <code>
|
||||
|
@ -719,9 +720,9 @@ var Item = this.Item = Base.extend({
|
|||
appendTop: append(true),
|
||||
|
||||
/**
|
||||
* Inserts the specified item as a child of this item by appending it to the
|
||||
* list of children and moving it below all other children. You can use this
|
||||
* function for groups, compound paths and layers.
|
||||
* Inserts the specified item as a child of this item by appending it to
|
||||
* the list of children and moving it below all other children. You can
|
||||
* use this function for groups, compound paths and layers.
|
||||
*
|
||||
* Sample code:
|
||||
* <code>
|
||||
|
|
|
@ -52,11 +52,11 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
|
|||
};
|
||||
|
||||
this[set] = function(value) {
|
||||
this.getStyle()[set](value);
|
||||
this._style[set](value);
|
||||
};
|
||||
|
||||
this[get] = function() {
|
||||
return this.getStyle()[get]();
|
||||
return this._style[get]();
|
||||
};
|
||||
}, { beans: true }));
|
||||
|
||||
|
|
|
@ -22,9 +22,11 @@ var Raster = this.Raster = Item.extend({
|
|||
|
||||
setSize: function() {
|
||||
var size = Size.read(arguments);
|
||||
// Get reference to image before changing canvas
|
||||
var image = this.getImage();
|
||||
// Set canvas internally sets _size
|
||||
// Setting canvas internally sets _size
|
||||
this.setCanvas(CanvasProvider.getCanvas(size));
|
||||
// Draw image back onto new canvas
|
||||
this.drawImage(image, 0, 0);
|
||||
},
|
||||
|
||||
|
@ -51,11 +53,22 @@ var Raster = this.Raster = Item.extend({
|
|||
var u = new Point(1, 0).transform(matrix).subtract(orig);
|
||||
var v = new Point(0, 1).transform(matrix).subtract(orig);
|
||||
return new Size(
|
||||
72 / u.length,
|
||||
72 / v.length
|
||||
72 / u.getLength(),
|
||||
72 / v.getLength()
|
||||
);
|
||||
},
|
||||
|
||||
getContext: function() {
|
||||
if (!this._context) {
|
||||
this._context = this.getCanvas().getContext('2d');
|
||||
}
|
||||
return this._context;
|
||||
},
|
||||
|
||||
setContext: function(context) {
|
||||
this._context = context;
|
||||
},
|
||||
|
||||
getCanvas: function() {
|
||||
if (!this._canvas) {
|
||||
this._canvas = CanvasProvider.getCanvas(this._size);
|
||||
|
@ -75,17 +88,6 @@ var Raster = this.Raster = Item.extend({
|
|||
this._bounds = null;
|
||||
},
|
||||
|
||||
getContext: function() {
|
||||
if (!this._context) {
|
||||
this._context = this.getCanvas().getContext('2d');
|
||||
}
|
||||
return this._context;
|
||||
},
|
||||
|
||||
setContext: function(context) {
|
||||
this._context = context;
|
||||
},
|
||||
|
||||
getImage: function() {
|
||||
return this._image || this.getCanvas();
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue