Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: box-shadow rendering #1848

Merged
merged 2 commits into from May 26, 2019
Merged

feat: box-shadow rendering #1848

merged 2 commits into from May 26, 2019

Conversation

niklasvh
Copy link
Owner

@niklasvh niklasvh commented May 26, 2019

Implements box shadow rendering.

Fixes: #1086
Fixes: #221
Fixes: #1622
Fixes: #1353

@niklasvh niklasvh merged commit 5f31b74 into master May 26, 2019
@niklasvh niklasvh deleted the box-shadow branch May 26, 2019 04:54
@skullface
Copy link

THANK YOU!

@a294597562
Copy link

a294597562 commented Jul 9, 2019

it's not support css box-shadow ,for example 'box-shadow: -1px 1px 3px 0 green' ,if the tag also have
css 'border-radius 50%'

@justrealmilk
Copy link

doesn't work

@wangkaiwen
Copy link

doesn't work
image
image

@wangkaiwen
Copy link

if(window.devicePixelRatio!==1){
image
image

}

@viewtance
Copy link

it doesn't work, any special requirement needed?

@wangkaiwen
Copy link

wangkaiwen commented Jan 9, 2020

it doesn't work, any special requirement needed?

please try to modify the source code according to my picture.
my version1.0.0-rc.3.
line6500

        CanvasRenderer.prototype.mask = function (paths) {
            var x=this.options.x,y=this.options.y;
            this.ctx.beginPath();
            this.ctx.moveTo(x, y);
            this.ctx.lineTo(this.canvas.width+x, y);
            this.ctx.lineTo(this.canvas.width+x, this.canvas.height+y);
            this.ctx.lineTo(x, this.canvas.height+y);
            this.ctx.lineTo(x, y);
            this.formatPath(paths.slice(0).reverse());
            this.ctx.closePath();
        };

line6719

_this.ctx.shadowOffsetX = shadow.offsetX.number + maskOffset*window.devicePixelRatio;

@somelou
Copy link

somelou commented Mar 28, 2020

it doesn't work, any special requirement needed?

please try to modify the source code according to my picture.
my version1.0.0-rc.3.
line6500

        CanvasRenderer.prototype.mask = function (paths) {
            var x=this.options.x,y=this.options.y;
            this.ctx.beginPath();
            this.ctx.moveTo(x, y);
            this.ctx.lineTo(this.canvas.width+x, y);
            this.ctx.lineTo(this.canvas.width+x, this.canvas.height+y);
            this.ctx.lineTo(x, this.canvas.height+y);
            this.ctx.lineTo(x, y);
            this.formatPath(paths.slice(0).reverse());
            this.ctx.closePath();
        };


line6719

_this.ctx.shadowOffsetX = shadow.offsetX.number + maskOffset*window.devicePixelRatio;

thanks! It works in version 1.0.0-rc.5

@deborah-sharpcloud
Copy link

using html2Canvas(element, { scale: window.devicePixelRatio }) worked for me (if you don't want to modify the source code)

@ws456999
Copy link

ws456999 commented Apr 9, 2020

using html2Canvas(element, { scale: window.devicePixelRatio }) worked for me (if you don't want to modify the source code)

it doesn't work

@Thul999
Copy link

Thul999 commented May 25, 2020

it doesn't work, any special requirement needed?

please try to modify the source code according to my picture.
my version1.0.0-rc.3.
line6500

        CanvasRenderer.prototype.mask = function (paths) {
            var x=this.options.x,y=this.options.y;
            this.ctx.beginPath();
            this.ctx.moveTo(x, y);
            this.ctx.lineTo(this.canvas.width+x, y);
            this.ctx.lineTo(this.canvas.width+x, this.canvas.height+y);
            this.ctx.lineTo(x, this.canvas.height+y);
            this.ctx.lineTo(x, y);
            this.formatPath(paths.slice(0).reverse());
            this.ctx.closePath();
        };

line6719

_this.ctx.shadowOffsetX = shadow.offsetX.number + maskOffset*window.devicePixelRatio;

It works but only if the element doesn't have border-radius.

@Amy0714Angela
Copy link

html2canvas 1.4.1 , doesn't work,either

@drveresh
Copy link

drveresh commented Oct 9, 2022

@hakimio, @agenntsmi It is still not working with v1.4.1. Can somebody give us a working example?

@hakimio
Copy link

hakimio commented Oct 9, 2022

Try changes from PR #2367 to see if it fixes your issue.

@drveresh
Copy link

drveresh commented Oct 9, 2022

@hakimio I tried all [border-shadow, -webkit-box-shadow, colors(hex,rgb,etc.)] combinations, with outer/inner DIV and/or IMG, but nothing worked.

image

Can you please share one jsfiddle with an example if it is working for you?

@hakimio
Copy link

hakimio commented Oct 9, 2022

No, it won't work properly with the released version.
EDIT: at least not when you are using border-radius.

@drveresh drveresh mentioned this pull request Oct 9, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet