From a8f804837c21d71a6fa5adc127d9b64eb23c47ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?llu=C3=ADs=20g=C3=B3mez=20i=20bigord=C3=A0?= Date: Fri, 23 May 2008 20:46:28 +0000 Subject: changed the code to be in a single file colorgrid.c moved the help patch to a more common name svn path=/trunk/externals/pdvjtools/; revision=9871 --- colorgrid/base64.tcl | 29 ------ colorgrid/colorgrid-help.pd | 47 ++++++++++ colorgrid/colorgrid.c | 209 ++++++++++++++++++++++++++++++++------------ colorgrid/colorgrid.tk | 88 ------------------- colorgrid/colorgrid.tk2c | 66 -------------- colorgrid/g_colorgrid.h | 39 --------- colorgrid/help-colorgrid.pd | 47 ---------- colorgrid/tk2c.bash | 24 ----- 8 files changed, 199 insertions(+), 350 deletions(-) delete mode 100644 colorgrid/base64.tcl create mode 100755 colorgrid/colorgrid-help.pd delete mode 100755 colorgrid/colorgrid.tk delete mode 100755 colorgrid/colorgrid.tk2c delete mode 100755 colorgrid/g_colorgrid.h delete mode 100755 colorgrid/help-colorgrid.pd delete mode 100755 colorgrid/tk2c.bash diff --git a/colorgrid/base64.tcl b/colorgrid/base64.tcl deleted file mode 100644 index 26ad408..0000000 --- a/colorgrid/base64.tcl +++ /dev/null @@ -1,29 +0,0 @@ - package require base64 - - proc encode {} { - .txt delete 1.0 end - set fileID [open [tk_getOpenFile] RDONLY] - fconfigure $fileID -translation binary - set rawData [read $fileID] - close $fileID - set encodedData [base64::encode $rawData] - .txt insert 1.0 $encodedData - } - - proc clipcopy {} { - clipboard clear - clipboard append [.txt get 1.0 end] - } - - wm title . "Base64 Gif Encoder" - text .txt -wrap none -font "Courier 10" - menu .mbar - . configure -menu .mbar - .mbar add command -label "Encode File" -command encode - .mbar add command -label "Copy2Clipboard" -command clipcopy - .mbar add command -label "Exit" -command {destroy .; exit} - - pack .txt -expand 1 -fill both - - encode - ### End of Script diff --git a/colorgrid/colorgrid-help.pd b/colorgrid/colorgrid-help.pd new file mode 100755 index 0000000..77af92b --- /dev/null +++ b/colorgrid/colorgrid-help.pd @@ -0,0 +1,47 @@ +#N canvas 26 1 762 514 10; +#X floatatom 93 434 5 0 0 0 - - -; +#X floatatom 217 434 5 0 0 0 - - -; +#X floatatom 430 220 5 0 0 0 - - -; +#X floatatom 496 220 5 0 0 0 - - -; +#X obj 430 245 pack f f; +#X text 471 221 X; +#X text 537 220 Y; +#X msg 93 131 bang; +#X floatatom 342 431 5 0 0 0 - - -; +#X text 93 451 R; +#X text 217 450 G; +#X text 342 445 B; +#X text 39 12 Grid is a 2-dimensional color picker; +#X text 39 25 Written by Lluis Gomez i Bigorda ( lluis@artefacte.org +); +#X text 39 39 ( inspired by the grid object written by Yves Degoyon +); +#X msg 339 246 xgoto \$1 \$2; +#X text 330 195 Set position without changing output:; +#X obj 496 246 t b f; +#X floatatom 430 133 5 0 0 0 - - -; +#X floatatom 496 133 5 0 0 0 - - -; +#X obj 430 158 pack f f; +#X text 471 134 X; +#X text 537 133 Y; +#X obj 496 159 t b f; +#X text 330 108 Set position :; +#X msg 339 159 goto \$1 \$2; +#X obj 90 376 colorgrid colorgrid1 256 0 256 50 0 50 0 1 1 10 10 147 +392.06; +#X connect 2 0 4 0; +#X connect 3 0 17 0; +#X connect 4 0 15 0; +#X connect 7 0 26 0; +#X connect 15 0 26 0; +#X connect 17 0 4 0; +#X connect 17 1 4 1; +#X connect 18 0 20 0; +#X connect 19 0 23 0; +#X connect 20 0 25 0; +#X connect 23 0 20 0; +#X connect 23 1 20 1; +#X connect 25 0 26 0; +#X connect 26 0 0 0; +#X connect 26 1 1 0; +#X connect 26 2 8 0; diff --git a/colorgrid/colorgrid.c b/colorgrid/colorgrid.c index a653c0f..fbd39e8 100755 --- a/colorgrid/colorgrid.c +++ b/colorgrid/colorgrid.c @@ -16,7 +16,6 @@ #include "m_imp.h" #include "g_canvas.h" #include "t_tk.h" -#include "g_colorgrid.h" #ifdef NT #include @@ -29,6 +28,103 @@ #define DEFAULT_COLORGRID_HEIGHT 50 #define DEFAULT_COLORGRID_NBLINES 10 +typedef struct _colorgrid +{ + t_object x_obj; + t_glist *x_glist; + t_symbol *x_name; + t_outlet *x_xoutlet; + t_outlet *x_youtlet; + t_outlet *x_zoutlet; + int x_null; /* To dissable resize */ + int x_height; /* height of the colorgrid */ + t_float x_min; /* minimum value of x */ + t_float x_max; /* max value of x */ + int x_width; /* width of the colorgrid */ + t_float y_min; /* minimum value of y */ + t_float y_max; /* max value of y */ + t_float x_current; /* x coordinate of current position */ + t_float y_current; /* y coordinate of current position */ + int x_selected; /* stores selected state */ + int x_point; /* indicates if a point is plotted */ + int x_colorgrid; /* indicates if a colorgrid is requested */ + t_float x_xstep; /* sets the step ( grain ) for x */ + t_float x_ystep; /* sets the step ( grain ) for y */ + int x_xlines; /* number of vertical lines */ + int x_ylines; /* number of horizontal lines */ + t_symbol* x_fname; +} t_colorgrid; + +void load_tk_procs () { + // ########### colorgrid procedures -- ydegoyon@free.fr ######### + // package require Img + sys_gui("package require base64\n"); + sys_gui("proc colorgrid_apply {id} {\n"); + // strip "." from the TK id to make a variable name suffix + sys_gui("set vid [string trimleft $id .]\n"); + // for each variable, make a local variable to hold its name... + sys_gui("set var_graph_colorgrid [concat graph_colorgrid_$vid]\n"); + sys_gui("global $var_graph_colorgrid\n"); + sys_gui("set var_graph_xlines [concat graph_xlines_$vid]\n"); + sys_gui("global $var_graph_xlines\n"); + sys_gui("set var_graph_ylines [concat graph_ylines_$vid]\n"); + sys_gui("global $var_graph_ylines\n"); + sys_gui("set cmd [concat $id dialog [eval concat $$var_graph_xlines] [eval concat $$var_graph_ylines] [eval concat $$var_graph_colorgrid] \\;]\n"); + // puts stderr $cmd + sys_gui("pd $cmd\n"); + sys_gui("}\n"); + sys_gui("proc colorgrid_cancel {id} {\n"); + sys_gui("set cmd [concat $id cancel \\;]\n"); + // puts stderr $cmd + sys_gui("pd $cmd\n"); + sys_gui("}\n"); + sys_gui("proc colorgrid_ok {id} {\n"); + sys_gui("colorgrid_apply $id\n"); + sys_gui("colorgrid_cancel $id\n"); + sys_gui("}\n"); + sys_gui("proc pdtk_colorgrid_dialog {id xlines ylines colorgrid} {\n"); + sys_gui("set vid [string trimleft $id .]\n"); + sys_gui("set var_graph_colorgrid [concat graph_colorgrid_$vid]\n"); + sys_gui("global $var_graph_colorgrid\n"); + sys_gui("set var_graph_xlines [concat graph_xlines_$vid]\n"); + sys_gui("global $var_graph_xlines\n"); + sys_gui("set var_graph_ylines [concat graph_ylines_$vid]\n"); + sys_gui("global $var_graph_ylines\n"); + sys_gui("set $var_graph_colorgrid $colorgrid\n"); + sys_gui("set $var_graph_xlines $xlines\n"); + sys_gui("set $var_graph_ylines $ylines\n"); + sys_gui("toplevel $id\n"); + sys_gui("wm title $id {colorgrid}\n"); + sys_gui("wm protocol $id WM_DELETE_WINDOW [concat colorgrid_cancel $id]\n"); + sys_gui("label $id.label -text {COLORGRID PROPERTIES}\n"); + sys_gui("pack $id.label -side top\n"); + sys_gui("frame $id.buttonframe\n"); + sys_gui("pack $id.buttonframe -side bottom -fill x -pady 2m\n"); + sys_gui("button $id.buttonframe.cancel -text {Cancel} -command \"colorgrid_cancel $id\"\n"); + sys_gui("button $id.buttonframe.apply -text {Apply} -command \"colorgrid_apply $id\"\n"); + sys_gui("button $id.buttonframe.ok -text {OK} -command \"colorgrid_ok $id\"\n"); + sys_gui("pack $id.buttonframe.cancel -side left -expand 1\n"); + sys_gui("pack $id.buttonframe.apply -side left -expand 1\n"); + sys_gui("pack $id.buttonframe.ok -side left -expand 1\n"); + sys_gui("frame $id.42rangef\n"); + sys_gui("pack $id.42rangef -side top\n"); + sys_gui("label $id.42rangef.lxlines -text \"X sections :\"\n"); + sys_gui("entry $id.42rangef.xlines -textvariable $var_graph_xlines -width 7\n"); + sys_gui("pack $id.42rangef.lxlines $id.42rangef.xlines -side left\n"); + sys_gui("frame $id.72rangef\n"); + sys_gui("pack $id.72rangef -side top\n"); + sys_gui("label $id.72rangef.lylines -text \"Y sections :\"\n"); + sys_gui("entry $id.72rangef.ylines -textvariable $var_graph_ylines -width 7\n"); + sys_gui("pack $id.72rangef.lylines $id.72rangef.ylines -side left\n"); + sys_gui("checkbutton $id.showcolorgrid -text {Show Grid} -variable $var_graph_colorgrid -anchor w\n"); + sys_gui("pack $id.showcolorgrid -side top\n"); + sys_gui("bind $id.42rangef.xlines [concat colorgrid_ok $id]\n"); + sys_gui("bind $id.72rangef.ylines [concat colorgrid_ok $id]\n"); + sys_gui("focus $id.42rangef.xlines\n"); + sys_gui("}\n"); + // ########### colorgrid procedures END -- lluis@artefacte.org ######### +} + t_widgetbehavior colorgrid_widgetbehavior; static t_class *colorgrid_class; static int colorgridcount=0; @@ -85,12 +181,12 @@ static void colorgrid_draw_update(t_colorgrid *x, t_glist *glist) COLORGRID_SYS_VGUI3(".x%x.c delete %xPOINT\n", canvas, x); } - if ( x->x_current < text_xpix(&x->x_obj, x->x_glist) ) xpoint = text_xpix(&x->x_obj, x->x_glist); - if ( x->x_current > text_xpix(&x->x_obj, x->x_glist) + x->x_width - pointsize ) - xpoint = text_xpix(&x->x_obj, x->x_glist) + x->x_width - pointsize; - if ( x->y_current < text_ypix(&x->x_obj, x->x_glist) ) ypoint = text_ypix(&x->x_obj, x->x_glist); - if ( x->y_current > text_ypix(&x->x_obj, x->x_glist) + x->x_height - pointsize ) - ypoint = text_ypix(&x->x_obj, x->x_glist) + x->x_height - pointsize; + if ( x->x_current < x->x_obj.te_xpix ) xpoint = x->x_obj.te_xpix; + if ( x->x_current > x->x_obj.te_xpix + x->x_width - pointsize ) + xpoint = x->x_obj.te_xpix + x->x_width - pointsize; + if ( x->y_current < x->x_obj.te_ypix ) ypoint = x->x_obj.te_ypix; + if ( x->y_current > x->x_obj.te_ypix + x->x_height - pointsize ) + ypoint = x->x_obj.te_ypix + x->x_height - pointsize; // draw the selected point COLORGRID_SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -outline {} -fill #FF0000 -tags %xPOINT\n", canvas, xpoint, ypoint, xpoint+5, ypoint+5, x); @@ -970,46 +1066,46 @@ zNL4zNH4zND4zM/4zM74zM341dX41dX41tX419X42NX42dX42tX42tX429X4\ //post("%s",tagRoot); - COLORGRID_SYS_VGUI3("image create photo img%x -data {%s}\n",x,fdata); + COLORGRID_SYS_VGUI3("image create photo img%x -data [base64::decode {%s}]\n",x,fdata); COLORGRID_SYS_VGUI6(".x%x.c create image %d %d -image img%x -tags %sS\n", canvas,text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),x,tagRoot); COLORGRID_SYS_VGUI5(".x%x.c coords %sS %d %d \n", canvas, tagRoot, - text_xpix(&x->x_obj, x->x_glist) + 128, text_ypix(&x->x_obj, x->x_glist) + 25); + x->x_obj.te_xpix + 128, x->x_obj.te_ypix + 25); COLORGRID_SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -tags %so0\n", - canvas, text_xpix(&x->x_obj, x->x_glist), text_ypix(&x->x_obj, x->x_glist) + x->x_height+1, - text_xpix(&x->x_obj, x->x_glist)+7, text_ypix(&x->x_obj, x->x_glist) + x->x_height+2, + canvas, x->x_obj.te_xpix, x->x_obj.te_ypix + x->x_height+1, + x->x_obj.te_xpix+7, x->x_obj.te_ypix + x->x_height+2, tagRoot); COLORGRID_SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -tags %so1\n", - canvas, text_xpix(&x->x_obj, x->x_glist)+x->x_width-7, text_ypix(&x->x_obj, x->x_glist) + x->x_height+1, - text_xpix(&x->x_obj, x->x_glist)+x->x_width, text_ypix(&x->x_obj, x->x_glist) + x->x_height+2, + canvas, x->x_obj.te_xpix+x->x_width-7, x->x_obj.te_ypix + x->x_height+1, + x->x_obj.te_xpix+x->x_width, x->x_obj.te_ypix + x->x_height+2, tagRoot); COLORGRID_SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -tags %so2\n", - canvas, text_xpix(&x->x_obj, x->x_glist)+x->x_width-131, text_ypix(&x->x_obj, x->x_glist) + x->x_height+1, - text_xpix(&x->x_obj, x->x_glist)+x->x_width-126, text_ypix(&x->x_obj, x->x_glist) + x->x_height+2, + canvas, x->x_obj.te_xpix+x->x_width-131, x->x_obj.te_ypix + x->x_height+1, + x->x_obj.te_xpix+x->x_width-126, x->x_obj.te_ypix + x->x_height+2, tagRoot); if ( x->x_colorgrid ) { - int xlpos = text_xpix(&x->x_obj, x->x_glist)+x->x_width/x->x_xlines; - int ylpos = text_ypix(&x->x_obj, x->x_glist)+x->x_height/x->x_ylines; + int xlpos = x->x_obj.te_xpix+x->x_width/x->x_xlines; + int ylpos = x->x_obj.te_ypix+x->x_height/x->x_ylines; int xcount = 1; int ycount = 1; - while ( xlpos < text_xpix(&x->x_obj, x->x_glist)+x->x_width ) + while ( xlpos < x->x_obj.te_xpix+x->x_width ) { COLORGRID_SYS_VGUI9(".x%x.c create line %d %d %d %d -fill #FFFFFF -tags %xLINE%d%d\n", - canvas, xlpos, text_ypix(&x->x_obj, x->x_glist), - xlpos, text_ypix(&x->x_obj, x->x_glist)+x->x_height, + canvas, xlpos, x->x_obj.te_ypix, + xlpos, x->x_obj.te_ypix+x->x_height, x, xcount, 0 ); xlpos+=x->x_width/x->x_xlines; xcount++; } - while ( ylpos < text_ypix(&x->x_obj, x->x_glist)+x->x_height ) + while ( ylpos < x->x_obj.te_ypix+x->x_height ) { COLORGRID_SYS_VGUI9(".x%x.c create line %d %d %d %d -fill #FFFFFF -tags %xLINE%d%d\n", - canvas, text_xpix(&x->x_obj, x->x_glist), ylpos, - text_xpix(&x->x_obj, x->x_glist)+x->x_width, ylpos, + canvas, x->x_obj.te_xpix, ylpos, + x->x_obj.te_xpix+x->x_width, ylpos, x, 0, ycount); ylpos+=x->x_height/x->x_ylines; ycount++; @@ -1026,46 +1122,46 @@ static void colorgrid_draw_move(t_colorgrid *x, t_glist *glist) tagRoot = rtext_gettag(glist_findrtext(glist,(t_text *)x)); COLORGRID_SYS_VGUI7(".x%x.c coords %xCOLORGRID %d %d %d %d\n", canvas, x, - text_xpix(&x->x_obj, x->x_glist), text_ypix(&x->x_obj, x->x_glist), - text_xpix(&x->x_obj, x->x_glist)+x->x_width, text_ypix(&x->x_obj, x->x_glist)+x->x_height); + x->x_obj.te_xpix, x->x_obj.te_ypix, + x->x_obj.te_xpix+x->x_width, x->x_obj.te_ypix+x->x_height); COLORGRID_SYS_VGUI5(".x%x.c coords %sS %d %d \n", canvas, tagRoot, - text_xpix(&x->x_obj, x->x_glist) + 128, text_ypix(&x->x_obj, x->x_glist) + 25); + x->x_obj.te_xpix + 128, x->x_obj.te_ypix + 25); COLORGRID_SYS_VGUI7(".x%x.c coords %so0 %d %d %d %d\n", canvas, tagRoot, - text_xpix(&x->x_obj, x->x_glist), text_ypix(&x->x_obj, x->x_glist) + x->x_height+1, - text_xpix(&x->x_obj, x->x_glist)+7, text_ypix(&x->x_obj, x->x_glist) + x->x_height+2 ); + x->x_obj.te_xpix, x->x_obj.te_ypix + x->x_height+1, + x->x_obj.te_xpix+7, x->x_obj.te_ypix + x->x_height+2 ); COLORGRID_SYS_VGUI7(".x%x.c coords %so1 %d %d %d %d\n", canvas, tagRoot, - text_xpix(&x->x_obj, x->x_glist)+x->x_width-7, text_ypix(&x->x_obj, x->x_glist) + x->x_height+1, - text_xpix(&x->x_obj, x->x_glist)+x->x_width, text_ypix(&x->x_obj, x->x_glist) + x->x_height+2 ); + x->x_obj.te_xpix+x->x_width-7, x->x_obj.te_ypix + x->x_height+1, + x->x_obj.te_xpix+x->x_width, x->x_obj.te_ypix + x->x_height+2 ); COLORGRID_SYS_VGUI7(".x%x.c coords %so2 %d %d %d %d\n", canvas, tagRoot, - text_xpix(&x->x_obj, x->x_glist)+x->x_width-131, text_ypix(&x->x_obj, x->x_glist) + x->x_height+1, - text_xpix(&x->x_obj, x->x_glist)+x->x_width-126, text_ypix(&x->x_obj, x->x_glist) + x->x_height+2 ); + x->x_obj.te_xpix+x->x_width-131, x->x_obj.te_ypix + x->x_height+1, + x->x_obj.te_xpix+x->x_width-126, x->x_obj.te_ypix + x->x_height+2 ); if ( x->x_point ) { colorgrid_draw_update(x, glist); } if ( x->x_colorgrid ) { - int xlpos = text_xpix(&x->x_obj, x->x_glist)+x->x_width/x->x_xlines; - int ylpos = text_ypix(&x->x_obj, x->x_glist)+x->x_height/x->x_ylines; + int xlpos = x->x_obj.te_xpix+x->x_width/x->x_xlines; + int ylpos = x->x_obj.te_ypix+x->x_height/x->x_ylines; int xcount = 1; int ycount = 1; - while ( xlpos < text_xpix(&x->x_obj, x->x_glist)+x->x_width ) + while ( xlpos < x->x_obj.te_xpix+x->x_width ) { COLORGRID_SYS_VGUI9(".x%x.c coords %xLINE%d%d %d %d %d %d\n", - canvas, x, xcount, 0, xlpos, text_ypix(&x->x_obj, x->x_glist), - xlpos, text_ypix(&x->x_obj, x->x_glist) + x->x_height); + canvas, x, xcount, 0, xlpos, x->x_obj.te_ypix, + xlpos, x->x_obj.te_ypix + x->x_height); xlpos+=x->x_width/x->x_xlines; xcount++; } - while ( ylpos < text_ypix(&x->x_obj, x->x_glist)+x->x_height ) + while ( ylpos < x->x_obj.te_ypix+x->x_height ) { COLORGRID_SYS_VGUI9(".x%x.c coords %xLINE%d%d %d %d %d %d\n", - canvas, x, 0, ycount, text_xpix(&x->x_obj, x->x_glist), ylpos, - text_xpix(&x->x_obj, x->x_glist) + x->x_width, ylpos); + canvas, x, 0, ycount, x->x_obj.te_xpix, ylpos, + x->x_obj.te_xpix + x->x_width, ylpos); ylpos+=x->x_height/x->x_ylines; ycount++; } @@ -1195,12 +1291,12 @@ static void colorgrid_output_current(t_colorgrid* x) t_float xvalue, yvalue, rvalue, gvalue, bvalue; t_float xmodstep, ymodstep; - xvalue = x->x_min + (x->x_current - text_xpix(&x->x_obj, x->x_glist)) * (x->x_max-x->x_min) / x->x_width ; + xvalue = x->x_min + (x->x_current - x->x_obj.te_xpix) * (x->x_max-x->x_min) / x->x_width ; if (xvalue < x->x_min ) xvalue = x->x_min; if (xvalue > x->x_max ) xvalue = x->x_max; xmodstep = ((float)((int)(xvalue*10000) % (int)(x->x_xstep*10000))/10000.); xvalue = xvalue - xmodstep; - yvalue = x->y_max - (x->y_current - text_ypix(&x->x_obj, x->x_glist) ) * (x->y_max-x->y_min) / x->x_height ; + yvalue = x->y_max - (x->y_current - x->x_obj.te_ypix ) * (x->y_max-x->y_min) / x->x_height ; if (yvalue < x->y_min ) yvalue = x->y_min; if (yvalue > x->y_max ) yvalue = x->y_max; ymodstep = ((float)((int)(yvalue*10000) % (int)(x->x_ystep*10000))/10000.); @@ -1262,10 +1358,10 @@ static void colorgrid_getrect(t_gobj *z, t_glist *owner, { t_colorgrid* x = (t_colorgrid*)z; - *xp1 = text_xpix(&x->x_obj, x->x_glist); - *yp1 = text_ypix(&x->x_obj, x->x_glist); - *xp2 = text_xpix(&x->x_obj, x->x_glist)+x->x_width; - *yp2 = text_ypix(&x->x_obj, x->x_glist)+x->x_height; + *xp1 = x->x_obj.te_xpix; + *yp1 = x->x_obj.te_ypix; + *xp2 = x->x_obj.te_xpix+x->x_width; + *yp2 = x->x_obj.te_ypix+x->x_height; } static void colorgrid_save(t_gobj *z, t_binbuf *b) @@ -1275,8 +1371,7 @@ static void colorgrid_save(t_gobj *z, t_binbuf *b) // post( "saving colorgrid : %s", x->x_name->s_name ); binbuf_addv(b, "ssiissiffiffiffiiff", gensym("#X"),gensym("obj"), (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix, - atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), - x->x_name, x->x_width, x->x_min, + gensym("colorgrid"), x->x_name, x->x_width, x->x_min, x->x_max, x->x_height, x->y_min, x->y_max, x->x_colorgrid, x->x_xstep, @@ -1346,8 +1441,8 @@ static void colorgrid_delete(t_gobj *z, t_glist *glist) static void colorgrid_displace(t_gobj *z, t_glist *glist, int dx, int dy) { t_colorgrid *x = (t_colorgrid *)z; - int xold = text_xpix(&x->x_obj, x->x_glist); - int yold = text_ypix(&x->x_obj, x->x_glist); + int xold = x->x_obj.te_xpix; + int yold = x->x_obj.te_ypix; // post( "colorgrid_displace dx=%d dy=%d", dx, dy ); @@ -1355,7 +1450,7 @@ static void colorgrid_displace(t_gobj *z, t_glist *glist, int dx, int dy) x->x_current += dx; x->x_obj.te_ypix += dy; x->y_current += dy; - if(xold != text_xpix(&x->x_obj, x->x_glist) || yold != text_ypix(&x->x_obj, x->x_glist)) + if(xold != x->x_obj.te_xpix || yold != x->x_obj.te_ypix) { colorgrid_draw_move(x, x->x_glist); } @@ -1407,8 +1502,8 @@ static void colorgrid_goto(t_colorgrid *x, t_floatarg newx, t_floatarg newy) // post( "colorgrid_set x=%f y=%f", newx, newy ); - x->x_current = newx + text_xpix(&x->x_obj, x->x_glist); - x->y_current = newy + text_ypix(&x->x_obj, x->x_glist); + x->x_current = newx + x->x_obj.te_xpix; + x->y_current = newy + x->x_obj.te_ypix; if(xold != x->x_current || yold != x->y_current) { colorgrid_output_current(x); @@ -1428,8 +1523,8 @@ static void colorgrid_xgoto(t_colorgrid *x, t_floatarg newx, t_floatarg newy) // post( "colorgrid_set x=%f y=%f", newx, newy ); - x->x_current = newx + text_xpix(&x->x_obj, x->x_glist); - x->y_current = newy + text_ypix(&x->x_obj, x->x_glist); + x->x_current = newx + x->x_obj.te_xpix; + x->y_current = newy + x->x_obj.te_ypix; if(xold != x->x_current || yold != x->y_current) { colorgrid_draw_update(x, x->x_glist); @@ -1538,7 +1633,7 @@ static void colorgrid_free(t_colorgrid *x) void colorgrid_setup(void) { -#include "colorgrid.tk2c" + load_tk_procs(); post ( colorgrid_version ); colorgrid_class = class_new(gensym("colorgrid"), (t_newmethod)colorgrid_new, (t_method)colorgrid_free, sizeof(t_colorgrid), 0, A_GIMME, 0); @@ -1558,5 +1653,5 @@ void colorgrid_setup(void) class_setwidget(colorgrid_class, &colorgrid_widgetbehavior); class_setpropertiesfn(colorgrid_class, colorgrid_properties); class_setsavefn(colorgrid_class, colorgrid_save); - class_sethelpsymbol(colorgrid_class, gensym("help-colorgrid.pd")); + class_sethelpsymbol(colorgrid_class, gensym("colorgrid-help.pd")); } diff --git a/colorgrid/colorgrid.tk b/colorgrid/colorgrid.tk deleted file mode 100755 index b5bb173..0000000 --- a/colorgrid/colorgrid.tk +++ /dev/null @@ -1,88 +0,0 @@ -############ colorgrid procedures -- ydegoyon@free.fr ######### -package require Img - -proc colorgrid_apply {id} { -# strip "." from the TK id to make a variable name suffix - set vid [string trimleft $id .] -# for each variable, make a local variable to hold its name... - set var_graph_colorgrid [concat graph_colorgrid_$vid] - global $var_graph_colorgrid - set var_graph_xlines [concat graph_xlines_$vid] - global $var_graph_xlines - set var_graph_ylines [concat graph_ylines_$vid] - global $var_graph_ylines - - set cmd [concat $id dialog \ - [eval concat $$var_graph_xlines] \ - [eval concat $$var_graph_ylines] \ - [eval concat $$var_graph_colorgrid] \ - \;] - #puts stderr $cmd - pd $cmd -} - -proc colorgrid_cancel {id} { - set cmd [concat $id cancel \;] - #puts stderr $cmd - pd $cmd -} - -proc colorgrid_ok {id} { - colorgrid_apply $id - colorgrid_cancel $id -} - -proc pdtk_colorgrid_dialog {id xlines ylines colorgrid} { - set vid [string trimleft $id .] - set var_graph_colorgrid [concat graph_colorgrid_$vid] - global $var_graph_colorgrid - set var_graph_xlines [concat graph_xlines_$vid] - global $var_graph_xlines - set var_graph_ylines [concat graph_ylines_$vid] - global $var_graph_ylines - - set $var_graph_colorgrid $colorgrid - set $var_graph_xlines $xlines - set $var_graph_ylines $ylines - - toplevel $id - wm title $id {colorgrid} - wm protocol $id WM_DELETE_WINDOW [concat colorgrid_cancel $id] - - label $id.label -text {COLORGRID PROPERTIES} - pack $id.label -side top - - frame $id.buttonframe - pack $id.buttonframe -side bottom -fill x -pady 2m - button $id.buttonframe.cancel -text {Cancel}\ - -command "colorgrid_cancel $id" - button $id.buttonframe.apply -text {Apply}\ - -command "colorgrid_apply $id" - button $id.buttonframe.ok -text {OK}\ - -command "colorgrid_ok $id" - pack $id.buttonframe.cancel -side left -expand 1 - pack $id.buttonframe.apply -side left -expand 1 - pack $id.buttonframe.ok -side left -expand 1 - - frame $id.42rangef - pack $id.42rangef -side top - label $id.42rangef.lxlines -text "X sections :" - entry $id.42rangef.xlines -textvariable $var_graph_xlines -width 7 - pack $id.42rangef.lxlines $id.42rangef.xlines -side left - - frame $id.72rangef - pack $id.72rangef -side top - label $id.72rangef.lylines -text "Y sections :" - entry $id.72rangef.ylines -textvariable $var_graph_ylines -width 7 - pack $id.72rangef.lylines $id.72rangef.ylines -side left - - checkbutton $id.showcolorgrid -text {Show Grid} -variable $var_graph_colorgrid \ - -anchor w - pack $id.showcolorgrid -side top - - bind $id.42rangef.xlines [concat colorgrid_ok $id] - bind $id.72rangef.ylines [concat colorgrid_ok $id] - focus $id.42rangef.xlines -} - -############ colorgrid procedures END -- lluis@artefacte.org ######### diff --git a/colorgrid/colorgrid.tk2c b/colorgrid/colorgrid.tk2c deleted file mode 100755 index 6e6abec..0000000 --- a/colorgrid/colorgrid.tk2c +++ /dev/null @@ -1,66 +0,0 @@ -// ########### colorgrid procedures -- ydegoyon@free.fr ######### -sys_gui("package require Img\n"); -sys_gui("proc colorgrid_apply {id} {\n"); -// strip "." from the TK id to make a variable name suffix -sys_gui("set vid [string trimleft $id .]\n"); -// for each variable, make a local variable to hold its name... -sys_gui("set var_graph_colorgrid [concat graph_colorgrid_$vid]\n"); -sys_gui("global $var_graph_colorgrid\n"); -sys_gui("set var_graph_xlines [concat graph_xlines_$vid]\n"); -sys_gui("global $var_graph_xlines\n"); -sys_gui("set var_graph_ylines [concat graph_ylines_$vid]\n"); -sys_gui("global $var_graph_ylines\n"); -sys_gui("set cmd [concat $id dialog [eval concat $$var_graph_xlines] [eval concat $$var_graph_ylines] [eval concat $$var_graph_colorgrid] \\;]\n"); -// puts stderr $cmd -sys_gui("pd $cmd\n"); -sys_gui("}\n"); -sys_gui("proc colorgrid_cancel {id} {\n"); -sys_gui("set cmd [concat $id cancel \\;]\n"); -// puts stderr $cmd -sys_gui("pd $cmd\n"); -sys_gui("}\n"); -sys_gui("proc colorgrid_ok {id} {\n"); -sys_gui("colorgrid_apply $id\n"); -sys_gui("colorgrid_cancel $id\n"); -sys_gui("}\n"); -sys_gui("proc pdtk_colorgrid_dialog {id xlines ylines colorgrid} {\n"); -sys_gui("set vid [string trimleft $id .]\n"); -sys_gui("set var_graph_colorgrid [concat graph_colorgrid_$vid]\n"); -sys_gui("global $var_graph_colorgrid\n"); -sys_gui("set var_graph_xlines [concat graph_xlines_$vid]\n"); -sys_gui("global $var_graph_xlines\n"); -sys_gui("set var_graph_ylines [concat graph_ylines_$vid]\n"); -sys_gui("global $var_graph_ylines\n"); -sys_gui("set $var_graph_colorgrid $colorgrid\n"); -sys_gui("set $var_graph_xlines $xlines\n"); -sys_gui("set $var_graph_ylines $ylines\n"); -sys_gui("toplevel $id\n"); -sys_gui("wm title $id {colorgrid}\n"); -sys_gui("wm protocol $id WM_DELETE_WINDOW [concat colorgrid_cancel $id]\n"); -sys_gui("label $id.label -text {COLORGRID PROPERTIES}\n"); -sys_gui("pack $id.label -side top\n"); -sys_gui("frame $id.buttonframe\n"); -sys_gui("pack $id.buttonframe -side bottom -fill x -pady 2m\n"); -sys_gui("button $id.buttonframe.cancel -text {Cancel} -command \"colorgrid_cancel $id\"\n"); -sys_gui("button $id.buttonframe.apply -text {Apply} -command \"colorgrid_apply $id\"\n"); -sys_gui("button $id.buttonframe.ok -text {OK} -command \"colorgrid_ok $id\"\n"); -sys_gui("pack $id.buttonframe.cancel -side left -expand 1\n"); -sys_gui("pack $id.buttonframe.apply -side left -expand 1\n"); -sys_gui("pack $id.buttonframe.ok -side left -expand 1\n"); -sys_gui("frame $id.42rangef\n"); -sys_gui("pack $id.42rangef -side top\n"); -sys_gui("label $id.42rangef.lxlines -text \"X sections :\"\n"); -sys_gui("entry $id.42rangef.xlines -textvariable $var_graph_xlines -width 7\n"); -sys_gui("pack $id.42rangef.lxlines $id.42rangef.xlines -side left\n"); -sys_gui("frame $id.72rangef\n"); -sys_gui("pack $id.72rangef -side top\n"); -sys_gui("label $id.72rangef.lylines -text \"Y sections :\"\n"); -sys_gui("entry $id.72rangef.ylines -textvariable $var_graph_ylines -width 7\n"); -sys_gui("pack $id.72rangef.lylines $id.72rangef.ylines -side left\n"); -sys_gui("checkbutton $id.showcolorgrid -text {Show Grid} -variable $var_graph_colorgrid -anchor w\n"); -sys_gui("pack $id.showcolorgrid -side top\n"); -sys_gui("bind $id.42rangef.xlines [concat colorgrid_ok $id]\n"); -sys_gui("bind $id.72rangef.ylines [concat colorgrid_ok $id]\n"); -sys_gui("focus $id.42rangef.xlines\n"); -sys_gui("}\n"); -// ########### colorgrid procedures END -- lluis@artefacte.org ######### diff --git a/colorgrid/g_colorgrid.h b/colorgrid/g_colorgrid.h deleted file mode 100755 index 27694ef..0000000 --- a/colorgrid/g_colorgrid.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (c) 2002 Yves Degoyon -* For information on usage and redistribution, and for a DISCLAIMER OF ALL -* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ - -/* a header for colorgrid which enables to control -* 2 parameters with the mouse cursor -*/ - -#ifndef __G_COLORGRID_H -#define __G_COLORGRID_H - -typedef struct _colorgrid -{ - t_object x_obj; - t_glist *x_glist; - t_symbol *x_name; - t_outlet *x_xoutlet; - t_outlet *x_youtlet; - t_outlet *x_zoutlet; - int x_null; /* To dissable resize */ - int x_height; /* height of the colorgrid */ - t_float x_min; /* minimum value of x */ - t_float x_max; /* max value of x */ - int x_width; /* width of the colorgrid */ - t_float y_min; /* minimum value of y */ - t_float y_max; /* max value of y */ - t_float x_current; /* x coordinate of current position */ - t_float y_current; /* y coordinate of current position */ - int x_selected; /* stores selected state */ - int x_point; /* indicates if a point is plotted */ - int x_colorgrid; /* indicates if a colorgrid is requested */ - t_float x_xstep; /* sets the step ( grain ) for x */ - t_float x_ystep; /* sets the step ( grain ) for y */ - int x_xlines; /* number of vertical lines */ - int x_ylines; /* number of horizontal lines */ - t_symbol* x_fname; -} t_colorgrid; - -#endif diff --git a/colorgrid/help-colorgrid.pd b/colorgrid/help-colorgrid.pd deleted file mode 100755 index 77af92b..0000000 --- a/colorgrid/help-colorgrid.pd +++ /dev/null @@ -1,47 +0,0 @@ -#N canvas 26 1 762 514 10; -#X floatatom 93 434 5 0 0 0 - - -; -#X floatatom 217 434 5 0 0 0 - - -; -#X floatatom 430 220 5 0 0 0 - - -; -#X floatatom 496 220 5 0 0 0 - - -; -#X obj 430 245 pack f f; -#X text 471 221 X; -#X text 537 220 Y; -#X msg 93 131 bang; -#X floatatom 342 431 5 0 0 0 - - -; -#X text 93 451 R; -#X text 217 450 G; -#X text 342 445 B; -#X text 39 12 Grid is a 2-dimensional color picker; -#X text 39 25 Written by Lluis Gomez i Bigorda ( lluis@artefacte.org -); -#X text 39 39 ( inspired by the grid object written by Yves Degoyon -); -#X msg 339 246 xgoto \$1 \$2; -#X text 330 195 Set position without changing output:; -#X obj 496 246 t b f; -#X floatatom 430 133 5 0 0 0 - - -; -#X floatatom 496 133 5 0 0 0 - - -; -#X obj 430 158 pack f f; -#X text 471 134 X; -#X text 537 133 Y; -#X obj 496 159 t b f; -#X text 330 108 Set position :; -#X msg 339 159 goto \$1 \$2; -#X obj 90 376 colorgrid colorgrid1 256 0 256 50 0 50 0 1 1 10 10 147 -392.06; -#X connect 2 0 4 0; -#X connect 3 0 17 0; -#X connect 4 0 15 0; -#X connect 7 0 26 0; -#X connect 15 0 26 0; -#X connect 17 0 4 0; -#X connect 17 1 4 1; -#X connect 18 0 20 0; -#X connect 19 0 23 0; -#X connect 20 0 25 0; -#X connect 23 0 20 0; -#X connect 23 1 20 1; -#X connect 25 0 26 0; -#X connect 26 0 0 0; -#X connect 26 1 1 0; -#X connect 26 2 8 0; diff --git a/colorgrid/tk2c.bash b/colorgrid/tk2c.bash deleted file mode 100755 index 9dfeb03..0000000 --- a/colorgrid/tk2c.bash +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -#set -x - -while read line -do - for word in $line - do - if [ "X"$word != "X"${word#\#} ] - then - echo // ${line#\#} - break - else - line=${line//\'/\\\'} -#useless, slashes never gets in - line=${line//\\/\\\\} -#this one's dirty, i know - line=${line//;/\\\\;} - line=${line//\"/\\\"} - echo 'sys_gui("'$line'\n");' - break - fi - done -done -- cgit v1.2.1