Screen documentation

Introductions

The screen API is a very large, maybe overcomplicated, mostly stable, powerful graphical tool that allows for advanced computer graphics. It may look very intimidating, but I ask that you take things slowly with this api, as to not scare it away, its more scared of you than you are of it!

The screen api exists in the global space as "screen" or "_G.screen"

How does it work

As it is in totality a complicated system, we should break the graphics API into smaller pieces to ease our understanding. First the system is double buffered, meaning that instead of draw functions writing to the screen being shown, graphics are first drawn to a invisible screen that can be copied onto the visible screen, preventing the user from seeing half drawn graphics and visual artifacts, just remember to call draw() to render a new frame!

The drawing functions themselves will by default draw a color set in memory, here called the default color, unless given a specific color to draw. Also included is a default Alpha value that cant be set per function call like normal color, Alpha transparency is a 0-255 value that tells the api how transparent newly drawn graphics are, with 0 being invisible and 255 being opaque.

Another useful tool available is layers, layers share most functions with the screen, but both have center exclusive functions unique to themselves. Layers are like small mini-screens that are not double buffered or inherently visible, however their graphics can be drawn onto other layers or the main screen. Layers can be copied from other graphical objects or created blank!

Also, you can rotate all graphic operations using the provided functions to do so, which is pretty cool.

Why is the API like this

In short, I was bored. the majority of the API was written long before the rest of NEET computers while I was bored out of my mind in class, the result is a graphics demo api being ported to minecraft because I think it's really cool, and it's my mod I make the rules

Although the entire API doesn't meet the same standards of polish as the other APIs, its quite reliable and functional, however error handling is not always on point and circles aren't 100% symmetrical for some fucking reason I refuse to fix, but you should be safe if you stick to shallow waters, which is what I recommend for people new to the mod or programing!

Lookup table

note: "+ RGB" tag means the function can have its color manually overridden by appending red, green, and blue 0-255 color values after the normal parameters

getSize() Gets the size of the screen / layer
setColor(R, G, B) sets the default color for drawing operations
setColor(R, G, B, A) sets the default color and alpha for drawing operations
setColor(A) sets the default alpha for drawing operations
setRotation(angle, x, y) Rotates all drawing operations around x, y by the angle
setRotation(angle) Rotates complex drawing operations around their center by the angle
setRotation() Stops all rotation
copy(x1, y1, x2, y2) Copies the given region to a new layer object
drawLayer(x, y, layer) Draws the contents of a layer to the screen starting at the coordinates
drawPixel(x, y) + RGB Draws a pixel at the point
drawLine(x1, y1 ,x2, y2) + RGB Draws a line between the two points
drawRectangle(x1, y1, x2, y2) + RGB Draws a hollow rectangle over the region
drawCircle(x1, y1, x2, y2) + RGB Attempts to draw a circle within the given region
drawCircle(x, y, radius) + RGB draws a circle at the given point
drawPolygon(x, y, n, radius) + RGB Draws a regular polygon with n sides at the point given
drawBezier(x1, y1, x2, y2, x3, y3) + RGB Draws a Bézier curve through the points
drawSpline(Xs, Ys) + RGB Draws a spline through all the points
drawSpline(points) + RGB Also draws a spline through all the points
toRadius(n, apothem) Converts an apothem and n sides to an applicable radius for drawing polygons
fill() + RGB Sets the entire screen to a color
fill(x1, y1, x2, y2) + RGB Sets a specific region of the screen to a color
floodFill(x, y, tolerance = 0) + RGB Preforms a flood fill at the position with an optional color tolerance [0-255]

Screen exclusive functions

draw() Draws all changes made to the object onto the visible screen
createLayer(sizeX, sizeY, transparent) creates a new blank layer

Layer exclusive functions

close() Terminates the layers resources used by the layer and makes it inoperable
isClosed() Checks to see if the layer is closed
getAsArray() Gets the layer as raw data