/* TEACH GO_RECTANGLE                         Ben Rabau, 27th Aug 1993

This file shows a few examples of rectangles in GO.

For more general detailed information see

HELP * GO
REF * GO

         CONTENTS - (Use <ENTER> g to access required sections)

 -- Small example: creation of two rectangles:
 -- Location and dimension
 -- appearance
 -- rotation
 -- rounding and the go_oblong class

 */

;;; This requires the following files to be loaded:
uses go;
uses go_rectangle;

;;; It also requires an active go_pane (see TEACH * GO_PANE):
go_init_rc();

/*
-- Small example: creation of two rectangles: -------------------------
 */
vars rect1 = newgo_rectangle();
vars rect2 = newgo_rectangle();

;;; By default they will appear with their centre in the origin of the pane.
;;; The following commands superimposes them:
go_add_to( rect1 , go_default_pane );
go_add_to( rect2 , go_default_pane );


/*
-- Location and dimension ---------------------------------------------
 */
;;; They can be moved to different location. For example with:
go_centre_to( 100, 0, rect1 );
go_centre_to( 0, 100, rect2 );

;;; Their width and height can be altered. Note that the centre will
;;; remain stable.
30 -> go_width( rect1 );
80 -> go_height( rect2 );

;;; This is not the same as changing their bounding box since that will
;;; adapt the scale to fit it in the available space (this is a general
;;; characteristic of the bounding box for GO objects).
40 -> go_bounding_height( rect2 );
go_yscale( rect2 ) =>

;;; See also remark under "rotation".

/*
-- appearance ---------------------------------------------------------
 */
;;; Some characteristics can be changed because it is also a go_screen_object
15 -> go_linewidth( rect1 );
'green' -> go_fgcolour( rect1 );

/*
-- rotation -----------------------------------------------------------
 */
;;; Since a rectangle is a special case of a go_polygon, the objects can
;;; also be rotated:
30 -> go_angle( rect2 );

;;; Here it becomes clear that a bounding box change is not the same as
;;; a change in width and height of th rectangle. The latter refer to a
;;; characteristic which is independent of rotation!
go_width( rect2 ) =>
go_bounding_width( rect2 ) =>

/*
-- rounding and the go_oblong class -----------------------------------
 */
;;; Since a rectangle is a go_polygon it can also be rounded:
go_smooth( rect1 );
40 -> go_rounding( rect2 );

;;; This would correspond to an oblong. If you want to create an oblong
;;; rather than a "rounded rectangle" you can also use the go_oblong class:
uses go_oblong;
vars an_oblong = instance go_oblong;
                     go_width  = 150;
                     go_height = 50;
                 endinstance;
go_add_to( an_oblong, go_default_pane );


;;; eof

--- C.all/lib/proto/go/teach/go_rectangle
--- Copyright University of Sussex 1993. All rights reserved.
