Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::view::IntRect Struct Reference

Axis-aligned rectangle in DISCRETE (integer) coordinates. More...

#include <geometry.hpp>

Public Member Functions

constexpr int right () const
constexpr int bottom () const
constexpr int center_x () const
 Integer center.
constexpr int center_y () const
constexpr bool is_empty () const
constexpr bool contains (int px, int py) const
constexpr bool contains (const IntRect &r) const
IntRect reduced (int d) const
IntRect reduced (int dx, int dy) const
IntRect expanded (int d) const
IntRect expanded (int dx, int dy) const
constexpr IntRect translated (int dx, int dy) const
constexpr IntRect with_x (int v) const
constexpr IntRect with_y (int v) const
constexpr IntRect with_width (int v) const
constexpr IntRect with_height (int v) const
constexpr IntRect with_size (int w, int h) const
constexpr IntRect with_position (int nx, int ny) const
constexpr IntRect with_size_keeping_center (int w, int h) const
 Resize about the center, in integer arithmetic.
IntRect remove_from_top (int amount)
IntRect remove_from_bottom (int amount)
IntRect remove_from_left (int amount)
IntRect remove_from_right (int amount)
constexpr bool intersects (const IntRect &o) const
IntRect intersection (const IntRect &o) const
IntRect union_with (const IntRect &o) const
constexpr Rect to_float () const
 Widening conversion — always exact.
constexpr bool operator== (const IntRect &r) const
constexpr bool operator!= (const IntRect &r) const

Public Attributes

int x = 0
int y = 0
int width = 0
int height = 0

Detailed Description

Axis-aligned rectangle in DISCRETE (integer) coordinates.

Every operation here uses integer arithmetic — most importantly, the center is an integer division and therefore truncates. See the note on Rect.

Member Function Documentation

◆ bottom()

int pulp::view::IntRect::bottom ( ) const
inlineconstexpr

◆ center_x()

int pulp::view::IntRect::center_x ( ) const
inlineconstexpr

Integer center.

IntRect{0,0,7,7}.center_x() == 3, NOT 3.5 — the half pixel is truncated away, and that is the whole point of this type.

◆ center_y()

int pulp::view::IntRect::center_y ( ) const
inlineconstexpr

◆ contains() [1/2]

bool pulp::view::IntRect::contains ( const IntRect & r) const
inlineconstexpr

◆ contains() [2/2]

bool pulp::view::IntRect::contains ( int px,
int py ) const
inlineconstexpr

◆ expanded() [1/2]

IntRect pulp::view::IntRect::expanded ( int d) const
inline

◆ expanded() [2/2]

IntRect pulp::view::IntRect::expanded ( int dx,
int dy ) const
inline

◆ intersection()

IntRect pulp::view::IntRect::intersection ( const IntRect & o) const
inline

◆ intersects()

bool pulp::view::IntRect::intersects ( const IntRect & o) const
inlineconstexpr

◆ is_empty()

bool pulp::view::IntRect::is_empty ( ) const
inlineconstexpr

◆ operator!=()

bool pulp::view::IntRect::operator!= ( const IntRect & r) const
inlineconstexpr

◆ operator==()

bool pulp::view::IntRect::operator== ( const IntRect & r) const
inlineconstexpr

◆ reduced() [1/2]

IntRect pulp::view::IntRect::reduced ( int d) const
inline

◆ reduced() [2/2]

IntRect pulp::view::IntRect::reduced ( int dx,
int dy ) const
inline

◆ remove_from_bottom()

IntRect pulp::view::IntRect::remove_from_bottom ( int amount)
inline

◆ remove_from_left()

IntRect pulp::view::IntRect::remove_from_left ( int amount)
inline

◆ remove_from_right()

IntRect pulp::view::IntRect::remove_from_right ( int amount)
inline

◆ remove_from_top()

IntRect pulp::view::IntRect::remove_from_top ( int amount)
inline

◆ right()

int pulp::view::IntRect::right ( ) const
inlineconstexpr

◆ to_float()

Rect pulp::view::IntRect::to_float ( ) const
inlineconstexpr

Widening conversion — always exact.

◆ translated()

IntRect pulp::view::IntRect::translated ( int dx,
int dy ) const
inlineconstexpr

◆ union_with()

IntRect pulp::view::IntRect::union_with ( const IntRect & o) const
inline

◆ with_height()

IntRect pulp::view::IntRect::with_height ( int v) const
inlineconstexpr

◆ with_position()

IntRect pulp::view::IntRect::with_position ( int nx,
int ny ) const
inlineconstexpr

◆ with_size()

IntRect pulp::view::IntRect::with_size ( int w,
int h ) const
inlineconstexpr

◆ with_size_keeping_center()

IntRect pulp::view::IntRect::with_size_keeping_center ( int w,
int h ) const
inlineconstexpr

Resize about the center, in integer arithmetic.

(width - w) / 2 truncates: IntRect{0,0,7,7}.with_size_keeping_center(4,4) is at x=1 (because 3/2 == 1), where the float rect would be at x=1.5.

◆ with_width()

IntRect pulp::view::IntRect::with_width ( int v) const
inlineconstexpr

◆ with_x()

IntRect pulp::view::IntRect::with_x ( int v) const
inlineconstexpr

◆ with_y()

IntRect pulp::view::IntRect::with_y ( int v) const
inlineconstexpr

Member Data Documentation

◆ height

int pulp::view::IntRect::height = 0

◆ width

int pulp::view::IntRect::width = 0

◆ x

int pulp::view::IntRect::x = 0

◆ y

int pulp::view::IntRect::y = 0

The documentation for this struct was generated from the following file:
  • /home/runner/work/pulp/pulp/core/view/include/pulp/view/geometry.hpp