McTrafik
McTrafik

Reputation: 2939

GWT Canvas (2.2.0) Transparent StrokeStyle

I am making a drawing application w/ GWT (2.2.0) canvas.

The problem that I'm having is that I can't set the opacity of the color.

HTML5Canvas supports the alpha channel. However through GWT it passes whatever string into a CssColor which drops the alpha.

Meaning in JS this works (I think):

context.strokeStyle = "rgba(0,0,0,0.5)";

But in GWT this doesn't (ignores alpha)

context.setStrokeStyle("rgba(0,0,0,0.5)");

because it transfers to

setStrokeStyle(CssColor.make("rgba(0,0,0,0.5)"))

And CssColor doesn't support transparency.

Any suggestions on how to go around this issue.

P.S. This is a very needed feature to be able to, say have an eraser and a highlighter.

EDIT: Square erasers can be done using context.clearRect(...), but that's not what I'm going for.

Upvotes: 1

Views: 4003

Answers (1)

ngspkinga
ngspkinga

Reputation: 411

I found for you a nice example here. I hope it will help you!

Upvotes: 1

Related Questions