DrawGrid:
Filter:
Classes | GUI > Accessories

DrawGrid : Object

Draws grid lines on a UserView for plotting
Source: Grid.sc

Description

DrawGrid is used by Plotter to draw the grid lines on a graph. It can however also be used to draw GridLines on any UserView and could even be used to add grid lines to UserViews behind sliders or in any GUI.

Note that DrawGrid does not hold any reference to the UserView but is meant to have its .draw method called inside of the UserView's drawFunc. It only needs to know what bounds the grid lines should be drawn within and what the horizontal and vertical GridLines are.

Class Methods

DrawGrid.new(bounds, horzGrid, vertGrid)

Arguments:

bounds

The bounds describing the extents of the grid (not including any labels). Multiple DrawGrid may be used to draw grids on a single UserView.

horzGrid

A GridLines, BlankGridLines or GridLines subclass.

vertGrid

A GridLines, BlankGridLines or GridLines subclass.

Returns:

A DrawGrid.

DrawGrid.test(horzGrid, vertGrid, bounds)

For testing new GridLines objects.

Arguments:

horzGrid

A GridLines object or subclass.

vertGrid

A GridLines object or subclass.

bounds

Bounds describing the extents of the grid (not including any labels) within the parent view. Can be a Point or Rect. Default: 500 @ 400.

Returns:

A DrawGrid.

Inherited class methods

Instance Methods

.draw

This draws to the currently active UserView. This method is meant to be called from inside the drawFunc of a UserView.

Returns:

nil

.horzGrid = g

Set the X axis grid lines.

Arguments:

g

A GridLines.

Returns:

Self.

.vertGrid = g

Set the Y axis grid lines.

Arguments:

g

A GridLines.

Returns:

Self.

.bounds

.bounds = b

Get/set bounds describing the extents of the grid (not including any labels).

Arguments:

b

A Rect.

Returns:

A Rect.

.font = f

Get/set the font used by the grid lines labels.

Arguments:

f

A Font.

Returns:

A Font.

.fontColor = c

Get/set the font color.

Arguments:

c

A Color.

Returns:

A Color.

.gridColors = colors

Set the colors of the grid lines for each axis.

Arguments:

colors

An Array of two colors for the x and y grid lines, respectively.

Returns:

Self.

.opacity

.opacity = value

Get/set opacity.

Returns:

A Float.

.smoothing

.smoothing = value

A Boolean which turns on/off anti-aliasing. See Pen: *smoothing.

Returns:

A Boolean.

.linePattern

.linePattern = value

Set the line dash pattern. pattern should be a FloatArray of values that specify the lengths of the painted segments and not painted segments. See Pen: *lineDash.

Returns:

Self.

.x

.x = value

A DrawGridX object that draws the x (horizontal) axis. In general you shouldn't need to set this.

Returns:

.y

.y = value

A DrawGridY object that draws the y (vertical) axis. In general you shouldn't need to set this.

Returns:

.copy

Safely make a copy of this object and its working members.

Returns:

A new DrawGrid.

Inherited instance methods

Examples