Re: XForms: Drawing problem

T.C. Zhao (tc_zhao@yahoo.com)
Sun, 31 Oct 1999 21:16:45 -0800 (PST)

# To subscribers of the xforms list from "T.C. Zhao" <tc_zhao@yahoo.com> :

can't see anything wrong with the program. You may
want to add #include <math.h> for floor().

--- Marien van Westen <myrnout@hetnet.nl> wrote:
> # To subscribers of the xforms list from Marien van Westen
> <myrnout@hetnet.nl> :
>
> Hello,
>
> Being rather new to the Xforms programming I start with working
> programs
> from the /DEMOS directory and change some lines.
> In the freedraw.c program I changed the following routine:
>
> void draw_triangle(int fill, int x, int y, int w, int h, unsigned
> long
> col)
> {
> XPoint xpoint[4];
> GC gc = fl_state[fl_vmode].gc[0];
> Window win = fl_winget();
>
> xpoint[0].x = x; xpoint[0].y = y + h - 1;
> xpoint[1].x = x + w/2; xpoint[1].y = y;
> xpoint[2].x = x + w - 1; xpoint[2].y = y + h - 1;
> XSetForeground(dpy, gc, fl_get_pixel(col));
>
> if(fill)
> XFillPolygon (dpy, win, gc, xpoint, 3, Nonconvex, Unsorted);
> else
> {
> xpoint[3].x = xpoint[0].x; xpoint[3].y = xpoint[0].y;
> XDrawLines(dpy, win, gc, xpoint, 4, CoordModeOrigin);
> }
> }
>
> Into this one:
>
> void draw_triangle(int fill, int x, int y, int w, int h, unsigned
> long
> col)
> /* Draws Sierpinski Triangle */
> {
> int xp, yp, i, n ;
> XPoint xpoint[5000];
> GC gc = fl_state[fl_vmode].gc[0];
> Window win = fl_winget();
> xpoint[0].x = x; xpoint[0].y = y + h - 1;
> xpoint[1].x = x + w/2; xpoint[1].y = y;
> xpoint[2].x = x + w - 1; xpoint[2].y = y + h - 1;
> XSetForeground(dpy, gc, fl_get_pixel(col));
> xp=xpoint[1].x ; yp=xpoint[1].y;
> for (i= 3; i<5000; i++)
> {
> n = rand() % 3 ;
> xp = floor((xpoint[n].x+xp)/2);
> yp = floor((xpoint[n].y+yp)/2);
> xpoint[i].x = xp; xpoint[i].y = yp;
> }
> XDrawPoints(dpy, win, gc, xpoint, 5000, CoordModeOrigin);
> }
>
> The routine does what it should do (push the triangle button with
> Width
> and Height set to maximum value to see what happens).
> But when I change to another desktop and then return back to the
> desktop where this program runs,
> some strange things happen. The triangle button has
> changed shape and the "outline" button has moved.
> Trying to resize the window causes Xwindows to crash (happens with
> KDE,
> Fvwm2 and icewm in the same way).
>
> Can anybody tell me what I am doing wrong? I am using version 0.88 of
> the library.
>
> Marien van Westen (myrnout@hetnet.nl)
>
> _________________________________________________
> To unsubscribe, send the message "unsubscribe" to
> xforms-request@bob.usuhs.mil or see
> http://bob.usuhs.mil/mailserv/xforms.html
> XForms Home Page: http://bragg.phys.uwm.edu/xforms
> List Archive: http://bob.usuhs.mil/mailserv/list-archives/
>
>

=====

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/