mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Bring back private UIDs for Color.
SVG Export for multiple gradients was broken.
This commit is contained in:
parent
4fde7ab37d
commit
dbac9c06de
3 changed files with 17 additions and 3 deletions
|
@ -47,7 +47,7 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{
|
||||||
// NOTE: We do not use the same pool as the rest of the library here,
|
// NOTE: We do not use the same pool as the rest of the library here,
|
||||||
// since this is only required to be unique at runtime among other
|
// since this is only required to be unique at runtime among other
|
||||||
// CurveLocation objects.
|
// CurveLocation objects.
|
||||||
this._id = CurveLocation._id = (CurveLocation._id || 0) + 1;
|
this._id = UID.get(CurveLocation);
|
||||||
this._curve = curve;
|
this._curve = curve;
|
||||||
// Also store references to segment1 and segment2, in case path
|
// Also store references to segment1 and segment2, in case path
|
||||||
// splitting / dividing is going to happen, in which case the segments
|
// splitting / dividing is going to happen, in which case the segments
|
||||||
|
|
|
@ -605,6 +605,9 @@ 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 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
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
var UID = {
|
var UID = {
|
||||||
_id: 1,
|
_id: 1,
|
||||||
|
_pools: {},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the next unique id.
|
* Returns the next unique id.
|
||||||
|
@ -24,7 +25,17 @@ var UID = {
|
||||||
* @return {Number} The next unique id
|
* @return {Number} The next unique id
|
||||||
* @static
|
* @static
|
||||||
**/
|
**/
|
||||||
get: function() {
|
get: function(ctor) {
|
||||||
return this._id++;
|
if (ctor) {
|
||||||
|
// Use one UID pool per given constructor
|
||||||
|
var name = ctor._class,
|
||||||
|
pool = this._pools[name];
|
||||||
|
if (!pool)
|
||||||
|
pool = this._pools[name] = { _id: 1 };
|
||||||
|
return pool._id++;
|
||||||
|
} else {
|
||||||
|
// Use the global UID pool:
|
||||||
|
return this._id++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue