Board  0.9.5
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
LibBoard::Bezier Struct Reference

A cubice polygonal line described by a series of 2D points. More...

#include <Bezier.h>

Inheritance diagram for LibBoard::Bezier:
LibBoard::ShapeWithStyle LibBoard::Shape

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 cubic bezier curve. More...
 
 Bezier (const std::vector< Point > &points, const std::vector< Point > &controls, const Style &style)
 A cubic bezier curve. More...
 
 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())
 Bezier. More...
 
 Bezier (Point p0, Point control0, Point p1, Point control1, const Style &style)
 Bezier. More...
 
 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())
 Bezier. More...
 
 Bezier (double x0, double y0, double xc0, double yc0, double x1, double y1, double xc1, double yc1, const Style &style)
 Bezier. More...
 
const std::string & name () const override
 
Bezierrotate (double angle, const Point &center) override
 Rotate the Bezier curve. More...
 
Bezier rotated (double angle, const Point &center) const
 
Bezierrotate (double angle) override
 
Bezier rotated (double angle) const
 
Beziertranslate (double dx, double dy) override
 
Bezier translated (double dx, double dy) const
 
Bezierscale (double sx, double sy) override
 
Bezierscale (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. More...
 
virtual void accept (const ShapeVisitor &visitor) override
 Accepts a visitor object. More...
 
virtual void accept (ConstShapeVisitor &visitor) const override
 Accepts a const-shape visitor object. More...
 
virtual void accept (const ConstShapeVisitor &visitor) const override
 Accepts a const-shape visitor object. More...
 
virtual Shapeaccept (CompositeShapeTransform &transform) const override
 Accept a composite shape transform. More...
 
virtual Shapeaccept (const CompositeShapeTransform &transform) const override
 Accept a constant composite shape transform. More...
 
Rect boundingBox (LineWidthFlag) const override
 
Bezierclone () const override
 
const Pathpath () const
 
const Pathcontrols () const
 
Path discretizedPath () const
 
std::vector< PointpathThroughLocalExtremums () const
 
Bezieroperator+= (const Bezier &other)
 
Bezier operator+ (const Bezier &other) const
 
 Bezier (const Bezier &)=default
 
 Bezier (Bezier &&)=default
 
Bezieroperator= (Bezier &&)=default
 
Bezieroperator= (const Bezier &)=default
 
Point eval (const Point &p0, const Point &p1, const Point &p2, const Point &p3, double t) const
 
Point eval (Path::size_type interval, double t) const
 
- 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)
 
ShapeWithStyleoperator= (const ShapeWithStyle &other)
 
 ~ShapeWithStyle ()
 
const std::string & name () const
 
const ColorpenColor () const
 
ShapeWithStylesetPenColor (const Color &)
 
const ColorfillColor () const
 
ShapeWithStylesetFillColor (const Color &)
 
double lineWidth () const
 
ShapeWithStylesetLineWidth (double)
 
LineStyle lineStyle () const
 
ShapeWithStylesetLineStyle (LineStyle)
 
LineCap lineCap () const
 
ShapeWithStylesetLineCap (LineCap)
 
LineJoin lineJoin () const
 
ShapeWithStylesetLineJoin (LineJoin)
 
Style style () const
 
ShapeWithStylesetStyle (const Style &)
 
bool filled () const
 
- Public Member Functions inherited from LibBoard::Shape
 Shape ()
 
virtual ~Shape ()
 
virtual Point center (LineWidthFlag lineWidthFlag=IgnoreLineWidth) const
 
ShaperotateDeg (double angle, const Point &center)
 
ShaperotateDeg (double angle)
 
ShapemoveCenter (double x, double y, LineWidthFlag lineWidthFlag=IgnoreLineWidth)
 
ShapemoveCenter (Point p, LineWidthFlag lineWidthFlag=IgnoreLineWidth)
 
Shaperesize (double width, double height, LineWidthFlag lineWidthFlag)
 
ShapescaleToWidth (double w, LineWidthFlag lineWidthFlag)
 
ShapescaleToHeight (double h, LineWidthFlag lineWidthFlag)
 
Rect bbox (LineWidthFlag) const
 
 Shape (const Shape &other)
 

Static Public Member Functions

static Bezier smoothedPolyline (const std::vector< Point > &path, double roundness, const Style &style=Style::defaultStyle())
 
static Bezier smoothedPolyline (const Path &path, double roundness, const Style &style=Style::defaultStyle())
 
static Bezier interpolation (const Point &y0, const Point &y1, const Point &y2, const Point &y3, const Style &style=Style::defaultStyle())
 
