Difference between revisions of "Noise:setColorLookup"

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

Latest revision as of 00:08, 29 July 2025

Available since: Gideros 2020.5
Class: FastNoise

Description

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

Noise:setColorLookup(colors)

colors is a table of tables, each containing up to 3 values:

  • first value: height (number) must be in range [0..1]
  • second value: color (number) in hex format
  • third value: alpha (number, default = 1) must be in range [0..1] (optional)

Parameters

colors: (table) color table

Example

require "FastNoise"

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},
	}
)