Copyright 2008 Shoptalk Systems

GRAPHIC #handle, width, height

Description:

Create a graphic object of size width and height and assign it to variable #handle.  A graphic object has methods for performing various drawing operations.

A graphic object can be inserted into a web page using the RENDER statement.

Example:

  graphic #drawHere, 300, 200
  #drawHere place(150, 100)
  #drawHere down()
  for x = 1 to 150
    #drawHere go(x)
    #drawHere turn(93)
  next x
  render #drawHere

Graphic object methods:

See the Graphics Overview for a walkthrough of graphics in Run BASIC.

There are various methods that you can call against a graphics object to perform drawing operations.  Turtle graphics operations are supported.

#handle BOX(x, y) - Draw a box from the current position to x, y.
#handle CIRCLE(r) - Draw a circle of radius r at the current position.
#handle CLS(["color"] | [r, g, b]) - Clear the graphics area to white, or to named color, or to an RBG color.
#handle COLOR("color" | [r, g, b]) - Set the drawing color to a named color, or to an RGB color.
#handle DISCARD() - Discard all the drawing operations in the currently open segment.
#handle DOWN() - Set the drawing pen to down  (this is the default).
#handle DRAWIMAGE("name", x, y) - Draw the image named "name" at x, y.
#handle FILL("color" | [r, g, b]) - Like CLS() but it doesn't actually forget previously drawn graphics
#handle FLUSH(["name"]) - Finish the current drawing segment (and optionally name it "name") and make another segment.
#handle FONT("fontname", pointSize [,"bold"][, "italic"]) - Specify a font by name and size to use for drawing text.  Italic and bold are optional.
#handle GO(d) - Make the turtle go distance d.
#handle DEBUG$() - Return the string "Graphic".
#handle HEIGHT() - Return the height in pixels of the graphic object.
#handle HOME() - Place the pen in the center of the graphic area.
#handle LINE(originX, originY, destX, destY) - Draw a line from originX, originY to destX, destY.
#handle NORTH() - Tell the turtle to point to the top of the graphic object.
#handle PLACE(x, y) - Set the position to be x, y.
#handle REDRAW() - Redraw all the existing drawing segments.
#handle SET(x, y) - Draw a point of the currently set size at x, y.
#handle SIZE(s) - Set the size of the drawing pen to s pixels.
#handle STRINGWIDTH(str$) - Return the width in pixels of str$ using the current font.
#handle TURN(a) - Turn the turtle a degrees to the right.  a can be negative to turn to the left.
#handle UP() - Set the drawing pen to up (don't draw).
#handle WIDTH() - Return the width in pixels of the graphic object.
#handle X() - Return the current position x.
#handle Y() - Return the current position y.

To draw text at the current position use this form:

#handle "\this text will show up\each backslash makes a new line"

To draw text when you need to display backslashes:

#handle "|you can show \ backslashes"

Segment related graphics commands

#handle DELSEGMENT(n| "name") -  Delete the segment numbered n or named "name"
#handle DISCARD() - Forget all drawing operations in the current segment
#handle FLUSH(["name"]) - Make a new segment from drawing items since the last segment was made, optionally name the segment "name"
#handle REDRAW(["name"]) - Redraw all the drawing segments.  Optionally redraw just one named segment.
#handle SEGMENT() - Return the current segment ID

See also: LOADGRAPHIC, LOADIMAGE