#include <vector>
{
const double s = 1.0;
std::vector<Point> e = Tools::pathBoundaryPoints(path, strokeWidth, lineCap, lineJoin, miterLimit);
for (size_t i = 0; i < limit; ++i) {
list <<
Line(a + shift, b + shift, Color::Black, strokeWidth * 0.01).
scale(s);
list <<
Line(a - shift, b - shift, Color::Black, strokeWidth * 0.01).
scale(s);
list <<
Line(a, b, Color::Red, strokeWidth * 0.01);
if ((lineCap == RoundCap) || (lineJoin == RoundJoin)) {
list << circle(a, strokeWidth * 0.5, Color::Green, Color::Null, strokeWidth * 0.01);
}
}
if ((!path.
isClosed() && lineCap == RoundCap) || (lineJoin == RoundJoin)) {
list << circle(a, strokeWidth * 0.5, Color::Green, Color::Null, strokeWidth * 0.01);
}
for (size_t i = 0; i < e.size(); ++i) {
list << circle(c, 10.0, Color::Blue, Color::Null, strokeWidth * 0.01);
list <<
Line(c -
Point(10.0, 0.0), c +
Point(10.0, 0), Color::Blue, strokeWidth * 0.01);
list <<
Line(c -
Point(0.0, 10.0), c +
Point(0, 10.0), Color::Blue, strokeWidth * 0.01);
}
return list;
}
{
Board::enableLineWidthScaling();
board.
clear(Color::White);
pA << p1 << p2 << p3 << p4 << p5;
l.
append(
strikeOut(pA, 50.0, RoundCap, MiterJoin, 3.0), Direction::Right, Alignment::Center, 30.0);
l.
append(
strikeOut(pB, 50.0, RoundCap, BevelJoin, 3.0), Direction::Right, Alignment::Center, 30.0);
l.
append(
strikeOut(pC, 50.0, RoundCap, MiterJoin, 3.0), Direction::Right, Alignment::Center, 30.0);
l.
append(
strikeOut(pA, 50.0, RoundCap, RoundJoin, 3.0), Direction::Right, Alignment::Center, 30.0);
l.
append(
Text(0, 0,
"Round cap, miter/bevel/miter/round join", Fonts::Courier, 14.0), Direction::Right, Alignment::Center);
board.
append(l, Direction::Bottom, Alignment::Left);
l.
append(
strikeOut(pA, 50.0, ButtCap, MiterJoin, 3.0), Direction::Right, Alignment::Center, 30.0);
l.
append(
strikeOut(pB, 50.0, ButtCap, BevelJoin, 3.0), Direction::Right, Alignment::Center, 30.0);
l.
append(
strikeOut(pC, 50.0, ButtCap, MiterJoin, 3.0), Direction::Right, Alignment::Center, 30.0);
l.
append(
strikeOut(pA, 50.0, ButtCap, RoundJoin, 3.0), Direction::Right, Alignment::Center, 30.0);
l.
append(
Text(0, 0,
"Butt cap, miter/bevel/miter/round join", Fonts::Courier, 14.0), Direction::Right, Alignment::Center);
board.
append(l, Direction::Bottom, Alignment::Left);
l.
append(
strikeOut(pA, 50.0, SquareCap, MiterJoin, 3.0), Direction::Right, Alignment::Center, 30.0);
l.
append(
strikeOut(pB, 50.0, SquareCap, BevelJoin, 3.0), Direction::Right, Alignment::Center, 30.0);
l.
append(
strikeOut(pC, 50.0, SquareCap, MiterJoin, 3.0), Direction::Right, Alignment::Center, 30.0);
l.
append(
strikeOut(pA, 50.0, SquareCap, RoundJoin, 3.0), Direction::Right, Alignment::Center, 30.0);
l.
append(
Text(0, 0,
"Square cap, miter/bevel/miter/round join", Fonts::Courier, 14.0), Direction::Right, Alignment::Center);
board.
append(l, Direction::Bottom, Alignment::Left);
Polyline poly(Path::Closed, Color::Blue, Color::Null, 1.0, SolidStyle, ButtCap, MiterJoin);
list.
append(poly, Direction::Right, Alignment::Center);
list.
append(poly, Direction::Right, Alignment::Center);
board.
append(list, Direction::Right, Alignment::Center);
board.
saveEPS(
"stroke_path.eps", PageSize::A4);
board.
saveSVG(
"stroke_path.svg", PageSize::BoundingBox, 0.0, Unit::Centimeter);
}
Declaration of the Board class.
@copyright This source code is part of the Board project, a C++ library whose purpose is to allow sim...
int main(int argc, char *argv[])
Definition arithmetic.cpp:16
Polyline rectangle(double left, double top, double width, double height, Color penColor=Style::defaultPenColor(), Color fillColor=Style::defaultFillColor(), double lineWidth=Style::defaultLineWidth(), const LineStyle lineStyle=Style::defaultLineStyle(), const LineCap cap=Style::defaultLineCap(), const LineJoin join=Style::defaultLineJoin())
Definition Polyline.cpp:569
LineCap
Definition Style.h:35
LineJoin
Definition Style.h:41
ShapeList strikeOut(const Path &path, double strokeWidth, LineCap lineCap, LineJoin lineJoin, double miterLimit=4.0)
Definition stroke_path.cpp:17
Class for EPS, FIG or SVG drawings.
Definition Board.h:61
void saveEPS(std::ostream &out, PageSize size=PageSize::BoundingBox, double margin=0.0, Unit unit=Unit::Millimeter, const std::string &title=std::string()) const
Definition Board.cpp:539
void clear(const Color &color=Color::Null)
Definition Board.cpp:149
void saveSVG(const char *filename, PageSize size=PageSize::BoundingBox, double margin=0.0, Unit unit=Unit::Millimeter) const
Definition Board.cpp:765
A line between two points.
Definition Line.h:38
Line & scale(double sx, double sy) override
Definition Line.cpp:99
A path, according to Postscript and SVG definition.
Definition Path.h:45
bool isClosed() const
Is the path closed?
Definition Path.h:433
std::size_t size() const
The number of points in the path.
Definition Path.h:448
Struct representing a 2D point.
Definition Point.h:42
Point & normalise()
Definition Point.h:470
Point rotatedPI2() const
Definition Point.h:431
A polygonal line described by a series of 2D points.
Definition Polyline.h:38
A group of shapes.
Definition ShapeList.h:47
ShapeList & append(const Shape &shape, Direction direction=Direction::Right, Alignment alignment=Alignment::Center, double margin=0.0, LineWidthFlag lineWidthFlag=UseLineWidth)
Definition ShapeList.cpp:232
ShapeList & clear()
Definition ShapeList.cpp:90
Shape & scaleToWidth(double w, LineWidthFlag lineWidthFlag)
Definition Shape.cpp:85
A piece of text.
Definition Text.h:40