diff --git a/src/style/CharacterStyle.js b/src/style/CharacterStyle.js
index 5147da25..3f588b84 100644
--- a/src/style/CharacterStyle.js
+++ b/src/style/CharacterStyle.js
@@ -38,15 +38,13 @@ var CharacterStyle = this.CharacterStyle = PathStyle.extend({
* @class The CharacterStyle object represents the character style of a text
* item ({@link TextItem#characterStyle})
*
- * Example:
- *
- * var text = new PointText(new Point(50, 50));
+ * @classexample {@paperscript height=100}
+ * var text = new PointText(new Point(50, 60));
* text.content = 'Hello world.';
* text.characterStyle = {
- * fontSize: 50,
- * fillColor: 'black',
+ * fontSize: 30,
+ * font: 'times'
* };
- *
*
* @extends PathStyle
*/
@@ -57,6 +55,12 @@ var CharacterStyle = this.CharacterStyle = PathStyle.extend({
* @name CharacterStyle#font
* @default 'sans-serif'
* @type String
+ *
+ * @example {@paperscript height=150}
+ * var textItem = new PointText(new Point(20, 80));
+ * textItem.content = 'Hello world.';
+ * textItem.fontSize = 30;
+ * textItem.font = 'times';
*/
/**
@@ -65,5 +69,10 @@ var CharacterStyle = this.CharacterStyle = PathStyle.extend({
* @name CharacterStyle#fontSize
* @default 10
* @type Number
+ *
+ * @example {@paperscript height=150}
+ * var textItem = new PointText(new Point(20, 80));
+ * textItem.content = 'Hello world.';
+ * textItem.fontSize = 30;
*/
});
diff --git a/src/style/ParagraphStyle.js b/src/style/ParagraphStyle.js
index 9f651cfa..76d4f3cb 100644
--- a/src/style/ParagraphStyle.js
+++ b/src/style/ParagraphStyle.js
@@ -38,14 +38,6 @@ var ParagraphStyle = this.ParagraphStyle = Style.extend({
* Currently, the ParagraphStyle object may seem a bit empty, with just the
* {@link #justification} property. Yet, we have lots in store for Paper.js
* when it comes to typography. Please stay tuned.
- *
- * Example:
- *
- * var text = new PointText(new Point(0,0)); - * text.fillColor = 'black'; - * text.content = 'Hello world.'; - * text.paragraphStyle.justification = 'center'; - **/ /** @@ -54,5 +46,25 @@ var ParagraphStyle = this.ParagraphStyle = Style.extend({ * @name ParagraphStyle#justification * @default 'left' * @type String('left', 'right', 'center') + * + * @example {@paperscript height=150 split=false} + * // Examples of the different justifications: + * + * // Create a vertical line that runs from the top center + * // of the view to the bottom center of the view: + * var bounds = view.bounds; + * var path = new Path(bounds.topCenter, bounds.bottomCenter); + * path.strokeColor = 'pink'; + * + * var textItem = new PointText(view.center - [0, 30]); + * textItem.content = 'left justified'; + * + * var textItem2 = new PointText(view.center); + * textItem2.content = 'center justified'; + * textItem2.justification = 'center'; + * + * var textItem3 = new PointText(view.center + [0, 30]); + * textItem3.content = 'right justified'; + * textItem3.justification = 'right'; */ }); diff --git a/src/style/Style.js b/src/style/Style.js index ad404b8b..0aa393cf 100644 --- a/src/style/Style.js +++ b/src/style/Style.js @@ -17,6 +17,8 @@ /** * Internal base-class for all style objects, e.g. PathStyle, CharacterStyle, * PargraphStyle. + * + * @ignore */ var Style = Item.extend({ initialize: function(style) { diff --git a/src/text/PointText.js b/src/text/PointText.js index 0fda2a82..eef89045 100644 --- a/src/text/PointText.js +++ b/src/text/PointText.js @@ -23,16 +23,16 @@ var PointText = this.PointText = TextItem.extend({ * @param {Point} point the position where the text will start * @constructs PointText * - * @example - * var text = new PointText(new Point(50, 100)); - * text.justification = 'center'; - * text.fillColor = 'black'; - * text.content = 'The contents of the point text'; - * * @class A PointText item represents a piece of typography in your Paper.js * project which starts from a certain point and extends by the amount of * characters contained in it. * + * @classexample {@paperscript height=100} + * var text = new PointText(258, 60); + * text.justification = 'center'; + * text.fontSize = 30; + * text.content = 'Hello world.'; + * * @extends TextItem */ initialize: function(point) { diff --git a/src/text/TextItem.js b/src/text/TextItem.js index 5a5c4bd4..00757487 100644 --- a/src/text/TextItem.js +++ b/src/text/TextItem.js @@ -48,7 +48,6 @@ var TextItem = this.TextItem = Item.extend({ * * // Create a point-text item at {x: 30, y: 30}: * var text = new PointText(new Point(30, 30)); - * text.fillColor = 'black'; * * // Set the content of the text item: * text.content = 'Hello world'; @@ -58,7 +57,6 @@ var TextItem = this.TextItem = Item.extend({ * * // Create a point-text item at {x: 30, y: 30}: * var text = new PointText(new Point(30, 30)); - * text.fillColor = 'black'; * * text.content = 'Move your mouse over the view, to see its position'; * @@ -86,8 +84,6 @@ var TextItem = this.TextItem = Item.extend({ }, /** - * {@grouptitle Style Properties} - * * The character style of the text item. * * @type CharacterStyle @@ -114,4 +110,60 @@ var TextItem = this.TextItem = Item.extend({ setParagraphStyle: function(style) { this._paragraphStyle.initialize(style); } + + /** + * {@grouptitle Style Properties} + * The font of the text item. + * + * @example {@paperscript height=150} + * var textItem = new PointText(new Point(20, 80)); + * textItem.content = 'Hello world.'; + * textItem.fontSize = 30; + * textItem.font = 'times'; + * + * @name TextItem#font + * @default 'sans-serif' + * @type String + */ + + /** + * The font size in points of the text item. + * + * @name TextItem#fontSize + * @default 10 + * @type Number + * + * @example {@paperscript height=150} + * var textItem = new PointText(new Point(20, 80)); + * textItem.content = 'Hello world.'; + * textItem.fontSize = 30; + */ + + /** + * The justification of the text item. + * + * @example {@paperscript height=150 split=false} + * // Examples of the different justifications: + * + * // Create a vertical line that runs from the top center + * // of the view to the bottom center of the view: + * var bounds = view.bounds; + * var path = new Path(bounds.topCenter, bounds.bottomCenter); + * path.strokeColor = 'pink'; + * + * var textItem = new PointText(view.center - [0, 30]); + * textItem.content = 'left justified'; + * + * var textItem2 = new PointText(view.center); + * textItem2.content = 'center justified'; + * textItem2.justification = 'center'; + * + * var textItem3 = new PointText(view.center + [0, 30]); + * textItem3.content = 'right justified'; + * textItem3.justification = 'right'; + * + * @name TextItem#justification + * @default 'left' + * @type String('left', 'right', 'center') + */ }); diff --git a/test/tests/Path.js b/test/tests/Path.js index 69e37ca2..803936d8 100644 --- a/test/tests/Path.js +++ b/test/tests/Path.js @@ -168,6 +168,36 @@ test('After simplifying a path using #simplify(), the path should stay fullySele }, true); }); +test('After simplifying a path using #simplify(), the path should stay fullySelected', function() { + var path = new Path(); + for (var i = 0; i < 30; i++) { + path.add(i * 10, 10); + }; + path.fullySelected = true; + equals(function() { + return path.selected; + }, true); + + path.simplify(); + + equals(function() { + return path.selected; + }, true); + equals(function() { + return path.fullySelected; + }, true); +}); + +test('After cloning a selected item, it should be added to the Project#selectedItems array', function() { + var path = new Path.Circle(new Size(80, 50), 35); + path.selected = true; + var copy = path.clone(); + + equals(function() { + return paper.project.selectedItems.length + }, 2); +}); + test('After simplifying a path using #simplify(), the path should stay selected', function() { var path = new Path(); for (var i = 0; i < 30; i++) {