Skip to content

added optional open/close parameter to startNewSubPath#11

Open
Hannobal wants to merge 2 commits intoadishavit:masterfrom
Hannobal:OpenPaths
Open

added optional open/close parameter to startNewSubPath#11
Hannobal wants to merge 2 commits intoadishavit:masterfrom
Hannobal:OpenPaths

Conversation

@Hannobal
Copy link

I often want to use paths without a fill, but with multiple sub-paths that share the Stroke style (e.g. to plot a maze). So I added an optional parameter to startNewSubPath, that is either Open or Closed. Since the default is Closed, the old behavior is preserved. I used an enum to make the using code more expressive, i.e.

path.startNewSubPath(Open);

instead of

path.startNewSubPath(false);

struct SubPath {
SubPath(bool close) : close(close) {};
std::vector<Point> elements;
bool close = true;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename close to closed or isClosed or inverted isOpen.
closemay be mistakenly interpreted as "near".

Also, why is it a bool ? Just make it a OpenOrClosed.
Set the enum values to make the later if () naturally readable.

}

void startNewSubPath()
void startNewSubPath(OpenOrClosed closure = Closed)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename closure to isClosed or inverted isOpen.

@Hannobal
Copy link
Author

Thanks for the review. I made the changes you suggested. Using the enum throughout is certainly more explicit. I was unsure if I should add the static_cast<bool>. It probably isn't necessary but it certainly doesn't hurt either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants