by [Theo Verelst] I'm starting this page as a sketch of the idea that a [c compiler] can be run as part of a [bwise] canvas, where compilation is automatic, and followed by automatic execution of the resulting program, and in the first example showing of the esulting image on-canvas. Sketch doesn't mean the method doesn't in principle work without (much) adaptation in general, but I'm not done doing a streamlined XP/linux automatic version, a few things require hand actions. [http://195.241.128.75/Wiki/srcsine1.png] The following two files are needed in the current directory where [bwise] must be running, under I guess any reasonable version of tcl/tk. ---- # file: cansine6.tcl global bcount scopeindex wireindex shellindex drumindex entrycount moncount proccount seqcount stackcount termindex textcount set bcount 0 set scopeindex 0 set wireindex 5 set shellindex 0 set drumindex 0 set entrycount 3 set moncount 1 set proccount 2 #image create photo sine -file sine.ppm image create photo sine -width 512 -height 512 .mw.c create rectangle 246.0 10.0 286.0 40.0 -activedash {} -activefill {} -activeoutline {} -activeoutlinestipple {} -activestipple {} -activewidth 0.0 -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledoutline {} -disabledoutlinestipple {} -disabledstipple {} -disabledwidth 0 -fill yellow -offset 0,0 -outline darkblue -outlineoffset 0,0 -outlinestipple {} -state {} -stipple {} -tags {Proc1 newblock block} -width 1.0 .mw.c create text 266.0 40.0 -activefill {} -activestipple {} -anchor n -disabledfill {} -disabledstipple {} -fill darkblue -font {Helvetica -12} -justify left -offset 0,0 -state {} -stipple {} -tags {Proc1 crb label} -text Proc1 -width 0 .mw.c create text 245.0 29.0 -activefill {} -activestipple {} -anchor se -disabledfill {} -disabledstipple {} -fill black -font {Helvetica -12} -justify left -offset 0,0 -state {} -stipple {} -tags {Proc1 crb pinname in} -text in -width 0 .mw.c create line 226.0 30.0 246.0 30.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {Proc1 newblock pin in typein} -width 2.0 .mw.c create text 287.0 29.0 -activefill {} -activestipple {} -anchor sw -disabledfill {} -disabledstipple {} -fill black -font {Helvetica -12} -justify left -offset 0,0 -state {} -stipple {} -tags {Proc1 crb pinname out} -text out -width 0 .mw.c create line 306.0 30.0 286.0 30.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {Proc1 newblock pin out typeout} -width 2.0 .mw.c create rectangle 351.0 10.0 391.0 40.0 -activedash {} -activefill {} -activeoutline {} -activeoutlinestipple {} -activestipple {} -activewidth 0.0 -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledoutline {} -disabledoutlinestipple {} -disabledstipple {} -disabledwidth 0 -fill yellow -offset 0,0 -outline darkblue -outlineoffset 0,0 -outlinestipple {} -state {} -stipple {} -tags {Proc2 newblock block} -width 1.0 .mw.c create text 371.0 40.0 -activefill {} -activestipple {} -anchor n -disabledfill {} -disabledstipple {} -fill darkblue -font {Helvetica -12} -justify left -offset 0,0 -state {} -stipple {} -tags {Proc2 crb label} -text Proc2 -width 0 .mw.c create text 350.0 29.0 -activefill {} -activestipple {} -anchor se -disabledfill {} -disabledstipple {} -fill black -font {Helvetica -12} -justify left -offset 0,0 -state {} -stipple {} -tags {Proc2 crb pinname in} -text in -width 0 .mw.c create line 331.0 30.0 351.0 30.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {Proc2 newblock pin in typein} -width 2.0 .mw.c create text 392.0 29.0 -activefill {} -activestipple {} -anchor sw -disabledfill {} -disabledstipple {} -fill black -font {Helvetica -12} -justify left -offset 0,0 -state {} -stipple {} -tags {Proc2 crb pinname out} -text out -width 0 .mw.c create line 411.0 30.0 391.0 30.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {Proc2 newblock pin out typeout} -width 2.0 .mw.c create line 306.0 30.0 331.0 30.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {wire1 connect wire Proc1 out Proc2 in} -width 1.0 .mw.c create rectangle 53.0 72.0 565.0 584.0 -activedash {} -activefill {} -activeoutline {} -activeoutlinestipple {} -activestipple {} -activewidth 0.0 -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledoutline {} -disabledoutlinestipple {} -disabledstipple {} -disabledwidth 0 -fill yellow -offset 0,0 -outline darkblue -outlineoffset 0,0 -outlinestipple {} -state {} -stipple {} -tags {sine newblock block} -width 1.0 .mw.c create text 309.0 584.0 -activefill {} -activestipple {} -anchor n -disabledfill {} -disabledstipple {} -fill darkblue -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {sine crb label} -text sine -width 0 .mw.c create text 52.0 91.0 -activefill {} -activestipple {} -anchor se -disabledfill {} -disabledstipple {} -fill black -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {sine crb pinname in} -text in -width 0 .mw.c create line 33.0 92.0 53.0 92.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {sine newblock pin in typein} -width 2.0 .mw.c create text 566.0 91.0 -activefill {} -activestipple {} -anchor sw -disabledfill {} -disabledstipple {} -fill black -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {sine crb pinname out} -text out -width 0 .mw.c create line 585.0 92.0 565.0 92.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {sine newblock pin out typeout} -width 2.0 .mw.c create image 53.0 72.0 -activeimage {} -anchor nw -disabledimage {} -image sine -state {} -tags {sine newimage block image} .mw.c create line 411.0 30.0 33.0 92.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {wire4 connect wire Proc2 out sine in} -width 1.0 # now the block related variables\n set Proc1.bfunc { if ![catch {exec gcc -O -o [file rootname ${Proc1.in}] ${Proc1.in} -lm} r] {set Proc1.out [file rootname ${Proc1.in}]} { set Proc1.out $r } } set Proc1.bfunc_init {} set Proc1.in {sine.c} set Proc1.out {sine} set Proc2.bfunc {if ![catch [exec ${Proc2.in} ] r2] {set Proc2.out sine.ppm} {} } set Proc2.bfunc_init {} set Proc2.in {sine} set Proc2.out {sine.ppm} set sine.bfunc {set sine.out [sine read ${sine.in} ]} set sine.bfunc_init {} set sine.in {sine.ppm} set sine.out {} ---- /* File: sine.c */ /* combine transparent sine graphs in a ppm image */ /* Commercial rights reserved, Theo Verelst, free use otherwise, mentioning author */ #include #include #include #include #define PI 3.1415926535 unsigned char *im; int w,h; unsigned char * createim(w,h) int w,h; { unsigned char *d; int x,y; d = (unsigned char *) malloc(3*w*h); for (x=0; x(256-sin(((double) k)*x)*256); j--) point_trans((int) (0.5 + (x*512.0)/(2.0*PI)), j, 0, 255, 255, max); } } main(argc,argv) int argc; char *argv[]; { w = 512; h = 512; im = createim(w,h); if (im == NULL) { printf("Malloc error: quiting.\n"); exit(-1); } rectangle(0,0,w,h); drawsine(); writeppm("sine.ppm", w,h); } ----