Angles¶

Some color representations use angles as some of their properties. Angles can have one of the following types:

class thcolor.Angle.Type

Class representing the type of an angle, its unit really. The following types are available:

INVALID

An invalid angle, for internal processing.

DEG

An angle in degrees. A full circle is represented by 360 degrees.

An angle in gradiants. A full circle is represented by 400 gradiants.

An angle in radiants. A full circle is represented by 2π radiants.

TURN

An angle in turns. A full circle is represented by 1 turn.

Angles in thcolor are instances of the following class:

class thcolor.Angle(*args, **kwargs)

Class representing an angle within thcolor, used for some color representations (most notably hue). Its constructor depends on the first given argument, which represents the angle type as one of the Angle.Type constants.

Angle(Angle.Type.DEG, degrees)

Create an angle with a value in degrees (canonical values are between 0 and 360 excluded). For example, to create a 270° angle:

angle = Angle(Angle.Type.DEG, 270)

Create an angle with a value in gradiants (canonical values are between 0 and 400 excluded). For example, to create a 565.5 gradiants angle:

angle = Angle(Angle.Type.GRAD, 565.5)

Create an angle with a value in radiants (canonical values are between 0 and 2π excluded). For example, to create a π radiants angle:

from math import pi
angle = Angle(Angle.Type.RAD, pi)
Angle(Angle.Type.TURN, turns)

Create an angle with a value in turns (canonical values are between 0 and 1 excluded). For example, to create a 3.5 turns angle:

angle = Angle(Angle.Type.TURN, 3.5)
degrees

The read-only angle value in degrees. If the angle isn’t in degrees already, it will be converted automatically.

The read-only angle value in gradiants. If the angle isn’t in gradiants already, it will be converted automatically.