|
Board 0.9.6
|
A Bezier curve described by two series of 2D points (curve points and control points). More...
#include <Bezier.h>
Public Member Functions | |
| Bezier (const std::vector< Point > &points, const std::vector< Point > &controls, 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()) | |
| A Bezier curve described by two series of 2D points (curve points and control points). | |
| Bezier (const std::vector< Point > &points, const std::vector< Point > &controls, const Style &style) | |
| A cubic bezier curve. | |
| Bezier (Point p0, Point control0, Point p1, Point control1, 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()) | |
| A bezier curve defined by its two extremities and two control points. | |
| Bezier (Point p0, Point control0, Point p1, Point control1, const Style &style) | |
| A bezier curve defined by its two extremities and two control points. | |
| Bezier (double x0, double y0, double xc0, double yc0, double x1, double y1, double xc1, double yc1, 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()) | |
| A bezier curve defined by its two extremities and two control points. | |
| Bezier (double x0, double y0, double xc0, double yc0, double x1, double y1, double xc1, double yc1, const Style &style) | |
| A bezier curve defined by its two extremities and two control points. | |
| const std::string & | name () const override |
| Bezier & | rotate (double angle, const Point ¢er) override |
| Rotate the Bezier curve. | |
| Bezier | rotated (double angle, const Point ¢er) const |
| Rotated copy of the curve. | |
| Bezier & | rotate (double angle) override |
| Rotate the Bezier curve around its bounding box center. | |
| Bezier | rotated (double angle) const |
| Return a rotated copy of the curve around its bounding box center. | |
| Bezier & | translate (double dx, double dy) override |
| Bezier | translated (double dx, double dy) const |
| Bezier & | scale (double sx, double sy) override |
| Bezier & | scale (double s) override |
| Bezier | scaled (double sx, double sy) const |
| Bezier | scaled (double s) const |
| void | scaleAll (double s) override |
| Bezier | resized (double w, double h, LineWidthFlag lineWidthFlag) const |
| void | flushPostscript (std::ostream &stream, const TransformEPS &transform) const override |
| void | flushFIG (std::ostream &stream, const TransformFIG &transform, std::map< Color, int > &colormap) const override |
| void | flushSVG (std::ostream &stream, const TransformSVG &transform) const override |
| void | flushTikZ (std::ostream &stream, const TransformTikZ &transform) const override |
| virtual void | accept (ShapeVisitor &visitor) override |
| Accepts a visitor object. | |
| virtual void | accept (const ShapeVisitor &visitor) override |
| Accepts a visitor object. | |
| virtual void | accept (ConstShapeVisitor &visitor) const override |
| Accepts a const-shape visitor object. | |
| virtual void | accept (const ConstShapeVisitor &visitor) const override |
| Accepts a const-shape visitor object. | |
| virtual Shape * | accept (CompositeShapeTransform &transform) const override |
| Accept a composite shape transform. | |
| virtual Shape * | accept (const CompositeShapeTransform &transform) const override |
| Accept a constant composite shape transform. | |
| Rect | boundingBox (LineWidthFlag) const override |
| Return the bounding box of the curve. | |
| Bezier * | clone () const override |
| Return a copy of the curve. | |
| const Path & | path () const |
| The series of points defining the curve, as a path. | |
| const Path & | controls () const |
| The series of control points points defining the curve, as a path. | |
| Path | discretizedPath () const |
| A sequence of properly spaced points approximating the curve. | |
| std::vector< Point > | pathThroughLocalExtremums () const |
| A path through local extremums. | |
| Bezier & | operator+= (const Bezier &other) |
| Add points and crontrol points of another curve. | |
| Bezier | operator+ (const Bezier &other) const |
| Concatenate two Bezier curves. | |
| Point | eval (Path::size_type interval, double t) const |
| Get a point of the curve given its interval between two curve points and a position in [0..1]. | |
| Bezier (const Bezier &)=default | |
| Bezier (Bezier &&)=default | |
| Bezier & | operator= (Bezier &&)=default |
| Bezier & | operator= (const Bezier &)=default |
| ~Bezier () override=default | |
Public Member Functions inherited from LibBoard::ShapeWithStyle | |
| ShapeWithStyle (Color penColor, Color fillColor, double lineWidth, LineStyle style, const LineCap cap, const LineJoin join) | |
| ShapeWithStyle (const Style &style) | |
| ShapeWithStyle (const ShapeWithStyle &other) | |
| ShapeWithStyle & | operator= (const ShapeWithStyle &other) |
| ~ShapeWithStyle () | |
| const std::string & | name () const |
| Shape * | clone () const =0 |
| const Color & | penColor () const |
| ShapeWithStyle & | setPenColor (const Color &) |
| const Color & | fillColor () const |
| ShapeWithStyle & | setFillColor (const Color &) |
| double | lineWidth () const |
| ShapeWithStyle & | setLineWidth (double) |
| LineStyle | lineStyle () const |
| ShapeWithStyle & | setLineStyle (LineStyle) |
| LineCap | lineCap () const |
| ShapeWithStyle & | setLineCap (LineCap) |
| LineJoin | lineJoin () const |
| ShapeWithStyle & | setLineJoin (LineJoin) |
| Style | style () const |
| ShapeWithStyle & | setStyle (const Style &) |
| bool | filled () const |
Public Member Functions inherited from LibBoard::Shape | |
| Shape () | |
| virtual | ~Shape () |
| virtual const std::string & | name () const |
| virtual Shape * | clone () const =0 |
| virtual Point | center (LineWidthFlag lineWidthFlag=IgnoreLineWidth) const |
| virtual Shape & | rotate (double angle, const Point ¢er)=0 |
| virtual Shape & | rotate (double angle)=0 |
| Shape & | rotateDeg (double angle, const Point ¢er) |
| Shape & | rotateDeg (double angle) |
| virtual Shape & | translate (double dx, double dy)=0 |
| Shape & | moveCenter (double x, double y, LineWidthFlag lineWidthFlag=IgnoreLineWidth) |
| Shape & | moveCenter (Point p, LineWidthFlag lineWidthFlag=IgnoreLineWidth) |
| virtual Shape & | scale (double sx, double sy)=0 |
| virtual Shape & | scale (double s)=0 |
| Shape & | resize (double width, double height, LineWidthFlag lineWidthFlag) |
| Shape & | scaleToWidth (double w, LineWidthFlag lineWidthFlag) |
| Shape & | scaleToHeight (double h, LineWidthFlag lineWidthFlag) |
| virtual Rect | boundingBox (LineWidthFlag) const =0 |
| Rect | bbox (LineWidthFlag) const |
| virtual void | scaleAll (double s)=0 |
| virtual void | flushPostscript (std::ostream &stream, const TransformEPS &transform) const =0 |
| virtual void | flushFIG (std::ostream &stream, const TransformFIG &transform, std::map< Color, int > &colormap) const =0 |
| virtual void | flushSVG (std::ostream &stream, const TransformSVG &transform) const =0 |
| virtual void | flushTikZ (std::ostream &stream, const TransformTikZ &transform) const =0 |
| virtual void | accept (ShapeVisitor &visitor) |
| Accepts a visitor object. | |
| virtual void | accept (const ShapeVisitor &visitor) |
| Accepts a visitor object. | |
| virtual void | accept (ConstShapeVisitor &visitor) const |
| Accepts a const-shape visitor object. | |
| virtual void | accept (const ConstShapeVisitor &visitor) const |
| Accepts a const-shape visitor object. | |
| virtual Shape * | accept (CompositeShapeTransform &transform) const |
| Accept a composite shape transform. | |
| virtual Shape * | accept (const CompositeShapeTransform &transform) const |
| Accept a constant composite shape transform. | |
| Shape (const Shape &other) | |
Static Public Member Functions | |
| static Bezier | smoothedPolyline (const std::vector< Point > &path, double roundness, const Style &style=Style::defaultStyle()) |
| Build a Bezier curve as a 'rounded' version of a Polyline. | |
| static Bezier | smoothedPolyline (const Path &path, double roundness, const Style &style=Style::defaultStyle()) |
| Build a Bezier curve as a 'rounded' version of a Polyline. | |
| static Bezier | interpolation (const Point &a, const Point &b, const Point &c, const Point &d, const Style &style=Style::defaultStyle()) |
| Bezier interpolation passing through 4 points. | |
Static Public Member Functions inherited from LibBoard::ShapeWithStyle | |
| static void | setLineWidthScaling (bool) |
Protected Attributes | |
| Path | _path |
| Path | _controls |
Protected Attributes inherited from LibBoard::ShapeWithStyle | |
| Style | _style |
Additional Inherited Members | |
Protected Member Functions inherited from LibBoard::ShapeWithStyle | |
| void | updateLineWidth (double s) |
A Bezier curve described by two series of 2D points (curve points and control points).
The Bezier structure.
| LibBoard::Bezier::Bezier | ( | const std::vector< Point > & | points, |
| const std::vector< Point > & | controls, | ||
| 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() |
||
| ) |
A Bezier curve described by two series of 2D points (curve points and control points).
| points | Points of the bezier curve (n points) |
| controls | Controls points (2(n-1) points) |
| penColor | |
| fillColor | |
| lineWidth | |
| lineStyle | |
| cap | |
| join |
| LibBoard::Bezier::Bezier | ( | const std::vector< Point > & | points, |
| const std::vector< Point > & | controls, | ||
| const Style & | style | ||
| ) |
A cubic bezier curve.
| points | Points of the bezier curve (n points) |
| controls | Controls points (2(n-1) points) |
| style | Shape style. |
| LibBoard::Bezier::Bezier | ( | Point | p0, |
| Point | control0, | ||
| Point | p1, | ||
| Point | control1, | ||
| 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() |
||
| ) |
| LibBoard::Bezier::Bezier | ( | double | x0, |
| double | y0, | ||
| double | xc0, | ||
| double | yc0, | ||
| double | x1, | ||
| double | y1, | ||
| double | xc1, | ||
| double | yc1, | ||
| 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() |
||
| ) |
A bezier curve defined by its two extremities and two control points.
| x0 | Start point (x coordinate) |
| y0 | Start point (y coordinate) |
| xc0 | Start control point (x coordinate) |
| yc0 | Start control point (y coordinate) |
| x1 | End point (x coordinate) |
| y1 | End point (y coordinate) |
| xc1 | End control point (x coordinate) |
| yc1 | End control point (y coordinate) |
| penColor | |
| fillColor | |
| lineWidth | |
| lineStyle | |
| cap | |
| join |
| LibBoard::Bezier::Bezier | ( | double | x0, |
| double | y0, | ||
| double | xc0, | ||
| double | yc0, | ||
| double | x1, | ||
| double | y1, | ||
| double | xc1, | ||
| double | yc1, | ||
| const Style & | style | ||
| ) |
A bezier curve defined by its two extremities and two control points.
| x0 | Start point (x coordinate) |
| y0 | Start point (y coordinate) |
| xc0 | Start control point (x coordinate) |
| yc0 | Start control point (y coordinate) |
| x1 | End point (x coordinate) |
| y1 | End point (y coordinate) |
| xc1 | End control point (x coordinate) |
| yc1 | End control point (y coordinate) |
| style | Shape style. |
|
default |
|
default |
|
overridedefault |
|
overridevirtual |
Accept a composite shape transform.
| transform | A composite shape transform object. |
Reimplemented from LibBoard::Shape.
References LibBoard::CompositeShapeTransform::map().
|
overridevirtual |
Accept a constant composite shape transform.
| transform | A constant composite shape transform object.. |
Reimplemented from LibBoard::Shape.
References LibBoard::CompositeShapeTransform::map().
|
overridevirtual |
Accepts a const-shape visitor object.
| visitor | A const-shape visitor object. |
Reimplemented from LibBoard::Shape.
References LibBoard::ConstShapeVisitor::visit().
|
overridevirtual |
Accepts a visitor object.
| visitor | A visitor object. |
Reimplemented from LibBoard::Shape.
References LibBoard::ShapeVisitor::visit().
|
overridevirtual |
Accepts a const-shape visitor object.
| visitor | A const-shape visitor object. |
Reimplemented from LibBoard::Shape.
References LibBoard::ConstShapeVisitor::visit().
|
overridevirtual |
Accepts a visitor object.
| visitor | A visitor object. |
Reimplemented from LibBoard::Shape.
References LibBoard::ShapeVisitor::visit().
|
overridevirtual |
Return the bounding box of the curve.
Implements LibBoard::Shape.
References _path, LibBoard::Path::boundingBox(), LibBoard::IgnoreLineWidth, LibBoard::ShapeWithStyle::lineCap(), LibBoard::ShapeWithStyle::lineWidth(), LSHOW, LibBoard::Path::Open, path(), LibBoard::Tools::pathBoundingBox(), pathThroughLocalExtremums(), LibBoard::Path::points(), LibBoard::RoundJoin, and LibBoard::UseLineWidth.
Referenced by main().
|
overridevirtual |
Return a copy of the curve.
Implements LibBoard::ShapeWithStyle.
Referenced by LibBoard::RoughVisitor::map(), LibBoard::RoughVisitor::map(), and LibBoard::RoughVisitor::map().
|
inline |
The series of control points points defining the curve, as a path.
References _controls.
Referenced by LibBoard::bezierControls(), interpolation(), LibBoard::RoughVisitor::map(), operator+=(), scale(), smoothedPolyline(), and smoothedPolyline().
| Path LibBoard::Bezier::discretizedPath | ( | ) | const |
A sequence of properly spaced points approximating the curve.
References _controls, _path, path(), and LibBoard::Path::points().
Referenced by main().
| Point LibBoard::Bezier::eval | ( | Path::size_type | interval, |
| double | t | ||
| ) | const |
Get a point of the curve given its interval between two curve points and a position in [0..1].
| interval | Position of the preceding curve point. |
| t | Time position within the interval, in [0..1]. |
References _controls, _path, and LibBoard::Path::size().
Referenced by pathThroughLocalExtremums().
|
overridevirtual |
Write the FIG code of the shape in a stream according to a transform.
| stream | The output stream. |
| transform | A 2D transform to be applied. |
| colormap |
Implements LibBoard::Shape.
References LibBoard::Tools::unused(), and LibBoard::Tools::warning.
|
overridevirtual |
Write the EPS code of the shape in a stream according to a transform.
| stream | The output stream. |
| transform | A 2D transform to be applied. |
Implements LibBoard::Shape.
References _controls, _path, LibBoard::ShapeWithStyle::_style, LibBoard::Path::empty(), LibBoard::Tools::error, LibBoard::ShapeWithStyle::fillColor(), LibBoard::ShapeWithStyle::filled(), LibBoard::Color::flushPostscript(), LibBoard::ShapeWithStyle::lineWidth(), LibBoard::Transform::mapX(), LibBoard::TransformEPS::mapY(), LibBoard::Color::Null, LibBoard::ShapeWithStyle::penColor(), LibBoard::Path::points(), LibBoard::Style::postscriptProperties(), and LibBoard::Path::size().
|
overridevirtual |
Write the SVG code of the shape in a stream according to a transform.
| stream | The output stream. |
| transform | A 2D transform to be applied. |
Implements LibBoard::Shape.
References _controls, _path, LibBoard::ShapeWithStyle::_style, LibBoard::Path::empty(), LibBoard::Tools::error, LibBoard::Transform::mapX(), LibBoard::TransformSVG::mapY(), LibBoard::Path::points(), LibBoard::Path::size(), and LibBoard::Style::svgProperties().
|
overridevirtual |
Write the TikZ code of the shape in a stream according to a transform.
| stream | The output stream. |
| transform | A 2D transform to be applied. |
Implements LibBoard::Shape.
References LibBoard::Tools::unused(), and LibBoard::Tools::warning.
|
static |
Bezier interpolation passing through 4 points.
| a | |
| b | |
| c | |
| d | |
| style |
References controls(), and LibBoard::ShapeWithStyle::style().
Referenced by main(), LibBoard::RoughVisitor::map(), LibBoard::RoughVisitor::map(), and LibBoard::RoughVisitor::map().
|
overridevirtual |
The generic name of the shape (e.g., Circle, Rectangle, etc.)
Reimplemented from LibBoard::Shape.
Add points and crontrol points of another curve.
| other | A Bezier curve. |
References _controls, _path, LibBoard::Path::back(), controls(), LibBoard::Path::front(), LibBoard::Point::norm(), LibBoard::Point::normalised(), path(), LibBoard::Path::points(), and LibBoard::Path::push_back().
|
inline |
The series of points defining the curve, as a path.
References _path.
Referenced by LibBoard::bezierControls(), boundingBox(), discretizedPath(), LibBoard::RoughVisitor::map(), operator+=(), smoothedPolyline(), and smoothedPolyline().
| std::vector< Point > LibBoard::Bezier::pathThroughLocalExtremums | ( | ) | const |
A path through local extremums.
References _controls, _path, LibBoard::Tools::almostEqual(), LibBoard::Path::back(), eval(), LibBoard::Path::points(), LibBoard::Tools::solveQuadratic(), LibBoard::Point::x, and LibBoard::Point::y.
Referenced by boundingBox(), and main().
| Bezier LibBoard::Bezier::resized | ( | double | w, |
| double | h, | ||
| LineWidthFlag | lineWidthFlag | ||
| ) | const |
Returns a resized copy of the Bezier.
| w | Width of the new Bezier. |
| h | Height of the new Bezier. |
| lineWidthFlag | Should the line width be considered when computing bounding boxes. |
References LibBoard::Shape::resize().
|
overridevirtual |
Rotate the Bezier curve around its bounding box center.
| angle | The rotation angle. |
Implements LibBoard::Shape.
References _controls, _path, LibBoard::Shape::center(), and LibBoard::Path::rotate().
Rotate the Bezier curve.
| angle | The rotation angle. |
| center | Center of the rotation. |
Implements LibBoard::Shape.
References _controls, _path, LibBoard::Shape::center(), and LibBoard::Path::rotate().
| Bezier LibBoard::Bezier::rotated | ( | double | angle | ) | const |
Return a rotated copy of the curve around its bounding box center.
| angle | The rotation angle. |
References LibBoard::Shape::center(), and rotate().
Rotated copy of the curve.
| angle | A rotation angle (in radians) |
| center | The center of rotation |
References LibBoard::Shape::center(), and rotate().
|
overridevirtual |
Scale the Bezier, given a scaling factor.
| s | Scaling factor. |
Implements LibBoard::Shape.
References scale().
|
overridevirtual |
Scale the Bezier, given two scaling factors.
| sx | Scaling factor along the x axis. |
| sy | Scaling factor along the y axis. |
Implements LibBoard::Shape.
References _controls, _path, LibBoard::Path::begin(), LibBoard::Path::clear(), controls(), LibBoard::Path::Open, LibBoard::Path::points(), LibBoard::Path::scale(), and LibBoard::ShapeWithStyle::updateLineWidth().
|
overridevirtual |
Scales all the values (positions, dimensions, etc.) associated with the shape.
| s | The scaling factor. |
Implements LibBoard::Shape.
References _controls, _path, and LibBoard::Path::scaleAll().
| Bezier LibBoard::Bezier::scaled | ( | double | s | ) | const |
Returns a scaled copy of the line.
| s | The scaling factor. |
References scale().
| Bezier LibBoard::Bezier::scaled | ( | double | sx, |
| double | sy | ||
| ) | const |
Returns a scaled copy of the line.
| sx | The scaling factor along the x axis. |
| sy | The scaling factor along the y axis. |
References scale().
Referenced by main().
|
static |
Build a Bezier curve as a 'rounded' version of a Polyline.
| path | A path defining a polyline. |
| roundness | |
| style |
References controls(), LibBoard::Path::isClosed(), path(), LibBoard::Path::points(), LibBoard::Path::push_back(), LibBoard::Path::size(), smoothedPolyline(), and LibBoard::ShapeWithStyle::style().
|
static |
Build a Bezier curve as a 'rounded' version of a Polyline.
| path | A sequence of points defining a polyline. |
| roundness | |
| style |
References LibBoard::Path::back(), controls(), LibBoard::mix(), path(), LibBoard::Path::push_back(), LibBoard::Path::size(), and LibBoard::ShapeWithStyle::style().
Referenced by main(), LibBoard::RoughVisitor::map(), mustache(), and smoothedPolyline().
|
overridevirtual |
Translate the Bezier by a given offset.
| dx | Shift of the first coordinate. |
| dy | Shift of the second coordinate. |
Implements LibBoard::Shape.
References _controls, _path, and LibBoard::Path::translate().
Referenced by translated().
| Bezier LibBoard::Bezier::translated | ( | double | dx, |
| double | dy | ||
| ) | const |
Returns a translated copy of the Bezier.
| dx | Shift of the first coordinate. |
| dy | Shift of the second coordinate. |
References translate().
|
protected |
Referenced by Bezier(), Bezier(), Bezier(), Bezier(), controls(), discretizedPath(), eval(), flushPostscript(), flushSVG(), operator+=(), pathThroughLocalExtremums(), rotate(), rotate(), scale(), scaleAll(), and translate().
|
protected |
Referenced by Bezier(), Bezier(), Bezier(), Bezier(), boundingBox(), discretizedPath(), eval(), flushPostscript(), flushSVG(), operator+=(), path(), pathThroughLocalExtremums(), rotate(), rotate(), scale(), scaleAll(), and translate().