Plot x,y

Parameters

x - x coordinate of the pixel

y - y coordinate of the pixel

Description

Draws a single pixel in the current drawing colour.

The smallest drawing command there is: one dot at x,y, in the colour set by Color, on the current buffer. Sprinkle Plots for starfields, rain, sparks and other particle dots - a couple of hundred per frame is no problem.

Like the other drawing commands it respects Origin and is clipped to the Viewport, so off-screen plots are safe. If you need the exact colour value rather than the current Color, use WritePixel; if you need thousands of pixels a frame, look at WritePixelFast with LockBuffer.

See also: Color, Line, WritePixel, Oval.

Example

; Plot Example
; ------------

Graphics 640,480,0,2
SetBuffer BackBuffer()

SeedRnd MilliSecs()

; A fixed field of 200 stars
Dim sx(199),sy(199)
For i=0 To 199
    sx(i)=Rand(0,639)
    sy(i)=Rand(40,479)
Next

While Not KeyDown(1)

    Cls

    For i=0 To 199
        ; Twinkle: each star gets a random brightness this frame
        bright=Rand(60,255)
        Color bright,bright,bright

        ; Plot draws a single pixel in the current colour
        Plot sx(i),sy(i)
    Next

    Color 255,255,255
    Text 0,0,"Esc: exit"
    Text 0,20,"Plot draws each star as a single twinkling pixel"

    Flip

Wend

End

Index