enable.brush module

Brush classes to make filling regions cleaner.

class enable.brush.Brush[source]

Bases: traits.has_traits.ABCHasStrictTraits

A brush describes how to fill the pixels of a region.

To use a brush when drawing, call set_brush with the current gc as the argument.

observe_update_traits(event)[source]
abstract set_brush(gc)[source]

Apply the brush settings to a graphics context.

Parameters

gc (graphics context) – The graphics context to use the brush with.

updated = Event()

A trait which fires when the brush is updated.

class enable.brush.ColorBrush[source]

Bases: enable.brush.Brush

A simple brush that paints a solid color.

color = ColorTrait("transparent", update=True)

The color to brush the region with.

set_brush(gc)[source]

Apply the brush settings to a graphics context.

This sets the fill color of the GC to the specified color.

Parameters

gc (graphics context) – The graphics context to use the brush with.

class enable.brush.ColorStop[source]

Bases: traits.has_traits.HasStrictTraits

A point on a gradient with a fixed color.

color = ColorTrait("transparent", update=True)

The color at the color stop.

observe_update_traits(event)[source]
offset = Range(0.0, 1.0, update=True)

The position of the color stop in the gradient, between 0.0 and 1.0.

to_array()[source]

Return an array which represents the color stop.

This is the raw form of the color stop required by Kiva.

Returns

stop_array – Return an array of (offset, r, b, b, a).

Return type

numpy array

updated = Event()

A trait which fires when the color stop is updated.

class enable.brush.Gradient[source]

Bases: traits.has_traits.HasStrictTraits

A color gradient.

observe_stops(event)[source]
stops = List(Instance(ColorStop))

The sequence of color stops for the gradient.

to_array()[source]

Return a sorted list of stop arrays.

This is the raw form of the stops required by Kiva.

Returns

stop_array_list – A list of array of (offset, r, b, b, a) values corresponding to the color stops. This array should not be mutated.

Return type

arrays

updated = Event()

A trait which fires when the gradient is updated.

class enable.brush.GradientBrush[source]

Bases: enable.brush.Brush

A brush that paints a color gradient.

gradient = Instance(Gradient, args=(), allow_none=False, update=True)

The sequence of color stops for the gradient.

observe_stops(event)[source]
spread_method = Enum("pad", "reflect", "repeat", update=True)

How the gradient extends beyond the main area of the gradient.

pad

Extend using the first and last colors.

reflect

Extend using a reflection of the gradient.

repeat

Extend by repeating the gradient.

units = Enum("userSpaceOnUse", "objectBoundingBox", update=True)

The coordinate space used by the gradient points.

userSpaceOnUse

Coordinates are specified in the current graph context’s coordinate system.

objectBoundingBox

Coordinates are specified between 0.0 and 1.0 and are relative to the bounding box of the path being filled.

class enable.brush.LinearGradientBrush[source]

Bases: enable.brush.GradientBrush

A brush that paints a linear color gradient.

end = Tuple(Float, Float, update=True)

The stop point of the linear gradient.

set_brush(gc)[source]

Apply the brush settings to a graphics context.

This calls linear_gradient on the GC with the appropriate values.

Parameters

gc (graphics context) – The graphics context to use the brush with.

start = Tuple(Float, Float, update=True)

The start point of the linear gradient.

class enable.brush.RadialGradientBrush[source]

Bases: enable.brush.GradientBrush

A brush that paints a radial color gradient.

center = Tuple(Float, Float, update=True)

The center point of the radial gradient.

focus = Tuple(Float, Float, update=True)

The focus point of the radial gradient.

radius = Float(update=True)

The radius of the radial gradient.

set_brush(gc)[source]

Apply the brush settings to a graphics context.

This calls radial_gradient on the GC with the appropriate values.

Parameters

gc (graphics context) – The graphics context to use the brush with.