This is the component provided by Items#basic-graphics-card. For simple programs the API/Term will usually all you need. For more complex operations, or to get a bit more performance, you may wish to interact with the GPU directly, though.
As of OC 1.3 screens of tier 2 and 3 have a 16 color palette. For tier two this palette contains all colors the screen can possibly display, and is initialized to the standard Minecraft colors. As a side-effect you can specify the colors using gpu.setBackground(colors.red, true)
, for example. Keep in mind this only works on tier two screens. For tier three, the palette is initialized to grayscale values and the remaining 240 colors are stored as truncated RGB values as was the case in older versions of OpenComputers.
Component name: gpu
.
Callbacks:
bind(address: string): boolean[, string]
true
on success, false
and an error message on failure.getBackground(): number, boolean
0xRRGGBB
, or a palette index. The second returned value indicates which of the two it is (true
for palette color, false
for RGB value).setBackground(color: number[, isPaletteIndex: boolean]): number[, index]
nil
.
Note that the color is expected to be specified in hexadecimal RGB format, i.e. 0xRRGGBB
. This is to allow uniform color operations regardless of the color depth supported by the screen and GPU.getForeground(): number, boolean
getBackground
, but for the foreground color.setForeground(color: number): number[, index]
setBackground
, but for the foreground color.getPaletteColor(index: number): number
setPaletteColor(index: number, value: number): number
maxDepth(): number
getDepth(): number
setDepth(bit: number): boolean
true
if the depth was set, false
otherwise.maxResolution(): number, number
getResolution(): number, number
setResolution(width: number, height: number): boolean
true
if the resolution was set, false
otherwise.getSize(): number, number
get(x: number, y: number): string
set(x: number, y: number, value: string): boolean
true
if the string was set to the buffer, false
otherwise.copy(x: number, y: number, width: number, height: number, tx: number, ty: number): boolean
x
, y
, width
and height
parameters. The target rectangle is defined by x + tx
, y + ty
, width
and height
. Returns true
on success, false
otherwise.fill(x: number, y: number, width: number, height: number, char: string): boolean
x
and y
coordinates and the rectangle's width
and height
. The fill character char
must be a string of length one, i.e. a single character. Returns true
on success, false
otherwise.
) is usually less expensive, i.e. consumes less energy, because it is considered a “clear” operation (see config).Example use:
local component = require("component") local gpu = component.gpu -- get primary gpu component local w, h = gpu.getResolution() gpu.fill(1, 1, w, h, " ") -- clears the screen gpu.setForeground(0x000000) gpu.setBackground(0xFFFFFF) gpu.fill(1, 1, w/2, h/2, "X") -- fill top left quarter of screen gpu.copy(1, 1, w/2, h/2, w/2, h/2) -- copy top left quarter of screen to lower right
Components | 3D Printer - Abstract Bus - Access Point - Chunkloader - Computer - Crafting - Data Card - Database - Debug - Drone - Drive - EEPROM - Experience - Filesystem - Generator - Geolyzer - GPU - Hologram - Internet - Inventory Controller - Leash - Microcontroller - Modem - Motion Sensor - Navigation - Net Splitter - Piston - Redstone - Redstone in Motion - Robot - Screen - Sign - Tank Controller - Tractor Beam - Transposer - Tunnel - World Sensor | |
---|---|---|
Others | Component Access - Signals | |
Cross-Mod Integration | Applied Energistics |