refactor text render

Support G inherit props.
Refactor text render. Text glyphs will perfectly draw along the path
This commit is contained in:
Horcrux
2016-07-22 23:49:15 +08:00
parent 63f793c54e
commit 7e13b801e1
41 changed files with 467 additions and 477 deletions

View File

@@ -3,20 +3,22 @@ import _ from 'lodash';
import patternReg from './patternReg';
export default function (colorOrBrush) {
if (colorOrBrush === 'none') {
if (colorOrBrush === 'none' || _.isNil(colorOrBrush)) {
return null;
} else if (_.isNil(colorOrBrush)) {
colorOrBrush = '#000';
}
let matched = colorOrBrush.match(patternReg);
// brush
if (matched) {
return [1, matched[1]];
//todo:
} else { // solid color
let c = new Color(colorOrBrush).rgbaArray();
return [0, c[0] / 255, c[1] / 255, c[2] / 255, c[3]];
try {
let matched = colorOrBrush.match(patternReg);
// brush
if (matched) {
return [1, matched[1]];
//todo:
} else { // solid color
let c = new Color(colorOrBrush).rgbaArray();
return [0, c[0] / 255, c[1] / 255, c[2] / 255, c[3]];
}
} catch(err) {
console.warn(`"${colorOrBrush}" is not a valid color or brush`);
return null;
}
}