Drawing
flaui.lib.system.drawing
This module provides a wrapper class for System.Drawing namespace objects. It also defines an Enum class KnownColor that specifies the known system colors. Wrapper class for System.Drawing namespace objects
Color
Represents an ARGB (alpha, red, green, blue) color from System.Drawing.Color object
from_argb(argb=None, alpha=None, base_color=None, red=None, green=None, blue=None)
staticmethod
Creates a ColorData object from various input formats matching C# System.Drawing.Color
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
argb
|
Optional[int]
|
A value specifying the 32-bit ARGB value, defaults to None |
None
|
alpha
|
Optional[int]
|
The alpha component. Valid values are 0 through 255, defaults to None |
None
|
base_color
|
Optional[ColorData]
|
The System.Drawing.Color from which to create the new System.Drawing.Color, defaults to None |
None
|
red
|
Optional[int]
|
The red component. Valid values are 0 through 255, defaults to None |
None
|
green
|
Optional[int]
|
The green component. Valid values are 0 through 255, defaults to None |
None
|
blue
|
Optional[int]
|
The blue component. Valid values are 0 through 255, defaults to None |
None
|
Returns:
| Type | Description |
|---|---|
ColorData
|
The ColorData object representing the color. |
Raises:
| Type | Description |
|---|---|
ValueError
|
On invalid input combination |
Source code in flaui/lib/system/drawing.py
from_known_color(known_color)
staticmethod
Creates a System.Drawing.Color structure from the specified predefined color.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
known_color
|
KnownColor
|
An element of the System.Drawing.KnownColor enumeration. |
required |
Returns:
| Type | Description |
|---|---|
ColorData
|
The System.Drawing.Color that this method creates. |
Source code in flaui/lib/system/drawing.py
from_name(name)
staticmethod
Creates a System.Drawing.Color structure from the specified name of a predefined color.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
A string that is the name of a predefined color. Valid names are the same as the names of the elements of the System.Drawing.KnownColor enumeration. |
required |
Returns:
| Type | Description |
|---|---|
ColorData
|
The System.Drawing.Color that this method creates. |
Source code in flaui/lib/system/drawing.py
ColorData
Bases: BaseSettings
Represents an ARGB (alpha, red, green, blue) System.Drawing.Color color object.
a
property
Gets the alpha component value of this System.Drawing.Color structure.
Returns:
| Type | Description |
|---|---|
bytes
|
The alpha component value of this System.Drawing.Color. |
b
property
Gets the blue component value of this System.Drawing.Color structure.
Returns:
| Type | Description |
|---|---|
bytes
|
The blue component value of this System.Drawing.Color. |
g
property
Gets the green component value of this System.Drawing.Color structure.
Returns:
| Type | Description |
|---|---|
bytes
|
The green component value of this System.Drawing.Color. |
is_empty
property
Specifies whether this System.Drawing.Color structure is uninitialized.
Returns:
| Type | Description |
|---|---|
bool
|
This property returns True if this color is uninitialized; otherwise, False. |
is_known_color
property
Gets a value indicating whether this System.Drawing.Color structure is a predefined color. Predefined colors are represented by the elements of the System.Drawing.KnownColor enumeration.
Returns:
| Type | Description |
|---|---|
bool
|
True if this System.Drawing.Color was created from a predefined color by using either the System.Drawing.Color.FromName(System.String) method or the System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor) method; otherwise, False. |
is_named_color
property
Gets a value indicating whether this System.Drawing.Color structure is a named color or a member of the System.Drawing.KnownColor enumeration.
Returns:
| Type | Description |
|---|---|
bool
|
True if this System.Drawing.Color was created by using either the System.Drawing.Color.FromName(System.String) method or the System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor) method; otherwise, False. |
is_system_color
property
Gets a value indicating whether this System.Drawing.Color structure is a system color. A system color is a color that is used in a Windows display element. System colors are represented by elements of the System.Drawing.KnownColor enumeration.
Returns:
| Type | Description |
|---|---|
str
|
True if this System.Drawing.Color was created from a system color by using either the System.Drawing.Color.FromName(System.String) method or the System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor) method; otherwise, False. |
name
property
Gets the name of this System.Drawing.Color.
Returns:
| Type | Description |
|---|---|
str
|
The name of this System.Drawing.Color. |
r
property
Gets the red component value of this System.Drawing.Color structure.
Returns:
| Type | Description |
|---|---|
bytes
|
The red component value of this System.Drawing.Color. |
equals(another_color)
Indicates whether the current object is equal to another object of the same type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
another_color
|
ColorData
|
An object to compare with this object. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the current object is equal to other; otherwise, False. |
Source code in flaui/lib/system/drawing.py
get_brightness()
Gets the hue-saturation-lightness (HSL) lightness value for this System.Drawing.Color structure.
Returns:
| Type | Description |
|---|---|
float
|
The lightness of this System.Drawing.Color. The lightness ranges from 0.0 through 1.0, where 0.0 represents black and 1.0 represents white. |
Source code in flaui/lib/system/drawing.py
get_hash_code()
Returns a hash code for this System.Drawing.Color structure.
Returns:
| Type | Description |
|---|---|
int
|
An integer value that specifies the hash code for this System.Drawing.Color. |
get_hue()
Gets the hue-saturation-lightness (HSL) hue value, in degrees, for this System.Drawing.Color structure.
Returns:
| Type | Description |
|---|---|
float
|
The hue, in degrees, of this System.Drawing.Color. The hue is measured in degrees, ranging from 0.0 through 360.0, in HSL color space. |
Source code in flaui/lib/system/drawing.py
get_saturation()
Gets the hue-saturation-lightness (HSL) saturation value for this System.Drawing.Color structure.
Returns:
| Type | Description |
|---|---|
float
|
The saturation of this System.Drawing.Color. The saturation ranges from 0.0 through 1.0, where 0.0 is grayscale and 1.0 is the most saturated. |
Source code in flaui/lib/system/drawing.py
to_argb()
Gets the 32-bit ARGB value of this System.Drawing.Color structure.
Returns:
| Type | Description |
|---|---|
int
|
The 32-bit ARGB value of this System.Drawing.Color. |
to_known_color()
Gets the System.Drawing.KnownColor value of this System.Drawing.Color structure.
Returns:
| Type | Description |
|---|---|
KnownColor
|
An element of the System.Drawing.KnownColor enumeration, if the System.Drawing.Color is created from a predefined color by using either the System.Drawing.Color.FromName(System.String) method or the System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor) method; otherwise, 0. |
Source code in flaui/lib/system/drawing.py
to_string()
Converts this System.Drawing.Color structure to a human-readable string.
Returns:
| Type | Description |
|---|---|
int
|
A string that is the name of this System.Drawing.Color, if the System.Drawing.Color is created from a predefined color by using either the System.Drawing.Color.FromName(System.String) method or the System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor) method; otherwise, a string that consists of the ARGB component names and their values. |
Source code in flaui/lib/system/drawing.py
KnownColor
Bases: Enum
Specifies the known system colors
Point
Bases: BaseModel
Represents a Point object, works with underlying C# System.Drawing.Point object.
Note that this doesn't handle PointF object and the methods are currently listed only for Point object.
is_empty
property
Indicates if the Point object is empty
Returns:
| Type | Description |
|---|---|
bool
|
Flag True if empty else False |
x
property
writable
Gets x-cordinate of this Point
Returns:
| Type | Description |
|---|---|
int
|
x-cordinate of the Point |
y
property
writable
Gets y-cordinate of this Point
Returns:
| Type | Description |
|---|---|
int
|
y-cordinate of the Point |
__add__(other)
Translates a point by a given Size
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Size
|
Size object to add |
required |
Returns:
| Type | Description |
|---|---|
Point
|
A new Point object with the translated coordinates |
Source code in flaui/lib/system/drawing.py
__eq__(other)
Compares two Point objects for equality
Accepts any object (matches BaseModel signature) and returns False when the other object is not a Point.
Source code in flaui/lib/system/drawing.py
__ne__(other)
Compares two Point objects for inequality
Accepts any object (matches BaseModel signature).
__sub__(other)
Translates the Point by the negative of the specified Size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Size
|
Size object to subtract |
required |
Returns:
| Type | Description |
|---|---|
Point
|
A new Point object with the translated coordinates |
Source code in flaui/lib/system/drawing.py
add(point, size)
Adds the specified Size tot he specified Point
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Point
|
The point to add |
required |
size
|
Size
|
The size to add |
required |
Returns:
| Type | Description |
|---|---|
Point
|
The point that is the result of the addition operation |
Source code in flaui/lib/system/drawing.py
distance(other_x=None, other_y=None, other_point=None)
Calculates the distance between two points or the distance between a point and an x/y coordinate pair.
This is similar to Distance method listed in FlaUI.Core.Tools.ExtensionMethods.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other_x
|
Optional[int]
|
The x-coordinate of the second point., defaults to None |
None
|
other_y
|
Optional[int]
|
The y-coordinate of the second point., defaults to None |
None
|
other_point
|
Optional[Point]
|
The second point, defaults to None |
None
|
Returns:
| Type | Description |
|---|---|
float
|
Distance calculated |
Source code in flaui/lib/system/drawing.py
equals(other)
Specifies whether this point instance contains the same coordinates as another point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Point
|
Value to compare |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if equal, else False |
Source code in flaui/lib/system/drawing.py
get_hash_code()
Returns a hash code for this Point.
Returns:
| Type | Description |
|---|---|
int
|
An integer value that specifies the hash code for this Point. |
offset(x=None, y=None, point=None)
Translates this Point by the specified amount/specified Point
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Optional[int]
|
x-coordinate, defaults to None |
None
|
y
|
Optional[int]
|
y-coordinate, defaults to None |
None
|
point
|
Optional[Point]
|
Point object, defaults to None |
None
|
Source code in flaui/lib/system/drawing.py
parse_cs_object(v)
classmethod
Parses C# Point object from System.Drawing namespace
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
Union[int, Tuple[int, int], Tuple[float, float], Point, Size]
|
Input value |
required |
Returns:
| Type | Description |
|---|---|
Point
|
Parsed C# object |
Source code in flaui/lib/system/drawing.py
subtract(point, size)
Returns the result of subtracting specified Size from the specified Point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Point
|
Point object |
required |
size
|
Size
|
Size object |
required |
Returns:
| Type | Description |
|---|---|
Point
|
Subtracted Point object |
Source code in flaui/lib/system/drawing.py
to_size()
Explicitly converts the specified Point structure to Size structure
Returns:
| Type | Description |
|---|---|
Size
|
Size object |
to_string()
Converts this Point to a human-readable string.
Returns:
| Type | Description |
|---|---|
str
|
Point as readable string. |
Rectangle
Bases: BaseModel
Represents a Rectangle object, works with underlying C# System.Drawing.Rectangle object.
Note that this doesn't handle RectangleF object and the methods are currently listed only for Rectangle object.
bottom
property
Gets the y-coordinate that is the sum of the Y and Height property values of this Rectangle structure.
Returns:
| Type | Description |
|---|---|
int
|
Parsed value |
height
property
writable
Gets vertical component of this Size
Returns:
| Type | Description |
|---|---|
int
|
Vertical component of the Size |
is_empty
property
Indicates if the Point object is empty
Returns:
| Type | Description |
|---|---|
bool
|
Flag True if empty else False |
left
property
Gets the x-coordinate of the left edge of this Rectangle structure.
Returns:
| Type | Description |
|---|---|
int
|
X-coordinate |
location
property
Gets or sets the coordinates of the upper-left corner of this Rectangle structure.
Returns:
| Type | Description |
|---|---|
Point
|
Point object |
right
property
Gets the x-coordinate that is the sum of X and Width property values of this Rectangle structure.
Returns:
| Type | Description |
|---|---|
int
|
X-coordinate |
size
property
writable
top
property
Gets the y-coordinate of the top edge of this Rectangle structure.
Returns:
| Type | Description |
|---|---|
int
|
Y-coordinate |
width
property
writable
Gets the width of this Rectangle structure.
Returns:
| Type | Description |
|---|---|
int
|
Width value |
x
property
writable
Gets the x of this Rectangle structure.
Returns:
| Type | Description |
|---|---|
int
|
X value |
y
property
writable
Gets the y of this Rectangle structure.
Returns:
| Type | Description |
|---|---|
int
|
Y value |
__eq__(other)
Tests whether two Rectangle structures have equal location and size.
Accepts any object (matches BaseModel signature) and returns False when the other object is not a Rectangle.
Source code in flaui/lib/system/drawing.py
__ne__(other)
Compares two Rectangle objects for inequality
Accepts any object (matches BaseModel signature).
center()
contains(other)
Determines if the specified point is contained within this Rectangle structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Union[Tuple[int, int], Point]
|
Value to compare |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if it contains, else False |
Source code in flaui/lib/system/drawing.py
east(by=0)
Returns East of the rectangle as a Point object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by
|
int
|
Move by, defaults to 0 |
0
|
Returns:
| Type | Description |
|---|---|
Point
|
Point object |
equals(other)
Specifies whether this Rectangle instance contains the same coordinates as another point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Rectangle
|
Value to compare |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if equal, else False |
Source code in flaui/lib/system/drawing.py
from_ltrb(value)
Creates a Rectangle structure with the specified edge locations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
List[int]
|
Value to set |
required |
Returns:
| Type | Description |
|---|---|
Rectangle
|
Rectangle object |
Source code in flaui/lib/system/drawing.py
get_hash_code()
Returns a hash code for this Rectangle.
Returns:
| Type | Description |
|---|---|
int
|
An integer value that specifies the hash code for this Rectangle. |
immediate_exterior_east()
immediate_exterior_north()
immediate_exterior_south()
immediate_exterior_west()
immediate_interior_east()
immediate_interior_north()
immediate_interior_south()
immediate_interior_west()
inflate(value)
Enlarges this Rectangle by the specified amount.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Tuple[int, int]
|
Value to enlarge |
required |
Returns:
| Type | Description |
|---|---|
Rectangle
|
Enlarged Rectangle |
Source code in flaui/lib/system/drawing.py
intersects_with(other)
Determines if this rectangle intersects with rect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Rectangle
|
Value to check |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if there is any intersection, otherwise False |
Source code in flaui/lib/system/drawing.py
interset(other)
Replaces this Rectangle with the intersection of itself and the specified Rectangle. Returns a third Rectangle structure that represents the intersection of two other Rectangle structures. If there is no intersection, an empty Rectangle is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Union[Rectangle, Tuple[Rectangle, Rectangle]]
|
Value to intersect with |
required |
Returns:
| Type | Description |
|---|---|
Rectangle
|
Updated rectangle |
Source code in flaui/lib/system/drawing.py
make_even()
Makes the width and height of a rectangle a multiple of 2, if not already.
This is a direct coversion of Even method listed in FlaUI.Core.Tools.ExtensionMethods class.
Returns:
| Type | Description |
|---|---|
Rectangle
|
A new Rectangle object with even dimensions (optional), or None if the input rectangle is None. |
Source code in flaui/lib/system/drawing.py
north(by=0)
Returns North of the rectangle as a Point object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by
|
int
|
Move by, defaults to 0 |
0
|
Returns:
| Type | Description |
|---|---|
Point
|
Point object |
offset(x=None, y=None, point=None)
Adjusts the location of this rectangle by the specified amount.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Optional[int]
|
x-coordinate, defaults to None |
None
|
y
|
Optional[int]
|
y-coordinate, defaults to None |
None
|
point
|
Optional[Point]
|
Point object, defaults to None |
None
|
Source code in flaui/lib/system/drawing.py
parse_cs_object(v)
classmethod
Parses C# Rectangle object from System.Drawing namespace
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
Union[List[int], Tuple[Point, Size], Rectangle]
|
Input value |
required |
Returns:
| Type | Description |
|---|---|
Point
|
Parsed C# object |
Source code in flaui/lib/system/drawing.py
south(by=0)
Returns South of the rectangle as a Point object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by
|
int
|
Move by, defaults to 0 |
0
|
Returns:
| Type | Description |
|---|---|
Point
|
Point object |
to_string()
Converts the attributes of this Rectangle to a human-readable string.
Returns:
| Type | Description |
|---|---|
str
|
Point as readable string. |
union(others)
Gets a Rectangle structure that contains the union of two Rectangle structures.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
others
|
Tuple[Rectangle, Rectangle]
|
Tuple of rectangles to compare |
required |
Returns:
| Type | Description |
|---|---|
Rectangle
|
A Rectangle structure that bounds the union of the two Rectangle structures. |
Source code in flaui/lib/system/drawing.py
west(by=0)
Returns West of the rectangle as a Point object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by
|
int
|
Move by, defaults to 0 |
0
|
Returns:
| Type | Description |
|---|---|
Point
|
Point object |
Size
Bases: BaseModel
Represents a Size object, works with underlying C# System.Drawing.Size object. Stores an ordered pair of integers, which specify a Height and Width.
Note, this does not utilize SizeF object, just works with Size object.
height
property
writable
Gets vertical component of this Size
Returns:
| Type | Description |
|---|---|
int
|
Vertical component of the Size |
is_empty
property
Indicates if the Size object is empty
Returns:
| Type | Description |
|---|---|
bool
|
Flag True if empty else False |
width
property
writable
Gets horizontal component of this Size
Returns:
| Type | Description |
|---|---|
int
|
horizontal component of the Size |
__add__(other)
Translates a size by a given Size
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Size
|
Size object to add |
required |
Returns:
| Type | Description |
|---|---|
Size
|
A new Size object with the translated coordinates |
Source code in flaui/lib/system/drawing.py
__eq__(other)
Compares two Size objects for equality
Accepts any object (matches BaseModel signature) and returns False when the other object is not a Size.
Source code in flaui/lib/system/drawing.py
__ne__(other)
Compares two Size objects for inequality
Accepts any object (matches BaseModel signature).
__sub__(other)
Translates the Size by the negative of the specified Size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Size
|
Size object to subtract |
required |
Returns:
| Type | Description |
|---|---|
Size
|
A new Size object with the translated coordinates |
Source code in flaui/lib/system/drawing.py
add(other)
equals(other)
Specifies whether this size instance contains the same coordinates as another size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Size
|
Value to compare |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if equal, else False |
Source code in flaui/lib/system/drawing.py
get_hash_code()
Returns a hash code for this Size.
Returns:
| Type | Description |
|---|---|
int
|
An integer value that specifies the hash code for this Size. |
parse_cs_object(v)
classmethod
Parses C# Size object from System.Drawing namespace
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
Union[Tuple[int, int], Tuple[float, float], Point, Size]
|
Input value |
required |
Returns:
| Type | Description |
|---|---|
Size
|
Parsed C# object |
Source code in flaui/lib/system/drawing.py
subtract(other)
to_point()
Explicitly converts Size structure to Point structure
Returns:
| Type | Description |
|---|---|
Point
|
Parsed Point object |
to_string()
Converts this Size to a human-readable string.
Returns:
| Type | Description |
|---|---|
str
|
Size as readable string. |