Announcement

Collapse

New Sub-Forum

In an effort to help make sure there are appropriate categories for topics of discussion that are happening, there is now a sub-forum for databases and database programming under Special Interest groups. Please direct questions, etc., about this topic to that sub-forum moving forward. Thank you.
See more
See less

Inconsistent GRAPHIC POLYGON

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Inconsistent GRAPHIC POLYGON

    I'm using the GRAPHIC POLYGON function, but not getting consistent results.

    The program below simply draws the letter "A" in a graphics box using GRAPHIC POLYGON, but the letter graphic only appears about 60% of the time. The rest of the time a blank graphics window appears.

    I'm just getting started with PB/CC and can't figure out where this inconsistency is coming from.

    Any ideas?

    Mark


    '------------------------------
    #COMPILE EXE
    #DIM ALL
    '------------------------------
    TYPE PolyPoint
    x AS SINGLE
    y AS SINGLE
    END TYPE

    TYPE LetterArray
    count AS LONG
    xy(1 TO 300) AS PolyPoint
    END TYPE
    '------------------------------------------
    FUNCTION PBMAIN () AS LONG
    GLOBAL Letter AS LetterArray
    GLOBAL A() AS polypoint
    LOCAL j&
    '-----------------------------------
    DIM A(VAL(READ$(1)))
    A(0).x = VAL(READ$(1))
    A(0).y = VAL(READ$(2))
    FOR j& = 1 TO A(0).x
    A(j&).x = VAL(READ$(j&*2+1))
    A(j&).y = VAL(READ$(j&*2+2))
    NEXT
    CALL DrawLetter(A())
    SLEEP 3000
    '----------------------------
    'Data for "A"
    DATA 16, 100
    DATA 500, 500
    DATA 300, 500
    DATA 183, 200
    DATA -183, 200
    DATA -300, 500
    DATA -500, 500
    DATA -110, -500
    DATA 0, -500
    DATA 0, -280
    DATA -109, 10
    DATA 109, 10
    DATA 1, -280
    DATA 1, -500
    DATA 110, -500
    DATA 500, 500
    DATA 495, 495
    END FUNCTION
    '-------------------------------
    SUB Drawletter (letter() AS polypoint)
    LOCAL j&, hwin AS DWORD
    LOCAL Character AS LetterArray

    Character.count = Letter(0).x

    FOR j& = 1 TO Letter(0).x
    Character.xy(j&).x = Letter(j&).x
    Character.xy(j&).y = Letter(j&).y
    NEXT

    GRAPHIC WINDOW "Box", 0, 0, 640, 640 TO hWin
    GRAPHIC ATTACH hWin, 0
    GRAPHIC SCALE (-500,-500)-(500,500)
    GRAPHIC POLYGON Character, %BLACK, %BLACK

    END SUB
    Mark Buehnerkemper, OD
    www.echartacuity.com
    [email protected]

  • #2
    Your program always works for me, but you might replace
    Graphic Attach hWin, 0
    with
    Graphic Attach hWin, 0, ReDraw
    then after Graphic Polygon Character, %Black, %Black add
    Graphic ReDraw
    Politically incorrect signatures about immigration patriots are forbidden. Googling “immigration patriots” is forbidden. Thinking about Googling ... well, don’t even think about it.

    Comment


    • #3
      Thanks for the idea, Mark, but it didn't solve the problem.

      I found that if I put a short delay (SLEEP 20) before GRAPHIC SCALE, it works everytime.

      Go figure.

      Thanks again,

      Mark
      Mark Buehnerkemper, OD
      www.echartacuity.com
      [email protected]

      Comment


      • #4
        The number 20 seems kind of arbitrary. You might try 0. (See the Help file. Sleep 0 is special.)
        Politically incorrect signatures about immigration patriots are forbidden. Googling “immigration patriots” is forbidden. Thinking about Googling ... well, don’t even think about it.

        Comment

        Working...
        X