Server IP : 92.204.138.22 / Your IP : 18.217.183.229 Web Server : Apache System : Linux ns1009439.ip-92-204-138.us 4.18.0-553.8.1.el8_10.x86_64 #1 SMP Tue Jul 2 07:26:33 EDT 2024 x86_64 User : internationaljou ( 1019) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/graphviz/lefty/ |
Upload File : |
load ('def.lefty'); definit (); # # initialize window data # canvas = defcanvas; wrect = [0 = ['x' = 0; 'y' = 0;]; 1 = ['x' = 400; 'y' = 500;];]; setwidgetattr (canvas, ['window' = wrect;]); # # data structures # objarray = []; objnum = 0; # # misc functions # min = function (a, b) { if (a <= b) return a; return b; }; max = function (a, b) { if (b <= a) return a; return b; }; rectof = function (p1, p2) { return [ 0 = ['x' = min (p1.x, p2.x); 'y' = min (p1.y, p2.y);]; 1 = ['x' = max (p1.x, p2.x); 'y' = max (p1.y, p2.y);]; ]; }; pointadd = function (p1, p2) { return ['x' = p2.x + p1.x; 'y' = p2.y + p1.y;]; }; pointsub = function (p1, p2) { return ['x' = p2.x - p1.x; 'y' = p2.y - p1.y;]; }; # # rendering functions # drawbox = function (obj, color) { box (canvas, obj, obj.rect, ['color' = color;]); }; redrawboxes = function () { local i; clear (canvas); for (i = 0; i < objnum; i = i + 1) drawbox (objarray[i], 1); }; redraw = function (canvas) { redrawboxes (); }; # # editing functions # new = function (rect) { objarray[objnum] = [ 'rect' = rect; 'id' = objnum; ]; objnum = objnum + 1; return objarray[objnum - 1]; }; reshape = function (obj, rect) { obj.rect = rect; return obj; }; move = function (obj, p) { obj.rect[0] = pointadd (obj.rect[0], p); obj.rect[1] = pointadd (obj.rect[1], p); return obj; }; delete = function (obj) { if (obj.id ~= objnum - 1) { objarray[obj.id] = objarray[objnum - 1]; objarray[obj.id].id = obj.id; } remove (objnum - 1, objarray); objnum = objnum - 1; }; # # user interface functions # # left mouse button creates new box # middle button moves a box # right button deletes a box # leftdown = function (data) { if (data.obj ~= null) return; leftbox = new (rectof (data.pos, data.pos)); drawbox (leftbox, 1); setgfxattr (canvas, ['mode' = 'xor';]); }; leftmove = function (data) { if (~leftbox) return; drawbox (leftbox, 1); clearpick (canvas, leftbox); reshape (leftbox, rectof (data.ppos, data.pos)); drawbox (leftbox, 1); }; leftup = function (data) { if (~leftbox) return; drawbox (leftbox, 1); clearpick (canvas, leftbox); reshape (leftbox, rectof (data.ppos, data.pos)); setgfxattr (canvas, ['mode' = 'src';]); drawbox (leftbox, 1); remove ('leftbox'); }; middledown = function (data) { if (data.obj == null) return; middlebox = data.obj; middlepos = data.pos; setgfxattr (canvas, ['mode' = 'xor';]); }; middlemove = function (data) { if (~middlebox) return; drawbox (middlebox, 1); clearpick (canvas, middlebox); move (middlebox, pointsub (middlepos, data.pos)); middlepos = data.pos; drawbox (middlebox, 1); }; middleup = function (data) { if (~middlebox) return; drawbox (middlebox, 1); clearpick (canvas, middlebox); move (middlebox, pointsub (middlepos, data.pos)); setgfxattr (canvas, ['mode' = 'src';]); drawbox (middlebox, 1); remove ('middlepos'); remove ('middlebox'); }; rightup = function (data) { if (data.pobj == null) return; drawbox (data.obj, 0); clearpick (canvas, data.obj); delete (data.obj); }; dops = function () { local s; s = ['x' = 8 * 300; 'y' = 10.5 * 300;]; canvas = createwidget (-1, ['type' = 'ps'; 'size' = s;]); setwidgetattr (canvas, ['window' = wrect;]); redraw (canvas); destroywidget (canvas); canvas=defcanvas; };