Difference between revisions of "gc:drawImage"

From Inspired-Lua Wiki
Jump to navigation Jump to search
(Created page with "'''drawImage''' is a function that is part of gc. {{Since|3.0}} == Syntax == gc:'''drawImage'''(image, x, y) {| class="wikitable" |- ! Parameter !! Type !! D...")
 
 
(4 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
{{Since|3.0}}
 
{{Since|3.0}}
 +
In 3.6, it changed to have its first argument being an image resource. More info [[Changes_in_OS_3.6#Images|here]].
  
 
== Syntax  ==
 
== Syntax  ==
Line 10: Line 11:
 
! Parameter !! Type !! Description
 
! Parameter !! Type !! Description
 
|-
 
|-
| <u>image</u> || [[TI.Image]] || The image to display
+
| <u><center>image</center></u> || [[TI.Image]] or image resource (3.6) || The image to display
 
|-
 
|-
| <u>x</u> || number || the x coordinate of the upper-left corner of the image
+
| <u><center>x</center></u> || number || the x coordinate of the upper-left corner of the image
 
|-
 
|-
| <u>y</u> || number || the y coordinate of the upper-left corner of the image
+
| <u><center>y</center></u> || number || the y coordinate of the upper-left corner of the image
 
|}
 
|}
 +
  
 
== Example  ==
 
== Example  ==
 
<syntaxhighlight>
 
<syntaxhighlight>
 +
-- for ApiLevel < 2.3 (OS < 3.6) :
 
imgSRC = "\002\000\000\000\002\000\000\000\000\000\000\000\004\000\000\000\016\000\001\000\255\255\255\255\255\255\255\255"
 
imgSRC = "\002\000\000\000\002\000\000\000\000\000\000\000\004\000\000\000\016\000\001\000\255\255\255\255\255\255\255\255"
 
img = image.new(imgSRC)
 
img = image.new(imgSRC)
drawImage(img, 0, 0)
+
 
 +
-- Or, for ApiLevel >= 2.3 (OS >= 3.6) :
 +
img = image.new(_R.IMG.img_1)
 +
 
 +
function on.paint(gc)
 +
    gc:drawImage(img, 0, 0)
 +
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
== See also  ==
 
== See also  ==
 
*[[TI.Image]]
 
*[[TI.Image]]
 +
*[[image.new]]
  
 
<br /><br />
 
<br /><br />
  
 
[[Category:gc]]
 
[[Category:gc]]

Latest revision as of 20:16, 7 May 2014

drawImage is a function that is part of gc.

This has been introduced in TI-Nspire OS 3.0 (Changes).

In 3.6, it changed to have its first argument being an image resource. More info here.

Syntax

gc:drawImage(image, x, y)

Parameter Type Description
image
TI.Image or image resource (3.6) The image to display
x
number the x coordinate of the upper-left corner of the image
y
number the y coordinate of the upper-left corner of the image


Example

-- for ApiLevel < 2.3 (OS < 3.6) :
imgSRC = "\002\000\000\000\002\000\000\000\000\000\000\000\004\000\000\000\016\000\001\000\255\255\255\255\255\255\255\255"
img = image.new(imgSRC)

-- Or, for ApiLevel >= 2.3 (OS >= 3.6) :
img = image.new(_R.IMG.img_1)

function on.paint(gc)
    gc:drawImage(img, 0, 0)
end

See also