HTBasic Help
×
Menu
Index

CLIP Statement

 
The CLIP statement allows you to specify new soft-clip limits without changing the current VIEWPORT values and it enables and disables clipping at the soft-clip boundaries. If no CLIP statement is executed, the soft-clip boundaries are the most recently defined by either a VIEWPORT (soft-clip) or PLOTTER IS (hard-clip) statement.
 
Use the CLIP ON statement prior to any graphic statements that might generate points outside the soft-clip area. If CLIP ON is active, a theoretical move or draw to any point that is outside the defined soft-clip area is executed. If a draw is executed, then only that portion of the vector which lies inside the soft-clip area is drawn. The portion of the vector that lies outside the soft-clip area is clipped (chopped off) at the edge of the soft-clip boundary. If both the current logical position and the specified position are outside the soft-clip area the logical position is updated but no physical pen movement is made.
 
Execute a CLIP OFF statement to disable clipping so you may add labels, comments, graphics or any other plotting that is to be done outside the soft-clip area. When clipping is disabled, clipping will only be done on the physical device limits. If the soft-clip limits are smaller than the physical device boundaries, then CLIP OFF allows you to generate graphic coordinates that fall outside the soft-clip limits but inside the device physical boundaries. For example:
 
10 GINIT
20 VIEWPORT 10,100,50,80
30 FRAME
40 AXES 3,3,0,0,2,3
50 CLIP OFF
60 MOVE 15,-25
70 LABEL "LABEL OUTSIDE CLIP AREA"
80 END
 
The default WINDOW setting (0,RATIO*100,0,100) is mapped into the new VIEWPORT area of (10,100,50,80). We enclose the VIEWPORT area with the FRAME statement so you can see the area. Clipping is turned off and we move outside the soft-clip area to (15,-25) and draw a line.
 
The difference between the CLIP and VIEWPORT statements can be confusing. The following examples should help you see the different effects these commands have on graphics scaling and clipping.
 
VIEWPORT Example                                CLIP Example
10 GINIT                        10 GINIT
20 VIEWPORT 20,60,20,60         20 CLIP 20,60,20,60
25 WINDOW 0,148,0,100           25 WINDOW 0,148,0,100
30 FRAME                        30 FRAME
40 MOVE 10,10                   40 MOVE 10,10
50 DRAW 80,70                   50 DRAW 80,70
60 CLIP OFF                     60 CLIP OFF
70 DRAW 90,70                   70 DRAW 90,70
80 END                          80 END
 
In the VIEWPORT Example, the WINDOW values (0,148,0,100) are mapped into the new VIEWPORT area (20,60,20,60). All the MOVE and DRAW X,Y values are within the window and thus no clipping is done. In the CLIP Example , the VIEWPORT remains the entire screen and the WINDOW values are again mapped into the VIEWPORT area, but the CLIP command specifies that any line outside the range of the clipping area (20,60,20,60) is not displayed. After CLIP OFF, the final DRAW is displayed.
 
You specify the bounds and the units of your coordinate system with either the SHOW or the WINDOW statement. They both specify a rectangular area with dimensions as large or as small as you like. The units that you thus define are known as User Defined Units (UDUs) and are used by all the graphic drawing statements. The meaning of each unit is entirely up to you. They can be any units of measure you wish to work with (inches, miles, years, etc.). For example, if you are plotting a sine wave that has a domain of 0 to 2*PI and a range of -1 to +1, you would use these values as the bounds of your coordinate system.