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

A triangle with shaded filling according to colors given for each vertex. More...

#include <Polyline.h>

Inheritance diagram for LibBoard::GouraudTriangle:
LibBoard::Polyline LibBoard::ShapeWithStyle LibBoard::Shape

Public Member Functions

 GouraudTriangle (const Point &p0, const Color &color0, const Point &p1, const Color &color1, const Point &p2, const Color &color2, int subdivisions)
 
 GouraudTriangle (const Point &p0, float brightness0, const Point &p1, float brightness1, const Point &p2, float brightness2, const Color &fillColor, int subdivisions)
 
const std::string & name () const override
 
GouraudTrianglerotate (double angle, const Point &center) override
 
GouraudTriangle rotated (double angle, const Point &center) const
 
GouraudTrianglerotate (double angle) override
 
GouraudTriangle rotated (double angle) const
 
GouraudTriangle translated (double dx, double dy) const
 
GouraudTriangle scaled (double sx, double sy) const
 
GouraudTriangle scaled (double s) const
 
void scaleAll (double s) override
 
GouraudTriangle 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
 
GouraudTriangleclone () const override
 
- Public Member Functions inherited from LibBoard::Polyline
 Polyline (const std::vector< Point > &points, Path::OpenClosed openClosed, 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())
 
 Polyline (const std::vector< Point > &points, Path::OpenClosed openClosed, const Style &style)
 
 Polyline (const Path &path, 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())
 
 Polyline (const Path &path, const Style &style)
 
 Polyline (Path::OpenClosed openClosed, 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())
 
 Polyline (Path::OpenClosed openClosed, const Style &style)
 
const std::string & name () const override
 
Polylineoperator<< (const Point &p)
 
Pointoperator[] (const std::size_t n)
 
const Pointoperator[] (const std::size_t n) const
 
Polylinerotate (double angle, const Point &center) override
 
Polyline rotated (double angle, const Point &center) const
 
Polylinerotate (double angle) override
 
Polyline rotated (double angle) const
 
Polylinetranslate (double dx, double dy) override
 
Polyline translated (double dx, double dy) const
 
Polylinescale (double sx, double sy) override
 
Polylinescale (double s) override
 
Polyline scaled (double sx, double sy) const
 
Polyline scaled (double s) const
 
void scaleAll (double s) override
 
Polyline resized (double w, double h, LineWidthFlag lineWidthFlag) const
 
void addHole (const Path &path)
 Add a hole to the path. Warning: Hole share the polyline line style.
 
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 Shapeaccept (CompositeShapeTransform &transform) const override
 Accept a composite shape transform.
 
virtual Shapeaccept (const CompositeShapeTransform &transform) const override
 Accept a constant composite shape transform.
 
Rect boundingBox (LineWidthFlag) const override
 
Polylineclone () const override
 
std::size_t vertexCount () const
 
const Pathpath () const
 
void setRectangleFlag ()
 
 Polyline (const Polyline &)=default
 
 Polyline (Polyline &&)=default
 
Polylineoperator= (Polyline &&)=default
 
Polylineoperator= (const Polyline &)=default
 
 ~Polyline () 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)
 
ShapeWithStyleoperator= (const ShapeWithStyle &other)
 
 ~ShapeWithStyle ()
 
const std::string & name () const
 
Shapeclone () const =0
 
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 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)
 

Protected Attributes

Color _color0
 
Color _color1
 
Color _color2
 
int _subdivisions
 
- Protected Attributes inherited from LibBoard::Polyline
Path _path
 
std::vector< Path_holes
 
- Protected Attributes inherited from LibBoard::ShapeWithStyle
Style _style
 

Additional Inherited Members

- Static Public Member Functions inherited from LibBoard::ShapeWithStyle
static void setLineWidthScaling (bool)
 
- Protected Member Functions inherited from LibBoard::ShapeWithStyle
void updateLineWidth (double s)
 

Detailed Description

A triangle with shaded filling according to colors given for each vertex.

The GouraudTriangle structure.

Constructor & Destructor Documentation

◆ GouraudTriangle() [1/2]

LibBoard::GouraudTriangle::GouraudTriangle ( const Point p0,
const Color color0,
const Point p1,
const Color color1,
const Point p2,
const Color color2,
int  subdivisions 
)

◆ GouraudTriangle() [2/2]

LibBoard::GouraudTriangle::GouraudTriangle ( const Point p0,
float  brightness0,
const Point p1,
float  brightness1,
const Point p2,
float  brightness2,
const Color fillColor,
int  subdivisions 
)

Member Function Documentation

◆ clone()

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

Return a copy of the shape.

Returns
A copy of the shape.

Implements LibBoard::ShapeWithStyle.

◆ flushFIG()

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

Sends the Triangle to a FIG file format stream.

Warning! Because shading would generally require more colors in the colormap than allowed by the FIG file format, rendering a Gouraud triangle in an XFig file is the same as rendering a simple triangle whose filling color is the average of the vertex colors.

Parameters
stream
transform
colormap

Implements LibBoard::Shape.

References _color0, _color1, _color2, LibBoard::Polyline::_path, LibBoard::Color::blue(), LibBoard::Polyline::flushFIG(), LibBoard::Color::green(), LibBoard::Color::Null, and LibBoard::Color::red().

◆ flushPostscript()

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

◆ flushSVG()

void LibBoard::GouraudTriangle::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.

References _color0, _color1, _color2, LibBoard::Polyline::_path, _subdivisions, LibBoard::Color::blue(), LibBoard::Polyline::flushSVG(), flushSVG(), LibBoard::Color::green(), LibBoard::Color::red(), LibBoard::Point::x, and LibBoard::Point::y.

Referenced by flushSVG().

◆ flushTikZ()

void LibBoard::GouraudTriangle::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::GouraudTriangle::name ( ) const
overridevirtual

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

Returns

Reimplemented from LibBoard::Shape.

◆ resized()

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

Returns a resized copy of the triangle.

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

References LibBoard::Shape::resize().

◆ rotate() [1/2]

GouraudTriangle & LibBoard::GouraudTriangle::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 rotate().

◆ rotate() [2/2]

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

Rotate the shape around a given center of rotation.

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

Implements LibBoard::Shape.

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

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

◆ rotated() [1/2]

GouraudTriangle LibBoard::GouraudTriangle::rotated ( double  angle) const

◆ rotated() [2/2]

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

◆ scaleAll()

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

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

Parameters
sThe scaling factor.

Implements LibBoard::Shape.

References LibBoard::Polyline::_path, and LibBoard::Path::scaleAll().

◆ scaled() [1/2]

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

Returns a scaled copy of the triangle.

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

References LibBoard::Polyline::scale().

◆ scaled() [2/2]

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

Returns a scaled copy of the triangle.

Parameters
sxScaling factor along the x axis.
syscaling factor along the y axis.
Returns
A scaled copy of the arrow.

References LibBoard::Polyline::scale().

◆ translated()

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

Returns a translated copy of the triangle.

Parameters
dxThe shift along the x axis.
dyThe shift along the y axis.
Returns
A translated copy of the triangle.

References LibBoard::Polyline::translate().

Member Data Documentation

◆ _color0

Color LibBoard::GouraudTriangle::_color0
protected

◆ _color1

Color LibBoard::GouraudTriangle::_color1
protected

◆ _color2

Color LibBoard::GouraudTriangle::_color2
protected

◆ _subdivisions

int LibBoard::GouraudTriangle::_subdivisions
protected

Referenced by flushPostscript(), and flushSVG().


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