GTextureUtils mixin

Collection of utility methods for creating and manipulating GTexture instances.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

resolution double
The resolution used for GTexture creation in this class.
getter/setter pair

Static Methods

createCircle({Color color = kColorMagenta, double radius = 20, double x = 0, double y = 0, String? id}) GTexture
Creates a circular GTexture with the given parameters.
createRect({Color color = kColorMagenta, double x = 0, double y = 0, double w = 20, double h = 20, String? id}) GTexture
Creates a rectangle GTexture with the given parameters.
createRoundRect({Color color = kColorMagenta, double x = 0, double y = 0, double w = 20, double h = 20, double r = 8, String? id}) GTexture
Creates a rounded rectangle GTexture with the given parameters. The color parameter defines the fill color of the rectangle. The x and y parameters define the position of the top-left corner of the rectangle. The w and h parameters define the width and height of the rectangle, respectively. The r parameter defines the radius of the rectangle's corners. The optional id parameter can be used to cache the resulting texture under a specific ID in the texture cache.
createTriangle({Color color = kColorMagenta, double w = 20, double h = 20, double rotation = 0, String? id}) GTexture
Creates a triangle GTexture with the given parameters.
getNearestValidTextureSize(int size) int
Returns the nearest valid texture size for a given size. This is done by comparing the previous and next valid texture sizes, and returning the one that is closest to the input size.
getNextValidTextureSize(int size) int
Returns the next valid power of 2 texture size for a given size. For example, if the given size is 100, this function returns 128, which is the next power of 2 after 100. The returned size is always a power of 2.
getPreviousValidTextureSize(int size) int
Returns the largest valid texture size smaller than size, which is a power of 2. If size is already a power of 2, the result is the next power of 2 that is smaller than size.
getRectAtlasFromGTexture(GTexture base, int w, {int? h, int padding = 0, double scale = 1}) List<GTexture>
A utility method to create a list of rectangular GTextures from a given base texture, by dividing it into smaller rectangles of size w x h.
isValidTextureSize(int size) bool
Checks if a texture size is valid (i.e., a power of 2). Returns true if the size is valid, false otherwise.
scale9Rect(GTexture tx, double x, {double? y, double? w, double? h, bool adjustScale = false}) → void
Sets the scale-9-grid of a given GTexture based on x, y, w, and h parameters. If adjustScale is true, the values will be multiplied by the texture's scale factor.