Board 0.9.6
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Protected Member Functions | Protected Attributes | List of all members
LibBoard::Board Struct Reference

Class for EPS, FIG or SVG drawings. More...

#include <Board.h>

Inheritance diagram for LibBoard::Board:
LibBoard::ShapeList LibBoard::Shape

Classes

struct  State
 

Public Types

enum class  AspectRatio { Ignore , Preserve }
 The AspectRatio enum. More...
 
- Public Types inherited from LibBoard::ShapeList
typedef std::vector< Shape * >::size_type size_type
 

Public Member Functions

 Board (const Color &backgroundColor=Color::Null)
 
 Board (const Board &other)
 
 ~Board () override
 
Boardoperator= (const Board &other)
 
Boardoperator<< (const Shape &shape)
 
template<typename S >
Boardoperator<< (const std::vector< S > &shapes)
 
void clear (const Color &color=Color::Null)
 
void clear (unsigned char red, unsigned char green, unsigned char blue)
 
Boardrotate (double angle, const Point &center) override
 Rotate the board by an angle around a point.
 
Boardrotate (double angle) override
 Rotate the board by an angle around the center of its bounding box.
 
Boardtranslate (double dx, double dy) override
 Translate the board by a given vector.
 
Boardscale (double sx, double sy) override
 Scale the board in the x and y direction.
 
Boardscale (double s) override
 Scale the board.
 
Board rotated (double angle, const Point &center)
 
Board rotated (double angle)
 
Board translated (double dx, double dy)
 
Board scaled (double sx, double sy)
 
Board scaled (double s)
 
void drawDot (double x, double y)
 
void drawLine (double x1, double y1, double x2, double y2)
 
void drawLine (Point p, Point q)
 
void drawArrow (double x1, double y1, double x2, double y2, Arrow::ExtremityType type=Arrow::ExtremityType::Plain)
 
void drawArrow (Point p, Point q, Arrow::ExtremityType type=Arrow::ExtremityType::Plain)
 
void drawTriangle (double x1, double y1, double x2, double y2, double x3, double y3)
 
void drawTriangle (const Point &p1, const Point &p2, const Point &p3)
 
void fillTriangle (double x1, double y1, double x2, double y2, double x3, double y3)
 
void fillGouraudTriangle (const Point &p1, const Color &color1, const Point &p2, const Color &color2, const Point &p3, const Color &color3, unsigned char divisions=3)
 
void fillGouraudTriangle (const double x1, const double y1, const Color &color1, const double x2, const double y2, const Color &color2, const double x3, const double y3, const Color &color3, unsigned char divisions=3)
 
void fillGouraudTriangle (const Point &p1, const float brightness1, const Point &p2, const float brightness2, const Point &p3, const float brightness3, unsigned char divisions=3)
 
void fillGouraudTriangle (const double x1, const double y1, const float brightness1, const double x2, const double y2, const float brightness2, const double x3, const double y3, const float brightness3, unsigned char divisions=3)
 
void fillTriangle (const Point &p1, const Point &p2, const Point &p3)
 
void drawRectangle (double left, double top, double width, double height)
 
void drawRectangle (const Rect &rect)
 
void fillRectangle (double left, double top, double width, double height)
 
void fillRectangle (const Rect &rect)
 
void drawCircle (double x, double y, double radius)
 
void fillCircle (double x, double y, double radius)
 
void drawEllipse (double x, double y, double xRadius, double yRadius)
 
void fillEllipse (double x, double y, double xRadius, double yRadius)
 
void drawPolyline (const std::vector< Point > &points)
 
void drawClosedPolyline (const std::vector< Point > &points)
 
void fillPolyline (const std::vector< Point > &points)
 
void drawText (double x, double y, const char *text)
 
void drawText (Point p, const char *text)
 
void drawText (double x, double y, const std::string &text)
 
void drawText (Point p, const std::string &str)
 
BoardsetFont (const Fonts::Font font, double fontSize)
 
BoardsetFontSize (double fontSize)
 
BoardsetPenColorRGBi (unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255)
 
BoardsetPenColorRGBf (float red, float green, float blue, float alpha=1.0f)
 
BoardsetPenColor (const Color &color)
 
BoardsetFillColorRGBi (unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255)
 
BoardsetFillColorRGBf (float red, float green, float blue, float alpha=1.0f)
 
BoardsetFillColorHSV (float hue, float saturation, float value, float alpha=1.0f)
 
BoardsetFillColor (const Color &color)
 
BoardsetLineWidth (double width)
 
BoardsetLineStyle (LineStyle style)
 
BoardsetLineCap (LineCap cap)
 
BoardsetLineJoin (LineJoin join)
 
void setBackgroundColor (const Color &color)
 
void drawBoundingBox (LineWidthFlag lineWidthFlag)
 
void setClippingRectangle (double x, double y, double width, double height)
 
void setClippingRectangle (const Rect &rect)
 
void setClippingPath (const std::vector< Point > &points)
 
void setClippingPath (const Path &path)
 
void addDuplicates (const Shape &shape, std::size_t times, double dx, double dy, double scale=1.0)
 
void addDuplicates (const Shape &shape, std::size_t times, double dx, double dy, double scaleX, double scaleY, double angle=0.0)
 
void save (const char *filename, PageSize size=PageSize::BoundingBox, double margin=0.0, Unit unit=Unit::Millimeter) const
 
void save (const char *filename, double pageWidth, double pageHeight, double margin=0.0, Unit unit=Unit::Millimeter) const
 
void saveEPS (std::ostream &out, PageSize size=PageSize::BoundingBox, double margin=0.0, Unit unit=Unit::Millimeter, const std::string &title=std::string()) const
 
void saveEPS (const char *filename, PageSize size=PageSize::BoundingBox, double margin=0.0, Unit unit=Unit::Millimeter, const std::string &title=std::string()) const
 
void saveEPS (std::ostream &out, double pageWidth, double pageHeight, double margin=0.0, Unit unit=Unit::Millimeter, const std::string &title=std::string()) const
 
void saveEPS (const char *filename, double pageWidth, double pageHeight, double margin=0.0, Unit unit=Unit::Millimeter, const std::string &title=std::string()) const
 
void saveFIG (const char *filename, PageSize size=PageSize::BoundingBox, double margin=0.0, Unit unit=Unit::Millimeter) const
 
void saveFIG (std::ostream &out, PageSize size=PageSize::BoundingBox, double margin=0.0, Unit unit=Unit::Millimeter) const
 
void saveFIG (const char *filename, double pageWidth, double pageHeight, double margin=0.0, Unit unit=Unit::Millimeter) const
 
void saveFIG (std::ostream &out, double pageWidth, double pageHeight, double margin=0.0, Unit unit=Unit::Millimeter) const
 
void saveSVG (const char *filename, PageSize size=PageSize::BoundingBox, double margin=0.0, Unit unit=Unit::Millimeter) const
 
void saveSVG (std::ostream &out, PageSize size=PageSize::BoundingBox, double margin=0.0, Unit unit=Unit::Millimeter) const
 
void saveSVG (const char *filename, double pageWidth, double pageHeight, double margin=0.0, Unit unit=Unit::Millimeter) const
 
void saveSVG (std::ostream &out, double pageWidth, double pageHeight, double margin=0.0, Unit unit=Unit::Millimeter) const
 
void saveTikZ (const char *filename, PageSize size=PageSize::BoundingBox, double margin=0.0) const
 
void saveTikZ (std::ostream &out, PageSize size=PageSize::BoundingBox, double margin=0.0) const
 
void saveTikZ (const char *filename, double pageWidth, double pageHeight, double margin=0.0) const
 
