Difference between revisions of "Noise:setColorLookup"

From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(8 intermediate revisions by 3 users not shown)
Line 5: Line 5:
 
=== <translate>Description</translate> ===
 
=== <translate>Description</translate> ===
 
<translate><br />
 
<translate><br />
Set a color table used by texture generator functions: "getTexture" and "getTileTexture"<br />
+
Set a color table used by texture generator functions: [[Special:MyLanguage/Noise:getTexture|Noise:getTexture]] and [[Special:MyLanguage/Noise:getTileTexture|Noise:getTileTexture]]<br />
 
<br /></translate>
 
<br /></translate>
<source lang="lua">
+
<syntaxhighlight lang="lua">
Noise:setColorLookup(t)
+
Noise:setColorLookup(colors)
</source>
+
</syntaxhighlight>
 +
 
 
=== <translate>Parameters</translate> ===
 
=== <translate>Parameters</translate> ===
'''t''': (table) <translate>color table</translate> <br/>
+
'''colors''': (table) <translate>color table (see example for details)</translate> <br/>
Values:
 
'''first value''': height (number) <translate>must be in range [0..1]</translate>
 
'''second value''': color (number) <translate>in hex format</translate>
 
'''third value'':' alpha (number, default = 1) <translate>must be in range [0..1] (optional)</translate>
 
 
<br/>
 
<br/>
 
<br/>
 
<br/>
 
'''Example'''
 
'''Example'''
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
require "FastNoise"
 
require "FastNoise"
 +
-- color table is a table of tables, each containing up to 3 values...
 +
-- first value: height (number) must be in range [0..1]<br/>
 +
-- second value: color (number) in hex format<br/>
 +
-- third value: alpha (number, default = 1) must be in range [0..1] (optional)<br/>
  
 
local n = Noise.new()
 
local n = Noise.new()
 
n:setColorLookup{
 
n:setColorLookup{
{0.3, 0x4b3c37, 1},
+
{0.3, 0x4b3c37},
{0.4, 0xffffff, 1},
+
{0.4, 0xffffff, 0.8},
{0.45, 0x5c443d, 1},
+
{0.45, 0x5c443d},
{0.55, 0x3f6a14, 1},
+
{0.55, 0x3f6a14, 0.9},
{0.6, 0x589718, 1},
+
{0.6, 0x589718},
{0.7, 0x3666c6, 1},
+
{0.7, 0x3666c6},
{0.9, 0xd1d080, 1},
+
{0.9, 0xd1d080},
{1, 0x3463c3, 1},
+
{1, 0x3463c3},
}</source>
+
}</syntaxhighlight>
 
{{Noise}}
 
{{Noise}}

Latest revision as of 14:32, 13 July 2023


Available since: Gideros 2020.5
Class: Noise

Description


Set a color table used by texture generator functions: Noise:getTexture and Noise:getTileTexture

Noise:setColorLookup(colors)

Parameters

colors: (table) color table (see example for details)


Example

require "FastNoise"
-- color table is a table of tables, each containing up to 3 values...
-- first value: height (number) must be in range [0..1]<br/>
-- second value: color (number) in hex format<br/>
-- third value: alpha (number, default = 1) must be in range [0..1] (optional)<br/>

local n = Noise.new()
n:setColorLookup{
	{0.3, 0x4b3c37},
	{0.4, 0xffffff, 0.8},
	{0.45, 0x5c443d},
	{0.55, 0x3f6a14, 0.9},
	{0.6, 0x589718},
	{0.7, 0x3666c6},
	{0.9, 0xd1d080},
	{1, 0x3463c3},
}