Shape2D Class Reference

#include <Shape2D.h>

Description

An aspect that can express basic 2D objects, such as images and shapes.

Functions

void OnDraw ()
 
std::string GetInfo ()
 
- Functions inherited from Render2D
std::vector< Renderer::Vertex2D > GetVertices () const
 
Renderer::Polygon GetPolygon () const
 
- Functions inherited from Component
std::string GetTag ()
 
EntityGetHost () const
 
template<typename T >
T * GetHostAs () const
 
Entity::ID GetHostID () const
 
bool EmitEvent (const std::string &eventName, Entity::ID source=Entity::ID(), const std::vector< std::string > &args={})
 
bool CanHandleEvent (const std::string &eventName)
 
void InstallHook (const std::string &eventName, EventHandler, void *data=nullptr)
 
void UninstallHook (const std::string &eventName, EventHandler)
 
void InstallHandler (const std::string &eventName, EventHandler, void *data=nullptr)
 
void UninstallHandler (const std::string &eventName, EventHandler)
 
std::vector< std::string > GetKnownEvents () const
 

Formation

Forming aspects denotes what visual the aspect should assume.

Color color
 
void FormRectangle (float width, float height)
 
void FormImage (AssetID image, float forcedWidth=-1.f, float forcedHeight=-1.f)
 
void FormImageFrame (AssetID image, int frame, float forcedWidth=-1.f, float forcedHeight=-1.f)
 
void FormCircle (float radius, int numIterations)
 
void FormTriangles (std::vector< Dynacoe::Vector > &pts)
 
void FormLines (const std::vector< Dynacoe::Vector > &pts)
 

Additional Inherited Members

- Public Types inherited from Render2D
enum  RenderMode {
  Normal,
  Translucent,
  None
}
 
- Public Types inherited from Component
using EventHandler = bool(*)(void *, Component *component, Entity::ID self, Entity::ID source, const std::vector< std::string > &args)
 
- Properties inherited from Render2D
RenderMode mode
 
bool absolute
 
- Protected Member Functions inherited from Component
virtual void OnStep ()
 
virtual void OnAttach ()
 
void InstallEvent (const std::string &eventName, EventHandler mainHandler=nullptr, void *data=nullptr)
 
void UninstallEvent (const std::string &)
 

Member Function Documentation

void FormRectangle ( float  width,
float  height 
)

Forms the aspect into a rectangle.

The top-left corner of the rectangle is the position of the Aspect from GetPosition(). Width and height are expressed in pixels.

Parameters
widthThe width of the rectangle in pixels.
heightThe height of the rectangle in pixels.
void FormImage ( AssetID  image,
float  forcedWidth = -1.f,
float  forcedHeight = -1.f 
)

Forms the aspect into the shape and visual of an image.

The scale is a ratio of the source image dimensions. If the Image has multiple frames, the image is drawn as an animation.

Parameters
imageThe image to display as the aspect. If image does not refer to a valid Image, no action is taken. If the Image has multiple frames, the subsequent frame is drawn upon next Graphics::Draw of the aspect.
void FormImageFrame ( AssetID  image,
int  frame,
float  forcedWidth = -1.f,
float  forcedHeight = -1.f 
)

Forms the aspect into a frame of an image.

Behaves like FormImage, but a specific frame index is specified to draw rather than the image as an animation.

Parameters
imageThe image to form as the aspect. If image does not refer to a valid Image, no action is taken
frameThe frame of the image to use, starting at 0. If the frame is negative, the aspect is drawn as if FormImage() had been called.
void FormCircle ( float  radius,
int  numIterations 
)

Forms the aspect into an estimated circle made of triangles.

Parameters
radiusThe radius of the circle. Measured in pixels.
numIterationsNumber of sides that the circle should have. The more iterations, the smoother the circle will become, but the more resource-intensive the Aspect becomes as well.
void FormTriangles ( std::vector< Dynacoe::Vector > &  pts)

Forms the aspect into a collection of triangle primitives.

The points are interpreted as pixels and are expected to be in groups of 3. If a non-multiple-of-three number of points is given, the remainder points are ignored.

Parameters
ptsThe points of the triangles.
void FormLines ( const std::vector< Dynacoe::Vector > &  pts)

Forms a collection of line segments.

Every two points form a line segment. If an odd number of points are given, the last point is ignored.

Parameters
ptsThe points of the lines.
void OnDraw ( )
virtual

Function that is called upon each Draw iteration. Component Draw()s are run before the entity's draw function.

Reimplemented from Component.

std::string GetInfo ( )
virtual

Returns a string containing human-readable information on the state of the component.

Reimplemented from Component.


The documentation for this class was generated from the following file:
  • /home/jc/git/Dynacoe/DynacoeSrc/includes/Dynacoe/Components/Shape2D.h