Where are you calling that code from – it’s not in a PtRaw widget’s
draw function, is it?
If you’re drawing in a widget’s draw function, the library sets up a lot
of stuff for you that you have to take care of yourself otherwise. You
can get away without setting a translation or clipping, but you must
tell Photon which region you want to draw from – see PgSetRegion() in
the docs.
Well, the answer to your question is “I’m not really sure.” I’m trying to update
code that someone else wrote (and that person isn’t here anymore). I believe that he
tried to do everything in PhAB, but when I started fixing things, I just editted the
…c files directly. I’m trying not to use widgets as much as possible. So far, that
has been fine for drawing simple figures like squares, circles, and block letters
(I didn’t use PgSetRegion for any of those).
Anyway, now I’m trying to draw a polygon (code below). Again, the function calls
return '0’s, indicating successful
completion. However, no polygon appears on the screen. (I’ve left a portion of
commented out code in
at the bottom. That code draws a block T just fine…)
I’m most appreciative of any help here.
Thanks,
Shannon
//////////////////////////////////////
START CODE //////////////////////////////////////////////
void draw_T1 (int xstart, int ystart)
{
int rxstart, rystart, rx3, ry3, rx6, rxend, ryend ;
PhPoint_t o ;
PhPoint_t p[8] ;
xend = xstart + 63 ;
yend = ystart + 63 ;
x3 = xstart + 21 ;
x6 = xstart + 42 ;
y3 = ystart + 21 ;
y6 = ystart + 42 ;
rxstart = ( (xstart * 0.707) + (ystart * 0.707) ) ;
rystart = ( (xstart * -0.707) + (ystart * 0.707) ) ;
rx3 = ( (x3 * 0.707) + (y3 * 0.707) ) ;
ry3 = ( (x3 * -0.707) + (y3 * 0.707) ) ;
rx6 = ( (x6 * 0.707) + (y6 * 0.707) ) ;
rxend = ( (xend * 0.707) + (yend * 0.707) ) ;
ryend = ( (xend * -0.707) + (yend * 0.707) ) ;
o.x = 0 ;
o.y = 0 ;
p[0].x = rxstart ;
p[0].y = rystart ;
p[1].x = rxstart ;
p[1].y = ry3 ;
p[2].x = rx3 ;
p[2].y = ry3 ;
p[3].x = rx3 ;
p[3].y = ryend ;
p[4].x = rx6 ;
p[4].y = ryend ;
p[5].x = rx6 ;
p[5].y = ry3 ;
p[6].x = rxend ;
p[6].y = ry3 ;
p[7].x = rxend ;
p[7].y = ryend ;
PgFFlush (Ph_START_DRAW) ;
PgSetFillColor (Pg_WHITE) ;
success = PgDrawPolygonmx (&p, 8, &o, Pg_DRAW_FILL | Pg_CLOSED) ;
PgFFlush (Ph_DONE_DRAW) ;
printf (“a zero = success; a negative one no. %d\n”, success ) ;
success = PgFlush () ;
printf (“a zero = success; a negative one no. %d\n”, success ) ;
/*
for (i=xstart ; i < xend ; i++) {
for (j=ystart ; j < y3 ; j++){
PgSetFillColor (Pg_WHITE) ;
PgDrawIRect (i, j, i, j, Pg_DRAW_FILL) ;
}
}
for (i=x3 ; i < x6 ; i++) {
for (j = ystart ; j < yend ; j++) {
PgSetFillColor (Pg_WHITE) ;
PgDrawIRect (i, j, i, j, Pg_DRAW_FILL) ;
}
}
*/
}
////////////////////////////////////// END CODE /////////////////////////////////////