Difference between revisions of "Paintutils (API)"

From ComputerCraft Wiki
Jump to: navigation, search
m (Hilarious typo is hilarious. :P)
 
(16 intermediate revisions by 10 users not shown)
Line 1: Line 1:
Paintutils is an API to draw and load images
+
{{lowercase}}
 +
Paintutils is a default API for advanced systems which can draw [[paintutils.drawPixel|pixels]] and [[paintutils.drawLine|lines]], [[paintutils.loadImage|load]] and [[paintutils.drawImage|draw]] image files. You can use [[Colors (API)|colors API]] for easier color manipulation.
  
<table style="width: 100%; border: solid 1px black; margin: 2px; border-spacing: 0px;">
+
{{API table|paintutils|image=Grid disk.png|2=
<tr><td colspan="2" style="font-weight: bold; font-size: large; padding-bottom: .3em; border-bottom: solid #C9C9C9 1px; background: #D3FFC2; line-height:28px;">
+
[[File:Grid_disk.png|24px]]&nbsp;&nbsp;
+
Paintutils (API)
+
</td></tr>
+
  
<tr><td style="width: 350px; background: #E0E0E0; padding: .4em; font-weight:bold;">Method Name</td><td style="background: #E0E0E0; padding: .4em; font-weight:bold;">Description</td></tr>
+
{{API table/row
 +
|[[paintutils.loadImage]]({{type|string}} path)
 +
|{{type|table}} image
 +
|Loads and returns an image object from <var>path</var>.
 +
|odd}}
  
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[paintutils.loadImage]](path)</td>
+
{{API table/row
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns an image object.</td></tr>
+
|[[paintutils.drawImage]]({{type|table}} image, {{type|number}} x, {{type|number}} y)
 +
|{{type|nil}}
 +
|Draws an image at (<var>x</var>, <var>y</var>) where <var>image</var> is an image object.
 +
|}}
  
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[paintutils.drawImage]](image, x, y)</td>
+
{{API table/row
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Draws an image at (x, y) where image is an image object.</td></tr>
+
|[[paintutils.drawPixel]]({{type|number}} x, {{type|number}} y [, {{type|number}} color*])
 +
|{{type|nil}}
 +
|Draws a pixel at (<var>x</var>, <var>y</var>) in the specified color.
 +
|odd}}
  
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[paintutils.drawPixel]](x, y, colour)</td>
+
{{API table/row
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Draws a pixel at (x, y) in the colour specified.</td></tr>
+
|[[paintutils.drawLine]]({{type|number}} startX, {{type|number}} startY, {{type|number}} endX, {{type|number}} endY [, {{type|number}} color*])
 +
|{{type|nil}}
 +
|Draws a line from (<var>startX</var>, <var>startY</var>) to (<var>endX</var>, <var>endY</var>) in the specified color.
 +
|}}
  
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[paintutils.drawLine]](startX, startY, endX, endY, colour)</td>
+
{{API table/row
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Draws a line from (startX, startY) to (endX, endY) in the colour specified.</td></tr>
+
|[[paintutils.drawBox]]({{type|number}} startX, {{type|number}} startY, {{type|number}} endX, {{type|number}} endY [, {{type|number}} color])
 
+
|{{type|nil}}
</table>
+
|Draws a box from (<var>startX</var>, <var>startY</var>) to (<var>endX</var>, <var>endY</var>) in the specified color. ''Requires version 1.64 or newer.''
 +
|odd}}
  
 +
{{API table/row
 +
|[[paintutils.drawFilledBox]]({{type|number}} startX, {{type|number}} startY, {{type|number}} endX, {{type|number}} endY [, {{type|number}} color])
 +
|{{type|nil}}
 +
|Draws a filled box from (<var>startX</var>, <var>startY</var>) to (<var>endX</var>, <var>endY</var>) in the specified color. ''Requires version 1.64 or newer.''
 +
|}}
 +
}}
 +
''<nowiki>*</nowiki> Note: In builds prior to ComputerCraft 1.6, the "color" parameter required by [[paintutils.drawPixel|paintutils.drawPixel()]] and [[paintutils.drawLine|paintutils.drawLine()]] is optional. From ComputerCraft 1.6 the parameter is required, but it was changed back to optional in ComputerCraft 1.64.''
  
 
[[Category:APIs]]
 
[[Category:APIs]]

Latest revision as of 13:47, 14 June 2015

Paintutils is a default API for advanced systems which can draw pixels and lines, load and draw image files. You can use colors API for easier color manipulation.

Grid disk.png  paintutils (API)
Function Return values Description
paintutils.loadImage(string path) table image Loads and returns an image object from path.
paintutils.drawImage(table image, number x, number y) nil Draws an image at (x, y) where image is an image object.
paintutils.drawPixel(number x, number y [, number color*]) nil Draws a pixel at (x, y) in the specified color.
paintutils.drawLine(number startX, number startY, number endX, number endY [, number color*]) nil Draws a line from (startX, startY) to (endX, endY) in the specified color.
paintutils.drawBox(number startX, number startY, number endX, number endY [, number color]) nil Draws a box from (startX, startY) to (endX, endY) in the specified color. Requires version 1.64 or newer.
paintutils.drawFilledBox(number startX, number startY, number endX, number endY [, number color]) nil Draws a filled box from (startX, startY) to (endX, endY) in the specified color. Requires version 1.64 or newer.

* Note: In builds prior to ComputerCraft 1.6, the "color" parameter required by paintutils.drawPixel() and paintutils.drawLine() is optional. From ComputerCraft 1.6 the parameter is required, but it was changed back to optional in ComputerCraft 1.64.