Segment

Segment-Related Graphics Commands
Graphic objects allow you to group drawing operations into segments, which can be named, discarded, redrawn and deleted.

The first segment begins with the first drawing command issued to a graphic object. It ends when **Flush** is issued. The next segment begins with the first drawing command after that **Flush** and ends when an additional **Flush** statement is issued, and so on.


 * A CLS statement deletes all graphic segments.**

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

The following demo draws a box, then flushes it and gives the segment a name. It's then rendered onto the web page. The graphic object is then filled with red and rendered. The red fill is discarded and the named segment is redrawn and rendered onto the web page.

code format="vbnet" 'demonstrate named flush, discard, redraw 'create a graphic object. graphic #g, 400, 400

'draw something 'display it on the web page render #g
 * 1) g place(22, 57)
 * 2) g box(300,300)

'flush segment and give it 'the name "boxey"
 * 1) g flush("boxey")

'fill graphic object with red
 * 1) g fill("red")

'display it on the web page render #g

'discard the red fill operation
 * 1) g discard

'redraw the segment containing the box
 * 1) g redraw("boxey")

'display it on the web page render #g code