Pixelflow Canvas (VS Code Extension)

A virtual CRT for old school graphics programming in Visual Studio Code.

This is the documentation for the »Pixelflow Canvas« Visual Studio Code extension. Use the pixelflow_canvas rubygem to interact with the canvas from Ruby.

Getting started

  1. Install the extension
  2. Launch the CRT with Ctrl+Shift+P (or F1) and Show Pixelflow Canvas
  3. Talk to the canvas via TCP – use the protocol or use the provided Ruby library

By default, the canvas listens on http://127.0.0.1:19223. The default resolution is 320x180 pixels, full RGB color (24-bit).

TCP Commands

To send a command, send raw bytes over the wire. The first byte is the command, followed by the arguments.

Name Bytes Description
set_size 01 ww ww hh hh Resizes the canvas to the given width and height
set_color_mode 02 mm Chooses between full color RGB (0) and palette mode (1)
set_palette 03 ii rr gg bb Sets the RGB values for a given color
set_advance 04 aa Chooses whether the cursor should advance right (0) or down (1)
move_to 05 xx xx yy yy
05 xx yy yy
05 xx xx yy
05 xx yy
Sets the cursor to a specific position (encoding of x and y depends on resolution)
set_pixel 06 cc
06 rr gg bb
Sets the pixel at the current position to a specific color (encoding of color depends on color mode)
set_buffer 07 cc cc ... cc
07 rr gg bb rr gg bb ... rr gg bb
Blits an entire buffer to the screen (encoding of colors depends on color mode)
set_interpolation_mode 08 mm Chooses between nearest neighbor (0) and bilinear interpolation (1)
fetch_events 09 Fetches all events from the event queue