Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
ShadyChirp

Drawing graphics on screen

Question

So, I have just recently gotten into OpenComputers, after using CC for a long time. But something that I have noticed, that has been bugging me alot, is that I can't draw squares of different shapes and colors. Also I have been struggling to change the background color when running my program. Are there any integrated commands for this, or do I have to write a long snippet of code?

To make my point clear, I will give an example, as written in computercraft:

term.setBackgroundColor(colors.gray) 
also, 
term.setTextColor(colors.orange)
and: 
paintutils.drawFilledBox(1,1,10,10,colors.white)

I hope this made any sense.. :|

Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

 

 

18 hours ago, Molinko said:

local colors = require "colors"
local component = require "component"
local gpu = component.gpu

gpu.setForeground(colors.gray)
gpu.setBackground(colors.orange)

gpu.fill(1, 1, 10, 10, colors.white)

Same flavors, different brand.

gpu component documentation

Hmm... I seem to be having some trouble here.. I can't get it to fill the screen.... It only throws back an error message.. 

Link to post
Share on other sites
  • 0

Sorry about that. My example used gpu.fill wrong.. It should be.. 

gpu.fill(1, 1, 10, 10, " ")

That last arg should be the char to use not the color to fill with. Color is obviously set with gpu.setBackground.

Edited by Molinko
Link to post
Share on other sites
  • 0

After fiddling around for some time i finally got it to work :) 
 

You see, it wouldn't set the color, so that the box always was colored black.. I fixed it by referring to my wished color with a number:

local colors = require "colors"
	local component = require "component"
		local gpu = component.gpu
			
			gpu.setForeground(1, true)
		gpu.setBackground(1, true)
	gpu.fill(1, 1, 10, 10, "x")
os.sleep(1)

So, as you see, the part where i specify the colors is different. But anyway, you have helped me alot! Wouldn't have figured this out without you

(I also set 'IsPaletteIndex' to true)
 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.