Wheel IDE

Online demo »

Screen, pixels

Pixels example

This example shows how draw black and white pixels.

Code

#project "Screen pixel example"

#include "lib/modules/standard.whl"
#include "lib/modules/device.whl"
#include "lib/modules/screen.whl"

#display "EV3"

proc main()
    ; Select the EV3 device in the simulator...
    selectDevice(DEVICE_EV3)

    ; Fill half the screen black...
    setFill(TRUE)
    setFillColor(BLACK)
    drawRect(0, 0, 89, 128)

    number s
    number x, y = 0

    setFillColor(WHITE)

    s = 1
    while y < 128
        ; Draw a line with white pixels...
        setFillColor(WHITE)
        for x = 0 to 89 step 2
            drawPixel(x, y)
        end
        ; Draw a line with black pixels...
        setFillColor(BLACK)
        for x = 90 to 178 step 2
            drawPixel(x, y)
        end
        y += s
        s += 1
    end

    updateScreen()

    ; Wait...
    halt()
end

Screenshot

See also: Modules