void saveTikZ (std::ostream &out, double pageWidth, double pageHeight, double margin=0.0) const
 
const ColorpenColor () const
 penColor
 
const ColorfillColor () const
 fillColor
 
const Stylestyle () const
 
- Public Member Functions inherited from LibBoard::ShapeList
 ShapeList ()
 
 ShapeList (const ShapeList &other)
 
ShapeListoperator= (const ShapeList &other)
 
 ShapeList (ShapeList &&other)
 
ShapeListoperator= (ShapeList &&other)
 
 ShapeList (const Shape &shape, unsigned int times, double dx, double dy, double scale)
 
 ShapeList (const Shape &shape, unsigned int times, double dx, double dy, double scaleX, double scaleY, double angle)
 
template<typename S >
 ShapeList (const std::vector< S > &shapes)
 
 ~ShapeList () override
 
const std::string & name () const override
 
ShapeListclear ()
 
ShapeListrotate (double angle, const Point &center) override
 
ShapeList rotated (double angle, const Point &center)
 
ShapeListrotate (double angle) override
 
ShapeList rotated (double angle)
 
ShapeListtranslate (double dx, double dy) override
 
ShapeList translated (double dx, double dy)
 
ShapeListscale (double sx, double sy) override
 
ShapeListscale (double s) override
 
ShapeList scaled (double sx, double sy) const
 
ShapeList scaled (double s) const
 
void scaleAll (double s) override
 
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
 
Rect boundingBox (LineWidthFlag) const override
 
ShapeListclone () const override
 
ShapeListpush_back (Shape *shape)
 
ShapeListoperator<< (const Shape &shape)
 
template<typename S >
ShapeListoperator<< (const std::vector< S > &shapes)
 
ShapeListoperator+= (const Shape &shape)
 
ShapeListappend (const Shape &shape, Direction direction=Direction::Right, Alignment alignment=Alignment::Center, double margin=0.0, LineWidthFlag lineWidthFlag=UseLineWidth)
 
void addRepeated (const Shape &shape, unsigned int times, double dx, double dy, double scaleX=1.0, double scaleY=1.0, double angle=0.0)
 
ShapeListduplicateLast (std::size_t copies=1)
 
template<typename T >
T & last (const std::size_t position=0)
 
Shapelast (const std::size_t position=0)
 
template<typename T >
T & topLevelFindLast (std::size_t position=0)
 
Shapetop ()
 
void accept (ShapeVisitor &visitor) override
 Accepts a visitor object.
 
void accept (const ShapeVisitor &visitor) override
 Accepts a visitor object.
 
void accept (ConstShapeVisitor &visitor) const override
 Accepts a const-shape visitor object.
 
void accept (const ConstShapeVisitor &visitor) const override
 Accepts a const-shape visitor object.
 
Shapeaccept (CompositeShapeTransform &transform) const override
 Accept a composite shape transform.
 
Shapeaccept (const CompositeShapeTransform &transform) const override
 Accept a constant composite shape transform.
 
TopLevelIterator begin ()
 begin
 
TopLevelIterator end ()
 end
 
TopLevelConstIterator begin () const
 begin
 
TopLevelConstIterator cbegin () const
 cbegin
 
TopLevelConstIterator end () const
 end
 
TopLevelConstIterator cend () const
 cend
 
DepthFirstIterator depthFirstBegin ()
 depthFirstBegin
 
DepthFirstIterator depthFirstEnd ()
 depthFirstEnd
 
BreadthFirstIterator breadthFirstBegin ()
 breadthFirstBegin
 
BreadthFirstIterator breadthFirstEnd ()
 breadthFirstEnd
 
std::size_t deepSize () const
 Recursively counts the number of shapes in the list.
 
std::size_t size () const
 The number of shapes in the list (at top level).
 
- Public Member Functions inherited from LibBoard::Shape
 Shape ()
 
virtual ~Shape ()
 
virtual const std::string & name () const
 
virtual Shapeclone () const =0
 
virtual Point center (LineWidthFlag lineWidthFlag=IgnoreLineWidth) const
 
virtual Shaperotate (double angle, const Point &center)=0
 
virtual Shaperotate (double angle)=0
 
ShaperotateDeg (double angle, const Point &center)
 
ShaperotateDeg (double angle)
 
virtual Shapetranslate (double dx, double dy)=0
 
ShapemoveCenter (double x, double y, LineWidthFlag lineWidthFlag=IgnoreLineWidth)
 
ShapemoveCenter (Point p, LineWidthFlag lineWidthFlag=IgnoreLineWidth)
 
virtual Shapescale (double sx, double sy)=0
 
virtual Shapescale (double s)=0
 
Shaperesize (double width, double height, LineWidthFlag lineWidthFlag)
 
ShapescaleToWidth (double w, LineWidthFlag lineWidthFlag)
 
