mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
SvgImporter: Improve 'none' style handling, and shorten code.
This commit is contained in:
parent
7b32e611b7
commit
dd3a242ee1
1 changed files with 11 additions and 11 deletions
|
@ -251,6 +251,7 @@ var SvgImporter = this.SvgImporter = new function() {
|
|||
// y: multiple values for y
|
||||
// dx: multiple values for x
|
||||
// dy: multiple values for y
|
||||
// TODO: Support for these is missing in Paper.js right now
|
||||
// rotate: character rotation
|
||||
// lengthAdjust:
|
||||
var text = new PointText(getPoint(svg, 'x', 'y', 0)
|
||||
|
@ -291,19 +292,18 @@ var SvgImporter = this.SvgImporter = new function() {
|
|||
function applyAttributeOrStyle(svg, item, name, value) {
|
||||
if (value == null)
|
||||
return;
|
||||
if (value === 'none')
|
||||
value = null;
|
||||
var entry = SvgStyles.attributes[name];
|
||||
if (entry) {
|
||||
if (entry.type === 'number') {
|
||||
value = parseFloat(value, 10);
|
||||
} else if (entry.type === 'array') {
|
||||
value = value.replace(/px/g, '').replace(/, /g, ',')
|
||||
.replace(/ /g, ',').split(',');
|
||||
for (var i = 0, l = value.length; i < l; i++)
|
||||
value[i] = parseFloat(value[i], 10);
|
||||
}
|
||||
item._style[entry.set](value);
|
||||
item._style[entry.set](value === 'none'
|
||||
? null
|
||||
: entry.type === 'number'
|
||||
? parseFloat(value, 10)
|
||||
: entry.type === 'array'
|
||||
? value.replace(/px/g, '').replace(/, /g, ',')
|
||||
.replace(/ /g, ',').split(',').map(function(val) {
|
||||
return parseFloat(val, 10);
|
||||
})
|
||||
: value);
|
||||
} else {
|
||||
switch (name) {
|
||||
case 'id':
|
||||
|
|
Loading…
Reference in a new issue