Krassnig / CodeDraw

CodeDraw is a beginner-friendly drawing library which can be used to create pictures, animations and even interactive applications.
https://krassnig.github.io/CodeDrawJavaDoc/
MIT License
18 stars 7 forks source link

Borders with filled shapes #11

Closed mrgreata closed 1 year ago

mrgreata commented 1 year ago

Liebegrüße Nik und Konstituierenden

Krassnig commented 1 year ago

Hello @mrgreata,

thank you for your suggestion, but at the moment we are not planning on adding this feature (maybe in the future). Instead you can create borders by using existing methods such as drawRectangle and fillRectangle. There are two approaches you can use:

Border around the edge

This approach draws the border on both sides of the edge. This means that the inside of the shape will be slightly smaller than the specified coordinates.

int borderSize = 10; // in px
cd.setLineWidth(borderSize);
cd.fillRectangle(200, 200, 200, 100); // fill first
cd.drawRectangle(200, 200, 200, 100);

Border outside of the edge

This approach draws the border outside the shape. This means the shape will retain it's width and height.

int borderSize = 10; // in px
cd.setLineWidth(borderSize * 2); // the size of the border will be 10px because the fillRectangle will draw over the drawRectangle
cd.drawRectangle(200, 200, 200, 100); // draw first
cd.fillRectangle(200, 200, 200, 100);