mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 23:39:59 -05:00
Introduce Style as a base class for all Style classes, and move the definition of create() there.
This commit is contained in:
parent
b9ebd12d22
commit
f064886c67
6 changed files with 35 additions and 28 deletions
|
@ -14,7 +14,7 @@
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var PathStyle = this.PathStyle = Base.extend(new function() {
|
var PathStyle = this.PathStyle = Style.extend(new function() {
|
||||||
/** @lends PathStyle# */
|
/** @lends PathStyle# */
|
||||||
|
|
||||||
// windingRule / resolution / fillOverprint / strokeOverprint are currently
|
// windingRule / resolution / fillOverprint / strokeOverprint are currently
|
||||||
|
@ -77,14 +77,6 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
|
||||||
? value.clone() : value;
|
? value.clone() : value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
statics: {
|
|
||||||
create: function(item) {
|
|
||||||
var style = new PathStyle(PathStyle.dont);
|
|
||||||
style._item = item;
|
|
||||||
return style;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
29
src/item/Style.js
Normal file
29
src/item/Style.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* Paper.js
|
||||||
|
*
|
||||||
|
* This file is part of Paper.js, a JavaScript Vector Graphics Library,
|
||||||
|
* based on Scriptographer.org and designed to be largely API compatible.
|
||||||
|
* http://paperjs.org/
|
||||||
|
* http://scriptographer.org/
|
||||||
|
*
|
||||||
|
* Distributed under the MIT license. See LICENSE file for details.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
|
||||||
|
* http://lehni.org/ & http://jonathanpuckey.com/
|
||||||
|
*
|
||||||
|
* All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal base-class for all style objects, e.g. PathStyle, CharacterStyle,
|
||||||
|
* PargraphStyle.
|
||||||
|
*/
|
||||||
|
var Style = Item.extend({
|
||||||
|
statics: {
|
||||||
|
create: function(item) {
|
||||||
|
var style = new this(this.dont);
|
||||||
|
style._item = item;
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
|
@ -44,6 +44,7 @@ var sources = [
|
||||||
'src/item/Layer.js',
|
'src/item/Layer.js',
|
||||||
'src/item/Raster.js',
|
'src/item/Raster.js',
|
||||||
'src/item/PlacedSymbol.js',
|
'src/item/PlacedSymbol.js',
|
||||||
|
'src/item/Style.js',
|
||||||
'src/item/PathStyle.js',
|
'src/item/PathStyle.js',
|
||||||
|
|
||||||
'src/path/Segment.js',
|
'src/path/Segment.js',
|
||||||
|
|
|
@ -64,6 +64,7 @@ var paper = new function() {
|
||||||
//#include "item/Layer.js"
|
//#include "item/Layer.js"
|
||||||
//#include "item/Raster.js"
|
//#include "item/Raster.js"
|
||||||
//#include "item/PlacedSymbol.js"
|
//#include "item/PlacedSymbol.js"
|
||||||
|
//#include "item/Style.js"
|
||||||
//#include "item/PathStyle.js"
|
//#include "item/PathStyle.js"
|
||||||
|
|
||||||
//#include "path/Segment.js"
|
//#include "path/Segment.js"
|
||||||
|
|
|
@ -48,7 +48,7 @@ var CharacterStyle = this.CharacterStyle = PathStyle.extend({
|
||||||
font: 'sans-serif'
|
font: 'sans-serif'
|
||||||
});
|
});
|
||||||
this.base(style);
|
this.base(style);
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The font of the character style.
|
* The font of the character style.
|
||||||
|
@ -65,12 +65,4 @@ var CharacterStyle = this.CharacterStyle = PathStyle.extend({
|
||||||
* @default 10
|
* @default 10
|
||||||
* @type Number
|
* @type Number
|
||||||
*/
|
*/
|
||||||
|
|
||||||
statics: {
|
|
||||||
create: function(item) {
|
|
||||||
var style = new CharacterStyle(CharacterStyle.dont);
|
|
||||||
style._item = item;
|
|
||||||
return style;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var ParagraphStyle = this.ParagraphStyle = Base.extend({
|
var ParagraphStyle = this.ParagraphStyle = Style.extend({
|
||||||
/** @lends ParagraphStyle# */
|
/** @lends ParagraphStyle# */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +46,7 @@ var ParagraphStyle = this.ParagraphStyle = Base.extend({
|
||||||
Base.initialize(this, style, {
|
Base.initialize(this, style, {
|
||||||
justification: 'left'
|
justification: 'left'
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The justification of the paragraph.
|
* The justification of the paragraph.
|
||||||
|
@ -55,12 +55,4 @@ var ParagraphStyle = this.ParagraphStyle = Base.extend({
|
||||||
* @default 'left'
|
* @default 'left'
|
||||||
* @type String('left', 'right', 'center')
|
* @type String('left', 'right', 'center')
|
||||||
*/
|
*/
|
||||||
|
|
||||||
statics: {
|
|
||||||
create: function(item) {
|
|
||||||
var style = new ParagraphStyle(ParagraphStyle.dont);
|
|
||||||
style._item = item;
|
|
||||||
return style;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue