TinyLib 0.1.1
Loading...
Searching...
No Matches
tl::Drawable Class Reference

#include <Drawable.h>

Inheritance diagram for tl::Drawable:
tl::Rectangle tl::Text

Public Member Functions

 Drawable (Vec4i bounds={0, 0, 0, 0})
 Creates a new drawable object with it's position and size.
 
 ~Drawable ()
 Nothing to clean up for now.
 
void setPosition (Vec2i)
 Set position of this drawable object.
 
void setSize (Vec2i)
 Set size of this drawable object.
 
Vec2i getPosition () const
 Get the current position of this drawable object.
 
Vec2i getSize () const
 Get the current size of this drawable object.
 
Color getColor () const
 Get the current color of this drawable object.
 
void move (Vec2i)
 Move this drawable object from current position.
 
void setColor (Color)
 Set the color of this drawable object.
 
bit intersects (Drawable &) const
 Check if this drawable is intersecting with another.
 
bit intersects (Window &) const
 Check if this drawable is inside the window.
 

Protected Attributes

s32 posX
 
s32 posY
 
s32 sizeX
 
s32 sizeY
 
u8 r = 0
 
u8 g = 0
 
u8 b = 0
 
u8 a = 0
 

Detailed Description

Definition at line 11 of file Drawable.h.

Constructor & Destructor Documentation

◆ Drawable()

tl::Drawable::Drawable ( Vec4i bounds = {0, 0, 0, 0})

Creates a new drawable object with it's position and size.

Parameters
boundsBoundaries of this drawable, (width, height, left, top).

Definition at line 9 of file Drawable.cpp.

◆ ~Drawable()

tl::Drawable::~Drawable ( )

Nothing to clean up for now.

Definition at line 17 of file Drawable.cpp.

Member Function Documentation

◆ getColor()

Color tl::Drawable::getColor ( ) const

Get the current color of this drawable object.

Returns
Current color.

Definition at line 75 of file Drawable.cpp.

◆ getPosition()

Vec2i tl::Drawable::getPosition ( ) const

Get the current position of this drawable object.

Returns
X-position, Y-position.

Definition at line 41 of file Drawable.cpp.

◆ getSize()

Vec2i tl::Drawable::getSize ( ) const

Get the current size of this drawable object.

Returns
Width, height.

Definition at line 49 of file Drawable.cpp.

◆ intersects() [1/2]

bit tl::Drawable::intersects ( Drawable & other) const

Check if this drawable is intersecting with another.

Parameters
otherThe drawable object to compare with this one.
Returns
True if both objects intersect.

Compares the boundaries of both drawable objects. Using position and size, if they overlap anywhere, then this is true for an intersection.

Definition at line 87 of file Drawable.cpp.

◆ intersects() [2/2]

bit tl::Drawable::intersects ( Window & window) const

Check if this drawable is inside the window.

Parameters
windowThe window to compare with.
Returns
True if this drawable is inside window.

If this drawable is fully outside window (not visible), then it will return false. Helpful for rendering only on-screen objects.

Definition at line 102 of file Drawable.cpp.

◆ move()

void tl::Drawable::move ( Vec2i pos)

Move this drawable object from current position.

Parameters
posHow far to move the x, y of this Drawable.

Sets position relative to current position offset by x and y parameters.

Definition at line 59 of file Drawable.cpp.

◆ setColor()

void tl::Drawable::setColor ( Color color)

Set the color of this drawable object.

Parameters
colorNew color for this object.

Definition at line 67 of file Drawable.cpp.

◆ setPosition()

void tl::Drawable::setPosition ( Vec2i pos)

Set position of this drawable object.

Parameters
posNew x, y position for this drawable.

Definition at line 25 of file Drawable.cpp.

◆ setSize()

void tl::Drawable::setSize ( Vec2i size)

Set size of this drawable object.

Parameters
sizeSet the width, height of this drawable.

Definition at line 33 of file Drawable.cpp.

Member Data Documentation

◆ a

u8 tl::Drawable::a = 0
protected

Definition at line 28 of file Drawable.h.

◆ b

u8 tl::Drawable::b = 0
protected

Definition at line 28 of file Drawable.h.

◆ g

u8 tl::Drawable::g = 0
protected

Definition at line 28 of file Drawable.h.

◆ posX

s32 tl::Drawable::posX
protected

Definition at line 27 of file Drawable.h.

◆ posY

s32 tl::Drawable::posY
protected

Definition at line 27 of file Drawable.h.

◆ r

u8 tl::Drawable::r = 0
protected

Definition at line 28 of file Drawable.h.

◆ sizeX

s32 tl::Drawable::sizeX
protected

Definition at line 27 of file Drawable.h.

◆ sizeY

s32 tl::Drawable::sizeY
protected

Definition at line 27 of file Drawable.h.


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