mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Remove unique IDs from Color objects.
This commit is contained in:
parent
0d2779dfc5
commit
2c2542fb2f
3 changed files with 11 additions and 11 deletions
|
@ -606,9 +606,6 @@ var Color = Base.extend(new function() {
|
||||||
}
|
}
|
||||||
// Default fallbacks: rgb, black
|
// Default fallbacks: rgb, black
|
||||||
this._type = type || 'rgb';
|
this._type = type || 'rgb';
|
||||||
// Define this Color's unique id in its own private id pool.
|
|
||||||
// NOTE: This is only required by SVG Export code!
|
|
||||||
this._id = UID.get(Color);
|
|
||||||
if (!components) {
|
if (!components) {
|
||||||
// Produce a components array now, and parse values. Even if no
|
// Produce a components array now, and parse values. Even if no
|
||||||
// values are defined, parsers are still called to produce
|
// values are defined, parsers are still called to produce
|
||||||
|
|
|
@ -324,7 +324,10 @@ new function() {
|
||||||
function getDefinition(item, type) {
|
function getDefinition(item, type) {
|
||||||
if (!definitions)
|
if (!definitions)
|
||||||
definitions = { ids: {}, svgs: {} };
|
definitions = { ids: {}, svgs: {} };
|
||||||
return item && definitions.svgs[type + '-' + item._id];
|
// Use #__id for items that don't have internal #_id properties (Color),
|
||||||
|
// and give them ids from their own private id pool named 'svg'.
|
||||||
|
var id = item._id || item.__id || (item.__id = UID.get('svg'));
|
||||||
|
return item && definitions.svgs[type + '-' + id];
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDefinition(item, node, type) {
|
function setDefinition(item, node, type) {
|
||||||
|
@ -333,10 +336,11 @@ new function() {
|
||||||
if (!definitions)
|
if (!definitions)
|
||||||
getDefinition();
|
getDefinition();
|
||||||
// Have different id ranges per type
|
// Have different id ranges per type
|
||||||
var id = definitions.ids[type] = (definitions.ids[type] || 0) + 1;
|
var typeId = definitions.ids[type] = (definitions.ids[type] || 0) + 1;
|
||||||
// Give the svg node an id, and link to it from the item id.
|
// Give the svg node an id, and link to it from the item id.
|
||||||
node.id = type + '-' + id;
|
node.id = type + '-' + typeId;
|
||||||
definitions.svgs[type + '-' + item._id] = node;
|
// See getDefinition() for an explanation of #__id:
|
||||||
|
definitions.svgs[type + '-' + (item._id || item.__id)] = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportDefinitions(node, options) {
|
function exportDefinitions(node, options) {
|
||||||
|
|
|
@ -25,11 +25,10 @@ var UID = {
|
||||||
* @return {Number} the next unique id
|
* @return {Number} the next unique id
|
||||||
* @static
|
* @static
|
||||||
**/
|
**/
|
||||||
get: function(ctor) {
|
get: function(name) {
|
||||||
if (ctor) {
|
if (name) {
|
||||||
// Use one UID pool per given constructor
|
// Use one UID pool per given constructor
|
||||||
var name = ctor._class,
|
var pool = this._pools[name];
|
||||||
pool = this._pools[name];
|
|
||||||
if (!pool)
|
if (!pool)
|
||||||
pool = this._pools[name] = { _id: 1 };
|
pool = this._pools[name] = { _id: 1 };
|
||||||
return pool._id++;
|
return pool._id++;
|
||||||
|
|
Loading…
Reference in a new issue