From ba7291700b6c6f56d6267ee2ec45324f70a1d636 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Tue, 21 Jun 2011 00:49:42 +0200 Subject: [PATCH 1/4] Hide Style from documentation. --- src/style/Style.js | 2 ++ 1 file changed, 2 insertions(+) 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) { From 2361556af636df936c4160203c215406c64a0ed8 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Tue, 21 Jun 2011 00:54:14 +0200 Subject: [PATCH 2/4] TextItem related documentation. --- src/style/CharacterStyle.js | 21 +++++++++---- src/style/ParagraphStyle.js | 28 ++++++++++++----- src/text/PointText.js | 1 - src/text/TextItem.js | 60 ++++++++++++++++++++++++++++++++++--- 4 files changed, 91 insertions(+), 19 deletions(-) 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/text/PointText.js b/src/text/PointText.js index 0fda2a82..927ede5f 100644 --- a/src/text/PointText.js +++ b/src/text/PointText.js @@ -26,7 +26,6 @@ var PointText = this.PointText = TextItem.extend({ * @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 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') + */ }); From 3a9da3c0a0bce80e8934b3910556ec055a51a4e1 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Tue, 21 Jun 2011 01:12:47 +0200 Subject: [PATCH 3/4] Documentation: add class example to PointText. --- src/text/PointText.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/text/PointText.js b/src/text/PointText.js index 927ede5f..eef89045 100644 --- a/src/text/PointText.js +++ b/src/text/PointText.js @@ -23,15 +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.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) { From 4c306b9997e7a070b108ccd79ca7906fd527de25 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Tue, 21 Jun 2011 01:31:07 +0200 Subject: [PATCH 4/4] Add failing test where after cloning a selected item, it isn't added to the Project#selectedItems array. --- test/tests/Path.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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++) {