EaselJS triangle with rounded corners?

How can I create a triangle with rounded corners in EaselJS? I'm using drawPolyStar to create the triangle,

var polystar = new createjs.Shape();
polystar.graphics.drawPolyStar(100, 100, 60, 3, 0, -90);

This is an image of what I want the triangle to look like: Outcome vs Expected triangle

EDIT: Image link doesn't seem to work. This is what the triangle should look like : enter image description here

But actual triangle has sharp corners.

1 answer

  • answered 2017-10-11 10:04 Lanny

    There are no canvas APIs for rounding corners of polygons that works like the roundRect API.

    There are a few approaches I can think of:

    1. Do the round corners yourself using arcTo. This would take some math to figure out, and there may even be some libraries or examples floating around


    // Line outer radius
    context.lineJoin = "round";
    context.lineWidth = cornerRadius;
    1. Using rounded stroke edges, you can sort of fake it. This fiddle shows how a thick line with round ends can make the outer edges look round. You could draw another smaller triangle on top to give the desired effect.