Sorry about my late reply, i've been procrastinating lately...
So, does the code with pgMoveTo and pgLineTo work correctly?
The PGFX functions like pgMoveTo, pgLineTo, and pgLine should work as expected.
The general form of your pgWriteCmd calls is correct, but the way the line
gropnode takes its parameters is a little weird. All primitives in PicoGUI
express a size as x, y, width, and height. For the line widget, to make the
clipping code less insane, the width is defined as x2-x1 and the height is
y2-y1. So, the width and height of a line may be zero or negative. The pgLine
function hides this weirdness.
Quoting [EMAIL PROTECTED]:
> Hi again,
> here are some functions that i wrote to try drawing,
>
> first i make a popup window, and some widgets in it, then initialize
> canvas
> widget like this
>
> canvas=pgNewWidget(PG_WIDGET_CANVAS,PG_DERIVE_INSIDE,boxes[0]);
>
> pgSetWidget(canvas,PG_WP_SIDE,PG_S_RIGHT,0);
>
> gc = pgNewCanvasContext(canvas,PGFX_PERSISTENT);
> pgMoveTo(gc,50,0);
> pgLineTo(gc,75,100);
> pgLineTo(gc,0,35);
> pgLineTo(gc,100,35);
> pgLineTo(gc,25,100);
> pgLineTo(gc,50,0);
> pgMoveTo(gc,0,0);
> pgLineTo(gc,0,35);
> pgSetLgop(gc,PG_LGOP_STIPPLE);
> // pgSetFont(gc,pgNewFont(NULL,20,PG_FSTYLE_UNDERLINE));
> // pgText(gc,10,110,pgNewString("canvas\nsizing\ntoo!"));
> // pgDeleteContext(gc);
>
> then with the following function, i'm trying to draw lines in canvas, by
> taking
> the coordinates from the coordinates matrix
>
> void yeni(char *coordinates[5][2])
> {
> int b=0,a=0;
> int x1,x2,y1,y2;
> pgWriteCmd(canvas,PGCANVAS_NUKE,0);
> pgWriteCmd(canvas,PGCANVAS_GROP,5,PG_GROP_LINE,0,0,0,0);
>
> pgWriteCmd(canvas,PGCANVAS_REDRAW,1);
> pgSubUpdate(canvas);
>
> do{
>
> x1=atoi(coordinates[a][b]);
> y1=atoi(coordinates[a][b+1]);
> x2=atoi(coordinates[a+1][b]);
> y2=atoi(coordinates[a][b+1]);
> // pgWriteCmd(canvas,PGCANVAS_FINDGROP,1,5);
> pgWriteCmd(canvas,PGCANVAS_GROP,5,PG_GROP_LINE,x1,y1,x2,y2);
>
>
> pgWriteCmd(canvas,PGCANVAS_REDRAW,0);
> pgSubUpdate(canvas);
> a++;
>
> } while(a!=5);
>
> }
>
>
> and this is also another version,
>
> void Grafik_Ciz(void)
> {
> // struct pgEvent evt;
> int x=4,a=6;
> int x1=10,x2=40,y1=90,y2=90;
> pgWriteCmd(canvas,PGCANVAS_NUKE,0);
> pgWriteCmd(canvas,PGCANVAS_GROP,5,PG_GROP_LINE,0,0,0,0);
>
> pgWriteCmd(canvas,PGCANVAS_REDRAW,0);
> pgSubUpdate(canvas);
>
> do{
> x--;
> a--;
> // pgWriteCmd(canvas,PGCANVAS_FINDGROP,1,5);
> pgWriteCmd(canvas,PGCANVAS_GROP,5,PG_GROP_LINE,x1,y1,x2,y2);
>
> if((a%2))
> {
>
x1+=30;
>
y2-=30;
> }
> else
> {
>
x2+=30;
>
y1-=30;
> }
>
> pgWriteCmd(canvas,PGCANVAS_REDRAW,0);
> pgSubUpdate(canvas);
> } while(x);
> }
>
> As you see the comment marks, i tried different versions of these
> functions, i
> put and removed different codes each time, though i'm still
> unsuccessful.
>
> Can you see the mistake(s)?
>
> thanks in advance..
>
> Quoting Micah Dowty <[EMAIL PROTECTED]>:
>
> > Hi. It sounds like you're doing things correctly... If you can, send
> me
> > the code
> > you're having trouble with and i'll see what i can do.
> >
> > Quoting [EMAIL PROTECTED]:
> >
> > > Hi, i still couldn't solve my problem,
> > > i modified my code like this:
> > >
> > > i have a canvas widget and a canvas context attached to it as
> > > PGFX_PERSISTENT
> > >
> > > i draw some lines to the canvas via pgMoveTo and pgLineTo
> functions.
> > > After this, i put the code
> > > pgWriteCmd(mycanvas,PGCANVAS_NUKE,0)
> > > again put some codes to draw lines via pgLineTo and pgMoveTo
> > functions,
> > > then
> > > pgWriteCmd(mycanvas,PGCANVAS_REDRAW,0) and
> > > pgContextUpdate or pgSubUpdate or pgUpdate (i tried them all)
> > >
> > > also i tried the PGFX_IMMEDIATE mode, it couldn't work. I looked
> up
> > the
> > > demos,
> > > that involve drawing to canvas, but i got confused.
> > >
> > > Also i tried some combinations of pgSetLgop function though i
> didn't
> > > understand
> > > what does it do.
> > >
> > > As you understand i'm not experienced so much on pgui, sorry for
> > > bothering you
> > > with these kind of questions.
> > >
> > > Thanks
> > >
> >
> >
> >
> > --
> > Only you can prevent creeping featurism!
> >
>
--
Only you can prevent creeping featurism!
_______________________________________________
Pgui-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/pgui-devel