Angles API

Some color representations use angles as some of their properties. The base class for angles is the following:

class thcolor.angles.Angle

Abstract class representing an angle within thcolor.

Used for some color representations (most notably hue).

asdegrees()

Get the current angle as a degrees angle.

Return type

DegreesAngle

asgradians()

Get the current angle as a gradians angle.

Return type

GradiansAngle

asprincipal()

Get the principal angle.

asradians()

Get the current angle as a radians angle.

Return type

RadiansAngle

asturns()

Get the current angle as a turns angle.

Return type

TurnsAngle

classmethod fromtext(expr, decoder=None)

Create a color from a string.

Parameters

expr (str) – The expression to decode.

Return type

Angle

Subclasses are the following:

class thcolor.angles.DegreesAngle(degrees)

An angle expressed in degrees.

A 270° angle can be created the following way:

angle = DegreesAngle(270)
Parameters

degrees (float) – Degrees; canonical values are between 0 and 360 excluded.

property degrees: float

Degrees.

Return type

float

class thcolor.angles.GradiansAngle(gradians)

An angle expressed in gradians.

A 565.5 gradians angle can be created the following way:

angle = GradiansAngle(565.5)
Parameters

gradians (float) – Gradians; canonical values are between 0 and 400.0 excluded.

property gradians: float

Gradians.

Return type

float

class thcolor.angles.RadiansAngle(radians)

An angle expressed in radians.

A π radians angle can be created the following way:

from math import pi
angle = RadiansAngle(pi)
Parameters

radians (float) – Radians; canonical are between 0 and 2π excluded.

property radians: float

Radians.

Return type

float

class thcolor.angles.TurnsAngle(turns)

An angle expressed in turns.

A 3.5 turns angle can be created the following way:

angle = TurnsAngle(3.5)
Parameters

turns (float) – Turns; canonical values are between 0 and 1 excluded.

property turns: float

Turns.

Return type

float