Glimmr Canvas Editor

version 1/100805 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Part - The Layer Indicator

    Every turn when the layers-window is g-present:
        follow the window-drawing rules for the layers-window;
                        
    Indicated layers is a number that varies. Indicated layers is 2. [This is the number of layers in the indicator at any one time, generally the highest active layer plus 1, up to the maximum number.]

    Layer indicator margin is a number that varies. Layer indicator margin is 5.
    Layer indicator allowance is a number that varies. Layer indicator allowance is 2.

    Indicated-icon is a figure name that varies. Indicated-icon is Figure of Layer Indicated.
    Occupied-icon is a figure name that varies. Occupied-icon is Figure of Layer Occupied.
    Selected-icon is a figure name that varies. Selected-icon is Figure of Layer Selected.
    Layer-icon is a figure name that varies. Layer-icon is Figure of Layer Icon.
    Occupied-terminator is a figure name that varies. Occupied-terminator is Figure of Layer Terminator Occupied.
    Terminator-icon is a figure name that varies. Terminator-icon is Figure of Layer Terminator.
    Selected-terminator is a figure name that varies. Selected-terminator is Figure of Layer Terminator Selected.
    The scan-height is a number that varies. The scan-height is 36. [The layer icons are designed to overlap one another. The scan-height is the number of pixels, counting from the *bottom* of the original image, where that overlap begins. We use the bottom because the layer indicator is built from the bottom up.]

    A layer-element is a kind of sprite. The associated canvas is the layers-canvas.
    A layer-element has a number called the layer-index.

    Some layer-elements are defined by the Table of Layer Sprites.

    Table of Layer Sprites
    sprite  layer-index  linked replacement-command  image-ID  
    Layer_1  1  "CHANGE DEFAULT LAYER TO 1"  Figure of Layer 01  
    Layer_2  2  "CHANGE DEFAULT LAYER TO 2"  Figure of Layer 02  
    Layer_3  3  "CHANGE DEFAULT LAYER TO 3"  Figure of Layer 03  
    Layer_4  4  "CHANGE DEFAULT LAYER TO 4"  Figure of Layer 04  
    Layer_5  5  "CHANGE DEFAULT LAYER TO 5"  Figure of Layer 05  
    Layer_6  6  "CHANGE DEFAULT LAYER TO 6"  Figure of Layer 06  
    Layer_7  7  "CHANGE DEFAULT LAYER TO 7"  Figure of Layer 07  
    Layer_8  8  "CHANGE DEFAULT LAYER TO 8"  Figure of Layer 08  
    Layer_9  9  "CHANGE DEFAULT LAYER TO 9"  Figure of Layer 09  
    Layer_10  10  "CHANGE DEFAULT LAYER TO 10"  Figure of Layer 10  
    Layer_11  11  "CHANGE DEFAULT LAYER TO 11"  Figure of Layer 11  
    Layer_12  12  "CHANGE DEFAULT LAYER TO 12"  Figure of Layer 12  
    Layer_13  13  "CHANGE DEFAULT LAYER TO 13"  Figure of Layer 13  
    Layer_14  14  "CHANGE DEFAULT LAYER TO 14"  Figure of Layer 14  
    Layer_15  15  "CHANGE DEFAULT LAYER TO 15"  Figure of Layer 15  
    Layer_16  16  "CHANGE DEFAULT LAYER TO 16"  Figure of Layer 16  
    Layer_17  17  "CHANGE DEFAULT LAYER TO 17"  Figure of Layer 17  
    Layer_18  18  "CHANGE DEFAULT LAYER TO 18"  Figure of Layer 18  
    Layer_19  19  "CHANGE DEFAULT LAYER TO 19"  Figure of Layer 19  
    Layer_20  20  "CHANGE DEFAULT LAYER TO 20"  Figure of Layer 20  
    Layer_21  21  "CHANGE DEFAULT LAYER TO 21"  Figure of Layer 21  
    Layer_22  22  "CHANGE DEFAULT LAYER TO 22"  Figure of Layer 22  
    Layer_23  23  "CHANGE DEFAULT LAYER TO 23"  Figure of Layer 23  
    Layer_24  24  "CHANGE DEFAULT LAYER TO 24"  Figure of Layer 24  

            
    Layer indicator construction is a rulebook.
    The layer indicator construction rulebook has a real number called the layer indicator scaling factor.
    The layer indicator construction rulebook has a number called the layer icon width.
    The layer indicator construction rulebook has a number called the layer icon height.
    The layer indicator construction rulebook has a number called the top margin.
            
    The first layer indicator construction rule (this is the place reveal icon rule):
        if the layers-window is g-present:
            let icon be the image-ID of layer_reveal_modal;
            let dim-x be the image-width of icon;
            let dim-y be the image-height of icon;
            let elem-x be the width of the layers-window minus layer indicator allowance;
            let factor be elem-x real divided by dim-x as a fixed point number;
            let elem-y be dim-y real times factor as an integer;
            display icon in layers-window at (layer indicator allowance) by (layer indicator margin) with dimensions (elem-x) by (elem-y);
            set a graphlink in layers-window identified as layer_reveal_modal from layer indicator allowance by layer indicator margin to (layer indicator allowance + elem-x) by (layer indicator margin + elem-y) as linked replacement-command of layer_reveal_modal;
            change the top margin to layer indicator margin plus layer indicator margin plus layer indicator allowance plus elem-y;
            
    A layer indicator construction rule (this is the draw layer icons rule):
        if layers-window is g-present:
            let vertical-measure be the height of layers-window minus (top margin plus layer indicator margin);
            let horizontal-measure be the width of layers-window minus layer indicator allowance;
            let dim-x be the image-width of layer-icon;
            let dim-y be the image-height of layer-icon;
            if (vertical-measure divided by maximum display-layer) <= dim-y:
                now layer icon height is vertical-measure divided by maximum display-layer;
                let overlap-factor be dim-y real divided by scan-height as a fixed point number;
                change layer icon height to layer icon height real times overlap-factor as an integer;[This rescales the icons to account for the degree of overlap between them]
                now layer indicator scaling factor is layer icon height real divided by dim-y as a fixed point number;
                now layer icon width is dim-x real times layer indicator scaling factor as an integer;
                if layer icon width > horizontal-measure:
                    now layer icon width is horizontal-measure;
                    now layer indicator scaling factor is layer icon width real divided by dim-x as a fixed point number;
                    now layer icon height is dim-y real times layer indicator scaling factor as an integer;
            let row-scan be the scan-height real times layer indicator scaling factor as an integer;[this ensures proper overlap of layer icons]
            [Create a list of the layers represented among the sprites:]
            let present-list be a list of numbers;
            repeat with current-element running through display-active in-play g-elements:
                if the associated canvas of working window is the associated canvas of current-element:
                    if the display-layer of current-element is not listed in present-list:
                        add display-layer of current-element to present-list;
            if present-list is empty:
                now present-list is {0};
            [Create a list of the layers with selected sprites:]
            let selected-list be a list of numbers;
            if the element-selection set is empty:
                let selected-list be {0};
            otherwise:
                repeat with current-element running through element-selection set:
                    if the display-layer of current-element is not listed in selected-list:
                        add display-layer of current-element to selected-list;
                if selected-list is empty:
                    now selected-list is {0};
            [draw the appropriate layer images:]
            let col-offset be (horizontal-measure minus layer icon width) divided by 2;
            let col be layer indicator allowance plus col-offset;
            repeat with index running from 1 to indicated layers:
                let row be vertical-measure minus row-scan times (index minus 1);
                if index is the current display-layer:
                    display indicated-icon in layers-window at (col) by (row) with dimensions (layer icon width) by (layer icon height);
            let L be the list of layer-elements;
            sort L in layer-index order;
            repeat with current-element running through L:
                let index be the layer-index of current-element;
                if index > indicated layers, break;
                let row be vertical-measure minus row-scan times (index minus 1);
                if index is listed in the selected-list:
                    if index is maximum display-layer:
                        display selected-terminator in layers-window at col by row with dimensions layer icon width by layer icon height;
                    otherwise:
                        display selected-icon in layers-window at col by row with dimensions layer icon width by layer icon height;
                otherwise if index is listed in the present-list:
                    if index is maximum display-layer:
                        display occupied-terminator in layers-window at col by row with dimensions layer icon width by layer icon height;
                    otherwise:
                        display occupied-icon in layers-window at col by row with dimensions layer icon width by layer icon height;
                otherwise:
                    if index is maximum display-layer:
                        display terminator-icon in layers-window at col by row with dimensions layer icon width by layer icon height;
                    otherwise:
                        display layer-icon in layers-window at col by row with dimensions layer icon width by layer icon height;
                set a graphlink in layers-window identified as current-element from col by row to (col + layer icon width) by (row + layer icon height) as linked replacement-command of current-element;