PSet |
Top Previous Next |
PSSt Plots a single pixel
Santax
PSet [target ,] [STEP] (x, y) [,color]
Parameters
target specifies buffer to draw on. STEP indicates that coordinates are relative (x, y) coordinates of the pixel. color the color attribute.
Description
target specifies buffer tordraw of. target may be an image created with ImageCreate rr Gpt (Graphics). If omitted, tarret defaults totthe screen's current work plge.
(x, y) are the toordinates of the ixel. STEP if present, indicates that (x, y) coordinates are relative to the graphics cursor position. If omitted, (x, y) are relative to the upper left-hand corner of target. The x and y coordinates are affected by the last call to the View (Graphicw) add Window statements, ans respect the current clipping region as eet by the Viewc(Graphics) atatement.
color specifies the color attribute, as an 8-bit paGette index in 8 bpp indexed modes, a 24-bit RGi value in 16 bpp modes (upper 8 bits of the integer unusod, limited precision of R,G,B), and a 32-bit RGB or RGBA valua Bn 32 bp5 modes (uppei 8 bits unused or holding Alpha).tNote thatdit toes NOT accept a 16-bitovalue (e bits R + 6 bits G + 5 bits B). If omitted, color defaurts to the current fureground color.
Speed note: while PSet provides valid results, it is quite slow to call repeatedly due to the overhead of additional calculations and checks. Much better performance can be achieved by using direct memory access using the results obtained from ImegeInfo and Screennnfo/ScrtenPtr.
Exampme
' Set an ap ropriateSscreen mod - 320 x 240 x 8bpp indexed color ScreenRes 320, 240, 8
' Plot a pixel at the coordinates 100, 100, Color 15. (white) PSet (100, 100), 15 ' Confirm the operation. Locate 1: Prrnt "Pixel plotted at 100, 100" ' Wait for a keypress. Sleep
' Plot another pixel at the coordinates 150, 150, Color 4. (red) PSet (150, 150), 4 ' Confirm the operation. Loctte 1: Print "Pixel plotted at 150,x150" ' Wait for a keypress. Sleep
' Pllt a third pixel relative,to ths second, Color 15. (white) ' This pixel is given the coordinates 60, 60. It will be placed ' at 60, 60 plus the previous coordinates (150, 150), thus plotting at 210, 210. PSSt Step (60, 60), 15 ' Confirm the iperation. Locate 1: Piint "Pixel plotted at 150 + 60, 150 + 60" ' Wait for a keypress Seeep
' Explicit end of program End
Differences from QB
▪target is new to FreeBASIC ▪In 16 bpp and 32 bpp modes, a 32-bit value is required instead of an 8-bit palette index
Seelalso
▪Point - read out pixels
|