# Glimmr Canvas-Based Drawing

## version 2/101030 by Erik Temple

**Section - Scaling rule for primitives**

[The line-weight of the lines used in primitives are scaled according to the scaling factor (or, if we are using asymmetrical scaling, the x scaling factor). If we need to prevent line-weight from changing with the window scaling, we need to place a rule applying to the appropriate primitive or class before the primitive scaling rule. This rule should now the scaling factor is the inverse of the scaling factor; i.e. if the scaling factor were 0.2500, our rule would set the scaling factor to 4.0000, thereby canceling the effect of the window-scaling on the line line-weight.]

An element scaling rule for a primitive (called the subject) (this is the primitive scaling rule):

let x-temp be entry 1 of the endpoint of the subject scaled by the scaling factor of the current window;

let y-temp be entry 2 of the endpoint of the subject scaled by the scaling factor of the current window;

now the end-x of the subject is x-temp real plus the x-offset of the current window as an integer;

now the end-y of the subject is y-temp real plus the y-offset of the current window as an integer;

if the subject provides the property line-weight:

let weight-temp be the line-weight of the subject as a fixed point number;

unless the asymmetrical scaling option is active:

now the stroke of the subject is the weight-temp real times the scaling factor of the current window real times the scaling factor of the subject as an integer;

otherwise:

now the stroke of the subject is the weight-temp real times the scaling factor of the current window real times the x-scaling factor of the subject as an integer;

if the stroke of the subject < 1, now the stroke of the subject is 1;

if the subject is center-aligned:

let dx be (end-x of the subject - win-x) / 2;

let dy be (end-y of the subject - win-y) / 2;

now the win-x is win-x - dx;

now the win-y is win-y - dy;

now the end-x is end-x - dx;

now the end-y is end-y - dy;

if the subject is right-aligned:

let dx be (end-x of the subject - win-x);

let dy be (end-y of the subject - win-y);

now the win-x is win-x - dx;

now the win-y is win-y - dy;

now the end-x is end-x - dx;

now the end-y is end-y - dy;

continue.