mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -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
|
||||
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) {
|
||||
// Produce a components array now, and parse values. Even if no
|
||||
// values are defined, parsers are still called to produce
|
||||
|
|
|
@ -324,7 +324,10 @@ new function() {
|
|||
function getDefinition(item, type) {
|
||||
if (!definitions)
|
||||
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) {
|
||||
|
@ -333,10 +336,11 @@ new function() {
|
|||
if (!definitions)
|
||||
getDefinition();
|
||||
// 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.
|
||||
node.id = type + '-' + id;
|
||||
definitions.svgs[type + '-' + item._id] = node;
|
||||
node.id = type + '-' + typeId;
|
||||
// See getDefinition() for an explanation of #__id:
|
||||
definitions.svgs[type + '-' + (item._id || item.__id)] = node;
|
||||
}
|
||||
|
||||
function exportDefinitions(node, options) {
|
||||
|
|
|
@ -25,11 +25,10 @@ var UID = {
|
|||
* @return {Number} the next unique id
|
||||
* @static
|
||||
**/
|
||||
get: function(ctor) {
|
||||
if (ctor) {
|
||||
get: function(name) {
|
||||
if (name) {
|
||||
// Use one UID pool per given constructor
|
||||
var name = ctor._class,
|
||||
pool = this._pools[name];
|
||||
var pool = this._pools[name];
|
||||
if (!pool)
|
||||
pool = this._pools[name] = { _id: 1 };
|
||||
return pool._id++;
|
||||
|
|
Loading…
Reference in a new issue