Additional graphics functions. Functions related to display transformations require the Mindustry Logic 8 instruction set.
Definition: const DISPLAY_SIZE_SMALL = 80;
Length of the side of the drawing area of the logic-display block.
Definition: const DISPLAY_SIZE_LARGE = 176;
Length of the side of the drawing area of the large-logic-display block.
Definition: void unpackcolor(out r, out g, out b, out a, in packedColor)
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 9 | 9 |
| Function body | 10 | 10 |
| Function call | 8 | 8 |
Unpacks numeric value created by the packcolor instruction (or a corresponding color literal) into
individual color channel components. The function produces real numbers between 0 and 1 (inclusive) for
all four color channels.
Note: When compiling for Mindustry 8, the built-in unpackcolor function is used instead of this one.
Inputs and outputs:
r: variable to receive the value corresponding to the red channelg: variable to receive the value corresponding to the green channelb: variable to receive the value corresponding to the blue channela: variable to receive the value corresponding to the alpha channelpackedColor: color value to unpack
Definition: def setAlpha(color, alpha)
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 4 | 4 |
| Function body | 5 | 5 |
| Function call | 5 | 5 |
Allows redefining the alpha channel of an existing color.
When compiled for target 7, this function is significantly more efficient than unpacking the color into individual color channels and repackaging them back. When compiled for target 8, the unpack/pack route is more efficient.
Inputs and outputs:
color: the color to modify, in packed color formatalpha: new value of the alpha channel, 0 to 255- return the packed color representation of the altered color.
Definition: def packHsv(hue, saturation, value, alpha)
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 22 | 22 |
| Function body | 23 | 23 |
| Function call | 7 | 7 |
Creates a packed color using the HSV color model. The individual components (hue, saturation, value, alpha) must be real numbers between 0 and 1.
Inputs and outputs:
hue: desired hue of the colorsaturation: desired saturation of the colorvalue: desired value of the coloralpha: desired alpha channel of the color- returns the desired color in the packed color representation
Definition: inline void drawflush()
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 1 | 1 |
Clears the processor's graphics buffer without outputting the contents into any display. Equivalent to
drawflush(null);.
Definition: def displaySize(display)
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 3 | 3 |
| Function body | 4 | 4 |
| Function call | 4 | 4 |
Returns the actual display size based on the type of display passed in as an argument. When the passed-in argument is not a display, the processor is stopped.
Definition: inline void rotateLeftSmall()
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 2 | 2 |
Rotates the output to the left (counterclockwise) by 90 degrees for a small display.
Definition: inline void rotateRightSmall()
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 2 | 2 |
Rotates the output to the right (clockwise) by 90 degrees for a small display.
Definition: inline void upsideDownSmall()
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 2 | 2 |
Rotates the output by 180 degrees (upside down) by 90 degrees for a small display.
Definition: inline void flipVerticalSmall()
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 2 | 2 |
Flips the output vertically (along the Y axis) for a small display.
Definition: inline void flipHorizontalSmall()
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 2 | 2 |
Flips the output horizontally (along the X axis) for a small display.
Definition: inline void rotateLeftLarge()
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 2 | 2 |
Rotates the output to the left (counterclockwise) by 90 degrees for a large display.
Definition: inline void rotateRightLarge()
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 2 | 2 |
Rotates the output to the right (clockwise) by 90 degrees for a large display.
Definition: inline void upsideDownLarge()
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 2 | 2 |
Rotates the output by 180 degrees (upside down) by 90 degrees for a large display.
Definition: inline void flipVerticalLarge()
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 2 | 2 |
Flips the output vertically (along the Y axis) for a large display.
Definition: inline void flipHorizontalLarge()
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 2 | 2 |
Flips the output horizontally (along the X axis) for a large display.
Definition: void rotateLeft(display)
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 10 | 10 |
| Function body | 11 | 11 |
| Function call | 4 | 4 |
Rotates the output to the left (counterclockwise) by 90 degrees for the given display.
Definition: void rotateRight(display)
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 10 | 10 |
| Function body | 11 | 11 |
| Function call | 4 | 4 |
Rotates the output to the right (clockwise) by 90 degrees for the given display.
Definition: void upsideDown(display)
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 10 | 10 |
| Function body | 11 | 11 |
| Function call | 4 | 4 |
Rotates the output by 180 degrees (upside down) by 90 degrees for the given display.
Definition: void flipVertical(display)
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 10 | 10 |
| Function body | 11 | 11 |
| Function call | 4 | 4 |
Flips the output vertically (along the Y axis) for the given display.
Definition: void flipHorizontal(display)
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 10 | 10 |
| Function body | 11 | 11 |
| Function call | 4 | 4 |
Flips the output horizontally (along the X axis) for the given display.
Definition: inline void scaleSmallToLarge()
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 1 | 1 |
Scales the graphics output so that an output that targets a small display gets displayed over the entire area of a large display.
Definition: inline void scaleLargeToSmall()
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 1 | 1 |
Scales the graphics output so that an output that targets a large display gets displayed over the entire area of a small display.
Definition: inline void scaleDisplay(x, y)
| Compiled code size when... | optimized for speed | optimized for size |
|---|---|---|
| Inlined function | 3 | 3 |
Applies scaling to the graphic output, trying to minimize rounding error caused by Mindustry Logic storing the scale parameters with a precision of 10 bits and a scale of 0.05.
Both x and y are increased by 1 / 40 (0.025), to compensate for the processor truncating the
value of either parameter after dividing it by 1 / 20 (0.05).
« Previous: Compatibility | Up: System library | Next: Math »