Glimmr Canvas Editor

version 1/100805 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter - Control for element drawing
        
    A clicking graphlink rule when drawing mode is true and the current graphlink window is the working window (this is the click to draw rule):
        now glulx replacement command is "";
        if first point is {-999, -999}:
            change first point to the canvas equivalent of the screen coordinates (current graphlink x) by (current graphlink y) of the current graphlink window;
            if the currently drawn element is a rendered string:
                follow the string creation rule;
                follow the window-drawing rules for the working window;
                rule succeeds;
            otherwise:
                say "Now click in the editor window to set the [if the currently drawn element is a line primitive]end point[otherwise]opposite corner[end if].";
        otherwise:
            change second point to the canvas equivalent of the screen coordinates (current graphlink x) by (current graphlink y) of the current graphlink window;
            unless the currently drawn element is a line primitive:
                if entry 1 of second point < entry 1 of first point:
                    let x1 be entry 1 of first point;
                    change entry 1 of first point to entry 1 of second point;
                    change entry 1 of second point to x1;
                if entry 2 of second point < entry 2 of first point:
                    let y1 be entry 2 of first point;
                    change entry 2 of first point to entry 2 of second point;
                    change entry 2 of second point to y1;
            follow the primitive creation rule;
        follow the window-drawing rules for the working window;
        rule succeeds.
        
    The click to draw rule is listed before the clicking in pager rule in the clicking graphlink rules.

    A clicking graphlink rule when drawing mode is true and the current graphlink window is not the working window (this is the cancel drawing mode rule):
        say "[bracket]Element drawing canceled.[close bracket][paragraph break]";
        follow the cancelling drawing rules;
        now glulx replacement command is "";
        rule succeeds.

    To force-restart line input:
        (- glk_request_line_event(gg_mainwin, buffer+WORDSIZE, INPUT_BUFFER_LEN-WORDSIZE, 0); -)

    The cancel drawing mode rule is listed before the click to draw rule in the clicking graphlink rules.

    Cancelling drawing rules are a rulebook.

    A cancelling drawing rule:
        now first point is {-999, -999};
        now second point is {-999, -999};
        return to normal input;
        now drawing mode is false;
        now glulx replacement command is "";
        repeat with item running through drawing tools:
            make inactive the item;
        refresh windows.