FixImage Documentation

Back to summary

import "image/rect";

Rect class

Rectangle with integer coordinates.

A short variant of the constructors is available: Rect(...)

Members

var x1: Integer;
var y1: Integer;
var x2: Integer;
var y2: Integer;
These represent the left-top (x1,y1) and bottom-right (x2,y2) coordinates of the rectangle. The bottom-right coordinates are exclusive (not part of the rectangle).

Initialization

static function create(): Rect
Creates an empty rectangle.
static function create(x: Integer, y: Integer, width: Integer, height: Integer): Rect
Creates a rectangle with given coordinates and size.

Properties

function get_width(): Integer
Returns the width of the rectangle.
function get_height(): Integer
Returns the height of the rectangle.
function is_valid(): Boolean
Returns whether this rectangle has positive area.

Operations

function set(r: Rect): Rect
function set(x: Integer, y: Integer, width: Integer, height: Integer): Rect
Sets the rectangle and returns itself.
function clear(): Rect
Clears the rectangle, making it empty. Returns itself.
function intersect(r: Rect): Rect
function intersect(x: Integer, y: Integer, width: Integer, height: Integer): Rect
Intersects the rectangle with other rectangle and returns itself.
function union(r: Rect): Rect
function union(x: Integer, y: Integer, width: Integer, height: Integer): Rect
Unions the rectangle with other rectangle and returns itself.
function translate(x: Integer, y: Integer): Rect
Translates the rectangle and returns itself.
function scale(scale: Float): Rect
function scale(sx: Float, sy: Float): Rect
Scales the rectangle (rounding the values afterwards) and returns itself.
function contains(x: Integer, y: Integer): Boolean
Returns whether the given point is inside the rectangle.
function contains(rect: Rect): Boolean
Returns whether the given rectangle is inside the rectangle.
function intersects(rect: Rect): Boolean
Returns whether the given rectangle intersects the rectangle.
function normalize(): Rect
Normalizes the rectangle so the negative area becomes positive. Returns itself.
function to_string(): String
Returns string representation of the rectangle.