Conquer Chess
Chess and Starcraft combined
Loading...
Searching...
No Matches
Functions
screen_rect.cpp File Reference
#include "screen_rect.h"
#include <cassert>
#include <cmath>
#include <iostream>
#include <sstream>
Include dependency graph for screen_rect.cpp:

Functions

screen_rect create_partial_rect_from_lhs (const screen_rect &r, const double f)
 Create a partial rectangle, from the left hand side.
 
screen_rect create_partial_rect_from_rhs (const screen_rect &r, const double f)
 Create a partial rectangle, from the right hand side.
 
screen_rect create_partial_rect_from_side (const side s, const screen_rect &r, const double f)
 Create a partial rectangle from a certain side.
 
screen_rect create_rect_inside (const screen_rect &r) noexcept
 Create a rectangle that is exactly one pixel inside the given one.
 
screen_rect get_bottom_left_corner (const screen_rect &r) noexcept
 Get the bottom-left corner (i.e. 25% of the rect)
 
screen_rect get_bottom_right_corner (const screen_rect &r) noexcept
 Get the bottom-right corner (i.e. 25% of the rect)
 
screen_rect create_centered_rect (const screen_coordinate c, const int w, const int h) noexcept
 Create a rectangle that is centered around a point, with a custom height and width.
 
screen_coordinate get_center (const screen_rect &r) noexcept
 
screen_rect get_default_screen_rect () noexcept
 Get the default screen rectangle.
 
int get_height (const screen_rect &r) noexcept
 
screen_rect get_lhs_half (const screen_rect &r) noexcept
 Get the left-hand side half (i.e. 50% of the rect)
 
screen_rect get_lower_eighth (const screen_rect &r) noexcept
 Get the lower eighth (i.e.
 
screen_rect get_lower_fourth (const screen_rect &r) noexcept
 Get the lower fourth (i.e. 25% of the rect, half of the lower half)
 
screen_rect get_lower_half (const screen_rect &r) noexcept
 Get the lower half (i.e. 50% of the rect)
 
screen_rect get_rhs_half (const screen_rect &r) noexcept
 Get the right-hand side half (i.e. 50% of the rect)
 
screen_rect get_top_left_corner (const screen_rect &r) noexcept
 Get the top-left corner (i.e. 25% of the rect)
 
screen_rect get_top_right_corner (const screen_rect &r) noexcept
 Get the top-right corner (i.e. 25% of the rect)
 
screen_rect get_upper_half (const screen_rect &r) noexcept
 Get the upper half (i.e. 50% of the rect)
 
int get_width (const screen_rect &r) noexcept
 
bool is_in (const screen_coordinate &pos, const screen_rect &r) noexcept
 Is the coordinat in the rectangle?
 
void test_screen_rect ()
 Test this class and its free functions.
 
bool operator== (const screen_rect &lhs, const screen_rect &rhs) noexcept
 
bool operator!= (const screen_rect &lhs, const screen_rect &rhs) noexcept
 
std::ostream & operator<< (std::ostream &os, const screen_rect &r) noexcept
 

Function Documentation

◆ create_centered_rect()

screen_rect create_centered_rect ( const screen_coordinate  c,
const int  w,
const int  h 
)
noexcept

Create a rectangle that is centered around a point, with a custom height and width.

Parameters
cthe location of the center
wthe width of the rectangle
hthe height of the rectangle

◆ create_partial_rect_from_lhs()

screen_rect create_partial_rect_from_lhs ( const screen_rect r,
const double  f 
)

Create a partial rectangle, from the left hand side.

Source:
+--------------------+
| |
+--------------------+
Result, for f around 0.25:
+---+.................
| | .
+---+.................

This rectangle will not overlap with create_partial_rect_from_rhs}

◆ create_partial_rect_from_rhs()

screen_rect create_partial_rect_from_rhs ( const screen_rect r,
const double  f 
)

Create a partial rectangle, from the right hand side.

Source:
+--------------------+
| |
+--------------------+
Result, for f around 0.75:
.....+---------------+
.....| |
.....+---------------+

This rectangle will not overlap with create_partial_rect_from_lhs}

◆ create_partial_rect_from_side()

screen_rect create_partial_rect_from_side ( const side  s,
const screen_rect r,
const double  f 
)

Create a partial rectangle from a certain side.

  • create_partial_rect_from_side(side::lhs, r, f) is equal to create_partial_rect_from_lhs(side::lhs, r, f).
  • create_partial_rect_from_side(side::rhs, r, f) is equal to create_partial_rect_from_rhs(side::lhs, r, f).

◆ create_rect_inside()

screen_rect create_rect_inside ( const screen_rect r)
noexcept

Create a rectangle that is exactly one pixel inside the given one.

◆ get_bottom_left_corner()

screen_rect get_bottom_left_corner ( const screen_rect r)
noexcept

Get the bottom-left corner (i.e. 25% of the rect)

◆ get_bottom_right_corner()

screen_rect get_bottom_right_corner ( const screen_rect r)
noexcept

Get the bottom-right corner (i.e. 25% of the rect)

◆ get_center()

screen_coordinate get_center ( const screen_rect r)
noexcept

◆ get_default_screen_rect()

screen_rect get_default_screen_rect ( )
noexcept

Get the default screen rectangle.

This is used mostly in testing of layouts.

◆ get_height()

int get_height ( const screen_rect r)
noexcept

◆ get_lhs_half()

screen_rect get_lhs_half ( const screen_rect r)
noexcept

Get the left-hand side half (i.e. 50% of the rect)

◆ get_lower_eighth()

screen_rect get_lower_eighth ( const screen_rect r)
noexcept

Get the lower eighth (i.e.

12.5% of the rect, half of the half of the lower half)

◆ get_lower_fourth()

screen_rect get_lower_fourth ( const screen_rect r)
noexcept

Get the lower fourth (i.e. 25% of the rect, half of the lower half)

◆ get_lower_half()

screen_rect get_lower_half ( const screen_rect r)
noexcept

Get the lower half (i.e. 50% of the rect)

◆ get_rhs_half()

screen_rect get_rhs_half ( const screen_rect r)
noexcept

Get the right-hand side half (i.e. 50% of the rect)

◆ get_top_left_corner()

screen_rect get_top_left_corner ( const screen_rect r)
noexcept

Get the top-left corner (i.e. 25% of the rect)

◆ get_top_right_corner()

screen_rect get_top_right_corner ( const screen_rect r)
noexcept

Get the top-right corner (i.e. 25% of the rect)

◆ get_upper_half()

screen_rect get_upper_half ( const screen_rect r)
noexcept

Get the upper half (i.e. 50% of the rect)

◆ get_width()

int get_width ( const screen_rect r)
noexcept

◆ is_in()

bool is_in ( const screen_coordinate pos,
const screen_rect r 
)
noexcept

Is the coordinat in the rectangle?

◆ operator!=()

bool operator!= ( const screen_rect lhs,
const screen_rect rhs 
)
noexcept

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
const screen_rect r 
)
noexcept

◆ operator==()

bool operator== ( const screen_rect lhs,
const screen_rect rhs 
)
noexcept

◆ test_screen_rect()

void test_screen_rect ( )

Test this class and its free functions.