- Static Public Member Functions inherited from LibBoard::ShapeWithStyle
static void setLineWidthScaling (bool)
 

Static Public Attributes

static const std::string _name
 

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)
 

Detailed Description

A cubice polygonal line described by a series of 2D points.

The Bezier structure.

Examples
examples/bezier.cpp.

Constructor & Destructor Documentation

◆ Bezier() [1/6]

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 cubic bezier curve.

Parameters
pointsPoints of the bezier curve (n points)
controlsControls points (2(n-1) points)
penColor
fillColor
lineWidth
lineStyle
cap
join

Referenced by clone(), resized(), rotated(), scaled(), and translated().

◆ Bezier() [2/6]

LibBoard::Bezier::Bezier ( const std::vector< Point > &  points,
const std::vector< Point > &  controls,
const Style style 
)

A cubic bezier curve.

Parameters
pointsPoints of the bezier curve (n points)
controlsControls points (2(n-1) points)
styleShape style.

◆ Bezier() [3/6]

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() 
)

Bezier.

Parameters
p0Start point
control0Start control point
p1End point
control1End control point
penColor
fillColor
lineWidth
lineStyle
cap
join

◆ Bezier() [4/6]

LibBoard::Bezier::Bezier ( Point  p0,
Point  control0,
Point  p1,
Point  control1,
const Style style 
)

Bezier.

Parameters
p0Start point
control0Start control point
p1End point
control1End control point
styleShape style.

◆ Bezier() [5/6]

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() 
)

Bezier.

Parameters
x0Start point (x coordinate)
y0Start point (y coordinate)
xc0Start control point (x coordinate)
yc0Start control point (y coordinate)
x1End point (x coordinate)
y1End point (y coordinate)
xc1End control point (x coordinate)
yc1End control point (y coordinate)
penColor
fillColor
lineWidth
lineStyle
cap
join

◆ Bezier() [6/6]

LibBoard::Bezier::Bezier ( double  x0,
double  y0,
double  xc0,
double  yc0,
double  x1,
double  y1,
double  xc1,
double  yc1,
const Style style 
)

Bezier.

Parameters
x0Start point (x coordinate)
y0Start point (y coordinate)
xc0Start control point (x coordinate)
yc0Start control point (y coordinate)
x1End point (x coordinate)
y1End point (y coordinate)
xc1End control point (x coordinate)
yc1End control point (y coordinate)
styleShape style.

Member Function Documentation

◆ accept() [1/6]

Shape * LibBoard::Bezier::accept ( CompositeShapeTransform transform) const
overridevirtual

Accept a composite shape transform.

Parameters
transformA composite shape transform object.

Reimplemented from LibBoard::Shape.

◆ accept() [2/6]

Shape * LibBoard::Bezier::accept ( const CompositeShapeTransform transform) const
overridevirtual

Accept a constant composite shape transform.

Parameters
transformA constant composite shape transform object..

Reimplemented from LibBoard::Shape.

◆ accept() [3/6]

void LibBoard::Bezier::accept ( const ConstShapeVisitor visitor) const
overridevirtual

Accepts a const-shape visitor object.

Parameters
visitorA const-shape visitor object.

Reimplemented from LibBoard::Shape.

◆ accept() [4/6]

void LibBoard::Bezier::accept ( const ShapeVisitor visitor)
overridevirtual

Accepts a visitor object.

Parameters
visitorA visitor object.

Reimplemented from LibBoard::Shape.

◆ accept() [5/6]

void LibBoard::Bezier::accept ( ConstShapeVisitor visitor) const
overridevirtual

Accepts a const-shape visitor object.

Parameters
visitorA const-shape visitor object.

Reimplemented from LibBoard::Shape.

◆ accept() [6/6]

void LibBoard::Bezier::accept ( ShapeVisitor visitor)
overridevirtual

Accepts a visitor object.

Parameters
visitorA visitor object.

Reimplemented from LibBoard::Shape.

◆ boundingBox()

Rect LibBoard::Bezier::boundingBox ( LineWidthFlag  ) const
overridevirtual

Compute the bounding box of the figure.

Returns
The rectangle of the bounding box.

Implements LibBoard::Shape.

◆ clone()

Bezier * LibBoard::Bezier::clone ( ) const
overridevirtual

Return a copy of the shape.

Returns
A copy of the shape.

Implements LibBoard::ShapeWithStyle.

References Bezier().

◆ flushFIG()

void LibBoard::Bezier::flushFIG ( std::ostream &  stream,
const TransformFIG transform,
std::map< Color, int > &  colormap 
) const
overridevirtual

