ColorFromElementId Method |
Creates a new color from an Element ID value
Namespace:
Eto.Drawing
Assembly:
Eto (in Eto.dll) Version: 2.5.3-dev
Syntax public static Color FromElementId(
int id,
int alpha = 255
)
Public Shared Function FromElementId (
id As Integer,
Optional alpha As Integer = 255
) As Color
static member FromElementId :
id : int *
?alpha : int
(* Defaults:
let _alpha = defaultArg alpha 255
*)
-> Color
Parameters
- id
- Type: SystemInt32
Identifier. - alpha (Optional)
- Type: SystemInt32
Alpha.
Return Value
Type:
ColorA new instance of a Color with the value from the element id
Remarks
This algorithm is from the SVG# code base:
The counter is used to generate IDs in the range [0,2^24-1]
The 24 bits of the counter are interpreted as follows:
[red 7 bits | green 7 bits | blue 7 bits |shuffle term 3 bits]
The shuffle term is used to define how the remaining high
bit is set on each color. The colors are generated in the
range [0,127] (7 bits) instead of [0,255]. Then the shuffle term
is used to adjust them into the range [0,255].
This algorithm has the feature that consecutive ids generate
visually distinct colors.
See Also