mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Make sure color components cannot be anything else than numbers.
This commit is contained in:
parent
fbe8a558bd
commit
e2a118e43e
1 changed files with 4 additions and 2 deletions
|
@ -240,7 +240,8 @@ var Color = this.Color = Base.extend(new function() {
|
|||
: name === 'hue'
|
||||
? function(value) {
|
||||
// Keep negative values within modulo 360 too:
|
||||
return ((value % 360) + 360) % 360;
|
||||
return isNaN(value) ? 0
|
||||
: ((value % 360) + 360) % 360;
|
||||
}
|
||||
: type === 'gradient'
|
||||
? function(value) {
|
||||
|
@ -249,7 +250,8 @@ var Color = this.Color = Base.extend(new function() {
|
|||
name === 'highlight');
|
||||
}
|
||||
: function(value) {
|
||||
return Math.min(Math.max(value, 0), 1);
|
||||
return isNaN(value) ? 0
|
||||
: Math.min(Math.max(value, 0), 1);
|
||||
};
|
||||
|
||||
this['get' + part] = function() {
|
||||
|
|
Loading…
Reference in a new issue