Add Text
This commit is contained in:
Horcrux
2016-01-23 11:09:00 +08:00
parent b871e0087e
commit d40921354b
9 changed files with 285 additions and 15 deletions
+30 -4
View File
@@ -5,12 +5,13 @@ import React, {
} from 'react-native';
let {
Text:ARTText,
Shape
Text:ARTText
} = ART;
import fillFilter from '../lib/fillFilter';
import strokeFilter from '../lib/strokeFilter';
const fontFamily = '"Helvetica Neue", "Helvetica", Arial';
class Text extends Component{
static displayName = 'Text';
static propTypes = {
@@ -21,15 +22,40 @@ class Text extends Component{
};
render() {
let {props} = this;
return <Shape d="M0, 0 L0, 0Z" />;
return <ARTText
let x = 0;
if (props.x) {
x = props.dx ? +props.x + (+props.dx) : +props.x;
}
let y = 0;
if (props.y) {
y = props.dy ? +props.y + (+props.dy) : +props.y;
}
let coords = props.origin ? props.origin.split(',') : [];
let originX = coords.length === 2 ? coords[0] : props.originX;
let originY = coords.length === 2 ? coords[1] :props.originY;
return <ARTText
{...props}
font={{
fontSize: props.fontSize || 12,
fontFamily: props.fontFamily || fontFamily,
fontWeight: props.fontWeight,
fontStyle: props.fontStyle
}}
rotation={props.rotation || props.rotate || 0}
scale={props.scale || 1}
originX={originX}
originY={originY}
strokeCap={props.strokeLinecap || props.strokeCap || 'square'}
strokeJoin={props.strokeLinejoin || props.strokeJoin || 'miter'}
alignment={props.textAnchor || props.alignment}
fill={fillFilter(props)}
stroke={strokeFilter(props)}
x={x}
y={y}
/>;
}
}