This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
CrazedProgrammer's profile picture

Surface 2 - A powerful graphics library

Started by CrazedProgrammer, 14 February 2017 - 10:29 PM
CrazedProgrammer #1
Posted 14 February 2017 - 11:29 PM
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:


If you have any questions or suggestions, leave a reply.
All feedback is appreciated :D/>
Edited on 15 February 2017 - 09:19 PM
Joseph Stalin #2
Posted 14 February 2017 - 11:37 PM
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?
CrazedProgrammer #3
Posted 14 February 2017 - 11:45 PM
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.