Difference between revisions of "Texture.new"
(reformatting) |
|||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
+ | |||
<languages /> | <languages /> | ||
− | '''<translate>Available since</translate>:''' Gideros 2011.6<br/> | + | |
− | '''<translate>Class</translate>:''' [[Special:MyLanguage/Texture|Texture]]<br/> | + | '''<translate>Available since</translate>:''' Gideros 2011.6 |
+ | <br/> | ||
+ | |||
+ | '''<translate>Class</translate>:''' [[Special:MyLanguage/Texture|Texture]] | ||
+ | <br/> | ||
+ | |||
=== <translate>Description</translate> === | === <translate>Description</translate> === | ||
− | <translate | + | <translate> |
− | Creates a new Texture object.<br /> | + | Creates a new Texture object. |
− | + | <br/> | |
+ | </translate> | ||
+ | |||
<source lang="lua"> | <source lang="lua"> | ||
− | + | Texture.new(filename,filtering,options) | |
</source> | </source> | ||
+ | |||
=== <translate>Parameters</translate> === | === <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> |
− | '''filtering''': (boolean, default = false) <translate>Whether or not the texture is filtered.</translate> <br/> | + | <br/> |
− | '''options''': (table, optional) <translate>A table that specifies optional paramaters. The following options are supported:</translate><br/> | + | '''filtering''': (boolean, default = false) <translate>Whether or not the texture is filtered.</translate> |
− | * '''transparentColor''':<translate>Specify which color stands for transparent, for formats that don't supply an alpha channel such as JPEG</translate | + | <br/> |
− | * '''wrap''':<translate>How to treat texels outside the texture. Possible values are Texture.CLAMP and Texture.REPEAT.</translate | + | '''options''': (table, optional) <translate>A table that specifies optional paramaters. The following options are supported:</translate> |
− | * '''format''':<translate>The GPU pixel format for the texture</translate | + | <br/> |
− | * '''extend''':<translate>Wether the texture should be extended to a power of two size. Defaults to true.</translate | + | * '''transparentColor''':<translate>Specify which color stands for transparent, for formats that don't supply an alpha channel such as JPEG</translate> |
− | * '''scale''':<translate>The scale at which this texture was made, if it cannot be determined by a suffix. Defaults to 1.</translate> | + | * '''wrap''':<translate>How to treat texels outside the texture. Possible values are Texture.CLAMP and Texture.REPEAT.</translate> |
+ | * '''format''':<translate>The GPU pixel format for the texture</translate> | ||
+ | * '''extend''':<translate>Wether the texture should be extended to a power of two size. Defaults to true.</translate> | ||
+ | * '''scale''':<translate>The scale at which this texture was made, if it cannot be determined by a suffix. Defaults to 1.</translate> | ||
+ | |||
=== <translate>Examples</translate> === | === <translate>Examples</translate> === | ||
− | '''Example'''<br/> | + | '''Example''' |
− | <source lang="lua">local texture = Texture.new("image.png", false, {transparentColor = 0xff00ff}) -- | + | <br/> |
− | local texture = Texture.new("image.png", true, {wrap = Texture.REPEAT}) | + | |
+ | <source lang="lua"> | ||
+ | -- 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}) | ||
+ | </source> | ||
+ | |||
__NOTOC__ | __NOTOC__ | ||
+ | |||
<languages /> | <languages /> | ||
− | '''<translate>Available since</translate>:''' Gideros 2016.08<br/> | + | |
− | '''<translate>Class</translate>:''' [[Special:MyLanguage/Texture|Texture]]<br/> | + | '''<translate>Available since</translate>:''' Gideros 2016.08 |
+ | <br/> | ||
+ | '''<translate>Class</translate>:''' [[Special:MyLanguage/Texture|Texture]] | ||
+ | <br/> | ||
+ | |||
=== <translate>Description</translate> === | === <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) | |
</source> | </source> | ||
+ | |||
=== <translate>Parameters</translate> === | === <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> |
− | '''width''': (number) <translate>width of the texture to create</translate> <br/> | + | <br/> |
− | '''height''': (number) <translate>Height of the texture to create</translate> <br/> | + | '''width''': (number) <translate>width of the texture to create</translate> |
− | '''filtering''': (boolean, default to false) <translate>indicate that the texture should be filtered</translate> '''optional'''<br/> | + | <br/> |
− | '''options''': (table, optional) <translate>A table that specifies optional paramaters. The following options are supported:</translate><br/> | + | '''height''': (number) <translate>Height of the texture to create</translate> |
− | * '''transparentColor''':<translate>Specify which color stands for transparent, for formats that don't supply an alpha channel such as JPEG</translate | + | <br/> |
− | * '''wrap''':<translate>How to treat texels outside the texture. Possible values are Texture.CLAMP and Texture.REPEAT.</translate | + | '''filtering''': (boolean, default to false) <translate>indicate that the texture should be filtered</translate> '''optional''' |
− | * '''format''':<translate>The GPU pixel format for the texture</translate | + | <br/> |
− | * '''extend''':<translate>Wether the texture should be extended to a power of two size. Defaults to true.</translate | + | '''options''': (table, optional) <translate>A table that specifies optional paramaters. The following options are supported:</translate> |
− | * '''scale''':<translate>The scale at which this texture was made, if it cannot be determined by a suffix. Defaults to 1.</translate> | + | <br/> |
+ | |||
+ | * '''transparentColor''':<translate>Specify which color stands for transparent, for formats that don't supply an alpha channel such as JPEG</translate> | ||
+ | * '''wrap''':<translate>How to treat texels outside the texture. Possible values are Texture.CLAMP and Texture.REPEAT.</translate> | ||
+ | * '''format''':<translate>The GPU pixel format for the texture</translate> | ||
+ | * '''extend''':<translate>Wether the texture should be extended to a power of two size. Defaults to true.</translate> | ||
+ | * '''scale''':<translate>The scale at which this texture was made, if it cannot be determined by a suffix. Defaults to 1.</translate> | ||
+ | |||
=== <translate>Examples</translate> === | === <translate>Examples</translate> === | ||
− | '''Example'''<br/> | + | '''Example''' |
− | <source lang="lua">local texture = Texture.new(nil,300,400, false, {extend=false}) | + | <br/> |
+ | |||
+ | <source lang="lua"> | ||
+ | -- 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}) | ||
+ | </source> | ||
+ | <br/> | ||
+ | <br/> |
Revision as of 20:45, 28 July 2019
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:Specify 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:Wether 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.
Examples
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
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. The following options are supported:
- transparentColor:Specify 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:Wether 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.
Examples
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})