Difference between revisions of "Texture.new"
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | '''Available since:''' Gideros 2011.6<br/> | + | '''<translate>Available since</translate>:''' Gideros 2011.6<br/> |
− | === Description === | + | === <translate>Description</translate> === |
<translate><br /> | <translate><br /> | ||
Creates a new Texture object.<br /> | Creates a new Texture object.<br /> | ||
Line 8: | Line 8: | ||
Texture.new(filename,filtering,options) | Texture.new(filename,filtering,options) | ||
</source> | </source> | ||
− | === Parameters === | + | === <translate>Parameters</translate> === |
'''filename''': (string) <translate>The name of the texture file to be loaded.</translate> <br/> | '''filename''': (string) <translate>The name of the texture file to be loaded.</translate> <br/> | ||
'''filtering''': (boolean, default = false) <translate>Whether or not the texture is filtered.</translate> <br/> | '''filtering''': (boolean, default = false) <translate>Whether or not the texture is filtered.</translate> <br/> | ||
'''options''': (table, optional) <translate>A table that specifies optional paramaters. Currently, "transparentColor", "wrap", "format" and "extend" fields are supported.</translate> '''optional'''<br/> | '''options''': (table, optional) <translate>A table that specifies optional paramaters. Currently, "transparentColor", "wrap", "format" and "extend" fields are supported.</translate> '''optional'''<br/> | ||
− | === Examples === | + | === <translate>Examples</translate> === |
'''Example'''<br/> | '''Example'''<br/> | ||
<source lang="lua">local texture = Texture.new("image.png", false, {transparentColor = 0xff00ff}) -- do not filter and make the color 0xff00ff transparent | <source lang="lua">local texture = Texture.new("image.png", false, {transparentColor = 0xff00ff}) -- do not filter and make the color 0xff00ff transparent | ||
local texture = Texture.new("image.png", true, {wrap = Texture.REPEAT}) -- enable filtering and repeat the texture</source> | local texture = Texture.new("image.png", true, {wrap = Texture.REPEAT}) -- enable filtering and repeat the texture</source> | ||
__NOTOC__ | __NOTOC__ | ||
− | '''Available since:''' Gideros 2016.08<br/> | + | '''<translate>Available since</translate>:''' Gideros 2016.08<br/> |
− | === Description === | + | === <translate>Description</translate> === |
<translate>Create a texture from pixel data.</translate> | <translate>Create a texture from pixel data.</translate> | ||
<source lang="lua"> | <source lang="lua"> | ||
Texture.new(pixels,width,height,filtering,options) | Texture.new(pixels,width,height,filtering,options) | ||
</source> | </source> | ||
− | === Parameters === | + | === <translate>Parameters</translate> === |
'''pixels''': (string) <translate>A string containing actual R,G,B,A compoents of each pixel in the new texture. Each component is stored as a byte. You can pass nil if you don't need to initialize texture content</translate> <br/> | '''pixels''': (string) <translate>A string containing actual R,G,B,A compoents of each pixel in the new texture. Each component is stored as a byte. You can pass nil if you don't need to initialize texture content</translate> <br/> | ||
'''width''': (number) <translate>width of the texture to create</translate> <br/> | '''width''': (number) <translate>width of the texture to create</translate> <br/> | ||
Line 29: | Line 29: | ||
'''filtering''': (boolean, default to false) <translate>indicate that the texture should be filtered</translate> '''optional'''<br/> | '''filtering''': (boolean, default to false) <translate>indicate that the texture should be filtered</translate> '''optional'''<br/> | ||
'''options''': (table, optional) <translate>A table that specifies optional paramaters. Currently, "transparentColor", "wrap", "format" and "extend" fields are supported.</translate> '''optional'''<br/> | '''options''': (table, optional) <translate>A table that specifies optional paramaters. Currently, "transparentColor", "wrap", "format" and "extend" fields are supported.</translate> '''optional'''<br/> | ||
− | === Examples === | + | === <translate>Examples</translate> === |
'''Example'''<br/> | '''Example'''<br/> | ||
<source lang="lua">local texture = Texture.new(nil,300,400;, false, {extend=false}) -- Create a 300x400 empty texture. Prevent gideros from extending the texture to the next power of two size</source> | <source lang="lua">local texture = Texture.new(nil,300,400;, false, {extend=false}) -- Create a 300x400 empty texture. Prevent gideros from extending the texture to the next power of two size</source> |
Revision as of 07:30, 24 August 2018
Available since: Gideros 2011.6
Description
Creates a new Texture object.
Texture.new(filename,filtering,options)
Parameters
filename: (string) The name of the texture file to be loaded.
filtering: (boolean, default = false) Whether or not the texture is filtered.
options: (table, optional) A table that specifies optional paramaters. Currently, "transparentColor", "wrap", "format" and "extend" fields are supported. optional
Examples
Example
local texture = Texture.new("image.png", false, {transparentColor = 0xff00ff}) -- do not filter and make the color 0xff00ff transparent
local texture = Texture.new("image.png", true, {wrap = Texture.REPEAT}) -- enable filtering and repeat the texture
Available since: Gideros 2016.08
Description
Create a texture from pixel data.
Texture.new(pixels,width,height,filtering,options)
Parameters
pixels: (string) A string containing actual R,G,B,A compoents of each pixel in the new texture. Each component is stored as a byte. You can pass nil if you don't need to initialize texture content
width: (number) width of the texture to create
height: (number) Height of the texture to create
filtering: (boolean, default to false) indicate that the texture should be filtered optional
options: (table, optional) A table that specifies optional paramaters. Currently, "transparentColor", "wrap", "format" and "extend" fields are supported. optional
Examples
Example
local texture = Texture.new(nil,300,400;, false, {extend=false}) -- Create a 300x400 empty texture. Prevent gideros from extending the texture to the next power of two size