http://yuml.me/diagram/scruffy/class/samples

enter image description here

I know how to draw a rectangle like this:

 context.fillRect(x, y, width, height);

How can those kind of images (not straight border, gradient, shadow) be created with gwt canvas? Is this possible at all? What do I have to look for?

有帮助吗?

解决方案

Yes, you can begin with:

// Define the path
ctx.beginPath();
ctx.lineTo(..., ...);
ctx.lineTo(..., ...);
...
ctx.closePath();

// Stroke the path
ctx.setStrokeStyle("#...");
ctx.stroke();

// Fill the path
final CanvasGradient gradient = ctx.createLinearGradient(...);
gradient.addColorStop(0., "#...");
gradient.addColorStop(1., "#...");
ctx.setFillStyle(gradient);
ctx.fill();

The shadow will have to be drawn separately.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top