Glimmr Canvas Editor

version 1/100805 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter - Spawning new element primitives
        
    This is the primitive creation rule:
        create a new primitive from the currently drawn element in the working window;
        follow the cancelling drawing rules.

    To create a new primitive from (X - a g-element) in (win - a g-window):
        increase the instance-counter of X by 1;
        let the new element be a new object cloned from X;
        now the new element is standard;
        change the display status of new element to g-active;
        unlink the element-name of the new element;
        change the element-name of the new element to "[kind-flag of the new element]" concatenated with the instance-counter of X;
        replace the text " " in the element-name of the new element with "_";
        replace the regular expression "\b(\w)(\w*)" in the element-name of the new element with "\u1\l2";
        [change the x-scaling factor of the new element to 1.0000;
        change the y-scaling factor of the new element to 1.0000;]
        unlink the of-kind of the new element;
        unlink the tag of the new element;
        unlink the replacement-command of the new element;
        [now the of-kind of the new element is the kind-flag of X;***]
        change the display-layer of the new element to the current display-layer;
        unlink the origin of the new element;
        unlink the endpoint of the new element;
        change the origin of the new element to first point;
        change the endpoint of the new element to second point;
        let x1 be entry 1 of the origin of the new element;
        let x2 be entry 1 of the endpoint of the new element;
        let y1 be entry 2 of the origin of the new element;
        let y2 be entry 2 of the endpoint of the new element;
        change the element-width of the new element to x2 - x1;
        change the element-height of the new element to y2 - y1;
        if the new element provides the property line-weight:
            change the line-weight of the new element to the current line-weight;
        change the tint of the new element to the current element color;
        if the new element provides the property background tint:
            change the background tint of the new element to current element background color;
        now the element-selection set is {};
        add the new element to the element-selection set;
        [follow the window-drawing rules for the layers-window;]
        say "New primitive element drawn: [element-name of new element].";