Posted 28 October 2017 - 06:22 PM
Paintutils sucks, but now it doesn't! Not with my brand new functions to spice up the Paintutils API!
Flip images, stretch images, merge images, you name it!!
Here's a demo. Demonstrates stretching, the blit-based drawImage, and using merge to remove all flickering.
You can use this by copying it into the beginning of your code. os.loadAPI isn't recommended.
Here are the functions:
One possible way to reduce flickering would be to merge every image into a buffer, then draw the buffer. I'll try to change all my billboards to use this!
Flip images, stretch images, merge images, you name it!!
pastebin get 7XAmsAbX pue
Here's a demo. Demonstrates stretching, the blit-based drawImage, and using merge to remove all flickering.
pastebin get weLUU423 puedemo
You can use this by copying it into the beginning of your code. os.loadAPI isn't recommended.
Here are the functions:
Spoiler
paintutils.drawImageBlit(image, x, y)
Replicates the functions of drawImage, but sacrifices transparency for speed.
paintutils.drawImageBlitCenter(image,x,y,object)
Same as drawImageBlit, but draws centered around X and Y. If no X or Y, then half of the screen width and height respectively are used. Either terminal size, or object size optionally.
paintutils.drawImageCenter(image,x,y,object)
Same as drawImageBlitCenter, but using the normal paintutils.drawImage function.
paintutils.merge({
image1,
x,
y
}, {
image2,
x,
y
}, ...)
Merges an arbitrary amount of images formatted like {image,x,y} into the same image. The first argument will be layered upon the second, second onto the third, and so forth.
flippedImage = paintutils.flipX(image)
and
flippedImage =paintutils.flipY(image)
Returns image, but flipped horizontally or vertically respectively. I don't know why this function wasn't default.
fullscreenRectangle = paintutils.fullscreen(color,object)
Returns an image of a rectangle of a flat color, and the size of the terminal screen. You can also use 'object' to make it output a rectangle the size of something like a monitor or a window.
newImage =paintutils.grayOut(image)
Returns the image in as best grayscale as I could get in computercraft.
newImage = paintutils.lighten(image)
Returns the image with colors lightened up. Useful for transitions.
newImage = paintutils.darken(image)
Returns the image with colors darkened up. Useful for transitions.
x, y = paintutils.getSize(image)
Returns the X and Y sizes of an image.
newImage = paintutils.stretchImage(image, xsize, ysize)
Stretches the image to xsize,ysize. Supports negative sizing and flipping.
stringImage = paintutils.unloadImage(image)
Converts a tabular NFP image format back to a string format that can be used with paintutils.loadImage() again, if saved to a file.
newImage = paintutils.autocrop(image)
Cuts out all blank space above and to the left of an image. Save some trees.
paintutils.centerWithBlankSpace(image,x,y,object)
Returns the same image, but with blank space added to make the image centered.One possible way to reduce flickering would be to merge every image into a buffer, then draw the buffer. I'll try to change all my billboards to use this!
Edited on 13 December 2017 - 02:05 AM