caleb531 / jcanvas

A jQuery plugin that makes the HTML5 canvas easy to work with.
https://projects.calebevans.me/jcanvas/
MIT License
626 stars 192 forks source link

Is it possible to add opacity to linear gradient? #4

Closed Prufrock1 closed 12 years ago

Prufrock1 commented 12 years ago

I'm trying to create a rectangle that has a gradient and is also opaque. is there something I can add to my .gradient() method to achieve this?

caleb531 commented 12 years ago

Use the opacity property. Here's a demohttp://calebevans.me/projects/jcanvas/sandbox.php?#var%20linear%20%3D%20%24%28%22canvas%22%29.gradient%28%7B%0A%20%20x1%3A%200%2C%20y1%3A%200%2C%0A%20%20x2%3A%2020%2C%20y2%3A%2080%2C%0A%20%20c1%3A%20%22%23729fcf%22%2C%20s1%3A%200.33%2C%0A%20%20c2%3A%20%22%233465a4%22%2C%20s2%3A%201%0A%7D%29%3B%0A%24%28%22canvas%22%29.drawArc%28%7B%0A%20%20fillStyle%3A%20linear%2C%0A%20%20x%3A%2050%2C%20y%3A%2050%2C%0A%20%20radius%3A%2030%2C%0A%20%20opacity%3A%200.5%0A%7D%29%3Bto show how to use it for gradients.

I believe you can also use RGBA colors when creating a gradient.

-Caleb

On Mon, Jan 9, 2012 at 3:03 PM, Paul Gladstone < reply@reply.github.com

wrote:

I'm trying to create a rectangle that has a gradient and is also opaque. is there something I can add to my .gradient() method to achieve this?


Reply to this email directly or view it on GitHub: https://github.com/caleb531/jcanvas/issues/4