Glimmr Canvas-Based Drawing

version 2/101030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Section - Centering algorithm for primitives
    [This could be done much more concisely using the win-x/win-y and end-x/end-y properties, but these are not set until the element scaling rulebook is followed, which doesn't grant as much flexiblity. This phrase may be used anytime after the determining offsets activity.]

    To decide what list of numbers is the center-point of (item - a primitive):
        let xx be a number;
        let yy be a number;
        let x be entry 1 of the origin of item;
        let y be entry 2 of the origin of item;
        unless the item is a point primitive:
            let xx be entry 1 of the endpoint of the item;
            let yy be entry 2 of the endpoint of the item;
        otherwise:
            let x be x - (line-weight of the item / 2);
            let y be y - (line-weight of the item / 2);
            let xx be x + line-weight of item;
            let yy be y + line-weight of item;
        let x be (xx - x) / 2 + x;
        let y be (yy - y) / 2 + y;
        let coord be {0, 0};
        now entry 1 of coord is x;
        now entry 2 of coord is y;
        decide on coord.