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
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
Comment