PSET
Source: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgPset Last revised: 2023-07-09
Plots a single pixel.
Syntax
PSet [target ,] [STEP] (x, y) [, color]Parameters
- target — Optional; specifies buffer to draw on (from
ImageCreateorGet (Graphics)). Defaults to screen's current work page. - STEP — Indicates that coordinates are relative to the current graphics cursor position.
- (x, y) — Coordinates of the pixel.
- color — Color attribute. If omitted, defaults to current foreground color.
- 8 bpp: 8-bit palette index
- 16 bpp: 24-bit RGB value (upper 8 bits unused, limited precision)
- 32 bpp: 32-bit RGB or RGBA value (upper 8 bits unused or Alpha)
Description
Plots a single pixel at the coordinates (x, y).
The x and y coordinates are affected by the last call to View (Graphics) and Window, and respect the current clipping region.
Speed note: PSet is relatively slow for repeated calls due to overhead. For performance-critical code, use direct memory access via ImageInfo and ScreenInfo/ScreenPtr.
Examples
vb
' Set 320×240×8bpp indexed color mode
ScreenRes 320, 240, 8
' Plot a white pixel at (100, 100)
PSet (100, 100), 15
Locate 1: Print "Pixel plotted at 100, 100"
Sleep
' Plot a red pixel at (150, 150)
PSet (150, 150), 4
Locate 1: Print "Pixel plotted at 150, 150"
Sleep
' Plot relative to previous: (150+60, 150+60) = (210, 210)
PSet Step (60, 60), 15
Locate 1: Print "Pixel plotted at 150 + 60, 150 + 60"
Sleep
EndDifferences from QB
targetis new to FreeBASIC.- In 16 bpp and 32 bpp modes, a 32-bit value is required instead of an 8-bit palette index.