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

cwu - An easy-to-use graphical API

Started by ntnick, 06 June 2014 - 11:42 PM
ntnick #1
Posted 07 June 2014 - 01:42 AM
cwu 2.0


cwu is an API designed to be easy to use and powerful at the same time.
It is inspired by GTK (GIMP Toolkit).

Example code:


os.loadAPI("cwu")
cwu.object_textLabel(1,1,colours.green,colours.white,"Hello, world!")


Install:

pastebin get s2PVQs5a cwu


Documentation:

Spoilercore_resColors()

Resets the text and background color to the default white and black.

screenH()

Returns the width and height of the screen.

object_textButton(x, y, tCol, bCol, text)

Makes a text button at x, y.

tCol - Button text color
bCol - Button background color

text - Text to display on the button

object_button(x, y, buttonCol, buttonWidth)

Makes a button at x, y.

buttonCol - Button color

buttonWidth - Width of the button

object_img(imgX, imgY, imgPath)

Draws an image at imgX, imgY.

imgPath - The path of the image to render.

object_textLabel(x, y, bCol, tCol, text)

Makes a text label at x, y.

bCol - Image background color
tCol - Image text color

text - The text to display on the image.

object_animation(images, fps, animX, animY)

Makes an animation at animX, animY.

fps - FPS to render animation at.
images - The table of images that make the animation.

graphics_bColor(col)

Sets the background color to col.

mtl_newWindow(posX, posY, sizeX, sizeY, color)

Creates an image at posX, posY with sizeX, sizeY.

color - Window color.
sizeX - Size of the window (X)
sizeY - Size of the window (Y)

object_clock(x, y, bcol, tcol)

Makes an object with the time at x, y.

bcol - The background color of the clock.
tcol - The text color of the clock.

object_textField(x,y,len,bCol,tCol)

Makes a text field that you can type in.

bCol - Background colour of the text field
tCol - Text colour of the text field

len - Length of the text field
x - X position of the text field
y - Y position of the text field

object_nonVisTxtField(x,y,len)

Makes an invisible text field.

x - X position of the text field
y - Y position of the text field

len - Length of the text field

text_right(y,bcol,tcol,text)

Puts text on the right side of the screen.

y - Y position of the text
bcol - Background colour of the text
tcol - Text colour of the text
text - Text
Edited on 16 June 2014 - 09:58 PM
ame824 #2
Posted 13 June 2014 - 11:06 PM
lua:52: attempt to call nil
bei allem
ntnick #3
Posted 14 June 2014 - 02:40 AM
lua:52: attempt to call nil
bei allem

I'll fix that.
ntnick #4
Posted 16 June 2014 - 05:31 PM
cwu 2.0 is out!

cwu 2.0 is out, with a few more functions.

object_textField(x,y,len,bCol,tCol)

Makes a text field that you can type in.

bCol - Background colour of the text field
tCol - Text colour of the text field

len - Length of the text field
x - X position of the text field
y - Y position of the text field

object_nonVisTxtField(x,y,len)

Makes an invisible text field.

x - X position of the text field
y - Y position of the text field

len - Length of the text field

text_right(y,bcol,tcol,text)

Puts text on the right side of the screen.

y - Y position of the text
bcol - Background colour of the text
tcol - Text colour of the text
text - Text

—-

There are some window utilities, documentation for those will be coming later.

—-

To install:

pastebin get s2PVQs5a

Raw text:

http://pastebin.com/raw.php?i=s2PVQs5a
Edited on 16 June 2014 - 03:32 PM