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

[Question] Help with pixels

Started by Stormkrow, 13 November 2012 - 11:31 PM
Stormkrow #1
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
Heracles421 #2
Posted 14 November 2012 - 01:43 AM
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
Stormkrow #3
Posted 14 November 2012 - 02:58 AM
Yeah as in make a pixel say 1, 2 be green and pixel 1, 3 be blue?
Espen #4
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 on 14 November 2012 - 02:27 AM
Stormkrow #5
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 ^^