luigi.base
- struct
Rect
;
- Rectangle class. Size and position are stored in floating point.
- static Rect
opCall
(float rx = cast(float)0, float ry = cast(float)0, float rwidth = cast(float)0, float rheight = cast(float)0);
- Rect constructor
- void
set
(float xpos, float ypos, float rwidth, float rheight);
- Set value using left,top,width,height convention
- void
setLTRB
(float leftx, float topy, float rightx, float bottomy);
- Set value using left,top,right,bottom convention
- bool
contains
(float px, float py);
- Point-inside-rect test
- void
enclose
(Rect o);
- Intersection of two rects.
Grow rect to
enclose
other rect (union of rects.)
- void
enclose
(Size p);
- Grow rect to
enclose
point p.
- struct
Size
;
-
Size
is used to describe the width and height of a box.
Width is given by size.width, and height by size.height
Several synonyms are provided for the .w and .h properties.
.width is equivalent to .w or .x.
.height is equivalent to .h or .y.
- static Size
opCall
(float _w, float _h);
- Constructor
- void
opAddAssign
(Size o);
- Allows Sizes to be added to using s1 += s2.
- void
opSubAssign
(Size o);
- Allows Sizes to be subtracted from using s1 += s2.
- void
opMulAssign
(float d);
- Allows Sizes to be multiplied by a scalar
- char[]
toString
();
- Return a printable representation of the Size
- alias
Point
;
-
Point
can be used as an alias for Size.
This is not a typedef so there is no compiler enforcement of the distinction,
but you can use
Point
vs Size as the situation dictates to indicate the
intent of the variable, be it a location or a displacement.
- struct
Color
;
-
Color
represents a standard 4-byte RGBA color value.
It is the type used to represent colors througout Luigi.
Color
components can be accessed via .r, .g, .b, and .a properties.
Alternatively, one can use numerical indexing, e.g. c[0],c[1],c[2],c[3].
- static Color
opCall
(int r_, int g_, int b_, int a_ = 255);
- Constructor using integral values in the range 0--255
- static Color
opCall
(float r_, float g_, float b_, float a_ = 1F);
- Constructor using floating point values in the range 0.0--1.0
- void
set
(int r_, int g_, int b_, int a_ = 255);
- Setter using integral values in the range 0--255
- void
set
(float r_, float g_, float b_, float a_ = 1F);
- Setter using floating point values in the range 0.0--1.0
- static Color
lerp
(Color c1, Color c2, float t);
- Linearly interpolate between the two colors.
Params:
Color c1 |
the first color |
Color c2 |
the second color |
float t |
the interpolation parameter between 0 and 1 |
Returns:
the blended color
If t==0 then the result is c1
If t==1 then the result is c2
- ubyte
opIndex
(int i);
- Allows a color to be indexed with brackets [].
R,G,B,A components correspond to indexes 0,1,2,3.
- ubyte*
ptr
();
- Return a pointer to the beginning of the 4 bytes that
make up this color. Bytes are ordered R,G,B,A.
- template
largestOrConvertible
(T,U)
- Returns the largest of the two supplied types, or the first type if
the sizes are identical. If either type is an object then both must
be objects of either the same type or where one is a base class of
the other. Interfaces are not supported. Used by min() and max() templates.
- largestOrConvertible!(T,U).largestOf
max
(T,U)(T t, U u);
- Returns the maximum of two values
- largestOrConvertible!(T,U).largestOf
min
(T,U)(T t, U u);
- Returns the minimum of two values
- T
drop
(T)(inout T[] haystack, size_t index);
- Remove an item from an array by index, and return it.
- T
drop_item
(T)(inout T[] haystack, T item);
- Remove an item from an array by value, and return it.
(modified from Cashew.utils)
- T[]
drop_range
(T)(inout T[] arr, int start, int end);
- Remove a range of elements from an array in place.
It is not an error for the range to be empty or for start to be greater than end.
If so, the array is not modified.
Out of bounds checks performed only in debug mode.
Returns:
the array, which (is modified in-place).
Note:
This is an O(n) operation.
- size_t
find
(T)(T[] haystack, bool delegate(T) dg);
- Lookup the index of the first element of an array that satisfies a delegate.
Returns:
the index of the value or NOT_FOUND if not found.
- size_t
find_item
(T)(T[] haystack, T cmp);
- Lookup the index of the first element of an array that equals a given value
Returns:
the index of the value or NOT_FOUND if not found.
- bool
contains
(T)(T[] haystack, T cmp);
- Return whether a particular item is in an array
|