Jump to content




[CC 1.76+] BLittle API


31 replies to this topic

#1 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 6,449 posts
  • LocationTasmania (AU)

Posted 13 December 2015 - 02:37 PM

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.


#2 oli414

  • Members
  • 29 posts
  • LocationThe Netherlands

Posted 13 December 2015 - 03:21 PM

That's amazing!

Great way of making the new characters more useful.

#3 Creator

    Mad Dash Victor

  • Members
  • 2,164 posts
  • LocationYou will never find me, muhahahahahaha

Posted 13 December 2015 - 03:39 PM

I have to say, great job!

#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 6,449 posts
  • LocationTasmania (AU)

Posted 13 December 2015 - 10:31 PM

Thanks guys. :)

#5 EldidiStroyrr

  • Members
  • 928 posts
  • LocationPot Land

Posted 13 December 2015 - 11:58 PM

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.


#6 Wojbie

  • Members
  • 606 posts
  • LocationKinda lost

Posted 14 December 2015 - 03:32 PM

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.


#7 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 6,449 posts
  • LocationTasmania (AU)

Posted 15 December 2015 - 12:07 PM

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!

#8 dan200

  • Administrators
  • 541 posts
  • LocationCambridge, England

Posted 24 December 2015 - 09:27 PM

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

#9 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 6,449 posts
  • LocationTasmania (AU)

Posted 24 December 2015 - 10:19 PM

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

#10 LoganDark

  • Members
  • 231 posts
  • LocationMacintosh HD/Users/LoganDark

Posted 25 December 2015 - 12:58 PM

View PostBomb 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...

#11 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 6,449 posts
  • LocationTasmania (AU)

Posted 31 January 2016 - 02:36 PM

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.


#12 CrazedProgrammer

  • Members
  • 477 posts
  • LocationWageningen, The Netherlands

Posted 15 March 2016 - 11:48 AM

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

#13 Creator

    Mad Dash Victor

  • Members
  • 2,164 posts
  • LocationYou will never find me, muhahahahahaha

Posted 15 March 2016 - 03:18 PM

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

#14 CrazedProgrammer

  • Members
  • 477 posts
  • LocationWageningen, The Netherlands

Posted 15 March 2016 - 04:52 PM

View PostCreator, 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.


#15 Lupus590

  • Members
  • 1,613 posts
  • LocationUK

Posted 15 March 2016 - 05:31 PM

View PostCrazedProgrammer, on 15 March 2016 - 04:52 PM, said:

View PostCreator, 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)

#16 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 6,449 posts
  • LocationTasmania (AU)

Posted 16 March 2016 - 12:03 AM

View PostLupus590, 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.

#17 ReBraLaCC

  • Members
  • 99 posts
  • LocationSublime Text 2

Posted 17 March 2016 - 04:17 PM

Does this only work on monitors?

Edited by ReBraLaCC, 17 March 2016 - 04:20 PM.


#18 CrazedProgrammer

  • Members
  • 477 posts
  • LocationWageningen, The Netherlands

Posted 17 March 2016 - 04:36 PM

View PostReBraLaCC, on 17 March 2016 - 04:17 PM, said:

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

#19 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 6,449 posts
  • LocationTasmania (AU)

Posted 18 March 2016 - 12:27 AM

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.

#20 Redall

  • Members
  • 118 posts
  • LocationFrance

Posted 23 March 2016 - 05:42 PM

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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users