helloworld
helloworld

Reputation: 1042

Displaying bounding rectangle in shapes in paperjs

I am trying to display the bounds on a Circle shape. But since the strokewidth is a bit high, the bounding rectangle is displaying inside the circle. So, instead of bounds, I tried to use strokeBounds, but it is not working. Here is my code:

var centerPoint = new Point(100, 100);
var centerCircle = new Path.Circle(centerPoint, 25);
centerCircle.strokeColor = '#000';
centerCircle.strokeWidth = 10;
centerCircle.bounds.selected = true;
centerCircle.strokeBounds.selected = true;

Here is the Sketch link to my code.

Here centerCircle.strokeBounds.selected is coming out to be undefined. How can I correctly display the bounding rectangle in this case?

Upvotes: 2

Views: 641

Answers (1)

sasensi
sasensi

Reputation: 4650

I also answered in the Github issue.

A workaround could be to draw a rectangle using strokebounds and to select it instead.

var bounds = new Path.Rectangle(centerCircle.strokeBounds);
bounds.selected = true;

See this Sketch for a demonstration.

Upvotes: 2

Related Questions