Jump to content




[Question] Help with pixels


  • You cannot reply to this topic
4 replies to this topic

#1 Stormkrow

  • Members
  • 50 posts
  • LocationSouth Africa

Posted 14 November 2012 - 12:31 AM

Any1 have a handy tutorial anywhere on making specific blocks different colors?
I can seem to find tutorials on this kinda thing?

Thanks

#2 Heracles421

  • Members
  • 258 posts

Posted 14 November 2012 - 01:43 AM

View PostStormkrow, on 14 November 2012 - 12:31 AM, said:

Any1 have a handy tutorial anywhere on making specific blocks different colors?
I can seem to find tutorials on this kinda thing?

Thanks
Do you mean each pixel?
You need to add a term.setTextColor(color) function

#3 Stormkrow

  • Members
  • 50 posts
  • LocationSouth Africa

Posted 14 November 2012 - 02:58 AM

Yeah as in make a pixel say 1, 2 be green and pixel 1, 3 be blue?

#4 Espen

    Curious Explorer

  • Members
  • 708 posts

Posted 14 November 2012 - 03:24 AM

In order to color a "pixel" (cursor position) you have to set the background color and then write a space.
local function setPixel(x, y, color)
  if not term.isColor() then
    error("This is not an advanced terminal.")
  end

  term.setBackgroundColor(color)  
  local oldX, oldY = term.getCursorPos()
  term.setCursorPos(x, y)
  write(" ")

  term.setCursorPos(oldX, oldY)
end

term.clear()
setPixel(1, 2, colors.lime)
setPixel(1, 3, colors.blue)

-- This is just to get the cursor out of the way so you can see the results.
local _, y = term.getSize()
term.setCursorPos(1, y)

Edit: Changed the ending of the code slightly.

Edited by Espen, 14 November 2012 - 03:27 AM.


#5 Stormkrow

  • Members
  • 50 posts
  • LocationSouth Africa

Posted 14 November 2012 - 03:34 AM

Well, i found what i was looking for!!! it was the paintutils api!!! Thanks alot though!! The paintutils.drawPixel(x,y,color) was what i mean very helpful, saw it in some code in another program! I further went into a computer and typed 'Help paintutils' and it popped up!! Thanks for effort though guys ^^





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users