Improve opacity support

This commit is contained in:
ziajka 2018-05-24 14:56:09 +02:00
parent 599491fa88
commit cbe8f2d584
4 changed files with 5 additions and 5 deletions

View File

@ -13,7 +13,7 @@ export class EllipseConverter implements SvgConverter {
const fill_opacity = node.attributes.getNamedItem("fill-opacity");
if (fill) {
drawing.fill_opacity = parseInt(fill_opacity.value, 10);
drawing.fill_opacity = parseFloat(fill_opacity.value);
}
const stroke = node.attributes.getNamedItem("stroke");

View File

@ -11,7 +11,7 @@ describe('RectConverter', () => {
it('should parse attributes', () => {
const node = document.createElement("rect");
node.setAttribute("fill", "#ffffff");
node.setAttribute("fill-opacity", "1.0");
node.setAttribute("fill-opacity", "0.7");
node.setAttribute("stroke", "#000000");
node.setAttribute("stroke-width", "2");
@ -20,7 +20,7 @@ describe('RectConverter', () => {
const drawing = rectConverter.convert(node);
expect(drawing.fill).toEqual("#ffffff");
expect(drawing.fill_opacity).toEqual(1.0);
expect(drawing.fill_opacity).toEqual(0.7);
expect(drawing.stroke).toEqual("#000000");
expect(drawing.stroke_width).toEqual(2.0);
expect(drawing.width).toEqual(100);

View File

@ -13,7 +13,7 @@ export class RectConverter implements SvgConverter {
const fill_opacity = node.attributes.getNamedItem("fill-opacity");
if (fill) {
drawing.fill_opacity = parseInt(fill_opacity.value, 10);
drawing.fill_opacity = parseFloat(fill_opacity.value);
}
const stroke = node.attributes.getNamedItem("stroke");

View File

@ -15,7 +15,7 @@ export class TextConverter implements SvgConverter {
const fill_opacity = node.attributes.getNamedItem('fill-opacity');
if (fill_opacity) {
drawing.fill_opacity = +fill_opacity.value;
drawing.fill_opacity = parseFloat(fill_opacity.value);
}
const font_family = node.attributes.getNamedItem('font-family');