mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Switch from inline @option tags to real doc tags.
This commit is contained in:
parent
c25548031b
commit
99ef521af4
7 changed files with 107 additions and 106 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 0d715f3430318411604eeb477080b7008a1dd27c
|
||||
Subproject commit d9e43ebb265a200172dfa6ac8366b2995317c04c
|
|
@ -189,7 +189,7 @@
|
|||
checkCollisions: function() {
|
||||
var crashRock;
|
||||
|
||||
// move rocks and do a hit test
|
||||
// move rocks and do a hit-test
|
||||
// between bounding rect of rocks and ship
|
||||
for (var i = 0; i < Rocks.children.length; i++) {
|
||||
var rock = Rocks.children[i];
|
||||
|
|
|
@ -116,9 +116,9 @@ var PaperScope = Base.extend(/** @lends PaperScope# */{
|
|||
/**
|
||||
* Gives access to paper's configurable settings.
|
||||
*
|
||||
* {@option settings.applyMatrix:Boolean}
|
||||
* {@option settings.handleSize:Number}
|
||||
* {@option settings.hitTolerance:Number}
|
||||
* @option settings.applyMatrix {Boolean}
|
||||
* @option settings.handleSize {Number}
|
||||
* @option settings.hitTolerance {Number}
|
||||
*
|
||||
* @name PaperScope#settings
|
||||
* @type Object
|
||||
|
|
|
@ -1665,38 +1665,38 @@ var Item = Base.extend(Emitter, /** @lends Item# */{
|
|||
},
|
||||
|
||||
/**
|
||||
* Perform a hit test on the item (and its children, if it is a
|
||||
* Perform a hit-test on the item (and its children, if it is a
|
||||
* {@link Group} or {@link Layer}) at the location of the specified point.
|
||||
*
|
||||
* The options object allows you to control the specifics of the hit test
|
||||
* The options object allows you to control the specifics of the hit-test
|
||||
* and may contain a combination of the following values:
|
||||
*
|
||||
* {@option options.tolerance:Number the tolerance of the hit test in
|
||||
* @option options.tolerance {Number} the tolerance of the hit-test in
|
||||
* points. Can also be controlled through
|
||||
* {@link Project#options}{@code .hitTolerance}.}
|
||||
* {@option options.class:{Function} Only hit test again a certain item
|
||||
* class and its sub-classes: {@code Group, Layer, Path, CompoundPath,
|
||||
* Shape, Raster, PlacedSymbol, PointText}, etc.}
|
||||
* {@option options.fill:{Boolean} hit test the fill of items.}
|
||||
* {@option options.stroke:{Boolean} hit test the stroke of path.}
|
||||
* items, taking into account the setting of stroke color and width.}
|
||||
* {@option options.segments:{Boolean} hit test for {@link Segment#point} of
|
||||
* {@link Path} items.}
|
||||
* {@option options.curves:{Boolean} hit test the curves of path items,
|
||||
* without taking the stroke color or width into account.}
|
||||
* {@option options.handles:{Boolean} hit test for the handles.}
|
||||
* ({@link Segment#handleIn} / {@link Segment#handleOut}) of path segments.}
|
||||
* {@option options.ends:{Boolean} only hit test for the first or
|
||||
* last segment points of open path items.}
|
||||
* {@option options.bounds:{Boolean} hit test the corners and
|
||||
* side-centers of the bounding rectangle of items ({@link Item#bounds}).}
|
||||
* {@option options.center:{Boolean} hit test the {@link Rectangle#center}
|
||||
* of the bounding rectangle of items ({@link Item#bounds}).}
|
||||
* {@option options.guides:{Boolean} hit test items that have
|
||||
* {@link Item#guide} set to {@code true}.}
|
||||
* {@option options.selected:{Boolean} only hit selected items.}
|
||||
* {@link PaperScope#settings}{@code .hitTolerance}.
|
||||
* @option options.class {Function} only hit-test again a certain item class
|
||||
* and its sub-classes: {@code Group, Layer, Path, CompoundPath,
|
||||
* Shape, Raster, PlacedSymbol, PointText}, etc.
|
||||
* @option options.fill {Boolean} hit-test the fill of items.
|
||||
* @option options.stroke {Boolean} hit-test the stroke of path items,
|
||||
* taking into account the setting of stroke color and width.
|
||||
* @option options.segments {Boolean} hit-test for {@link Segment#point} of
|
||||
* {@link Path} items.
|
||||
* @option options.curves {Boolean} hit-test the curves of path items,
|
||||
* without taking the stroke color or width into account.
|
||||
* @option options.handles {Boolean} hit-test for the handles.
|
||||
* ({@link Segment#handleIn} / {@link Segment#handleOut}) of path segments.
|
||||
* @option options.ends {Boolean} only hit-test for the first or last
|
||||
* segment points of open path items.
|
||||
* @option options.bounds {Boolean} hit-test the corners and side-centers of
|
||||
* the bounding rectangle of items ({@link Item#bounds}).
|
||||
* @option options.center {Boolean} hit-test the {@link Rectangle#center} of
|
||||
* the bounding rectangle of items ({@link Item#bounds}).
|
||||
* @option options.guides {Boolean} hit-test items that have
|
||||
* {@link Item#guide} set to {@code true}.
|
||||
* @option options.selected {Boolean} only hit selected items.
|
||||
*
|
||||
* @param {Point} point The point where the hit test should be performed
|
||||
* @param {Point} point The point where the hit-test should be performed
|
||||
* @param {Object} [options={ fill: true, stroke: true, segments: true,
|
||||
* tolerance: 2 }]
|
||||
* @return {HitResult} a hit result object that contains more
|
||||
|
@ -1812,6 +1812,7 @@ var Item = Base.extend(Emitter, /** @lends Item# */{
|
|||
* Checks whether the item matches the criteria described by the given
|
||||
* object, by iterating over all of its properties and matching against
|
||||
* their values through {@link #matches(name, compare)}.
|
||||
*
|
||||
* See {@link Project#getItems(match)} for a selection of illustrated
|
||||
* examples.
|
||||
*
|
||||
|
@ -1829,6 +1830,7 @@ var Item = Base.extend(Emitter, /** @lends Item# */{
|
|||
* partial matching (e.g. only providing the x-coordinate to match all
|
||||
* points with that x-value). Partial matching does work for
|
||||
* {@link Item#data}.
|
||||
*
|
||||
* See {@link Project#getItems(match)} for a selection of illustrated
|
||||
* examples.
|
||||
*
|
||||
|
@ -1960,11 +1962,12 @@ var Item = Base.extend(Emitter, /** @lends Item# */{
|
|||
* Exports (serializes) the item with its content and child items to a JSON
|
||||
* data string.
|
||||
*
|
||||
* The options object offers control over some aspects of the SVG export:
|
||||
* {@option options.asString:{Boolean} whether the JSON is returned
|
||||
* as a {@code Object} or a {@code String}.}
|
||||
* {@option options.precision:{Number} the amount of fractional
|
||||
* digits in numbers used in JSON data.}
|
||||
* The options object offers control over some aspects of the JSON export:
|
||||
*
|
||||
* @option options.asString {Boolean} whether the JSON is returned as a
|
||||
* {@code Object} or a {@code String}.
|
||||
* @option options.precision {Number} the amount of fractional digits in
|
||||
* numbers used in JSON data.
|
||||
*
|
||||
* @name Item#exportJSON
|
||||
* @function
|
||||
|
@ -1997,12 +2000,12 @@ var Item = Base.extend(Emitter, /** @lends Item# */{
|
|||
*
|
||||
* The options object offers control over some aspects of the SVG export:
|
||||
*
|
||||
* {@option options.asString:{Boolean} whether a SVG node or a
|
||||
* {@code String} is to be returned.}
|
||||
* {@option options.precision:{Number} the amount of fractional digits in
|
||||
* numbers used in SVG data.}
|
||||
* {@option options.matchShapes:{Boolean} whether path items should tried to
|
||||
* be converted to shape items, if their geometries can be made to match.}
|
||||
* @option options.asString {Boolean} whether a SVG node or a {@code String}
|
||||
* is to be returned.
|
||||
* @option options.precision {Number} the amount of fractional digits in
|
||||
* numbers used in SVG data.
|
||||
* @option options.matchShapes {Boolean} whether path items should tried to
|
||||
* be converted to shape items, if their geometries can be made to match.
|
||||
*
|
||||
* @name Item#exportSVG
|
||||
* @function
|
||||
|
@ -2020,8 +2023,8 @@ var Item = Base.extend(Emitter, /** @lends Item# */{
|
|||
*
|
||||
* The options object offers control over some aspects of the SVG import:
|
||||
*
|
||||
* {@option options.expandShapes:{Boolean} whether imported shape
|
||||
* items should be expanded to path items.}
|
||||
* @option options.expandShapes {Boolean} whether imported shape items
|
||||
* should be expanded to path items.
|
||||
*
|
||||
* @name Item#importSVG
|
||||
* @function
|
||||
|
@ -3188,12 +3191,12 @@ var Item = Base.extend(Emitter, /** @lends Item# */{
|
|||
* The function receives an event object which contains information about
|
||||
* the frame event:
|
||||
*
|
||||
* {@option event.count:{Number} the number of times the frame event was
|
||||
* fired.}
|
||||
* {@option event.time:{Number} the total amount of time passed since the
|
||||
* first frame event in seconds.}
|
||||
* {@option event.delta:{Number} the time passed in seconds since the last
|
||||
* frame event.}
|
||||
* @option event.count {Number} the number of times the frame event was
|
||||
* fired.
|
||||
* @option event.time {Number} the total amount of time passed since the
|
||||
* first frame event in seconds.
|
||||
* @option event.delta {Number} the time passed in seconds since the last
|
||||
* frame event.
|
||||
*
|
||||
* @see View#onFrame
|
||||
* @example {@paperscript}
|
||||
|
|
|
@ -287,38 +287,38 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
|
|||
},
|
||||
|
||||
/**
|
||||
* Perform a hit test on the items contained within the project at the
|
||||
* Perform a hit-test on the items contained within the project at the
|
||||
* location of the specified point.
|
||||
*
|
||||
* The options object allows you to control the specifics of the hit test
|
||||
* The options object allows you to control the specifics of the hit-test
|
||||
* and may contain a combination of the following values:
|
||||
*
|
||||
* {@option options.tolerance:Number the tolerance of the hit test in
|
||||
* @option options.tolerance {Number} the tolerance of the hit-test in
|
||||
* points. Can also be controlled through
|
||||
* {@link Project#options}{@code .hitTolerance}.}
|
||||
* {@option options.class:{Function} Only hit test again a certain item
|
||||
* class and its sub-classes: {@code Group, Layer, Path, CompoundPath,
|
||||
* Shape, Raster, PlacedSymbol, PointText}, etc.}
|
||||
* {@option options.fill:{Boolean} hit test the fill of items.}
|
||||
* {@option options.stroke:{Boolean} hit test the stroke of path.}
|
||||
* items, taking into account the setting of stroke color and width.}
|
||||
* {@option options.segments:{Boolean} hit test for {@link Segment#point} of
|
||||
* {@link Path} items.}
|
||||
* {@option options.curves:{Boolean} hit test the curves of path items,
|
||||
* without taking the stroke color or width into account.}
|
||||
* {@option options.handles:{Boolean} hit test for the handles.}
|
||||
* ({@link Segment#handleIn} / {@link Segment#handleOut}) of path segments.}
|
||||
* {@option options.ends:{Boolean} only hit test for the first or
|
||||
* last segment points of open path items.}
|
||||
* {@option options.bounds:{Boolean} hit test the corners and
|
||||
* side-centers of the bounding rectangle of items ({@link Item#bounds}).}
|
||||
* {@option options.center:{Boolean} hit test the {@link Rectangle#center}
|
||||
* of the bounding rectangle of items ({@link Item#bounds}).}
|
||||
* {@option options.guides:{Boolean} hit test items that have
|
||||
* {@link Item#guide} set to {@code true}.}
|
||||
* {@option options.selected:{Boolean} only hit selected items.}
|
||||
* {@link PaperScope#settings}{@code .hitTolerance}.
|
||||
* @option options.class {Function} only hit-test again a certain item class
|
||||
* and its sub-classes: {@code Group, Layer, Path, CompoundPath,
|
||||
* Shape, Raster, PlacedSymbol, PointText}, etc.
|
||||
* @option options.fill {Boolean} hit-test the fill of items.
|
||||
* @option options.stroke {Boolean} hit-test the stroke of path items,
|
||||
* taking into account the setting of stroke color and width.
|
||||
* @option options.segments {Boolean} hit-test for {@link Segment#point} of
|
||||
* {@link Path} items.
|
||||
* @option options.curves {Boolean} hit-test the curves of path items,
|
||||
* without taking the stroke color or width into account.
|
||||
* @option options.handles {Boolean} hit-test for the handles.
|
||||
* ({@link Segment#handleIn} / {@link Segment#handleOut}) of path segments.
|
||||
* @option options.ends {Boolean} only hit-test for the first or last
|
||||
* segment points of open path items.
|
||||
* @option options.bounds {Boolean} hit-test the corners and side-centers of
|
||||
* the bounding rectangle of items ({@link Item#bounds}).
|
||||
* @option options.center {Boolean} hit-test the {@link Rectangle#center} of
|
||||
* the bounding rectangle of items ({@link Item#bounds}).
|
||||
* @option options.guides {Boolean} hit-test items that have
|
||||
* {@link Item#guide} set to {@code true}.
|
||||
* @option options.selected {Boolean} only hit selected items.
|
||||
*
|
||||
* @param {Point} point the point where the hit test should be performed
|
||||
* @param {Point} point the point where the hit-test should be performed
|
||||
* @param {Object} [options={ fill: true, stroke: true, segments: true,
|
||||
* tolerance: true }]
|
||||
* @return {HitResult} a hit result object that contains more
|
||||
|
@ -584,14 +584,12 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
|
|||
* Exports (serializes) the project with all its layers and child items to
|
||||
* a JSON data string.
|
||||
*
|
||||
* The options object offers control over some aspects of the SVG export:
|
||||
* The options object offers control over some aspects of the JSON export:
|
||||
*
|
||||
* {@option options.asString:{Boolean} whether a SVG node or a {@code String}
|
||||
* is to be returned.}
|
||||
* {@option options.precision:{Number} the amount of fractional digits in
|
||||
* numbers used in SVG data.}
|
||||
* {@option options.matchShapes:{Boolean} whether imported path items should
|
||||
* tried to be converted to shape items, if their geometries match.}
|
||||
* @option options.asString {Boolean} whether the JSON is returned as a
|
||||
* {@code Object} or a {@code String}.
|
||||
* @option options.precision {Number} the amount of fractional digits in
|
||||
* numbers used in JSON data.
|
||||
*
|
||||
* @name Project#exportJSON
|
||||
* @function
|
||||
|
@ -621,12 +619,12 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
|
|||
*
|
||||
* The options object offers control over some aspects of the SVG export:
|
||||
*
|
||||
* {@option options.asString:{Boolean} whether a SVG node or a
|
||||
* {@code String} is to be returned.}
|
||||
* {@option options.precision:{Number} the amount of fractional digits in
|
||||
* numbers used in SVG data.}
|
||||
* {@option options.matchShapes:{Boolean} whether path items should tried to
|
||||
* be converted to shape items, if their geometries can be made to match.}
|
||||
* @option options.asString {Boolean} whether a SVG node or a {@code String}
|
||||
* is to be returned.
|
||||
* @option options.precision {Number} the amount of fractional digits in
|
||||
* numbers used in SVG data.
|
||||
* @option options.matchShapes {Boolean} whether path items should tried to
|
||||
* be converted to shape items, if their geometries can be made to match.
|
||||
*
|
||||
* @name Project#exportSVG
|
||||
* @function
|
||||
|
@ -644,8 +642,8 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
|
|||
*
|
||||
* The options object offers control over some aspects of the SVG import:
|
||||
*
|
||||
* {@option options.expandShapes:{Boolean} whether imported shape
|
||||
* items should be expanded to path items.}
|
||||
* @option options.expandShapes {Boolean} whether imported shape items
|
||||
* should be expanded to path items.
|
||||
*
|
||||
* @name Project#importSVG
|
||||
* @function
|
||||
|
|
|
@ -510,11 +510,11 @@ var View = Base.extend(Emitter, /** @lends View# */{
|
|||
* The function receives an event object which contains information about
|
||||
* the frame event:
|
||||
*
|
||||
* <b>{@code event.count}</b>: the number of times the frame event was
|
||||
* @option event.count {Number} the number of times the frame event was
|
||||
* fired.
|
||||
* <b>{@code event.time}</b>: the total amount of time passed since the
|
||||
* @option event.time {Number} the total amount of time passed since the
|
||||
* first frame event in seconds.
|
||||
* <b>{@code event.delta}</b>: the time passed in seconds since the last
|
||||
* @code event.delta {Number} the time passed in seconds since the last
|
||||
* frame event.
|
||||
*
|
||||
* @example {@paperscript}
|
||||
|
|
|
@ -46,7 +46,7 @@ test('the item on top should be returned', function() {
|
|||
test('hitting a stroked path', function() {
|
||||
var path = new Path([0, 0], [50, 0]);
|
||||
|
||||
// We are hit testing with an offset of 5pt on a path with a stroke width
|
||||
// We are hit-testing with an offset of 5pt on a path with a stroke width
|
||||
// of 10:
|
||||
|
||||
var hitResult = paper.project.hitTest([25, 5]);
|
||||
|
@ -260,7 +260,7 @@ test('hitting path handles (2)', function() {
|
|||
}
|
||||
});
|
||||
|
||||
test('hit testing stroke on segment point of a path', function() {
|
||||
test('hit-testing stroke on segment point of a path', function() {
|
||||
var path = new Path([0, 0], [50, 50], [100, 0]);
|
||||
path.strokeColor = 'black';
|
||||
path.closed = true;
|
||||
|
@ -273,7 +273,7 @@ test('hit testing stroke on segment point of a path', function() {
|
|||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
var description = 'This hit test should not throw an error';
|
||||
var description = 'This hit-test should not throw an error';
|
||||
if (error)
|
||||
description += ': ' + error;
|
||||
equals(error == null, true, description);
|
||||
|
@ -291,7 +291,7 @@ test('Hit testing a point that is extremely close to a curve', function() {
|
|||
} catch(e) {
|
||||
error = e;
|
||||
}
|
||||
var description = 'This hit test should not throw an error';
|
||||
var description = 'This hit-test should not throw an error';
|
||||
if (error)
|
||||
description += ': ' + error;
|
||||
equals(error == null, true, description);
|
||||
|
@ -475,7 +475,7 @@ test('hitting path with a text item in the project', function() {
|
|||
|
||||
});
|
||||
|
||||
test('Check hit testing of items that come after a transformed group.', function() {
|
||||
test('Check hit-testing of items that come after a transformed group.', function() {
|
||||
paper.project.currentStyle.fillColor = 'black';
|
||||
var point1 = new Point(100, 100);
|
||||
var point2 = new Point(140, 100);
|
||||
|
@ -509,37 +509,37 @@ test('Check hit testing of items that come after a transformed group.', function
|
|||
hitResult = paper.project.hitTest(point1);
|
||||
equals(function() {
|
||||
return hitResult && hitResult.item;
|
||||
}, path1, 'After translating group, hit testing project for point1 should give us path1.');
|
||||
}, path1, 'After translating group, hit-testing project for point1 should give us path1.');
|
||||
|
||||
hitResult = paper.project.hitTest(point2.add(delta));
|
||||
equals(function() {
|
||||
return hitResult && hitResult.item;
|
||||
}, path2, 'After translating group, hit testing project for point2 + delta should give us path2.');
|
||||
}, path2, 'After translating group, hit-testing project for point2 + delta should give us path2.');
|
||||
|
||||
hitResult = path1.hitTest(point1);
|
||||
equals(function() {
|
||||
return hitResult && hitResult.item;
|
||||
}, path1, 'After translating group, hit testing path1 for point1 should give us path1.');
|
||||
}, path1, 'After translating group, hit-testing path1 for point1 should give us path1.');
|
||||
|
||||
group.moveBelow(path1);
|
||||
|
||||
hitResult = paper.project.hitTest(point1);
|
||||
equals(function() {
|
||||
return hitResult && hitResult.item;
|
||||
}, path1, 'After moving group before path1, hit testing project for point1 should give us path1.');
|
||||
}, path1, 'After moving group before path1, hit-testing project for point1 should give us path1.');
|
||||
|
||||
hitResult = paper.project.hitTest(point2.add(delta));
|
||||
equals(function() {
|
||||
return hitResult && hitResult.item;
|
||||
}, path2, 'After moving group before path1, hit testing project for point2 + delta should give us path2.');
|
||||
}, path2, 'After moving group before path1, hit-testing project for point2 + delta should give us path2.');
|
||||
|
||||
hitResult = path1.hitTest(point1);
|
||||
equals(function() {
|
||||
return hitResult && hitResult.item;
|
||||
}, path1, 'After moving group before path1, hit testing path1 for point1 should give us path1.');
|
||||
}, path1, 'After moving group before path1, hit-testing path1 for point1 should give us path1.');
|
||||
});
|
||||
|
||||
test('Check hit testing of placed symbols.', function() {
|
||||
test('Check hit-testing of placed symbols.', function() {
|
||||
var point = new Point(100, 100);
|
||||
|
||||
var path = new Path.Circle([0, 0], 20);
|
||||
|
|
Loading…
Reference in a new issue