diff --git a/src/item/PathStyle.js b/src/item/PathStyle.js index e296ad01..ff06150f 100644 --- a/src/item/PathStyle.js +++ b/src/item/PathStyle.js @@ -14,7 +14,7 @@ * All rights reserved. */ -var PathStyle = this.PathStyle = Base.extend(new function() { +var PathStyle = this.PathStyle = Style.extend(new function() { /** @lends PathStyle# */ // windingRule / resolution / fillOverprint / strokeOverprint are currently @@ -77,14 +77,6 @@ var PathStyle = this.PathStyle = Base.extend(new function() { ? value.clone() : value; } } - }, - - statics: { - create: function(item) { - var style = new PathStyle(PathStyle.dont); - style._item = item; - return style; - } } }; diff --git a/src/item/Style.js b/src/item/Style.js new file mode 100644 index 00000000..03373b05 --- /dev/null +++ b/src/item/Style.js @@ -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; + } + } +}); diff --git a/src/load.js b/src/load.js index eba11721..18ce62f8 100644 --- a/src/load.js +++ b/src/load.js @@ -44,6 +44,7 @@ var sources = [ 'src/item/Layer.js', 'src/item/Raster.js', 'src/item/PlacedSymbol.js', + 'src/item/Style.js', 'src/item/PathStyle.js', 'src/path/Segment.js', diff --git a/src/paper.js b/src/paper.js index 045cffa4..2a4ec1c2 100644 --- a/src/paper.js +++ b/src/paper.js @@ -64,6 +64,7 @@ var paper = new function() { //#include "item/Layer.js" //#include "item/Raster.js" //#include "item/PlacedSymbol.js" +//#include "item/Style.js" //#include "item/PathStyle.js" //#include "path/Segment.js" diff --git a/src/text/CharacterStyle.js b/src/text/CharacterStyle.js index 711b28e6..704f3bdb 100644 --- a/src/text/CharacterStyle.js +++ b/src/text/CharacterStyle.js @@ -48,7 +48,7 @@ var CharacterStyle = this.CharacterStyle = PathStyle.extend({ font: 'sans-serif' }); this.base(style); - }, + } /** * The font of the character style. @@ -65,12 +65,4 @@ var CharacterStyle = this.CharacterStyle = PathStyle.extend({ * @default 10 * @type Number */ - - statics: { - create: function(item) { - var style = new CharacterStyle(CharacterStyle.dont); - style._item = item; - return style; - } - } }); diff --git a/src/text/ParagraphStyle.js b/src/text/ParagraphStyle.js index b9209367..09cedcab 100644 --- a/src/text/ParagraphStyle.js +++ b/src/text/ParagraphStyle.js @@ -14,7 +14,7 @@ * All rights reserved. */ -var ParagraphStyle = this.ParagraphStyle = Base.extend({ +var ParagraphStyle = this.ParagraphStyle = Style.extend({ /** @lends ParagraphStyle# */ /** @@ -46,7 +46,7 @@ var ParagraphStyle = this.ParagraphStyle = Base.extend({ Base.initialize(this, style, { justification: 'left' }); - }, + } /** * The justification of the paragraph. @@ -55,12 +55,4 @@ var ParagraphStyle = this.ParagraphStyle = Base.extend({ * @default 'left' * @type String('left', 'right', 'center') */ - - statics: { - create: function(item) { - var style = new ParagraphStyle(ParagraphStyle.dont); - style._item = item; - return style; - } - } });