mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Merge constructor._name with _type and use CamelCase for Item types.
This commit is contained in:
parent
293294a55a
commit
3f5d0a6925
19 changed files with 29 additions and 44 deletions
|
@ -50,12 +50,10 @@ var context = vm.createContext({
|
|||
// Load Paper.js library files:
|
||||
context.include('paper.js');
|
||||
|
||||
// Export all classes through PaperScope:
|
||||
context.Base.each(context, function(val, key) {
|
||||
if (val && val.prototype instanceof context.Base) {
|
||||
val._name = key;
|
||||
// Export all classes through PaperScope:
|
||||
if (val && val.prototype instanceof context.Base)
|
||||
context.PaperScope.prototype[key] = val;
|
||||
}
|
||||
});
|
||||
context.PaperScope.prototype['Canvas'] = context.Canvas;
|
||||
|
||||
|
|
|
@ -38,8 +38,6 @@
|
|||
* matrix multiplication).
|
||||
*/
|
||||
var Matrix = this.Matrix = Base.extend(/** @lends Matrix# */{
|
||||
_type: 'matrix',
|
||||
|
||||
/**
|
||||
* Creates a 2D affine transform.
|
||||
*
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* @class The Gradient object.
|
||||
*/
|
||||
var Gradient = this.Gradient = Base.extend(/** @lends Gradient# */{
|
||||
_type: 'gradient',
|
||||
_type: 'Gradient',
|
||||
|
||||
// TODO: Should type here be called 'radial' and have it receive a
|
||||
// boolean value?
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* @class The GradientColor object.
|
||||
*/
|
||||
var GradientColor = this.GradientColor = Color.extend(/** @lends GradientColor# */{
|
||||
_type: 'gradientcolor',
|
||||
_type: 'GradientColor',
|
||||
|
||||
/**
|
||||
* Creates a gradient color object.
|
||||
|
|
|
@ -36,7 +36,7 @@ this.Base = Base.inject(/** @lends Base# */{
|
|||
*/
|
||||
toString: function() {
|
||||
return this._id != null
|
||||
? (this.constructor._name || 'Object') + (this._name
|
||||
? (this._type || 'Object') + (this._name
|
||||
? " '" + this._name + "'"
|
||||
: ' @' + this._id)
|
||||
: '{ ' + Base.each(this, function(value, key) {
|
||||
|
|
|
@ -10,22 +10,13 @@
|
|||
* All rights reserved.
|
||||
*/
|
||||
|
||||
// Iterate over all produced Base classes and set the _name property of their
|
||||
// constructors to the key under which they are stored. This is a simple hack
|
||||
// that allow us to use their names.
|
||||
// Setting Function#name is not possible, as that is read-only.
|
||||
/*#*/ if (options.version == 'dev') {
|
||||
// When in dev mode, also export all classes through PaperScope, to mimick
|
||||
// scoping behavior of the built library.
|
||||
Base.each(this, function(val, key) {
|
||||
if (val && val.prototype instanceof Base) {
|
||||
val._name = key;
|
||||
/*#*/ if (options.version == 'dev') {
|
||||
// If we're in dev mode, also export all classes through PaperScope, to
|
||||
// mimick scoping behavior of the built library.
|
||||
if (val && val.prototype instanceof Base)
|
||||
PaperScope.prototype[key] = val;
|
||||
/*#*/ } // options.version == 'dev'
|
||||
}
|
||||
});
|
||||
|
||||
/*#*/ if (options.version == 'dev') {
|
||||
// See paper.js for the non-dev version of this code. We cannot handle dev there
|
||||
// due to the seperate loading of all source files, which are only availabe
|
||||
// after the execution of paper.js
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
* @extends Item
|
||||
*/
|
||||
var Group = this.Group = Item.extend(/** @lends Group# */{
|
||||
_type: 'group',
|
||||
_type: 'Group',
|
||||
_serializeFields: {
|
||||
children: []
|
||||
},
|
||||
|
|
|
@ -2563,7 +2563,7 @@ var Item = this.Item = Base.extend(Callback, {
|
|||
// Exclude Raster items since they never draw a stroke and handle
|
||||
// opacity by themselves (they also don't call _setStyles)
|
||||
if (item._blendMode !== 'normal' || item._opacity < 1
|
||||
&& item._type !== 'raster' && (item._type !== 'path'
|
||||
&& item._type !== 'Raster' && (item._type !== 'Path'
|
||||
|| item.getFillColor() && item.getStrokeColor())) {
|
||||
var bounds = item.getStrokeBounds();
|
||||
if (!bounds.width || !bounds.height)
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
* @extends Group
|
||||
*/
|
||||
var Layer = this.Layer = Group.extend(/** @lends Layer# */{
|
||||
_type: 'layer',
|
||||
_type: 'Layer',
|
||||
// DOCS: improve constructor code example.
|
||||
/**
|
||||
* Creates a new Layer item and places it at the end of the
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* @extends PlacedItem
|
||||
*/
|
||||
var PlacedSymbol = this.PlacedSymbol = PlacedItem.extend(/** @lends PlacedSymbol# */{
|
||||
_type: 'placedsymbol',
|
||||
_type: 'PlacedSymbol',
|
||||
_boundsSelected: true,
|
||||
_serializeFields: {
|
||||
symbol: null
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* @extends PlacedItem
|
||||
*/
|
||||
var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{
|
||||
_type: 'raster',
|
||||
_type: 'Raster',
|
||||
_boundsSelected: true,
|
||||
_serializeFields: {
|
||||
source: null
|
||||
|
|
|
@ -127,10 +127,7 @@ var paper = new function() {
|
|||
/*#*/ } // options.svg
|
||||
|
||||
/*#*/ include('core/PaperScript.js');
|
||||
|
||||
/*#*/ if (options.browser) {
|
||||
/*#*/ include('core/initialize.js');
|
||||
/*#*/ } // options.browser
|
||||
|
||||
/*#*/ if (options.version != 'dev') {
|
||||
// Finally inject the classes set on 'this' into the PaperScope class and create
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* @extends PathItem
|
||||
*/
|
||||
var CompoundPath = this.CompoundPath = PathItem.extend(/** @lends CompoundPath# */{
|
||||
_type: 'compoundpath',
|
||||
_type: 'CompoundPath',
|
||||
_serializeFields: {
|
||||
pathData: ''
|
||||
},
|
||||
|
@ -52,7 +52,7 @@ var CompoundPath = this.CompoundPath = PathItem.extend(/** @lends CompoundPath#
|
|||
|
||||
insertChild: function(index, item, _cloning) {
|
||||
// Only allow the insertion of paths
|
||||
if (item._type !== 'path')
|
||||
if (item._type !== 'Path')
|
||||
return null;
|
||||
item = this.base(index, item);
|
||||
// All children except for the bottom one (first one in list) are set
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
// DOCS: Explain that path matrix is always applied with each transformation.
|
||||
var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
||||
_type: 'path',
|
||||
_type: 'Path',
|
||||
_serializeFields: {
|
||||
pathData: ''
|
||||
},
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
* objects that are connected by this segment.
|
||||
*/
|
||||
var Segment = this.Segment = Base.extend(/** @lends Segment# */{
|
||||
_type: 'segment',
|
||||
_type: 'Segment',
|
||||
|
||||
/**
|
||||
* Creates a new Segment object.
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
* to be updated with every transformation.
|
||||
*/
|
||||
var Symbol = this.Symbol = Base.extend(/** @lends Symbol# */{
|
||||
_type: 'symbol',
|
||||
_type: 'Symbol',
|
||||
|
||||
/**
|
||||
* Creates a Symbol item.
|
||||
|
|
|
@ -386,13 +386,13 @@ new function() {
|
|||
}
|
||||
|
||||
var exporters = {
|
||||
group: exportGroup,
|
||||
layer: exportGroup,
|
||||
raster: exportRaster,
|
||||
pointtext: exportText,
|
||||
placedsymbol: exportPlacedSymbol,
|
||||
path: exportPath,
|
||||
compoundpath: exportCompoundPath
|
||||
Group: exportGroup,
|
||||
Layer: exportGroup,
|
||||
Raster: exportRaster,
|
||||
PointText: exportText,
|
||||
PlacedSymbol: exportPlacedSymbol,
|
||||
Path: exportPath,
|
||||
CompoundPath: exportCompoundPath
|
||||
};
|
||||
|
||||
function applyStyle(item, node) {
|
||||
|
|
|
@ -474,7 +474,7 @@ new function() {
|
|||
importer = importers[type],
|
||||
item = importer && importer(node, type);
|
||||
// See importGroup() for an explanation of this filtering:
|
||||
if (item && item._type !== 'group')
|
||||
if (item && item._type !== 'Group')
|
||||
item = applyAttributes(item, node);
|
||||
// Clear definitions at the end of import?
|
||||
if (clearDefs)
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
* @extends TextItem
|
||||
*/
|
||||
var PointText = this.PointText = TextItem.extend(/** @lends PointText# */{
|
||||
_type: 'pointtext',
|
||||
_type: 'PointText',
|
||||
|
||||
/**
|
||||
* Creates a point text item
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue