←  APIs and Utilities

ComputerCraft | Programmable Computers for Minecraft

»

Surface 2 - A powerful graphics library

CrazedProgrammer's Photo CrazedProgrammer 14 Feb 2017

Surface 2 is the successor to the popular Surface API.
It's been remade completely with an emphasis on flexibility, stability and multi-framework support.
Some features include:
  • ComputerCraft, OpenComputers, Love2D, Redirection Arcade and Riko 4 support
  • RGB and multiple palette support
  • NFT, NFP, BMP and RIF image saving and loading
  • Scaling, rotation, flipping
  • Per-layer transparency
  • Stencil stacks (nested clipping regions)
  • Lots of shapes
  • Sprite maps
  • Pixel fonts and text drawing
Download
pastebin get UxweEuqf surface

You can simply load the library using
local surface = dofile("surface")


Getting started
Surface 2 has extensive documentation and examples to get you started.


An example:
-- Loads Surface 2.
local surface = dofile("surface")

-- Loads the color.bmp image.
local surf = surface.load("home/color.bmp")
-- Converts the colours from RGB to CC, with dithering.
surf:toPalette(surface.palette.cc, true)

-- Creates the screen surface.
local screen = surface.create(57, 19)
-- Draws the image surface with smaller pixels.
screen:drawSurfaceSmall(surf, 0, 0)

-- Outputs the screen surface.
screen:output()
-- Waits for a mouse click.
os.pullEvent("mouse_click")
Produces this:
Posted Image

If you have any questions or suggestions, leave a reply.
All feedback is appreciated :D
Edited by CrazedProgrammer, 15 February 2017 - 10:19 PM.
Quote

Joseph Stalin's Photo Joseph Stalin 14 Feb 2017

Wow, nice! I can't wait to use this. I have a question though, can't you make a cool music visualiser (like cli-visualizer or cava) pane for wave-amp with this?
Quote

CrazedProgrammer's Photo CrazedProgrammer 14 Feb 2017

 Joseph Stalin, on 14 February 2017 - 11:37 PM, said:

Wow, nice! I can't wait to use this. I have a question though, can't you make a cool music visualiser (like cli-visualizer or cava) pane for wave-amp with this?
Thanks!
I certainly could, maybe I will do something like this in the future.
Quote