-
Notifications
You must be signed in to change notification settings - Fork 36
added cap and join style to Stroke #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -247,8 +247,13 @@ namespace svg | |
| class Stroke : public Serializeable | ||
| { | ||
| public: | ||
| Stroke(double width = -1, Color color = Color::Transparent, bool nonScalingStroke = false) | ||
| : width(width), color(color), nonScaling(nonScalingStroke) { } | ||
| enum Cap { CapUndefined, CapButt, CapRound, CapSquare }; | ||
| enum Join { JoinUndefined, JoinMiter, JoinRound, JoinBevel }; | ||
| Stroke(double width = -1, Color color = Color::Transparent, bool nonScalingStroke = false, | ||
| Cap capStyle = CapUndefined, Join joinStyle = JoinUndefined) | ||
| : width(width), color(color), nonScaling(nonScalingStroke), | ||
| capStyle(capStyle), joinStyle(joinStyle) | ||
| { } | ||
| std::string toString(Layout const & layout) const | ||
| { | ||
| // If stroke width is invalid. | ||
|
|
@@ -259,12 +264,29 @@ namespace svg | |
| ss << attribute("stroke-width", translateScale(width, layout)) << attribute("stroke", color.toString(layout)); | ||
| if (nonScaling) | ||
| ss << attribute("vector-effect", "non-scaling-stroke"); | ||
|
|
||
| switch(capStyle) { | ||
| case CapButt : ss << attribute("stroke-linecap", "butt"); break; | ||
| case CapRound : ss << attribute("stroke-linecap", "round"); break; | ||
| case CapSquare : ss << attribute("stroke-linecap", "square"); break; | ||
| default : break; | ||
| } | ||
|
|
||
| switch(capStyle) { | ||
| case JoinMiter : ss << attribute("stroke-linejoin", "miter"); break; | ||
| case JoinRound : ss << attribute("stroke-linejoin", "round"); break; | ||
| case JoinBevel : ss << attribute("stroke-linejoin", "bevel"); break; | ||
| default : break; | ||
| } | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... they always have a value here so without the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, an |
||
| return ss.str(); | ||
| } | ||
| private: | ||
| double width; | ||
| Color color; | ||
| bool nonScaling; | ||
| Cap capStyle; | ||
| Join joinStyle; | ||
| }; | ||
|
|
||
| class Font : public Serializeable | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
capStyleandjoinStylealways initialized with someenumvalue and thus... (cont. below)