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 to draw within. Multiple DrawGrid may be used to draw grids on a single UserView.

horzGrid

a GridLines or BlankGridLines or GridLines subclass

vertGrid

a GridLines or 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

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 gridLines

Arguments:

g

a GridLines

Returns:

self

.vertGrid = g

set the y gridLines

Arguments:

g

a GridLines

Returns:

self

.bounds

.bounds = b

get or set bounds

Arguments:

b

a Rect

Returns:

a Rect

.font = f

get or set Font

Arguments:

f

a Font

Returns:

a Font

.fontColor = c

get or set font color

Arguments:

c

a Color

Returns:

a Color

.gridColors = colors

Set the colors of each of the axis.

Arguments:

colors

an array of two colors: x,y

Returns:

self

.opacity

.opacity = value

get or set opacity

Returns:

float

.smoothing

.smoothing = value

see Pen smoothing

Returns:

smoothing

.linePattern

.linePattern = value

see Pen linePattern

Returns:

(returnvalue)

.init(bounds, h, v)

private

Arguments:

bounds
h
v

Returns:

(returnvalue)

.x

.x = value

private A DrawGridX object that draws the x (horizontal) axis

Returns:

a DrawGridX

.y

.y = value

private A DrawGridY object that draws the y (vertical) axis

Returns:

a DrawGridY

.copy

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

Returns:

a new DrawGrid

.clearCache

private

Returns:

self

Inherited instance methods

Examples