mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Merge branch 'master' of github.com:scriptographer/paper.js
This commit is contained in:
commit
e0f13dd3a0
6 changed files with 129 additions and 24 deletions
|
@ -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:
|
||||
* <code>
|
||||
* 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'
|
||||
* };
|
||||
* </code>
|
||||
*
|
||||
* @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;
|
||||
*/
|
||||
});
|
||||
|
|
|
@ -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:
|
||||
* <pre>
|
||||
* var text = new PointText(new Point(0,0));
|
||||
* text.fillColor = 'black';
|
||||
* text.content = 'Hello world.';
|
||||
* text.paragraphStyle.justification = 'center';
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -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';
|
||||
*/
|
||||
});
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
/**
|
||||
* Internal base-class for all style objects, e.g. PathStyle, CharacterStyle,
|
||||
* PargraphStyle.
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
var Style = Item.extend({
|
||||
initialize: function(style) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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')
|
||||
*/
|
||||
});
|
||||
|
|
|
@ -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++) {
|
||||
|
|
Loading…
Reference in a new issue