|
|
Line 1: |
Line 1: |
− | The SColor class represents RGBA colors.
| + | This page has moved to: https://docs.sine.space/v/scripting/client-scripting/static-classes/scolor |
− | | + | |
− | =Members=
| + | |
− | {{ScriptFunction|SColor|New|{float r, float g, float b, float a}|Create a color by red, green, blue and alpha parameters.|5=
| + | |
− | ''--create a cube and set a new material.''<br>
| + | |
− | ''--add ScriptingRuntime.''<br>
| + | |
− | local mat=Space.Host.ExecutingObject.Renderer.Material;<br>
| + | |
− | mat.SetColor("_Color",Color.New(0,0,1,1))<br>
| + | |
− | ''--the cube will turn to blue.''
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|SColor|FromHex|{string hex}|Create a color by Hex value.|5=
| + | |
− | ''--create a cube and set a new material.''<br>
| + | |
− | ''--add ScriptingRuntime.''<br>
| + | |
− | local mat=Space.Host.ExecutingObject.Renderer.Material;<br>
| + | |
− | mat.SetColor("_Color",Color.FromHex("FF0000"))<br>
| + | |
− | ''--the cube will turn to red.''
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|string|ToHex|();|Return the Hex value of the color.|5=
| + | |
− | Space.Log(Color.Red.ToHex())<br>
| + | |
− | ''--print "FF0000".''
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|SColor|Lerp|(SColor b, float t);|Linearly interpolates between current color and b by t.|5=
| + | |
− | ''--create a cube and set a new material.''<br>
| + | |
− | ''--add ScriptingRuntime.''<br>
| + | |
− | local mat=Space.Host.ExecutingObject.Renderer.Material<br>
| + | |
− | function ChangeColor()<br>
| + | |
− | mat.SetColor("_Color",Color.Red.Lerp(Color.Blue,Space.Math.PingPong(Space.Time,1)))<br>
| + | |
− | end<br>
| + | |
− | Space.Host.ExecutingObject.OnUpdate(ChangeColor)
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|bool|Equals|(SColor other);|Returns true if colors are same.|5=
| + | |
− | local colorR=Color.New(1,0,0,1)<br>
| + | |
− | Space.Log(colorR.Equals(Color.Red))<br>
| + | |
− | ''--Print "true".''
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|string|ToString|(SColor other);|Returns the RGBA value of the current color.|5=
| + | |
− | Space.Log(Color.Red.ToString())<br>
| + | |
− | ''--print "[1,0,0,1]".''
| + | |
− | }}
| + | |
− | | + | |
− | | + | |
− | =Properties=
| + | |
− | {{ScriptFunction|SColor|Black|{get;}|Solid black. RGBA is (0, 0, 0, 1).|5=
| + | |
− | ''--create a cube and set a new material.''<br>
| + | |
− | ''--add ScriptingRuntime.''<br>
| + | |
− | local mat=Space.Host.ExecutingObject.Renderer.Material;<br>
| + | |
− | mat.SetColor("_Color",Color.Black)<br>
| + | |
− | ''--the cube will turn to black.''
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|SColor|White|{get;}|Solid White. RGBA is (1, 1, 1, 1).|5=
| + | |
− | ''--create a cube and set a new material.''<br>
| + | |
− | ''--add ScriptingRuntime.''<br>
| + | |
− | local mat=Space.Host.ExecutingObject.Renderer.Material;<br>
| + | |
− | mat.SetColor("_Color",Color.White)<br>
| + | |
− | ''--the cube will turn to white.''
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|SColor|Red|{get;}|Solid Red. RGBA is (1, 0, 0, 1).|5=
| + | |
− | ''--create a cube and set a new material.''<br>
| + | |
− | ''--add ScriptingRuntime.''<br>
| + | |
− | local mat=Space.Host.ExecutingObject.Renderer.Material;<br>
| + | |
− | mat.SetColor("_Color",Color.Red)<br>
| + | |
− | ''--the cube will turn to red.''
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|SColor|Blue|{get;}|Solid Blue. RGBA is (0, 0, 1, 1).|5=
| + | |
− | ''--create a cube and set a new material.''<br>
| + | |
− | ''--add ScriptingRuntime.''<br>
| + | |
− | local mat=Space.Host.ExecutingObject.Renderer.Material;<br>
| + | |
− | mat.SetColor("_Color",Color.Blue)<br>
| + | |
− | ''--the cube will turn to blue.''
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|SColor|Green|{get;}|Solid Green. RGBA is (0, 1, 0, 1).|5=
| + | |
− | ''--create a cube and set a new material.''<br>
| + | |
− | ''--add ScriptingRuntime.''<br>
| + | |
− | local mat=Space.Host.ExecutingObject.Renderer.Material;<br>
| + | |
− | mat.SetColor("_Color",Color.Green)<br>
| + | |
− | ''--the cube will turn to green.''
| + | |
− | }}
| + | |
− | | + | |
− | {{ScriptFunction|SColor|Yellow|{get;}|Yellow. RGBA is (1, 0.92, 0.016, 1).|5=
| + | |
− | ''--create a cube and set a new material.''<br>
| + | |
− | ''--add ScriptingRuntime.''<br>
| + | |
− | local mat=Space.Host.ExecutingObject.Renderer.Material;<br>
| + | |
− | mat.SetColor("_Color",Color.Yellow)<br>
| + | |
− | ''--the cube will turn to yellow.''
| + | |
− | }}
| + | |
− | | + | |
− | {{Scripting Navbox}}
| + | |