Write the FIG code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.
colormap

Implements LibBoard::Shape.

◆ flushPostscript()

void LibBoard::Bezier::flushPostscript ( std::ostream &  stream,
const TransformEPS transform 
) const
overridevirtual

Write the EPS code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

◆ flushSVG()

void LibBoard::Bezier::flushSVG ( std::ostream &  stream,
const TransformSVG transform 
) const
overridevirtual

Write the SVG code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

◆ flushTikZ()

void LibBoard::Bezier::flushTikZ ( std::ostream &  stream,
const TransformTikZ transform 
) const
overridevirtual

Write the TikZ code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

◆ name()

const std::string & LibBoard::Bezier::name ( ) const
overridevirtual

Returns the generic name of the shape (e.g., Circle, Rectangle, etc.)

Returns

Reimplemented from LibBoard::Shape.

References _name.

◆ resized()

Bezier LibBoard::Bezier::resized ( double  w,
double  h,
LineWidthFlag  lineWidthFlag 
) const

Returns a resized copy of the Bezier.

Parameters
wWidth of the new Bezier.
hHeight of the new Bezier.
lineWidthFlagShould the line width be considered when computing bounding boxes.
Returns
A resized copy of the Bezier.

References Bezier().

◆ rotate() [1/2]

Bezier & LibBoard::Bezier::rotate ( double  angle)
overridevirtual

Rotate the shape around its center.

Parameters
angleThe rotation angle in radian.
Returns
A reference to the shape itself.

Implements LibBoard::Shape.

References LibBoard::Shape::center(), and LibBoard::Path::rotate().

◆ rotate() [2/2]

Bezier & LibBoard::Bezier::rotate ( double  angle,
const Point center 
)
overridevirtual

Rotate the Bezier curve.

Parameters
angle
center
Returns
The curve itself

Implements LibBoard::Shape.

References LibBoard::Shape::center(), and LibBoard::Path::rotate().

◆ rotated()

Bezier LibBoard::Bezier::rotated ( double  angle) const
Parameters
angle
Returns

References Bezier(), and LibBoard::Shape::center().

◆ scale() [1/2]

Bezier & LibBoard::Bezier::scale ( double  s)
overridevirtual

Scale the Bezier, given a scaling factor.

Parameters
sScaling factor.
Returns
A reference to the Bezier itself, once scaled.

Implements LibBoard::Shape.

References scale().

◆ scale() [2/2]

Bezier & LibBoard::Bezier::scale ( double  sx,
double  sy 
)
overridevirtual

Scale the Bezier, given two scaling factors.

Parameters
sxScaling factor along the x axis.
syScaling factor along the y axis.
Returns
A reference to the Bezier itself, once scaled.

Implements LibBoard::Shape.

References LibBoard::Path::scale(), and scaled().

Referenced by scale().

◆ scaleAll()

void LibBoard::Bezier::scaleAll ( double  s)
overridevirtual

Scales all the values (positions, dimensions, etc.) associated with the shape.

Parameters
sThe scaling factor.

Implements LibBoard::Shape.

References LibBoard::Path::scaleAll().

◆ scaled() [1/2]

Bezier LibBoard::Bezier::scaled ( double  s) const

Returns a scaled copy of the line.

Parameters
sThe scaling factor.
Returns
A scaled copy of the line.

References Bezier().

◆ scaled() [2/2]

Bezier LibBoard::Bezier::scaled ( double  sx,
double  sy 
) const

Returns a scaled copy of the line.

Parameters
sxThe scaling factor along the x axis.
syThe scaling factor along the y axis.
Returns
A scaled copy of the line.
Examples
examples/bezier.cpp.

References Bezier().

Referenced by scale().

◆ translate()

Bezier & LibBoard::Bezier::translate ( double  dx,
double  dy 
)
overridevirtual

Translate the Bezier by a given offset.

Parameters
dxThe x offset.
dyThe y offset.
Returns
A reference to the Bezier itself.

Implements LibBoard::Shape.

References LibBoard::Path::translate().

◆ translated()

Bezier LibBoard::Bezier::translated ( double  dx,
double  dy 
) const

Returns a translated copy of the Bezier.

Parameters
dxShift of the first coordinate.
dyShift of the second coordinate.
Returns
A copy of the Bezier, translated.

References Bezier().

Member Data Documentation

◆ _name

const std::string LibBoard::Bezier::_name
static

The generic name of the shape.

Referenced by name().


The documentation for this struct was generated from the following files: