←  APIs and Utilities

ComputerCraft | Programmable Computers for Minecraft

»

[CC 1.76+] BLittle API

Bomb Bloke's Photo Bomb Bloke 13 Dec 2015

pastebin get ujchRSnU blittle

So ComputerCraft 1.76 (the first build for MineCraft 1.8) offers an expanded fontset, including characters that happen to be fairly convenient for drawing pixel art with. oli's function here provides a great illustration as to how they can be used to plot most any 2x3 pattern of pixels within any given character space.

This here is an API to help automate the process; pass in a paintutils image, and it passes out a little version that can be blitted, reduced using the "smaller pixels" available within the new font. It also offers functions to save/load/draw these images.

You can alternatively generate a "window" that can be treated as a regular term object, which'll automatically shrink anything you "draw" into it.

There's a bit of a catch in that there's the potential for some loss of colour information during the conversion process. It fudges things as best it can, but the less complex your image is, the better the results should be (pure black and white should always be perfect, for example). You'll also have better results if the original image dimensions have a width divisible by two and a height divisible by 3.

For quick reference, a regular ComputerCraft terminal display can effectively display images of up to 102x57 pixels using the new fontset (up from 51x19), whereas external monitors (when built up to full size and with a text scale set to 0.5) can go up to 328x243 (from 164x81).

API Usage

Furthermore, here's a simple example script which imports images using my GIF API, and then draws them on an attached monitor:

Example Code

And here are some screenshots of what a few loaded images might look like:

Screenshots

Version History

Edited by Bomb Bloke, 15 May 2016 - 11:44 AM.
Quote

oli414's Photo oli414 13 Dec 2015

That's amazing!

Great way of making the new characters more useful.
Quote

Creator's Photo Creator 13 Dec 2015

I have to say, great job!
Quote

Bomb Bloke's Photo Bomb Bloke 13 Dec 2015

Thanks guys. :)
Quote

LDDestroier's Photo LDDestroier 13 Dec 2015

Oh great, now someone has to make Mario using this...

...great job, Bomb Bloke! YOU DID WELL!
Edited by LDDestroier, 13 December 2015 - 11:58 PM.
Quote

Wojbie's Photo Wojbie 14 Dec 2015

Just dropping it to say my thanks. :D
With this, your gif api and package i was able to easily convert termFont.png into new characters.
As i thank you i leave you with sneak peak of api i am working using said file. I call it BigPrint.
Spoiler

Edited by Wojbie, 14 December 2015 - 03:34 PM.
Quote

Bomb Bloke's Photo Bomb Bloke 15 Dec 2015

I'm not generally one for memes, but I'll admit it'll be a while before TF2 voice clips get old...

Good to hear you found it useful, Wojbie. :) Bet I'll be seeing that font set get a bit of use - it's quite neatly sized!
Quote

dan200's Photo dan200 24 Dec 2015

I used this API in the 1.76 release post :)
http://www.computerc...utercraft-1-76/
Quote

Bomb Bloke's Photo Bomb Bloke 24 Dec 2015

Creepers with Santa hats... Heh, hope none fall down my chimney!
Quote

LoganDark's Photo LoganDark 25 Dec 2015

 Bomb Bloke, on 24 December 2015 - 10:19 PM, said:

Creepers with Santa hats... Heh, hope none fall down my chimney!

*hears creeper burning in fireplace*

Soon that will be a problem...
Quote

Bomb Bloke's Photo Bomb Bloke 31 Jan 2016

A belated update.

Two new functions; createWindow() and shrinkGIF(). Names should pretty much speak for themselves.

createWindow() basically acts like window.create() does - for those who aren't familiar, you get a terminal object you can redirect to. After that you can draw in miniature using paintutils or whatever takes your fancy. Note that as with regular windows, you'll get better performance if you render into them while they're invisible (only here the effect is more pronounced).

Here's an example of it being applied to Gopher's 3D engine:

Spoiler

Edited by Bomb Bloke, 10 February 2016 - 11:16 PM.
Quote

CrazedProgrammer's Photo CrazedProgrammer 15 Mar 2016

That's amazing!
You did a great job for simplifying the use of these smaller pixels so everyone can enjoy them.
I see that the potential for this is huge.
My next program will feature these smaller pixels (in realtime 20FPS I hope) :P
Quote

Creator's Photo Creator 15 Mar 2016

Why 20 fps? What do these have to do with pixel sizes?
Quote

CrazedProgrammer's Photo CrazedProgrammer 15 Mar 2016

 Creator, on 15 March 2016 - 03:18 PM, said:

Why 20 fps? What do these have to do with pixel sizes?
I will have to optimize the algorithm enough to hit a constant 20FPS (the max ComputerCraft can output due to the way timer events are rounded off by 0.05 seconds).
Edited by CrazedProgrammer, 15 March 2016 - 04:52 PM.
Quote

Lupus590's Photo Lupus590 15 Mar 2016

 CrazedProgrammer, on 15 March 2016 - 04:52 PM, said:

 Creator, on 15 March 2016 - 03:18 PM, said:

Why 20 fps? What do these have to do with pixel sizes?
I will have to optimize the algorithm enough to hit a constant 20FPS (the max ComputerCraft can output due to the way timer events are rounded off by 0.05 seconds).
Which is due to MineCraft's tick rate being 20 (Ticks Per Second)
Quote

Bomb Bloke's Photo Bomb Bloke 16 Mar 2016

 Lupus590, on 15 March 2016 - 05:31 PM, said:

Which is due to MineCraft's tick rate being 20 (Ticks Per Second)

Well, sorta. CC could time things much finer than that, and certainly monitors can already output data much faster than that. But that is likely why Dan chose to limit the timing system in that manner.
Quote

ReBraLaCC's Photo ReBraLaCC 17 Mar 2016

Does this only work on monitors?
Edited by ReBraLaCC, 17 March 2016 - 04:20 PM.
Quote

CrazedProgrammer's Photo CrazedProgrammer 17 Mar 2016

 ReBraLaCC, on 17 March 2016 - 04:17 PM, said:

Does this only work on monitors?
No. It works on all displays.
Quote

Bomb Bloke's Photo Bomb Bloke 18 Mar 2016

Indeed, I used monitors for the screenshots purely because they can provide larger display resolutions. There's an animation of it being used on a regular display in this post.
Quote

Cross_Sans's Photo Cross_Sans 23 Mar 2016

Wow, that's just amazing, that's a usefull API ! Good work for you !
Quote