ShapescaleToHeight (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 Shapeaccept (CompositeShapeTransform &transform) const
 Accept a composite shape transform.
 
virtual Shapeaccept (const CompositeShapeTransform &transform) const
 Accept a constant composite shape transform.
 
 Shape (const Shape &other)
 

Static Public Member Functions

static void enableLineWidthScaling ()
 
static void disableLineWidthScaling ()
 
static void setLineWidthScaling (bool)
 
static Rect pageRect (PageSize size, Unit unit)
 Standard page size as a rectangle Rect(0,0,width,height)
 

Static Public Attributes

static const double Degree = 3.14159265358979323846 / 180.0
 

Static Protected Member Functions

static double toMillimeter (double x, Unit unit)
 

Protected Attributes

State _state
 
Color _backgroundColor
 
Path _clippingPath
 
- Protected Attributes inherited from LibBoard::ShapeList
std::vector< Shape * > _shapes
 

Additional Inherited Members

- Protected Member Functions inherited from LibBoard::ShapeList
void addShape (const Shape &shape, double scaleFactor)
 
void deleteShapes ()
 

Detailed Description

Class for EPS, FIG or SVG drawings.

The Board class.

Examples
examples/Huffman.cpp, examples/Julia.cpp, examples/arithmetic.cpp, examples/array.cpp, examples/arrows.cpp, examples/bezier.cpp, examples/board_font_text.cpp, examples/circled_framed.cpp, examples/clipping.cpp, examples/ellipse.cpp, examples/example1.cpp, examples/example2.cpp, examples/example3.cpp, examples/example4.cpp, examples/flag.cpp, examples/graph.cpp, examples/holes.cpp, examples/hull.cpp, examples/images.cpp, examples/interpolate.cpp, examples/koch.cpp, examples/line_segment.cpp, examples/line_style.cpp, examples/logo.cpp, examples/rough.cpp, examples/ruler.cpp, examples/sandbox.cpp, examples/scale_ellipse.cpp, examples/sierpinski.cpp, examples/stroke_path.cpp, examples/test_arrow.cpp, examples/test_depth.cpp, examples/tilings.cpp, examples/traversal.cpp, examples/triangles.cpp, and examples/xkcd.cpp.

Member Enumeration Documentation

◆ AspectRatio

enum class LibBoard::Board::AspectRatio
strong

The AspectRatio enum.

Enumerator
Ignore 

Ignore aspect ratio, e.g. for resize operations.

Preserve 

Preserve aspect ratio, e.g. for resize operations.

Constructor & Destructor Documentation

◆ Board() [1/2]

LibBoard::Board::Board ( const Color backgroundColor = Color::Null)

Constructs a new board and sets the background color, if any.

Parameters
backgroundColorA color for the drawing's background.

◆ Board() [2/2]

LibBoard::Board::Board ( const Board other)

Copy constructor.

Parameters
otherThe object to be copied.

◆ ~Board()

LibBoard::Board::~Board ( )
override

Member Function Documentation

◆ addDuplicates() [1/2]

void LibBoard::Board::addDuplicates ( const Shape shape,
std::size_t  times,
double  dx,
double  dy,
double  scale = 1.0 
)

Insert duplicates of a shape, n times, starting at its current position and iterating given translations and scalings.

Parameters
shapeThe shape to be duplicated.
timesThe number of duplicates.
dxThe x shift.
dyThe y shift.
scaleA scale factor between each copy.
Examples
examples/clipping.cpp, examples/logo.cpp, examples/ruler.cpp, and examples/scale_ellipse.cpp.

References LibBoard::Shape::clone(), scale(), LibBoard::Shape::scale(), and LibBoard::Shape::translate().

Referenced by main().

◆ addDuplicates() [2/2]

void LibBoard::Board::addDuplicates ( const Shape shape,
std::size_t  times,
double  dx,
double  dy,
double  scaleX,
double  scaleY,
double  angle = 0.0 
)

Insert duplicates of a shape, n times, starting at its current position and iterating a given translation.

Parameters
shapeThe shape to be duplicated.
timesThe number of duplicates.
dxThe x shift.
dyThe y shift.
scaleXAn x scale factor between each copy.
scaleYA y scale factor between each copy.
angleAn angular increment.

References LibBoard::Shape::clone(), LibBoard::Shape::rotate(), LibBoard::Shape::scale(), and LibBoard::Shape::translate().

◆ clear() [1/2]

void LibBoard::Board::clear ( const Color color = Color::Null)

Clears the board with a given background color.

Parameters
colorThe board background color (may be Color::None).
Examples
examples/arithmetic.cpp, examples/arrows.cpp, examples/ellipse.cpp, examples/example3.cpp, examples/example4.cpp, examples/graph.cpp, examples/holes.cpp, examples/line_style.cpp, examples/ruler.cpp, examples/stroke_path.cpp, and examples/tilings.cpp.

References _backgroundColor, and LibBoard::ShapeList::clear().

Referenced by main(), and main().

◆ clear() [2/2]

void LibBoard::Board::clear ( unsigned char  red,
unsigned char  green,
unsigned char  blue 
)
inline

Clears the board and set the background color from an RGB triple.

Parameters
red
green
blue

References LibBoard::ShapeList::clear().

◆ disableLineWidthScaling()

void LibBoard::Board::disableLineWidthScaling ( )
static

Globally disable linewidth scaling when using scale functions.

Examples
examples/example2.cpp.

References LibBoard::ShapeWithStyle::setLineWidthScaling().

Referenced by main().

◆ drawArrow() [1/2]

void LibBoard::Board::drawArrow ( double  x1,
double  y1,
double  x2,
double  y2,
Arrow::ExtremityType  type = Arrow::ExtremityType::Plain 
)

Draws a line from (x1,y1) to (x2,y2) with an arrow at (x2,y2) using current style parameters.

Parameters
x1First coordinate of the first extremity.
y1Second coordinate of the first extremity.
x2First coordinate of the second extremity.
y2Second coordinate of the second extremity.
typeThe arrow extremity type.
Examples
examples/arrows.cpp, examples/example1.cpp, and examples/line_segment.cpp.

References LibBoard::ShapeList::_shapes, _state, and LibBoard::Board::State::style.

Referenced by drawLine(), and main().

◆ drawArrow() [2/2]

void LibBoard::Board::drawArrow ( Point  p,
Point  q,
Arrow::ExtremityType  type = Arrow::ExtremityType::Plain 
)

Draws a line from p to q with an arrow at (x2,y2).

Parameters
pFirst extremity.
qSecond extremity.
typeThe arrow extremity type.

References LibBoard::ShapeList::_shapes, _state, and LibBoard::Board::State::style.

◆ drawBoundingBox()

void LibBoard::Board::drawBoundingBox ( LineWidthFlag  lineWidthFlag)

Draws the current drawing's bounding box as a rectangle.

Parameters
lineWidthFlagShould the line width be considered when computing bounding boxes.

References LibBoard::ShapeList::_shapes, _state, LibBoard::Shape::bbox(), LibBoard::ShapeList::boundingBox(), LibBoard::Polyline::clone(), LibBoard::Rect::height, LibBoard::Rect::left, LibBoard::rectangle(), LibBoard::Board::State::style, LibBoard::Rect::top, and LibBoard::Rect::width.

◆ drawCircle()

void LibBoard::Board::drawCircle ( double  x,
double  y,
double  radius 
)

Draws a circle.

Parameters
xFirst coordinate of the circle's center.
ySecond coordinate of the circle's center.
radiusRadius of the circle.
Examples
examples/example2.cpp.

References LibBoard::ShapeList::_shapes, _state, LibBoard::circle(), LibBoard::Ellipse::clone(), LibBoard::Style::fillColor, LibBoard::Style::lineStyle, LibBoard::Style::lineWidth, LibBoard::Style::penColor, and LibBoard::Board::State::style.

Referenced by main().

◆ drawClosedPolyline()

void LibBoard::Board::drawClosedPolyline ( const std::vector< Point > &  points)

Draws a closed polygonal line.

Parameters
pointsA vector of points.

References LibBoard::ShapeList::_shapes, _state, LibBoard::Path::Closed, and LibBoard::Board::State::style.

◆ drawDot()

void LibBoard::Board::drawDot ( double  x,
double  y 
)

Draws a dot at coordinates (x,y).

Parameters
xFirst coordinate of the dot.
ySecond coordinate of the dot.
Examples
examples/arrows.cpp, and examples/example4.cpp.

References LibBoard::ShapeList::_shapes, _state, LibBoard::Style::lineWidth, LibBoard::Style::penColor, and LibBoard::Board::State::style.

Referenced by main().

◆ drawEllipse()

void LibBoard::Board::drawEllipse ( double  x,
double  y,
double  xRadius,
double  yRadius 
)

Draws an ellipse.

Parameters
xFirst coordinate of the circle's center.
ySecond coordinate of the circle's center.
xRadiusRadius of the circle along the x axis.
yRadiusRadius of the circle along the y axis.
Examples
examples/example2.cpp.

References LibBoard::ShapeList::_shapes, _state, LibBoard::Style::fillColor, LibBoard::Style::lineStyle, LibBoard::Style::lineWidth, LibBoard::Style::penColor, and LibBoard::Board::State::style.

Referenced by main().

◆ drawLine() [1/2]

void LibBoard::Board::drawLine ( double  x1,
double  y1,
double  x2,
double  y2 
)

Draws a line from (x1,y1) to (x2,y2) using current style parameters.

Parameters
x1First coordinate of the first extremity.
y1Second coordinate of the first extremity.
x2First coordinate of the second extremity.
y2Second coordinate of the second extremity.
Examples
examples/line_segment.cpp, and examples/logo.cpp.

References LibBoard::ShapeList::_shapes, _state, and LibBoard::Board::State::style.

Referenced by main().

◆ drawLine() [2/2]

void LibBoard::Board::drawLine ( Point  p,
Point  q 
)

Draws a line from p to q using current style parameters.

Parameters
pFirst extremity.
qSecond extremity.

References LibBoard::ShapeList::_shapes, _state, and LibBoard::Board::State::style.

◆ drawPolyline()

void LibBoard::Board::drawPolyline ( const std::vector< Point > &  points)

Draws a polygonal line.

Parameters
pointsA vector of points.
Examples
examples/example1.cpp, and examples/example2.cpp.

References LibBoard::ShapeList::_shapes, _state, LibBoard::Path::Open, and LibBoard::Board::State::style.

Referenced by main().

◆ drawRectangle() [1/2]

void LibBoard::Board::drawRectangle ( const Rect rect)

◆ drawRectangle() [2/2]

void LibBoard::Board::drawRectangle ( double  left,
double  top,
double  width,
double  height 
)

Draws a rectangle.

Parameters
leftFirst coordinate of the upper left corner.
topSecond coordinate of the upper left corner.
widthWidth of the rectangle.
heightHeight of the rectangle.
Examples
examples/arithmetic.cpp, examples/example2.cpp, examples/line_segment.cpp, and examples/line_style.cpp.

References LibBoard::ShapeList::_shapes, _state, LibBoard::Polyline::clone(), LibBoard::rectangle(), LibBoard::Board::State::style, and LibBoard::ShapeList::top().

Referenced by drawPixel(), main(), and main().

◆ drawText() [1/4]

void LibBoard::Board::drawText ( double  x,
double  y,
const char *  text 
)

Draws a string of text.

Parameters
xThe first coordinates of the lower left corner.
yThe second coordinates of the lower left corner.
textThe text.
Examples
examples/arithmetic.cpp, examples/arrows.cpp, examples/example2.cpp, and examples/ruler.cpp.

References LibBoard::ShapeList::_shapes, _state, LibBoard::Board::State::font, LibBoard::Board::State::fontSize, LibBoard::Style::penColor, LibBoard::Board::State::style, and text().

Referenced by main(), and main().

◆ drawText() [2/4]

void LibBoard::Board::drawText ( double  x,
double  y,
const std::string &  text 
)

Draws a string of text.

Parameters
xThe first coordinates of the lower left corner.
yThe second coordinates of the lower left corner.
textThe text.

References LibBoard::ShapeList::_shapes, _state, LibBoard::Board::State::font, LibBoard::Board::State::fontSize, LibBoard::Style::penColor, LibBoard::Board::State::style, and text().

◆ drawText() [3/4]

void LibBoard::Board::drawText ( Point  p,
const char *  text 
)

Draws a string of text.

Parameters
pPosition of the bottom-left corner.
textThe text.

References LibBoard::ShapeList::_shapes, _state, LibBoard::Board::State::font, LibBoard::Board::State::fontSize, LibBoard::Style::penColor, LibBoard::Board::State::style, and text().

◆ drawText() [4/4]

void LibBoard::Board::drawText ( Point  p,
const std::string &  str 
)

Draws a string of text.

Parameters
pPosition of the bottom-left corner.
strThe text.

References LibBoard::ShapeList::_shapes, _state, LibBoard::Board::State::font, LibBoard::Board::State::fontSize, LibBoard::Style::penColor, and LibBoard::Board::State::style.

◆ drawTriangle() [1/2]

void LibBoard::Board::drawTriangle ( const Point p1,
const Point p2,
const Point p3 
)

Draws a triangle.

Parameters
p1First vertex.
p2Second vertex.
p3Third vertex.

References LibBoard::ShapeList::_shapes, _state, LibBoard::Path::Closed, and LibBoard::Board::State::style.

◆ drawTriangle() [2/2]

void LibBoard::Board::drawTriangle ( double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3 
)

Draws a triangle.

Parameters
x1First coordinate of the first vertex.
y1Second coordinate of the first vertex.
x2First coordinate of the second vertex.
y2Second coordinate of the second vertex.
x3First coordinate of the third vertex.
y3Second coordinate of the third vertex.
Examples
examples/example2.cpp.

References LibBoard::ShapeList::_shapes, _state, LibBoard::Path::Closed, and LibBoard::Board::State::style.

Referenced by main().

◆ enableLineWidthScaling()

void LibBoard::Board::enableLineWidthScaling ( )
static

Globally enable linewidth scaling when using scale functions.

References LibBoard::ShapeWithStyle::setLineWidthScaling().

Referenced by main().

◆ fillCircle()

void LibBoard::Board::fillCircle ( double  x,
double  y,
double  radius 
)

Draws a circle filled with the current pen color.

Parameters
xFirst coordinate of the circle's center.
ySecond coordinate of the circle's center.
radiusRadius of the circle.
Examples
examples/example2.cpp, and examples/line_segment.cpp.

References LibBoard::ShapeList::_shapes, _state, LibBoard::circle(), LibBoard::Ellipse::clone(), LibBoard::Style::lineStyle, LibBoard::Color::Null, LibBoard::Style::penColor, and LibBoard::Board::State::style.

Referenced by drawLine(), and main().

◆ fillColor()

const Color & LibBoard::Board::fillColor ( ) const
inline

fillColor

Returns
The current fill color.

References _state, LibBoard::Style::fillColor, and LibBoard::Board::State::style.

◆ fillEllipse()

void LibBoard::Board::fillEllipse ( double  x,
double  y,
double  xRadius,
double  yRadius 
)

Draws an ellipse filled with the current pen color.

Parameters
xFirst coordinate of the circle's center.
ySecond coordinate of the circle's center.
xRadiusX axis radius of the ellipse.
yRadiusY axis radius of the ellipse.

References LibBoard::ShapeList::_shapes, _state, LibBoard::Style::lineStyle, LibBoard::Color::Null, LibBoard::Style::penColor, and LibBoard::Board::State::style.

◆ fillGouraudTriangle() [1/4]

void LibBoard::Board::fillGouraudTriangle ( const double  x1,
const double  y1,
const Color color1,
const double  x2,
const double  y2,
const Color color2,
const double  x3,
const double  y3,
const Color color3,
unsigned char  divisions = 3 
)
inline

Draws a triangle with Gouraud-like shaded colors.

Parameters
x1
y1
color1
x2
y2
color2
x3
y3
color3
divisions

References fillGouraudTriangle().

◆ fillGouraudTriangle() [2/4]

void LibBoard::Board::fillGouraudTriangle ( const double  x1,
const double  y1,
const float  brightness1,
const double  x2,
const double  y2,
const float  brightness2,
const double  x3,
const double  y3,
const float  brightness3,
unsigned char  divisions = 3 
)
inline

Draws a triangle with a Gouraud-like shaded color according to the current fill color and a brightness value given for each vertex.

Parameters
x1
y1
brightness1
x2
y2
brightness2
x3
y3
brightness3
divisions

References fillGouraudTriangle().

◆ fillGouraudTriangle() [3/4]

void LibBoard::Board::fillGouraudTriangle ( const Point p1,
const Color color1,
const Point p2,
const Color color2,
const Point p3,
const Color color3,
unsigned char  divisions = 3 
)

Draws a triangle with Gouraud-like shaded colors.

Parameters
p1
color1
p2
color2
p3
color3
divisionsnumber of triangle subdivisions.
Examples
examples/example1.cpp, and examples/example3.cpp.

References LibBoard::ShapeList::_shapes.

Referenced by fillGouraudTriangle(), fillGouraudTriangle(), fillGouraudTriangle(), and main().

◆ fillGouraudTriangle() [4/4]

void LibBoard::Board::fillGouraudTriangle ( const Point p1,
const float  brightness1,
const Point p2,
const float  brightness2,
const Point p3,
const float  brightness3,
unsigned char  divisions = 3 
)

Draws a triangle with a Gouraud-like shaded color according to the current fill color and a brightness value given for each vertex.

Parameters
p1
brightness1
p2
brightness2
p3
brightness3
divisionsnumber of triangle subdivisions.

References _state, LibBoard::Color::blue(), fillGouraudTriangle(), LibBoard::Color::green(), LibBoard::Style::penColor, LibBoard::Color::red(), and LibBoard::Board::State::style.

◆ fillPolyline()

void LibBoard::Board::fillPolyline ( const std::vector< Point > &  points)

◆ fillRectangle() [1/2]

void LibBoard::Board::fillRectangle ( const Rect rect)

Draws a rectangle filled with the current pen color.

Parameters
rectPosition and size of the rectangle.

References fillRectangle(), LibBoard::Rect::height, LibBoard::Rect::left, LibBoard::Rect::top, and LibBoard::Rect::width.

◆ fillRectangle() [2/2]

void LibBoard::Board::fillRectangle ( double  left,
double  top,
double  width,
double  height 
)

Draws a rectangle filled with the current pen color.

Parameters
leftFirst coordinate of the upper left corner.
topSecond coordinate of the upper left corner.
widthWidth of the rectangle.
heightHeight of the rectangle.

References LibBoard::ShapeList::_shapes, _state, LibBoard::ShapeList::clone(), LibBoard::Style::fillColor, LibBoard::Style::lineWidth, LibBoard::Color::Null, LibBoard::Style::penColor, LibBoard::rectangle(), style(), LibBoard::Board::State::style, and LibBoard::ShapeList::top().

Referenced by fillRectangle().

◆ fillTriangle() [1/2]

void LibBoard::Board::fillTriangle ( const Point p1,
const Point p2,
const Point p3 
)

◆ fillTriangle() [2/2]

void LibBoard::Board::fillTriangle ( double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3 
)

Draws a filled triangle.

Parameters
x1First coordinate of the first vertex.
y1Second coordinate of the first vertex.
x2First coordinate of the second vertex.
y2Second coordinate of the second vertex.
x3First coordinate of the third vertex.
y3Second coordinate of the third vertex.

References LibBoard::ShapeList::_shapes, _state, LibBoard::Path::Closed, LibBoard::Style::lineCap, LibBoard::Style::lineJoin, LibBoard::Style::lineStyle, LibBoard::Color::Null, LibBoard::Style::penColor, and LibBoard::Board::State::style.

◆ operator<<() [1/2]

Board & LibBoard::Board::operator<< ( const Shape shape)

Add a shape to the board, using the current unit factor.

Parameters
shapeA shape. (Might be a list of shapes, actually!)
Returns
The board itself, as a ShapeList.

References LibBoard::ShapeList::addShape().

◆ operator<<() [2/2]

template<typename S >
Board & LibBoard::Board::operator<< ( const std::vector< S > &  shapes)

Add of shapes from a vector to the shape list.

References LibBoard::ShapeList::operator<<().

◆ operator=()

Board & LibBoard::Board::operator= ( const Board other)

The operator =

Parameters
otherThe object to be copied.
Returns
A reference to the left operand.

References LibBoard::ShapeList::_shapes, LibBoard::ShapeList::deleteShapes(), and LibBoard::ShapeList::end().

◆ pageRect()

Rect LibBoard::Board::pageRect ( PageSize  size,
Unit  unit 
)
static

Standard page size as a rectangle Rect(0,0,width,height)

Parameters
sizePage size enum
unitUnit
Returns
Rectangle according to unit

References LibBoard::Centimeter, LibBoard::Tools::error, LibBoard::Inch, LibBoard::Millimeter, LibBoard::Point, and LibBoard::ShapeList::size().

◆ penColor()

const Color & LibBoard::Board::penColor ( ) const
inline

penColor

Returns
The current pen color.
Examples
examples/arrows.cpp.

References _state, LibBoard::Style::penColor, and LibBoard::Board::State::style.

Referenced by main().

◆ rotate() [1/2]

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

Rotate the board by an angle around the center of its bounding box.

Parameters
angleRotation angle (in radians)
Returns
A reference to the board itself

Implements LibBoard::Shape.

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

◆ rotate() [2/2]

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

Rotate the board by an angle around a point.

Parameters
angleRotation angle (in radians)
centerRotation center
Returns
A reference to the board itself

Implements LibBoard::Shape.

Examples
examples/holes.cpp.

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

Referenced by main(), rotated(), and rotated().

◆ rotated() [1/2]

Board LibBoard::Board::rotated ( double  angle)

Get a rotated copy of the Board around its bounding box's center.

Parameters
angleRotation angle in radian
Returns
Rotated copy of the Board object.

References rotate().

◆ rotated() [2/2]

Board LibBoard::Board::rotated ( double  angle,
const Point center 
)

Get a rotated copy of the Board around a specified rotation center.

Parameters
angleRotation angle in radian
centerCenter of rotation
Returns
Rotated copy of the Board object.

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

◆ save() [1/2]

void LibBoard::Board::save ( const char *  filename,
double  pageWidth,
double  pageHeight,
double  margin = 0.0,
Unit  unit = Unit::Millimeter 
) const

Save the drawing in an EPS, XFIG of SVG file depending on the filename extension. When a size is given (not PageSize::BoundingBox), the drawing is scaled (up or down) so that it fits within the dimension while keeping its aspect ratio.

Parameters
filenamePath of the file to be created.
pageWidthWidth of the page.
pageHeightHeight of the page.
marginMinimal margin around the figure in the page.
unitThe unit used to express the previous length parameters (default value is millimeter).

References LibBoard::Tools::CaseInsensitive, saveEPS(), saveFIG(), saveSVG(), saveTikZ(), and LibBoard::Tools::stringEndsWith().

◆ save() [2/2]

void LibBoard::Board::save ( const char *  filename,
PageSize  size = PageSize::BoundingBox,
double  margin = 0.0,
Unit  unit = Unit::Millimeter 
) const

Save the drawing in an EPS, XFIG of SVG file depending on the filename extension. When a size is given (not PageSize::BoundingBox), the drawing is scaled (up or down) so that it fits within the dimension while keeping its aspect ratio.

Parameters
filenamePath of the file to be created.
sizePage size (Either PageSize::BoundingBox (default), A4 or Letter).
marginMinimal margin around the figure in the page.
unitThe unit used to express the margin (default value is millimeter). If size is "BoundingBox", this unit is used for the bounding box as well.
Examples
examples/arithmetic.cpp.

References LibBoard::BoundingBox, LibBoard::Millimeter, save(), LibBoard::ShapeList::size(), and toMillimeter().

Referenced by main(), and save().

◆ saveEPS() [1/4]

void LibBoard::Board::saveEPS ( const char *  filename,
double  pageWidth,
double  pageHeight,
double  margin = 0.0,
Unit  unit = Unit::Millimeter,
const std::string &  title = std::string() 
) const

Save the drawing in an EPS file. The drawing is scaled (up or down) so that it fits within the dimension while keeping its aspect ratio.

Parameters
filenameThe EPS file name.
pageWidthWidth of the page.
pageHeightHeight of the page.
marginMinimal margin around the figure in the page.
unitThe unit used to express the previous length parameters (default value is millimeter).
titleDocument title (Postscript comment).

References saveEPS().

◆ saveEPS() [2/4]

void LibBoard::Board::saveEPS ( const char *  filename,
PageSize  size = PageSize::BoundingBox,
double  margin = 0.0,
Unit  unit = Unit::Millimeter,
const std::string &  title = std::string() 
) const

Save the drawing in an EPS file. When a size is given (not PageSize::BoundingBox), the drawing is scaled (up or down) so that it fits within the dimension while keeping its aspect ratio.

Parameters
filenameThe EPS file name.
sizePage size (Either PageSize::BoundingBox (default), A4 or Letter).
marginMinimal margin around the figure in the page.
unitThe unit used to express the margin (default value is millimeter). If size is "BoundingBox", this unit is used for the bounding box as well.
titleDocument title (Postscript comment).

References LibBoard::BoundingBox, LibBoard::Millimeter, saveEPS(), LibBoard::ShapeList::size(), and toMillimeter().

◆ saveEPS() [3/4]

void LibBoard::Board::saveEPS ( std::ostream &  out,
double  pageWidth,
double  pageHeight,
double  margin = 0.0,
Unit  unit = Unit::Millimeter,
const std::string &  title = std::string() 
) const

Write the drawing in a stream as an EPS file. The drawing is scaled (up or down) so that it fits within the dimension while keeping its aspect ratio.

Parameters
outThe output stream.
pageWidthWidth of the page.
pageHeightHeight of the page.
marginMinimal margin around the figure in the page.
unitThe unit used to express the previous length parameters (default value is millimeter).
titleDocument title (Postscript comment).

References _backgroundColor, _clippingPath, LibBoard::ShapeList::_shapes, LibBoard::Shape::bbox(), BOARD_VERSION_STRING, LibBoard::Rect::bottom(), LibBoard::Path::boundingBox(), LibBoard::ShapeList::boundingBox(), LibBoard::Path::flushPostscript(), LibBoard::Polyline::flushPostscript(), LibBoard::Rect::height, LibBoard::Rect::left, LibBoard::Color::Null, LibBoard::TransformEPS::pageBoundingBox(), LibBoard::rectangle(), LibBoard::Rect::right(), LibBoard::Tools::secured_ctime(), LibBoard::TransformEPS::setBoundingBox(), LibBoard::Path::size(), toMillimeter(), LibBoard::Rect::top, LibBoard::UseLineWidth, and LibBoard::Rect::width.

◆ saveEPS() [4/4]

void LibBoard::Board::saveEPS ( std::ostream &  out,
PageSize  size = PageSize::BoundingBox,
double  margin = 0.0,
Unit  unit = Unit::Millimeter,
const std::string &  title = std::string() 
) const

Writes the drawing in a stream as an EPS file. When a size is given (not PageSize::BoundingBox), the drawing is scaled (up or down) so that it fits within the dimension while keeping its aspect ratio.

Parameters
outThe output stream.
sizePage size (Either PageSize::BoundingBox (default), A4 or Letter).
marginMinimal margin around the figure in the page.
unitThe unit used to express the margin (default value is millimeter). If size is "BoundingBox", this unit is used for the bounding box as well.
titleDocument title (Postscript comment).
Examples
examples/arrows.cpp, examples/clipping.cpp, examples/ellipse.cpp, examples/example1.cpp, examples/example2.cpp, examples/example3.cpp, examples/example4.cpp, examples/flag.cpp, examples/graph.cpp, examples/holes.cpp, examples/images.cpp, examples/koch.cpp, examples/line_segment.cpp, examples/line_style.cpp, examples/logo.cpp, examples/ruler.cpp, examples/scale_ellipse.cpp, examples/sierpinski.cpp, examples/stroke_path.cpp, and examples/tilings.cpp.

References LibBoard::BoundingBox, LibBoard::Millimeter, saveEPS(), LibBoard::ShapeList::size(), and toMillimeter().

Referenced by main(), save(), saveEPS(), saveEPS(), and saveEPS().

◆ saveFIG() [1/4]

void LibBoard::Board::saveFIG ( const char *  filename,
double  pageWidth,
double  pageHeight,
double  margin = 0.0,
Unit  unit = Unit::Millimeter 
) const

Saves the drawing in an XFig file. When a size is given (not PageSize::BoundingBox), the drawing is scaled (up or down) so that it fits within the dimension while keeping its aspect ratio.

Parameters
filenameThe XFig file name.
pageWidthWidth of the page.
pageHeightHeight of the page.
marginMinimal margin around the figure in the page.
unitThe unit used to express the previous length parameters (default value is millimeter).

References saveFIG().

◆ saveFIG() [2/4]

void LibBoard::Board::saveFIG ( const char *  filename,
PageSize  size = PageSize::BoundingBox,
double  margin = 0.0,
Unit  unit = Unit::Millimeter 
) const

Save the drawing in an XFig file. When a size is given (not PageSize::BoundingBox), the drawing is scaled (up or down) so that it fits within the dimension while keeping its aspect ratio.

Parameters
filenameThe name of the FIG file.
sizePage size (Either PageSize::BoundingBox (default), A4 or Letter).
marginMinimal margin around the figure in the page.
unitThe unit used to express the margin (default value is millimeter). If size is "BoundingBox", this unit is used for the bounding box as well.
Examples
examples/arrows.cpp, examples/ellipse.cpp, examples/example1.cpp, examples/example2.cpp, examples/example3.cpp, examples/example4.cpp, examples/graph.cpp, examples/images.cpp, examples/koch.cpp, examples/line_style.cpp, examples/logo.cpp, examples/ruler.cpp, examples/scale_ellipse.cpp, and examples/sierpinski.cpp.

References LibBoard::BoundingBox, LibBoard::Millimeter, saveFIG(), LibBoard::ShapeList::size(), and toMillimeter().

Referenced by main(), save(), saveFIG(), saveFIG(), and saveFIG().

◆ saveFIG() [3/4]

void LibBoard::Board::saveFIG ( std::ostream &  out,
double  pageWidth,
double  pageHeight,
double  margin = 0.0,
Unit  unit = Unit::Millimeter 
) const

Save the drawing in a stream as an XFig file. The drawing is scaled (up or down) so that it fits within the dimension while keeping its aspect ratio.

Parameters
outThe output stream.
pageWidthWidth of the page.
pageHeightHeight of the page.
marginMinimal margin around the figure in the page.
unitThe unit used to express the previous length parameters (default value is millimeter).

References _backgroundColor, LibBoard::ShapeList::_shapes, LibBoard::ShapeList::accept(), LibBoard::Shape::bbox(), BOARD_VERSION_STRING, LibBoard::ShapeList::boundingBox(), LibBoard::PenColorExtractor::colors(), LibBoard::FillColorExtractor::colors(), LibBoard::Polyline::flushFIG(), LibBoard::Rect::height, LibBoard::Color::Null, LibBoard::rectangle(), secured_sprintf, LibBoard::TransformFIG::setBoundingBox(), LibBoard::TransformFIG::setDepthMap(), toMillimeter(), LibBoard::UseLineWidth, LibBoard::Color::valid(), and LibBoard::Rect::width.

◆ saveFIG() [4/4]

void LibBoard::Board::saveFIG ( std::ostream &  out,
PageSize  size = PageSize::BoundingBox,
double  margin = 0.0,
Unit  unit = Unit::Millimeter 
) const

Saves the drawing in a stream as an XFig file. When a size is given (not PageSize::BoundingBox), the drawing is scaled (up or down) so that it fits within the dimension while keeping its aspect ratio.

Parameters
outThe output stream.
sizePage size (Either PageSize::BoundingBox (default), A4 or Letter).
marginMinimal margin around the figure in the page.
unitThe unit used to express the margin (default value is millimeter). If size is "BoundingBox", this unit is used for the bounding box as well.

References LibBoard::BoundingBox, LibBoard::Millimeter, saveFIG(), LibBoard::ShapeList::size(), and toMillimeter().

◆ saveSVG() [1/4]

void LibBoard::Board::saveSVG ( const char *  filename,
double  pageWidth,
double  pageHeight,
double  margin = 0.0,
Unit  unit = Unit::Millimeter 
) const

Save the drawing in an SVG file. When a size is given (not PageSize::BoundingBox), the drawing is scaled (up or down) so that it fits within the dimension while keeping its aspect ratio.

Parameters
filenameThe SVG file name.
pageWidthWidth of the page.
pageHeightHeight of the page.
marginMinimal margin around the figure in the page.
unitThe unit used to express the previous length parameters (default value is millimeter).

References saveSVG().

◆ saveSVG() [2/4]

void LibBoard::Board::saveSVG ( const char *  filename,
PageSize  size = PageSize::BoundingBox,
double  margin = 0.0,
Unit  unit = Unit::Millimeter 
) const

◆ saveSVG() [3/4]

void LibBoard::Board::saveSVG ( std::ostream &  out,
double  pageWidth,
double  pageHeight,
double  margin = 0.0,
Unit  unit = Unit::Millimeter 
) const

Save the drawing in a stream as an SVG file. The drawing is scaled (up or down) so that it fits within the dimension while keeping its aspect ratio.

Parameters
outThe output stream.
pageWidthWidth of the page.
pageHeightHeight of the page.
marginMinimal margin around the figure in the page.
unitThe unit used to express the previous length parameters (default value is millimeter).

References _backgroundColor, _clippingPath, LibBoard::ShapeList::_shapes, LibBoard::Shape::bbox(), BOARD_VERSION_STRING, LibBoard::Path::boundingBox(), LibBoard::ShapeList::boundingBox(), LibBoard::Polyline::flushSVG(), LibBoard::Path::flushSVGCommands(), LibBoard::Rect::height, LibBoard::Color::Null, LibBoard::rectangle(), LibBoard::TransformSVG::setBoundingBox(), LibBoard::Path::size(), toMillimeter(), LibBoard::UseLineWidth, and LibBoard::Rect::width.

◆ saveSVG() [4/4]

void LibBoard::Board::saveSVG ( std::ostream &  out,
PageSize  size = PageSize::BoundingBox,
double  margin = 0.0,
Unit  unit = Unit::Millimeter 
) const

Saves the drawing in a stream as an SVG file. When a size is given (not PageSize::BoundingBox), the drawing is scaled (up or down) so that it fits within the dimension while keeping its aspect ratio.

Parameters
outThe output stream.
sizePage size (Either PageSize::BoundingBox (default), A4 or Letter).
marginMinimal margin around the figure in the page.
unitThe unit used to express the margin (default value is millimeter). If size is "BoundingBox", this unit is used for the bounding box as well.

References LibBoard::BoundingBox, LibBoard::Millimeter, saveSVG(), LibBoard::ShapeList::size(), and toMillimeter().

◆ saveTikZ() [1/4]

void LibBoard::Board::saveTikZ ( const char *  filename,
double  pageWidth,
double  pageHeight,
double  margin = 0.0 
) const

Save the drawing in an TikZ file. When a size is given (not PageSize::BoundingBox), the drawing is scaled (up or down) so that it fits within the dimension while keeping its aspect ratio.

Parameters
filenameThe name of the file.
pageWidthWidth of the page in millimeters.
pageHeightHeight of the page in millimeters.
marginMinimal margin around the figure in the page, in millimeters.

References saveTikZ().

◆ saveTikZ() [2/4]

void LibBoard::Board::saveTikZ ( const char *  filename,
PageSize  size = PageSize::BoundingBox,
double  margin = 0.0 
) const

Save the drawing in an TikZ file. When a size is given (not PageSize::BoundingBox), the drawing is scaled (up or down) so that it fits within the dimension while keeping its aspect ratio.

Parameters
filenameThe name of the file.
sizePage size (Either PageSize::BoundingBox (default), A4 or Letter).
marginMinimal margin around the figure in the page, in millimeters.
Examples
examples/flag.cpp.

References saveTikZ(), and LibBoard::ShapeList::size().

Referenced by main(), save(), saveTikZ(), saveTikZ(), and saveTikZ().

◆ saveTikZ() [3/4]

void LibBoard::Board::saveTikZ ( std::ostream &  out,
double  pageWidth,
double  pageHeight,
double  margin = 0.0 
) const

Save the drawing in a stream as a TikZ file. The drawing is scaled (up or down) so that it fits within the dimension while keeping its aspect ratio.

Parameters
outThe output stream.
pageWidthWidth of the page in millimeters.
pageHeightHeight of the page in millimeters.
marginMinimal margin around the figure in the page, in millimeters.

References _backgroundColor, _clippingPath, LibBoard::ShapeList::_shapes, LibBoard::Path::boundingBox(), LibBoard::ShapeList::boundingBox(), LibBoard::Polyline::flushTikZ(), LibBoard::Path::flushTikZPoints(), LibBoard::Color::Null, LibBoard::rectangle(), LibBoard::TransformSVG::setBoundingBox(), LibBoard::Path::size(), and LibBoard::UseLineWidth.

◆ saveTikZ() [4/4]

void LibBoard::Board::saveTikZ ( std::ostream &  out,
PageSize  size = PageSize::BoundingBox,
double  margin = 0.0 
) const

Save the drawing in a stream as TikZ file. When a size is given (not PageSize::BoundingBox), the drawing is scaled (up or down) so that it fits within the dimension while keeping its aspect ratio.

Parameters
outThe output stream.
sizePage size (Either PageSize::BoundingBox (default), A4 or Letter).
marginMinimal margin around the figure in the page, in millimeters.

References saveTikZ(), and LibBoard::ShapeList::size().

◆ scale() [1/2]

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

◆ scale() [2/2]

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

Scale the board in the x and y direction.

Parameters
sxScale factor in the x direction
syScale factor in the y direction
Returns
A reference to the board itself

Implements LibBoard::Shape.

Examples
examples/example3.cpp.

References _clippingPath, LibBoard::Path::center(), LibBoard::Shape::center(), LibBoard::Path::scale(), LibBoard::ShapeList::scale(), LibBoard::Path::size(), LibBoard::Path::translate(), LibBoard::Point::x, and LibBoard::Point::y.

Referenced by addDuplicates(), main(), scaled(), and scaled().

◆ scaled() [1/2]

Board LibBoard::Board::scaled ( double  s)

Get a scaled copy of the Board.

Parameters
sscaling factor
Returns
Scaled copy of the Board object.

References scale().

◆ scaled() [2/2]

Board LibBoard::Board::scaled ( double  sx,
double  sy 
)

Get a scaled copy of the Board.

Parameters
sxx scaling factor
syy scaling factor
Returns
Scaled copy of the Board object.

References scale().

◆ setBackgroundColor()

void LibBoard::Board::setBackgroundColor ( const Color color)

Changes the background color of the whole drawing.

Parameters
colorA color (may be Color::None).

References _backgroundColor.

◆ setClippingPath() [1/2]

void LibBoard::Board::setClippingPath ( const Path path)

Define a clipping path for the whole drawing.

Parameters
pathA path.

References _clippingPath, LibBoard::Path::close(), LibBoard::Path::pop_back(), and LibBoard::Path::size().

◆ setClippingPath() [2/2]

void LibBoard::Board::setClippingPath ( const std::vector< Point > &  points)

Define a clipping path for the whole drawing.

Parameters
pointsA path.

References _clippingPath, LibBoard::Path::clear(), and LibBoard::ShapeList::end().

◆ setClippingRectangle() [1/2]

void LibBoard::Board::setClippingRectangle ( const Rect rect)

Define a clipping rectangle for the whole drawing.

Parameters
rectThe clipping rectangle.

References LibBoard::Rect::height, LibBoard::Rect::left, setClippingRectangle(), LibBoard::Rect::top, and LibBoard::Rect::width.

◆ setClippingRectangle() [2/2]

void LibBoard::Board::setClippingRectangle ( double  x,
double  y,
double  width,
double  height 
)

Define a clipping rectangle for the whole drawing.

Parameters
x
y
width
height
Examples
examples/flag.cpp.

References _clippingPath, and LibBoard::Path::clear().

Referenced by main(), and setClippingRectangle().

◆ setFillColor()

Board & LibBoard::Board::setFillColor ( const Color color)

Changes the current fill color.

In order to use no fill color, one may set this color to Color::None.

Parameters
colorThe fill color.
Returns
The board itself.
Examples
examples/arrows.cpp, examples/bezier.cpp, examples/board_font_text.cpp, examples/interpolate.cpp, examples/line_style.cpp, examples/rough.cpp, examples/test_arrow.cpp, and examples/triangles.cpp.

References _state, LibBoard::Style::fillColor, and LibBoard::Board::State::style.

Referenced by main().

◆ setFillColorHSV()

Board & LibBoard::Board::setFillColorHSV ( float  hue,
float  saturation,
float  value,
float  alpha = 1.0f 
)

Changes the current fill color (HSV version)

Parameters
hue
saturation
value
alpha
Returns

References _state, LibBoard::Style::fillColor, LibBoard::Color::setHSV(), and LibBoard::Board::State::style.

◆ setFillColorRGBf()

Board & LibBoard::Board::setFillColorRGBf ( float  red,
float  green,
float  blue,
float  alpha = 1.0f 
)

Changes the current fill color (RGB version).

Parameters
redRed component.
greenGreen component.
blueBlue component.
alphaThe opacity.
Returns
The board itself.
Examples
examples/example2.cpp.

References _state, LibBoard::Style::fillColor, LibBoard::Color::setRGBf(), and LibBoard::Board::State::style.

Referenced by main().

◆ setFillColorRGBi()

Board & LibBoard::Board::setFillColorRGBi ( unsigned char  red,
unsigned char  green,
unsigned char  blue,
unsigned char  alpha = 255 
)

Changes the current fill color.

Parameters
redRed component.
greenGreen component.
blueBlue component.
alphaThe opacity.
Returns
The board itself.
Examples
examples/example2.cpp.

References _state, LibBoard::Style::fillColor, LibBoard::Color::setRGBi(), and LibBoard::Board::State::style.

Referenced by main().

◆ setFont()

Board & LibBoard::Board::setFont ( const Fonts::Font  font,
double  fontSize 
)

Changes the current font and font size.

Parameters
fontThe name of the font.
fontSizeThe new font size.
Returns
The board itself.
Examples
examples/arrows.cpp, and examples/example2.cpp.

References _state, LibBoard::Board::State::font, and LibBoard::Board::State::fontSize.

Referenced by main().

◆ setFontSize()

Board & LibBoard::Board::setFontSize ( double  fontSize)

Changes the font size.

Parameters
fontSizeThe new font size.
Returns
The board itself.
Examples
examples/arithmetic.cpp, and examples/ruler.cpp.

References _state, and LibBoard::Board::State::fontSize.

Referenced by main(), and main().

◆ setLineCap()

Board & LibBoard::Board::setLineCap ( LineCap  cap)
inline

Set the line cap style.

Parameters
capThe cap-style.
Returns
The board itself.
Examples
examples/line_segment.cpp, and examples/logo.cpp.

References _state, LibBoard::Style::lineCap, and LibBoard::Board::State::style.

Referenced by main().

◆ setLineJoin()

Board & LibBoard::Board::setLineJoin ( LineJoin  join)
inline

Set the line join style.

Parameters
joinThe join-style
Returns
The board itself.
Examples
examples/example2.cpp, and examples/logo.cpp.

References _state, LibBoard::Style::lineJoin, and LibBoard::Board::State::style.

Referenced by main().

◆ setLineStyle()

Board & LibBoard::Board::setLineStyle ( LineStyle  style)
inline

Changes the current line style.

Parameters
styleThe new line style.
Returns
The board itself.
Examples
examples/line_style.cpp, and examples/logo.cpp.

References _state, LibBoard::Style::lineStyle, style(), and LibBoard::Board::State::style.

Referenced by main().

◆ setLineWidth()

Board & LibBoard::Board::setLineWidth ( double  width)

◆ setLineWidthScaling()

void LibBoard::Board::setLineWidthScaling ( bool  on)
static

Globally enable/disable linewidth scaling when using scale functions.

References LibBoard::ShapeWithStyle::setLineWidthScaling().

◆ setPenColor()

Board & LibBoard::Board::setPenColor ( const Color color)

Changes the current pen color.

In order to use no pen, one may set the pen color to Color::None.

Parameters
colorThe pen color.
Returns
The board itself.
Examples
examples/arithmetic.cpp, examples/arrows.cpp, examples/bezier.cpp, examples/board_font_text.cpp, examples/example1.cpp, examples/example2.cpp, examples/interpolate.cpp, examples/koch.cpp, examples/rough.cpp, examples/test_arrow.cpp, and examples/triangles.cpp.

References _state, LibBoard::Style::penColor, and LibBoard::Board::State::style.

Referenced by main(), and main().

◆ setPenColorRGBf()

Board & LibBoard::Board::setPenColorRGBf ( float  red,
float  green,
float  blue,
float  alpha = 1.0f 
)

Changes the current pen color.

Parameters
redRed component [0..1].
greenGreen component [0..1].
blueBlue component [0..1].
alphaTransparency [0..1].
Returns
The board itself.
Examples
examples/arrows.cpp, and examples/example4.cpp.

References _state, LibBoard::Style::penColor, LibBoard::Color::setRGBf(), and LibBoard::Board::State::style.

Referenced by main().

◆ setPenColorRGBi()

Board & LibBoard::Board::setPenColorRGBi ( unsigned char  red,
unsigned char  green,
unsigned char  blue,
unsigned char  alpha = 255 
)

Changes the current pen color.

Parameters
redRed component [0..255].
greenGreen component [0..255].
blueBlue component [0..255].
alphaTransparency channel [0..255].
Returns
The board itself.
Examples
examples/arithmetic.cpp, examples/arrows.cpp, examples/example1.cpp, examples/example2.cpp, examples/example3.cpp, examples/line_segment.cpp, and examples/logo.cpp.

References _state, LibBoard::Style::penColor, LibBoard::Color::setRGBi(), and LibBoard::Board::State::style.

Referenced by drawLine(), main(), and main().

◆ style()

const Style & LibBoard::Board::style ( ) const
inline

Return the current style used when drawing shapes with board methods.

Returns
Current style.
Examples
examples/line_style.cpp.

References _state, and LibBoard::Board::State::style.

Referenced by fillRectangle(), main(), and setLineStyle().

◆ toMillimeter()

double LibBoard::Board::toMillimeter ( double  x,
Unit  unit 
)
staticprotected

◆ translate()

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

Translate the board by a given vector.

Parameters
dxShift in the x direction
dyShift in the y direction
Returns
A reference to the board itself

Implements LibBoard::Shape.

References _clippingPath, LibBoard::Path::translate(), and LibBoard::ShapeList::translate().

Referenced by translated().

◆ translated()

Board LibBoard::Board::translated ( double  dx,
double  dy 
)

Get a translated copy of the Board.

Parameters
dxx shift value
dyy shift value
Returns
Translated copy of the Board object.

References translate().

Member Data Documentation

◆ _backgroundColor

Color LibBoard::Board::_backgroundColor
protected

The color of the background.

Referenced by clear(), saveEPS(), saveFIG(), saveSVG(), saveTikZ(), and setBackgroundColor().

◆ _clippingPath

Path LibBoard::Board::_clippingPath
protected

◆ _state

State LibBoard::Board::_state
protected

◆ Degree

const double LibBoard::Board::Degree = 3.14159265358979323846 / 180.0
static

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