1

Topic: AppGraphics - problem with line thickness

I have been experimenting a bit with AppGraphics and I got some problems with the line thickness setting. When I use lines with a larger than the minimum thickness, everything seems to be fine, except for horizontal and for vertical lines: these have the minimum thickness, whatever thickness parameter I use. For demonstration here a test program that draws a few thick lines (very thick for demonstration purposes). The first one is exactly horizontal, the next ones have an increasingly large inclination. With the inclination, the thickness increases, although the line is also a bit cigar-shaped. This can be seen on the first photo. However, sometimes the program for no apparent reason suddenly produces the correct thick lines, as can be seen in the second photo. Is this a bug, or did I forget to set some other parameter?

program graphtest
use appgraphics

integer (kind=c_short):: upattern
integer::myscreen
integer:: kleurv

myscreen = initwindow(1920, 1200, closeflag=.TRUE.)

kleurv = creatergb (0,140,240)
call setlinestyle (SOLID_LINE,upattern, 20)         
call setcolor (kleurv)

call line (0, 100, 1800, 100)       ! Horizontal line
call line (0, 300, 1800, 301)       ! Lines with increasing inclination
call line (0, 500, 1800, 510)       !       ..
call line (0, 700, 1800, 720)       !       ..
call line (0, 900, 1800, 950)       !       ..
call loop

end program


https://farm5.staticflickr.com/4492/37574912230_46d17a9bbb_z.jpg

Oh, the second photo is refused... I'll send it in a second message.

2

Re: AppGraphics - problem with line thickness

And here is the second photo, as it should be:

https://farm5.staticflickr.com/4451/37594033270_5b9e346cd3_h.jpg

Re: AppGraphics - problem with line thickness

PS,

Try using using Refresh() after the 1st and before the 5th line drawn.

Revised graphtest:

    program graphtest
        use appgraphics
        implicit none
        integer (kind=c_short):: upattern
        integer::myscreen
        integer:: kleurv

        myscreen = initwindow(1920, 1200, closeflag=.TRUE.)
        kleurv = creatergb (0,140,240)
        call setlinestyle (SOLID_LINE,upattern, 20)
        call setcolor (kleurv)

        call line (0, 100, 1800, 100)       ! Horizontal line

        call refreshall()                   !--- Refresh window

        call line (0, 300, 1800, 301)       ! Lines with increasing inclination
        call line (0, 500, 1800, 510)       !       ..
        call line (0, 700, 1800, 720)       !       ..
        call line (0, 900, 1800, 950)       !       ..

        call refreshall()                   !--- Refresh window for 5th line??
        call line (0, 900, 1800, 950)       !       ..

        call line (0, 900, 1750, -900)      !--- Line 45 up
        call line (0, -900, 1800, 950)      !--- Line 45 down

        call loop()
        call closewindow(myscreen)
    end program graphtest

Frank

4

Re: AppGraphics - problem with line thickness

Frank: "PS,
Try using using Refresh() after the 1st and before the 5th line drawn."

Thanks, that seems to work, but I have to repeat it before every linedraw command to be sure that the next line is rendered correctly. When I use it only once after the first line, a later line becomes again a "cigar" (if there is a system behind this behavior, I can't discover it). That's no problem for drawing a few straight lines, but it seems to me a bit inefficient for drawing an unpredictable graph with many short lines, if only for program-aesthetic reasons...

Peter

Re: AppGraphics - problem with line thickness

Peter,

I notice that the cigar-shaped phenomenon disappears if I minimize and then restore the window.  It's definitely a refresh issue.  Everything seems to work fine in my case, though, if I add just a final call refreshall() just before the call loop() line.

AppGraphics is quite low-level, and the line drawing routines are merely a thin wrapper around the appropriate Windows GDI calls.  A lot of the seemingly odd need to refresh the window is because of underlying Windows behavior.  I'll look into seeing if there is a fix, though.

Jeff Armstrong
Approximatrix, LLC

6

Re: AppGraphics - problem with line thickness

Thanks Jeff, that solves my problem with just one extra statement.

Peter