Original Author Paul Laughton, 2011
Page 161
De Re BASIC!
Gr.screen width, height{, density }
Returns the screen's width and height, and optionally its density, in the numeric variables. The density,
in dots per inch (dpi), is a standardized Android density value (usually 120, 160, or 240 dpi), and not
necessarily the real physical density of the screen.
If a Gr.orientation command changes the orientation, the width and height values from a previous
Gr.screen command are invalid.
Android's orientation-change animation takes time. You may need to wait for a second or so after
Gr.open or Gr.orientation before executing Gr.screen, otherwise the width and height values may be
set before the orientation change is complete.
Gr.screen returns a subset of the information returned by the newer Screen command.
Gr.scale x_factor, y_factor
Scale all drawing commands by the numeric x and y scale factors. This command is provided to allow
you to draw in a device-independent manner and then scale the drawing to the actual size of the screen
that your program is running on. For example:
! Set the device independent sizes
di_height = 480
di_width = 800
! Get the actual width and height
gr.open
% defaults: white, no status bar, landscape
gr.screen actual_w, actual_h
! Calculate the scale factors
scale_width = actual_w /di_width
scale_height = actual_h /di_height
! Set the scale
gr.scale scale_width, scale_height
Now, start drawing based upon di_height and di_width. The drawings will be scaled to fit the device
running the program.
Gr.cls
Clears the graphics screen. Deletes all previously drawn objects; all existing object references are invalid.
Deletes all existing Paints and resets all Gr.color or Gr.text {size|align|bold|strike|underline|skew}
settings. Disposes of the current Object List and Display List and creates a new Initial Display List.
Note: bitmaps are not deleted. They will not be drawn because no graphical objects point to them, but
the bitmaps still exist. Variables that point to them remain valid.
The Gr.render command must be called to make the cleared screen visible to the user.