gliffy / canvas2svg

Translates HTML5 Canvas draw commands to SVG
MIT License
683 stars 155 forks source link

shadowColor method missing #72

Open Zamiell opened 5 years ago

Zamiell commented 5 years ago

Looks like ctx.shadowColor isn't implemented in the latest version of the library. If anyone wants to add this, I'll pay a bounty.

Yaffle commented 4 years ago

I have tried to add support for a drop-shadow filter ( https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/filter ) :


    ctx.prototype.__applyFilter = function () {
        var filter = this.filter;
        if (filter != null) {
            var match = /^drop-shadow\(([^p]+)px\s+([^p]+)px\s+([^p]+)px\s+([\s\S]+?)\)$/.exec(filter);
            if (match != null) {
                var dx = match[1];
                var dy = match[2];
                var stdDeviation = Number.parseFloat(match[3]) / 2;
                var floodColor = match[4];
                var feDropShadowElement = this.__createElement("feDropShadow", {
                    dx: dx,
                    dy: dy,
                    stdDeviation: stdDeviation,
                    "flood-color": floodColor
                }, false);
                var id = randomString(this.__ids);
                var filterElement = this.__createElement("filter", {
                    id: id
                }, false);
                filterElement.appendChild(feDropShadowElement);
                this.__defs.appendChild(filterElement);
                this.__currentElement.setAttribute('filter', format("url(#{id})", {id:id}));
            }
        }
    };
Zamiell commented 3 years ago

Nice, DM me on Discord Zamiel#8743

Yaffle commented 3 years ago

@Zamiell i don't know how to use Discord, do you want to ask something?

Zamiell commented 3 years ago

Was gonna offer to pay you

Yaffle commented 3 years ago

@Zamiell , thanks, glad to see this, but no need I have some money