Addons/graphics/graph

From J Wiki
Jump to navigation Jump to search

graph: graph package

gdopen opens a graphics window gd... set state gd... draw graphics gdshow show graphics glclose win| close window|active window glcloseall '' close all graphics windows glselect win select graphics window

points are plotted in a box with 1 1 at bottom left and 1 1 at top right.

verbs whose names end in '01' plot in a box with 0 0 at bottom left to 1 1 at top right. Conversion to the standard box is done automatically.

colors should be given as 3 numbers in range (0,255), or as a single RGB number.

state-setting functions:

  gdcolor      set color
  gdfont       set pen size and style
  gdpen        set pen size and style
  gdpencolor   set pen color
  gdtextcolor  set text color

drawing functions (each has a matching verb ending in '01' e.g. gdarc01):

  gdarc        draw arc
  gdchord      draw chord
  gdellipse    draw ellipse
  gdlines      draw lines
  gdpie        draw pie-shaped wedge
  gdpixel      draw pixel
  gdpolygon    draw polygon
  gdrect       draw rectangle
  gdroundr     draw rounded rectangle
  gdtext       draw text

other definitions:

 gdadd        add wrapper
 gdbmp        write graph to bmp file
 gdclip       write graph to clipboard (Windows only)
 gddraw       draw wrapper
 gdemf        write graph to emf file (Windows only)
 gdopen       open/clear graphics window
 gdselect     select graphics window
 gdshow       show graph

Name Type Description
gdarc verb draw arc
gdarc01 verb draw arc in 0 0 1 1
gdbmp verb write graph to bmp file
gdchord verb draw chord
gdchord01 verb draw chord in 0 0 1 1
gdclose verb close graphics window
gdcloseall verb close all graphics windows
gdcolor verb set color
gddraw verb wrapper for draw methods
gdellipse verb draw ellipse
gdellipse01 verb draw ellipse in 0 0 1 1
gdemf verb write graph to emf file
gdlines verb draw lines
gdlines01 verb draw lines in 0 0 1 1
gdopen verb open/clear graphics window
gdpen verb set pen size and style
gdpencolor verb set pen color
gdpie verb draw pie-shaped wedge
gdpie01 verb draw pie-shaped wedge in 0 0 1 1
gdpixel verb draw pixel
gdpixel01 verb draw pixel in 0 0 1 1
gdpolygon verb draw
gdpolygon01 verb draw in 0 0 1 1
gdrect verb draw rectangle
gdrect01 verb draw rectangle in 0 0 1 1
gdroundr verb rounded rectangle
gdroundr01 verb rounded rectangle in 0 0 1 1
gdselect verb select graphics window
gdshow verb show graphics



Also:

points are plotted to pixels in a box with coordinates (0,0) at top left

points should be given as a 2 element vector or 2 column matrix colors should be given as 3 numbers in range (0,255) for RGB, or as a single RGB number.

Name Type Description
cile verb x cile values of y
fitrect01 verb fit rectangle data to 0 1
fitrect11 verb fit rectangle data to _1 1
fit01 verb fit data to range 0 1
fit11 verb fit data to range _1 1
grayscale verb generate grayscale
hue verb generate color from color set
hueRGB verb generate color from RGB color se
polygon verb vertices of a regular polygon
rotate verb rotate angle by given amount

cile

x cile values of y
example:
   3 cile i.12

fitrect01

fit rectangle data to 0 1
form: [anisotropic] fitrect01 data

if left argument is 1, applies same factors to both columns
otherwise, scales columns independently.

fit01

fit data to range 0 1
form: [anisotropic] fit data

if left argument is 1, scales columns independently,
otherwise applies same factors to all data,

grayscale

generate grayscale
example:
  grayscale (i.%<:) 5

hue

generate color from color set
x is color set
y is values from 0 to 1, selecting color

hueRGB

generate color from RGB color se
x is RGB color set (default HUES)
y is values from 0 to 1, selecting color

polygon

vertices of a regular polygon
y = number of points
x = scale factor on angle 2p1%y  (default 1)

e.g.   polygon 5 = pentagon
     2 polygon 5 = 5 pointed star

rotate

rotate angle by given amount

e.g. 0.5p1 rotate points = rotate clockwise a quarter turn