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

Rect shadow broken #11

Closed
SuperDog83 opened this issue Oct 28, 2018 · 3 comments
Closed

Rect shadow broken #11

SuperDog83 opened this issue Oct 28, 2018 · 3 comments

Comments

@SuperDog83
Copy link

SuperDog83 commented Oct 28, 2018

Hello again,
Was just experimenting with rect shadows and found out that:

  • Rendering shadows is really slow (and uses 100% of my GPU)
  • There is a bug when you call DrawImage before rendering the rect

For the bug, here's a screenshot:

img

what's excepted:

img

Here's the code used to draw the rect

cnv.Rect(this.X, this.Y, this.W, this.H)
cnv.SetFillStyle(this.Color)
cnv.SetShadowColor(this.ShadowColor)
cnv.SetShadowBlur(this.ShadowBlur)
cnv.SetShadowOffsetX(this.ShadowOffX)
cnv.SetShadowOffsetY(this.ShadowOffY)
cnv.Fill()
@tfriedel6
Copy link
Owner

Hi again!

I haven't been able to reproduce the DrawImage problem. Could you maybe post the code with the DrawImage?

As for the performance, that is certainly possible that that can be kinda slow. That's a disadvantage of me using a fairly fast computer, I don't really notice that sometimes. At some point I'll switch to a computer with an embedded GPU and check there.

But just to be sure, did you call cnv.BeginPath() before calling cnv.Rect()? If not, it will actually append the rect to the path every frame. I don't really like that behavior, but it does seem to be the way that the HTML canvas works as well.

@SuperDog83
Copy link
Author

SuperDog83 commented Oct 29, 2018

I have edited the code for the rect, but the issue is still there... :(

		cnv.BeginPath()
		cnv.Rect(this.X, this.Y, this.W, this.H)
		cnv.SetFillStyle(this.Color)
		cnv.SetShadowColor(this.ShadowColor)
		cnv.SetShadowBlur(this.ShadowBlur)
		cnv.SetShadowOffsetX(this.ShadowOffX)
		cnv.SetShadowOffsetY(this.ShadowOffY)
		cnv.Fill()

for the drawImage

func (this *Image) Render(cnv *canvas.Canvas) {
	cnv.DrawImage(this.Src, this.X, this.Y)
}

@tfriedel6
Copy link
Owner

I still haven't been able to reproduce the problem with the DrawImage and the shadow. According to your screenshots, the image should not be drawn at all. Is that right?

As for the performance, the shadows are indeed not all that fast. I hadn't noticed since on my computer they are quite fast, but I tried running it on my phone, and it slows down considerably. There does seem to be a faster way to do blurs, but I'm not sure yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants