Jump to content




Paint Utils Extra: The Essential API extention for your Paintutils needs!


3 replies to this topic

#1 LDDestroier

  • Members
  • 1,095 posts
  • LocationACDC Town

Posted 28 October 2017 - 05: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!!

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

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 by LDDestroier, 13 December 2017 - 03:05 AM.


#2 Dave-ee Jones

  • Members
  • 456 posts
  • LocationVan Diemen's Land

Posted 30 October 2017 - 03:27 AM

Was gonna say, a buffer would be good practise here, but then saw you mention it at the bottom of the page. Would be wise to do so with the fullscreen rectangle as well.

May I ask, what is the point of the fullscreen rectangle function? Why not use drawRectangle with terminal width and height arguments? That way you could pass them to the rectangle function far easier as well - but, again, you wouldn't need to because you already know the width/height of the terminal, having created the buffer with those dimensions in the first place.

I agree with you on the flip functions. Those should probably have been added in, but I guess it's another one of those 'they can program it themselves, I don't need to' moments that Dan and the others had. Frustrating. To be fair, I probably would've thought a similar way. :P

#3 LDDestroier

  • Members
  • 1,095 posts
  • LocationACDC Town

Posted 31 October 2017 - 11:41 AM

 Dave-ee Jones, on 30 October 2017 - 03:27 AM, said:

May I ask, what is the point of the fullscreen rectangle function? Why not use drawRectangle with terminal width and height arguments? That way you could pass them to the rectangle function far easier as well - but, again, you wouldn't need to because you already know the width/height of the terminal, having created the buffer with those dimensions in the first place.

To my knowledge, the drawRectangle function draws a rectangle. My rectangle function outputs the rectangle as a serialized function, so you can merge other pictures upon it and then avoid the problem of having a black screen for like, one frame.

 Dave-ee Jones, on 30 October 2017 - 03:27 AM, said:

I agree with you on the flip functions. Those should probably have been added in, but I guess it's another one of those 'they can program it themselves, I don't need to' moments that Dan and the others had. Frustrating. To be fair, I probably would've thought a similar way. :P

Feh.

#4 LDDestroier

  • Members
  • 1,095 posts
  • LocationACDC Town

Posted 07 December 2017 - 10:05 PM

Update! A plethora quanta of new functions to play with.
  • paintutils.stretchImage(image,xsize,ysize) Stretch an image to be a specific size!
  • paintutils.merge({image1,x,y}, {image2,x,y}, ...) Merge two or more images together into one single image!
  • paintutils.grayOut(image) Turns a picture into grayscale as best I could.
  • paintutils.lighten(image) Makes every color in a picture a lighter tone. Useful for transitions.
  • paintutils.darken(image) Makes every color in a picture a darker tone. Useful for transitions.
  • paintutils.getSize(image) Returns the X and Y sizes of the image.
  • paintutils.unloadImage(image) Returns the string formatted NFP that you would actually save to a file!
  • paintutils.autocrop(image) Removes all blank space to the left and below the image! Save some trees.
  • paintutils.drawImageBlitCenter(image,x,y,object) Draws an image centered to X and Y. If not X or Y, then the terminal's (or object's, optionally,) center point.
  • paintutils.drawImageCenter(image,x,y,object) Same as above, but with the regular drawImage function.
  • paintutils.centerWithBlankSpace(image,x,y,object) Returns the same image, but with blank space added to make the image centered.
I also found out that the optimized version of paintutils.drawImage() doesn't allow transparency in the images, so:
  • Renamed the new paintutils.drawImage() with paintutils.drawImageBlit()
If you're looking for a simple graphical enhancer API, look no further than Paintutils Extra!
BUY IT NOW

Edited by LDDestroier, 15 January 2018 - 04:20 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users