SetScale Xsize, Ysize

This command scales all graphics to the specified Xsize and Ysize no matter what the actual screen size is. You can pick any resolution you like and it will be scaled to the screen.

For example:

Graphics On
SetScale 100,100

Here the screen is scaled to 100 x 100. In effect the screen coordinates will now be a percentage of the screen. Point 50,50 will draw a pixel in the center of the screen independent of the screen resolution.

You may want to work with the actual screen resolution of your own device. In that case you would set the scale to your own resolution. For a Droid X the screen resolution is 480 x 854. So directly following the Graphics On command you would execute:

Graphics On
SetScale 480,854

By executing this command you are declaring your target resolution. Graphics will not be scaled on a Droid X but on any other device (with a different resolution) the graphics will be scaled.

When a Graphics On command is executed the scale is reset. Therefore you must execute the SetScale command AFTER you execute Graphics On.

Touch & Screen Size

When a SetScale command is in effect the ScreenX() and ScreenY() functions will return the scaled screen size. The Touch command will also return scaled coordinates.

Bitmaps in Memory

Bitmaps in memory are not altered by the SetScale command. When bitmaps are drawn to the screen they may be scaled, but the bitmap in memory does not change. GetBitmapWidth() and GetBitmapHeight() always return the actual bitmap size.

Diagonal Radius

The problem with doing all the math internally is that some scaling decisions had to be made for you. It is easy enough to scale 100 to 480 and 200 to 800, but there had to be a way to scale circles, text and bitmaps that did not skew them. A special diagonal ratio is calculated to scale circles, text and bitmaps.

diagonal ratio = actual diagonal screen length in pixels / SetScale diagonal length

The diagonal ratio is then used to scale the circle radius, text font size and Bitmaps (both x and y). It's an approximation, but it works fairly well.

Become a Patron