This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Baconarie's profile picture

Letter Scheme API - Printing big colored text like never before

Started by Baconarie, 09 September 2016 - 08:44 PM
Baconarie #1
Posted 09 September 2016 - 10:44 PM
Hey guys!

I always had the same issue when trying to print big colored text on a monitor: writing too many lines of code just to print a simple letter in a specific color with a specific size.. Took too much time and strangely enough i never decided to do something about it. Well today was the day that i needed to fix this horrible problem and after a few hours of thinking and experimenting i have done it. I present to you:


Letter Scheme API


What does it do?

You pass a few arguments to the provided function and it will print out a string on a monitor with the given color, starting position, etc. using the letter schemes saved in the API. You can easily change the letter schemes to whatever you like, it will work just fine.

Usage


drawText(txt, bc, tc, startx, starty, cls, monitor)

txt (String): the text you want to be printed
bc (Color): the background color, e.g. colors.black
tc (Color): the text color, e.g. colors.red
startx (Int): the starting x coordinate
starty (Int): the starting y coordinate
cls (Boolean): if you want to clear the screen before printing the text, e.g. true if you want to clear the screen
monitor (String): the side where your monitor is or if you're using wired modems the name of the monitor

Example

In the code snippet below i load the API (ofcourse you would load it, how would you else use this amazing stuff), call the drawText function and give the required parameters. Notice why i use true in the first call and not in the second. If i used true in the second call it would clear the screen and just remove the first line of text i have drawn. Pretty neat i'd say.

os.loadAPI("bill")
bill.drawText("Enjoy the", colors.black, colors.white, 13, 12, true, "left")
bill.drawText("show", colors.black, colors.red, 29, 8, false, "left")

Which results in



How to get it

Get it on pastebin


Future plans

Support for other characters?
Edited on 10 September 2016 - 08:58 AM
Cross_Sans #2
Posted 14 September 2016 - 01:17 PM
Looks really nice :)/>
KingofGamesYami #3
Posted 14 September 2016 - 11:12 PM
First I'd like to say Welcome to the Forums!

This program is awesome, but I prefer BigFont. Don't get me wrong, I'm not saying it's better but I like it more.

Plus one for the amazing first program though, it's a step above others I've seen. :)/>
Cross_Sans #4
Posted 15 September 2016 - 04:56 PM
First I'd like to say Welcome to the Forums!

This program is awesome, but I prefer BigFont. Don't get me wrong, I'm not saying it's better but I like it more.

Plus one for the amazing first program though, it's a step above others I've seen. :)/>
Yeah, i'm so sorry to forgot this.
Baconarie #5
Posted 20 September 2016 - 01:59 PM
Looks really nice :)/>

Thanks man, appreciate it!

First I'd like to say Welcome to the Forums!

This program is awesome, but I prefer BigFont. Don't get me wrong, I'm not saying it's better but I like it more.

Plus one for the amazing first program though, it's a step above others I've seen. :)/>

Thanks! Didn't know there was already a similar API on the forums.