Glimmr Canvas Editor

version 1/100805 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next

  • Section - Display and set-up for the color-picker
    [The color_picker element display rule does double duty. It's display task is to draw the "tray" in which the color chips sit. This is constructed of three images, the middle of which needs to be stretched to fit the number of color chips. So, we figure out here where *both* the color-picker and the chips will be placed, changing the origin and endpoint of each chip based on the width of the window.]

    The color_picker is a g-element. The associated canvas is the drawing-canvas. The origin is {0, 0}. The display status is g-inactive. The display-layer is 3.

    An element display rule for the color_picker:
        let x be the width of drawing-window / 2;
        let left-tiles be the number of entries of drawing colors divided by 2;
        let scan be x - (20 * left-tiles);
        let picker-width be 20 * (the number of entries of drawing colors + 1);
        display Figure of Color-Picker Left in drawing-window at (scan - 5) by 2 with dimensions 5 by 21;
        display Figure of Color-Picker Center in drawing-window at (scan) by 2 with dimensions (picker-width) by 21;
        repeat with chip running through color-chips:
            if chip is the mother color-chip:
            change entry 1 of the origin of chip to (scan + 2);
            change entry 1 of the endpoint of chip to (scan + 18);
            increase scan by 20;
        display Figure of Color-Picker Right in drawing-window at (scan) by 2;