first step of TSpan

This commit is contained in:
Horcrux
2016-08-30 09:37:38 +08:00
parent e78e5db092
commit bd26c04a1d
10 changed files with 400 additions and 137 deletions

View File

@@ -17,30 +17,6 @@ function arrayDiffer(a, b) {
return false;
}
function fontAndLinesDiffer(a, b) {
if (a === b) {
return false;
}
if (a.font !== b.font) {
if (a.font === null) {
return true;
}
if (b.font === null) {
return true;
}
if (
a.font.fontFamily !== b.font.fontFamily ||
a.font.fontSize !== b.font.fontSize ||
a.font.fontWeight !== b.font.fontWeight ||
a.font.fontStyle !== b.font.fontStyle
) {
return true;
}
}
return arrayDiffer(a.lines, b.lines);
}
const ViewBoxAttributes = {
minX: true,
minY: true,
@@ -104,16 +80,22 @@ const PathAttributes = merge({
}
}, RenderableAttributes);
const TextAttributes = merge({
alignment: true,
frame: {
diff: fontAndLinesDiffer
},
path: {
diff: arrayDiffer
}
const FontAttributes = merge({
fontFamily: true,
fontSize: true,
fontWeight: true,
fontStyle: true
}, RenderableAttributes);
const TSpanAttributes = merge({
line: true
}, FontAttributes);
const TextAttributes = merge({
alignment: true
}, FontAttributes);
const ClipPathAttributes = {
name: true
};
@@ -184,6 +166,7 @@ const RectAttributes = merge({
export {
PathAttributes,
TextAttributes,
TSpanAttributes,
GroupAttributes,
ClipPathAttributes,
CircleAttributes,