Difference between revisions of "Texture.new"
m (formatting) |
(removed language stuff) |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | + | '''Available since:''' Gideros 2011.6<br/> | |
− | ''' | + | '''Class:''' [[Texture]]<br/> |
− | ''' | ||
− | === | + | === Description === |
Creates a new Texture object. | Creates a new Texture object. | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 10: | Line 9: | ||
</source> | </source> | ||
− | === | + | === Parameters === |
− | '''filename''': (string) | + | '''filename''': (string) the name of the texture file to be loaded<br/> |
− | '''filtering''': (boolean, default = false) | + | '''filtering''': (boolean, default = false) whether or not the texture is filtered<br/> |
− | '''options''': (table, optional) | + | '''options''': (table, optional) a table that specifies optional paramaters. The following options are supported:<br/> |
− | * '''transparentColor''': | + | * '''transparentColor''': specifies which color stands for transparent for formats that don't supply an alpha channel such as JPEG |
− | * '''wrap''': | + | * '''wrap''': how to treat texels outside the texture. Possible values are Texture.CLAMP and Texture.REPEAT |
− | * '''format''': | + | * '''format''': the GPU pixel format for the texture |
− | * '''extend''': | + | * '''extend''': whether the texture should be extended to a power of two size. Defaults to true |
− | * '''scale''': | + | * '''scale''': the scale at which this texture was made, if it cannot be determined by a suffix. Defaults to 1 |
− | === | + | === Example === |
<source lang="lua"> | <source lang="lua"> | ||
-- do not filter and make the color 0xff00ff transparent | -- do not filter and make the color 0xff00ff transparent | ||
Line 28: | Line 27: | ||
local texture = Texture.new("image.png", true, {wrap = Texture.REPEAT}) | local texture = Texture.new("image.png", true, {wrap = Texture.REPEAT}) | ||
</source> | </source> | ||
+ | |||
+ | |||
+ | ---- | ||
__NOTOC__ | __NOTOC__ | ||
− | + | '''Available since:''' Gideros 2016.08<br/> | |
− | ''' | + | '''Class:''' [[Texture]]<br/> |
− | ''' | ||
− | === | + | === Description === |
− | + | Creates a texture from pixel data. | |
<source lang="lua"> | <source lang="lua"> | ||
Texture.new(pixels, width, height, filtering, options) | Texture.new(pixels, width, height, filtering, options) | ||
</source> | </source> | ||
− | === | + | === Parameters === |
− | '''pixels''': (string) | + | '''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<br/> |
− | '''width''': (number) | + | '''width''': (number) width of the texture to create<br/> |
− | '''height''': (number) | + | '''height''': (number) height of the texture to create<br/> |
− | '''filtering''': (boolean, default to false) | + | '''filtering''': (boolean, default to false) indicates that the texture should be filtered '''optional'''<br/> |
− | '''options''': (table, optional) | + | '''options''': (table, optional) a table that specifies optional paramaters. The following options are supported:<br/> |
− | * '''transparentColor''': | + | * '''transparentColor''': specifies which color stands for transparent for formats that don't supply an alpha channel such as JPEG |
− | * '''wrap''': | + | * '''wrap''': how to treat texels outside the texture. Possible values are Texture.CLAMP and Texture.REPEAT |
− | * '''format''': | + | * '''format''': the GPU pixel format for the texture |
− | * '''extend''': | + | * '''extend''': whether the texture should be extended to a power of two size. Defaults to true |
− | * '''scale''': | + | * '''scale''': the scale at which this texture was made, if it cannot be determined by a suffix. Defaults to 1 |
− | === | + | === Example === |
<source lang="lua"> | <source lang="lua"> | ||
-- Create a 300x400 empty texture. Prevent gideros from extending the texture to the next power of two size | -- Create a 300x400 empty texture. Prevent gideros from extending the texture to the next power of two size |
Revision as of 20:50, 2 January 2022
Available since: Gideros 2011.6
Class: Texture
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. The following options are supported:
- transparentColor: specifies which color stands for transparent for formats that don't supply an alpha channel such as JPEG
- wrap: how to treat texels outside the texture. Possible values are Texture.CLAMP and Texture.REPEAT
- format: the GPU pixel format for the texture
- extend: whether the texture should be extended to a power of two size. Defaults to true
- scale: the scale at which this texture was made, if it cannot be determined by a suffix. Defaults to 1
Example
-- do not filter and make the color 0xff00ff transparent
local texture = Texture.new("image.png", false, {transparentColor = 0xff00ff})
-- enable filtering and repeat the texture
local texture = Texture.new("image.png", true, {wrap = Texture.REPEAT})
Available since: Gideros 2016.08
Class: Texture
Description
Creates 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) indicates that the texture should be filtered optional
options: (table, optional) a table that specifies optional paramaters. The following options are supported:
- transparentColor: specifies which color stands for transparent for formats that don't supply an alpha channel such as JPEG
- wrap: how to treat texels outside the texture. Possible values are Texture.CLAMP and Texture.REPEAT
- format: the GPU pixel format for the texture
- extend: whether the texture should be extended to a power of two size. Defaults to true
- scale: the scale at which this texture was made, if it cannot be determined by a suffix. Defaults to 1
Example
-- Create a 300x400 empty texture. Prevent gideros from extending the texture to the next power of two size
local texture = Texture.new(nil,300,400, false, {extend=false})