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

CCGlass v0.0001 alpha

Started by Geforce Fan, 17 June 2013 - 06:00 PM
Geforce Fan #1
Posted 17 June 2013 - 08:00 PM
Moved to programs to get more attention, aswell as it belongs in there
http://www.computercraft.info/forums2/index.php?/topic/14120-glass-v0002-pixel-api/
Bubba #2
Posted 17 June 2013 - 09:04 PM
Why is this in the media section?
Geforce Fan #3
Posted 17 June 2013 - 09:08 PM
Please read the OP before asking questions, because it's explained in the OP :)/>


Also, added stuff to the post.
theoriginalbit #4
Posted 17 June 2013 - 11:09 PM
/offtopic I agree with Bubba. Why is this in the Media section. I'd say it should be in General.

/ontopic
That GUI looks like the Plastic GUI.
Geforce Fan #5
Posted 17 June 2013 - 11:21 PM
Yes, it is a bit like plastic. The home screen is anyway.(also the colors are copied from plastic's code, I don't know how to make them, so I just did that :P/>
For most practical applications(also the help screen) there is a function called tinyPrint that is all size 1 and allows for 5 lines on the screen. It also allows for customized colors. It's current use is Help, but it'll be super useful when I add a Books app.
theoriginalbit #6
Posted 17 June 2013 - 11:33 PM
also the colors are copied from plastic's code, I don't know how to make them, so I just did that :P/>

0xRRGGBB

where each set of two is 0-255 or 00-FF in HEX and represents either Red ( R ), Green ( G ), or Blue ( B ).

Use the hex values with a 0x in the font.
Tiin57 #7
Posted 18 June 2013 - 10:25 AM
Is there any documentation? From what I gather, this is some sort of API.
Geforce Fan #8
Posted 18 June 2013 - 02:05 PM
Alright, I'll just tell you the functions & variables.
glass - The variable wrapped to the peripheral
tinyPrint("text", line, color) - prints up to 5 lines of text on the screen, like in help. Line can be 1-5
highPrint("text") - Prints texts in red like in the home screen, where it says "Welcome username!"
midPrint("text") - Prints text in green like in the home screen, where it says "Glass V0.0001"
lowPrint("text") - Prints text in light blue like in the home screen, where it says "Do $$help for help."
tinyClear() - Clears Tiny Text
bigClear() - Clears Big text(highPrint, midPrint and lowPrint text.)
bigBox - The gray box where text is printed.


ALSO: For Glass to able to launch your application it need to put in in the folder CCGlass/

C&Ping this into the OP.





Is there any documentation? From what I gather, this is some sort of API.
This is a program for Terminal Glasses, but it does have it's own API. It's sort of like a system for the Terminal Glasses so you don't need a ton of them do do all your tasks.
theoriginalbit #9
Posted 19 June 2013 - 06:53 AM
also the colors are copied from plastic's code, I don't know how to make them, so I just did that :P/>
I got bored… so if you're still struggling with the HEX colours, and know RGB colours well enough, here is a function I wrote just for you :)/>


function rgb( _r, _g, _b )
  return bit.bor( bit.blshift( bit.bor( bit.blshift( _r, 8 ), _g ), 8 ), _b )
end


Example usage:

--# previously you did this
glcolors.blue = 0x7dd2e4
glass.addBox(160, 0, 5, 60, glcolors.blue, 0.75)
--# now you could do this
glcolors.blue = rgb(125, 210, 228)
glass.addBox(160, 0, 5, 60, glcolors.blue, 0.75)

If you're curious
Spoilerthis is the inverse function


local function hex( _hex )
  return bit.band( bit.brshift( _hex, 16 ), 0xff ), bit.band( bit.brshift( _hex, 8 ), 0xff ), bit.band( _hex, 0xff )
end

Example usage:

local r,g,b = hex( 0x7dd2e4 )
Mikeemoo #10
Posted 19 June 2013 - 08:53 AM
also the colors are copied from plastic's code, I don't know how to make them, so I just did that :P/>
I got bored… so if you're still struggling with the HEX colours, and know RGB colours well enough, here is a function I wrote just for you :)/>


function rgb( _r, _g, _b )
  return bit.bor( bit.blshift( bit.bor( bit.blshift( _r, 8 ), _g ), 8 ), _b )
end


Example usage:

--# previously you did this
glcolors.blue = 0x7dd2e4
glass.addBox(160, 0, 5, 60, glcolors.blue, 0.75)
--# now you could do this
glcolors.blue = rgb(125, 210, 228)
glass.addBox(160, 0, 5, 60, glcolors.blue, 0.75)

If you're curious
Spoilerthis is the inverse function


local function hex( _hex )
  return bit.band( bit.brshift( _hex, 16 ), 0xff ), bit.band( bit.brshift( _hex, 8 ), 0xff ), bit.band( _hex, 0xff )
end

Example usage:

local r,g,b = hex( 0x7dd2e4 )

Ha, I like that!
theoriginalbit #11
Posted 19 June 2013 - 09:03 AM
Ha, I like that!
Thanks :)/>

I would have made an rgba version too, but your mod doesn't accept it in that format. :P/>
Geforce Fan #12
Posted 19 June 2013 - 06:35 PM
Thanks. I'll probably use this later on, I know a place where I can get colors from :3
(in RGB)
Geforce Fan #13
Posted 19 June 2013 - 10:42 PM
Anyone know why this only displays "Welcome (your username)" on SMP then crashes?
Also: theoriginalbit, do you mind if I add that function to the GlassAPI?
MudkipTheEpic #14
Posted 19 June 2013 - 11:47 PM
This is why.
theoriginalbit #15
Posted 20 June 2013 - 12:12 AM
Thanks. I'll probably use this later on, I know a place where I can get colors from :3 (in RGB)
Also: theoriginalbit, do you mind if I add that function to the GlassAPI?
That's fine. :)/> just put a little note like so

-- kindly created by TheOriginalBIT
:P/> :P/>
Geforce Fan #16
Posted 20 June 2013 - 05:35 PM
Thanks. I'll probably use this later on, I know a place where I can get colors from :3 (in RGB)
Also: theoriginalbit, do you mind if I add that function to the GlassAPI?
That's fine. :)/> just put a little note like so

-- kindly created by TheOriginalBIT
:P/> :P/>
Thanks! This will hopefuly make it easier for app makers to use their own custom colors! :)/>
I put credits to you at the top credit thing, and right before the function.
1lann #17
Posted 21 June 2013 - 04:30 AM
You know, you could just use ColorHexa to choose colors (what I did) :P/>. It supports RGB to hex values and vice-verca: http://www.colorhexa.com/7dd2e4
GravityScore #18
Posted 21 June 2013 - 09:10 PM
You know, you could just use ColorHexa to choose colors (what I did) :P/>. It supports RGB to hex values and vice-verca: http://www.colorhexa.com/7dd2e4

And also words :P/> Like "sky blue", "crimson", "deep purple", etc…