canvas2svg icon indicating copy to clipboard operation
canvas2svg copied to clipboard

shadowColor method missing

Open Zamiell opened this issue 5 years ago • 5 comments

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.

Zamiell avatar May 07 '19 00:05 Zamiell

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}));
            }
        }
    };

Yaffle avatar Nov 12 '19 20:11 Yaffle

Nice, DM me on Discord Zamiel#8743

Zamiell avatar Feb 28 '21 03:02 Zamiell

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

Yaffle avatar Mar 01 '21 11:03 Yaffle

Was gonna offer to pay you

Zamiell avatar Mar 01 '21 15:03 Zamiell

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

Yaffle avatar Mar 01 '21 15:03 Yaffle