libscratchcpp
A library for C++ based Scratch project players
Loading...
Searching...
No Matches
libscratchcpp::Rect Class Reference

#include <scratchcpp/rect.h>

Public Member Functions

 Rect (double left, double top, double right, double bottom)
 
 Rect ()
 
double left () const
 
void setLeft (double left)
 
double top () const
 
void setTop (double top)
 
double right () const
 
void setRight (double right)
 
double bottom () const
 
void setBottom (double bottom)
 
double width () const
 
double height () const
 
void clamp (double left, double top, double right, double bottom)
 
void snapToInt ()
 
bool intersects (const Rect &rect) const
 
bool contains (double x, double y) const
 

Static Public Member Functions

static void intersected (const Rect &a, const Rect &b, Rect &dst)
 
static void united (const Rect &a, const Rect &b, Rect &dst)
 

Detailed Description

The Rect class represents a rectangle.

Constructor & Destructor Documentation

◆ Rect() [1/2]

Rect::Rect ( double left,
double top,
double right,
double bottom )

Constructs Rect.

◆ Rect() [2/2]

Rect::Rect ( )

Member Function Documentation

◆ bottom()

double Rect::bottom ( ) const

Returns the y-coordinate of the bottom edge.

◆ clamp()

void Rect::clamp ( double left,
double top,
double right,
double bottom )

Clamps the rectangle to the given bounds.

◆ contains()

bool Rect::contains ( double x,
double y ) const

Returns true if the given point is inside or on the edge of the rectangle.

◆ height()

double Rect::height ( ) const

Returns the height of the rectangle.

◆ intersected()

void Rect::intersected ( const Rect & a,
const Rect & b,
Rect & dst )
static

Saves the intersection of the given rectangles (in Scratch space) to dst.

◆ intersects()

bool Rect::intersects ( const Rect & rect) const

Returns true if the rectangle intersects the given rectangle.

◆ left()

double Rect::left ( ) const

Returns the x-coordinate of the left edge.

◆ right()

double Rect::right ( ) const

Returns the x-coordinate of the right edge.

◆ setBottom()

void Rect::setBottom ( double bottom)

Sets the y-coordinate of the bottom edge.

◆ setLeft()

void Rect::setLeft ( double left)

Sets the x-coordinate of the left edge.

◆ setRight()

void Rect::setRight ( double right)

Sets the x-coordinate of the right edge.

◆ setTop()

void Rect::setTop ( double top)

Sets the y-coordinate of the top edge.

◆ snapToInt()

void Rect::snapToInt ( )

Push out the rectangle to integer bounds.

◆ top()

double Rect::top ( ) const

Returns the y-coordinate of the top edge.

◆ united()

void Rect::united ( const Rect & a,
const Rect & b,
Rect & dst )
static

Saves the union of the given rectangles (in Scratch space) to dst.

◆ width()

double Rect::width ( ) const

Returns the width of the rectangle.


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