Difference between revisions of "Legacy:CreateColor"

From Spherical
Jump to: navigation, search
(Created initial page)
 
(Notes)
 
(2 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
==Usage==
 
==Usage==
  
 +
<center>'''Sphere 1.0 API'''</center>
 
{{Usage|func=CreateColor|params=r, g, b, a}}
 
{{Usage|func=CreateColor|params=r, g, b, a}}
 +
<center>'''Sphere 2.0 API'''</center>
 +
{{Usage|func=new Color|params=r, g, b, a}}
  
 
* '''r''' the red component
 
* '''r''' the red component
Line 12: Line 15:
 
==Notes==
 
==Notes==
  
The alpha component is optional. By default it's complete opaque (255).
+
* The alpha component is optional. By default it's complete opaque (255).
 +
* Avoid creating Color objects on the fly in render scripts, particularly when the actual RGB values used don't change from frame to frame.  This seems innocent enough, but can slow down your game considerably.  Instead, try to create Colors ahead of time so they can be reused each frame.
  
 
==Examples==
 
==Examples==
Line 35: Line 39:
 
* [[API:FlipScreen|FlipScreen]]()
 
* [[API:FlipScreen|FlipScreen]]()
  
[[Category:Functions]]
+
 
 +
{{API:Color/navbox}}

Latest revision as of 05:00, 20 June 2015

Returns a Sphere Color Object, to be used in color masks or drawing primitives.

Usage

Sphere 1.0 API
CreateColor(r, g, b, a);


Sphere 2.0 API
new Color(r, g, b, a);


  • r the red component
  • g the green component
  • b the blue component
  • a the alpha component

Notes

  • The alpha component is optional. By default it's complete opaque (255).
  • Avoid creating Color objects on the fly in render scripts, particularly when the actual RGB values used don't change from frame to frame. This seems innocent enough, but can slow down your game considerably. Instead, try to create Colors ahead of time so they can be reused each frame.

Examples

Create some colors:

var Red    = CreateColor(255, 0  , 0);
var Green  = CreateColor(0  , 255, 0);
var Yellow = CreateColor(255, 255, 0);

var TransparentRed = CreateColor(255, 0, 0, 125);

See also


API:Color/navbox