Color


Object Hierarchy:

Object hierarchy for Color

Description:

[ CCode ( cname = "sfColor" , default_value = "{0,0,0,255}" ) ]
[ SimpleType ]
public struct Color

Utility class for manipulating RGBA colors.

sf.Color is a simple color class composed of 4 components:

  • Red
  • Green
  • Blue
  • Alpha (opacity)

Each component is a public member, an unsigned integer in the range [0, 255]. Thus, colors can be constructed and manipulated very easily:

var color = Color(255, 0, 0); // red
color.r = 0; // make it black
color.b = 128; // make it dark blue
The fourth component of colors, named "alpha", represents the opacity of the color. A color with an alpha value of 255 will be fully opaque, while an alpha value of 0 will make a color fully transparent, whatever the value of the other components is.

The most common colors are already defined as static variables:

var black       = sf.Color.Black;
var white = sf.Color.White;
var red = sf.Color.Red;
var green = sf.Color.Green;
var blue = sf.Color.Blue;
var yellow = sf.Color.Yellow;
var magenta = sf.Color.Magenta;
var cyan = sf.Color.Cyan;
var transparent = sf.Color.Transparent;


Namespace: sf
Package: sfml

Content:

Constants:

Properties:

Creation methods:

Methods:

Fields: