Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Large 2D Graphics Library
#3
Finally the demo.

G2DEMO.BAS
Code: (Select All)
'$INCLUDE: 'G2.BI'

Const StartPosX = 0
Const StartPosY = 0
Const XMax = 639
Const YMax = 479

Dim A#(0 To 5, QX% To QY%), B#(0 To 1, QX% To QY%), C#(0 To 1, QX% To QY%)
Dim D#(0 To 1, QX% To QY%), E#(0 To 1, QX% To QY%), F#(0 To 1, QX% To QY%)
Dim G#(0 To 1, QX% To QY%), H#(0 To 1, QX% To QY%), I#(0 To 1, QX% To QY%)
Dim J#(0 To 1, QX% To QY%), K#(0 To 1, QX% To QY%), L#(0 To 1, QX% To QY%)
Dim M#(0 To 1, QX% To QY%), N#(0 To 1, QX% To QY%), O#(0 To 1, QX% To QY%)
Dim P#(0 To 1, QX% To QY%), Q#(0 To 1, QX% To QY%), R#(0 To 1, QX% To QY%)
Dim S#(0 To 1, QX% To QY%), T#(0 To 1, QX% To QY%), U#(0 To 1, QX% To QY%)
Dim V#(0 To 1, QX% To QY%), W#(0 To 1, QX% To QY%), X#(0 To 1, QX% To QY%)
Dim Y#(0 To 1, QX% To QY%), Z#(0 To 1, QX% To QY%)
Dim SList1%(0 To 1), SList2%(0 To 1)
Dim Win1 As Box2D, Win2 As Box2D, Win3 As Box2D, Win4 As Box2D
Dim BoundsA As Box2D, BoundsB As Box2D, BoundsC As Box2D
Dim BoundsD As Box2D, BoundsE As Box2D, BoundsF As Box2D
Dim BoundsG As Box2D, BoundsH As Box2D, BoundsI As Box2D
Dim BoundsJ As Box2D, BoundsK As Box2D, BoundsL As Box2D
Dim BoundsM As Box2D, BoundsN As Box2D, BoundsO As Box2D
Dim BoundsP As Box2D, BoundsQ As Box2D, BoundsR As Box2D
Dim BoundsS As Box2D, BoundsT As Box2D, BoundsU As Box2D
Dim BoundsV As Box2D, BoundsW As Box2D, BoundsX As Box2D
Dim BoundsY As Box2D, BoundsZ As Box2D
Dim V1 As AView2D, V2 As AView2D, V3 As AView2D, V4 As AView2D
Dim See1 As Vision, See2 As Vision, See3 As Vision, See4 As Vision
Color 9, 7, 12
Cls
Locate 13, 16
Print "Please wait - preparing 16 pre-defined shapes."
_Delay 2.0
Triangle 90, 50, 420, A#(), BoundsA
Square 80, 150, 420, B#(), BoundsB
Pentagon 55, 250, 420, C#(), BoundsC
Hexagon 45, 350, 420, D#(), BoundsD
Heptagon 40, 450, 420, E#(), BoundsE
Octagon 35, 550, 420, F#(), BoundsF
Nonagon 30, 50, 240, G#(), BoundsG
Decagon 30, 150, 240, H#(), BoundsH
Undecagon 25, 250, 240, I#(), BoundsI
Dodecagon 25, 350, 240, J#(), BoundsJ
Arrow 90, 450, 240, K#(), BoundsK
Diamond 90, 550, 240, L#(), BoundsL
Pentagram 55, 50, 80, M#(), BoundsM, SList1%()
StarOfDavid 45, 215, 80, N#(), BoundsN, SList2%()
ACircle 47, 385, 80, O#(), BoundsO
Ellipse 47, 25, 550, 80, P#(), BoundsP
Arrow 100, 320, 240, W#(), BoundsW
dummy% = CopyShape2D%(W#(), X#())
dummy% = OuterLimits2D%(X#(), BoundsX)

dummy% = SetNewWindow2D%(Win1, StartPosX, XMax, StartPosY, YMax)
dummy% = SetNewViewPort%(V1, StartPosX, XMax, StartPosY, YMax)
SetNewVision See1, Win1, V1
dummy% = SetNewWindow2D%(Win2, StartPosX, 132, 30, 129)
dummy% = SetNewViewPort%(V2, StartPosX, 320, StartPosY, 240)
SetNewVision See2, Win2, V2
dummy% = SetNewWindow2D%(Win3, 20, 80, 50, 110)
dummy% = SetNewViewPort%(V3, 320, XMax, 240, YMax)
SetNewVision See3, Win3, V3
dummy% = SetNewWindow2D%(Win4, 0, 263, 0, 188)
dummy% = SetNewViewPort%(V4, 160, 479, 120, 359)
SetNewVision See4, Win4, V4
Screen 12
BoundingBox
dummy% = DisplayPolygon%(A#(), 11, See1)
dummy% = DisplayPolygon%(B#(), 11, See1)
dummy% = DisplayPolygon%(C#(), 11, See1)
dummy% = DisplayPolygon%(D#(), 11, See1)
dummy% = DisplayPolygon%(E#(), 11, See1)
dummy% = DisplayPolygon%(F#(), 11, See1)
dummy% = DisplayPolygon%(G#(), 11, See1)
dummy% = DisplayPolygon%(H#(), 11, See1)
dummy% = DisplayPolygon%(I#(), 11, See1)
dummy% = DisplayPolygon%(J#(), 11, See1)
dummy% = DisplayPolygon%(K#(), 11, See1)
dummy% = DisplayPolygon%(L#(), 11, See1)
dummy% = DisplayShape2D%(M#(), 11, SList1%(), See1)
dummy% = DisplayShape2D%(N#(), 11, SList2%(), See1)
dummy% = DisplayPolygon%(O#(), 11, See1)
dummy% = DisplayPolygon%(P#(), 11, See1)
Beep
Z$ = Input$(1)
CreateArc 320, 240, 220, 15, 210, Q#(), BoundsQ
BoundingBox
dummy% = DisplayPolygon%(Q#(), 11, See1)
BEEP
Z$ = Input$(1)
BoundingBox
TwinCircleTangent 160, 250, 150, 470, 250, 100, PX1#, PY1#, PX2#, PY2#
TwinCircleTangent 160, 250, -150, 470, 250, -100, PX3#, PY3#, PX4#, PY4#
CalculateAngle 160, 250, PX3#, PY3#, SA1#
CalculateAngle 160, 250, PX1#, PY1#, EA1#
CalculateAngle 470, 250, PX2#, PY2#, SA2#
CalculateAngle 470, 250, PX4#, PY4#, EA2#
Angle1# = GetAngle#(SA1#, EA1#)
Angle2# = GetAngle#(SA2#, EA2#)
CreateArc 160, 250, 150, SA1#, Angle1#, R#(), BoundsR
CreateArc 470, 250, 100, SA2#, Angle2#, S#(), BoundsS
dummy% = MakePolygon%(S#(), R#())
dummy% = OuterLimits2D%(R#(), BoundsR)
dummy% = MoveTo2D%(R#(), BoundsR, 320, 240)
dummy% = DisplayPolygon%(R#(), 10, See1)
Beep
Z$ = Input$(1)
BoundingBox
CreateParametricCubicCurve 10, 10, 100, 200, 400, 400, 600, 50, T#(), BoundsT
DisplayLine 10, 10, 100, 200, 12, See1
DisplayLine 100, 200, 400, 400, 12, See1
DisplayLine 400, 400, 600, 50, 12, See1
Beep
Z$ = Input$(1)
dummy% = DisplayPolygon%(T#(), 14, See1)
Beep
Z$ = Input$(1)
Screen 0
Color 9, 7, 12
Cls
Locate 13, 19
Print "Please wait - Calculating a complex curve."
ReDim U#(0 To 44, QX% To QY%)
Open "G2DEMO.DAT" For Input As 1
For Index% = 1 To 44
    Input #1, U#(Index%, QX%)
    Input #1, U#(Index%, QY%)
Next Index%
Close (1)
dummy% = OuterLimits2D%(U#(), BoundsU)
dummy% = CreateComplexCurve%(U#(), V#(), BoundsV)
Screen 12
BoundingBox
dummy% = DisplayPolygon%(U#(), 11, See1)
Beep
Z$ = Input$(1)
dummy% = DisplayPolygon%(V#(), 14, See1)
Last% = UBound(V#)
DisplayLine V#(1, QX%), V#(1, QY%), V#(Last%, QX%), V#(Last%, QY%), 14, See1
Beep
Z$ = Input$(1)
BoundingBox
dummy% = DisplayPolygon%(V#(), 14, See1)
DisplayLine V#(1, QX%), V#(1, QY%), V#(Last%, QX%), V#(Last%, QY%), 14, See1
Beep
Z$ = Input$(1)
BoundingBox
dummy% = DisplayPolygon%(W#(), 14, See1)
Beep
Z$ = Input$(1)
For Index% = 1 To 14
    dummy% = Translate2D%(W#(), BoundsW, 20, 20)
    dummy% = DisplayPolygon%(W#(), 14, See1)
    _Delay 0.5
Next Index%
Beep
Z$ = Input$(1)
BoundingBox
dummy% = MoveTo2D%(W#(), BoundsW, 320, 240)
dummy% = DisplayPolygon%(W#(), 14, See1)
_Delay 0.5
dummy% = MoveTo2D%(W#(), BoundsW, 60, 400)
dummy% = DisplayPolygon%(W#(), 14, See1)
_Delay 0.5
dummy% = MoveTo2D%(W#(), BoundsW, 60, 60)
dummy% = DisplayPolygon%(W#(), 14, See1)
_Delay 0.5
dummy% = MoveTo2D%(W#(), BoundsW, 580, 60)
dummy% = DisplayPolygon%(W#(), 14, See1)
_Delay 0.5
dummy% = MoveTo2D%(W#(), BoundsW, 580, 400)
dummy% = DisplayPolygon%(W#(), 14, See1)
Beep
Z$ = Input$(1)
dummy% = MoveTo2D%(W#(), BoundsW, 320, 240)
dummy% = DisplayPolygon%(W#(), 10, See1)
_Delay 0.5
dummy% = InflateX2D%(W#(), BoundsW, 2)
dummy% = DisplayPolygon%(W#(), 11, See1)
_Delay 0.5
dummy% = InflateY2D%(W#(), BoundsW, 2)
dummy% = DisplayPolygon%(W#(), 12, See1)
_Delay 0.5
dummy% = InflateY2D%(W#(), BoundsW, 2)
dummy% = DisplayPolygon%(W#(), 11, See1)
_Delay 0.5
dummy% = InflateX2D%(W#(), BoundsW, 2)
dummy% = DisplayPolygon%(W#(), 12, See1)
_Delay 0.5
dummy% = Inflate2D%(W#(), BoundsW, .25)
dummy% = DisplayPolygon%(W#(), 14, See1)
Beep
Z$ = Input$(1)
BoundingBox
dummy% = MoveTo2D%(W#(), BoundsW, 60, 60)
dummy% = DisplayPolygon%(W#(), 13, See1)
_Delay 0.5
dummy% = ScaleX2D%(W#(), BoundsW, 2)
dummy% = DisplayPolygon%(W#(), 10, See1)
_Delay 0.5
dummy% = ScaleY2D%(W#(), BoundsW, 2)
dummy% = DisplayPolygon%(W#(), 11, See1)
_Delay 0.5
dummy% = ScaleXY2D%(W#(), BoundsW, 2, 2)
dummy% = DisplayPolygon%(W#(), 12, See1)
_Delay 0.5
dummy% = Scale2D%(W#(), BoundsW, .25)
dummy% = DisplayPolygon%(W#(), 14, See1)
Beep
Z$ = Input$(1)
dummy% = Inflate2D%(X#(), BoundsX, 2)
dummy% = MoveTo2D%(X#(), BoundsX, 100, 100)
For Index% = 1 To 10
    BoundingBox
    dummy% = DisplayPolygon%(X#(), 12, See1)
    dummy% = ShearX2D%(X#(), BoundsX, .1)
    dummy% = DisplayPolygon(X#(), 10, See1)
    dummy% = ShearY2D%(X#(), BoundsX, .1)
    dummy% = DisplayPolygon(X#(), 11, See1)
    _Delay 0.5
Next Index%
Beep
Z$ = Input$(1)
BoundingBox
dummy% = MoveTo2D%(W#(), BoundsW, 420, 0)
dummy% = DisplayPolygon%(W#(), 14, See1)
_Delay 0.5
For Index% = 1 To 18
    dummy% = Rotation2D%(W#(), BoundsW, 5)
    dummy% = DisplayPolygon%(W#(), 14, See1)
    _Delay 0.5
Next Index%
Beep
Z$ = Input$(1)
BoundingBox
dummy% = Inflate2D%(P#(), BoundsP, 3)
dummy% = MoveTo2D%(P#(), BoundsP, 320, 240)
dummy% = DisplayPolygon%(P#(), 11, See1)
_Delay 0.5
For Index% = 1 To 6
    dummy% = Spin2D%(P#(), BoundsW, 30)
    dummy% = DisplayPolygon%(P#(), 11, See1)
    _Delay 0.5
Next Index%
Beep
Z$ = Input$(1)
BoundingBox
dummy% = Spin2D%(W#(), BoundsW, -90)
dummy% = MoveTo2D%(W#(), BoundsW, 420, 240)
dummy% = DisplayPolygon%(W#(), 14, See1)
_Delay 0.5
For Index% = 1 To 11
    dummy% = Orbit2D%(W#(), BoundsW, 320, 240, 30)
    dummy% = DisplayPolygon%(W#(), 14, See1)
    _Delay 0.5
Next Index%
Beep
Z$ = Input$(1)
Cls
Line (StartPosX, StartPosY)-(320, 240), 15, B
dummy% = DisplayShape2D%(M#(), 14, SList1%(), See2)
Beep
Z$ = Input$(1)
Cls
Line (320, 240)-(XMax, YMax), 15, B
dummy% = DisplayShape2D%(M#(), 14, SList1%(), See3)
Beep
Z$ = Input$(1)
Cls
Line (160, 120)-(479, 359), 15, B
dummy% = DisplayShape2D%(M#(), 14, SList1%(), See4)
dummy% = DisplayShape2D%(N#(), 10, SList2%(), See4)
Beep
Z$ = Input$(1)
Cls
End

Sub BoundingBox
    Cls
    Line (StartPosX, StartPosY)-(XMax, YMax), 15, B
End Sub

'$INCLUDE: 'G2.BM'

G2DEMO.DAT (pre-calculated coordinates)
Code: (Select All)
52.78181814000001  21.02857136000001
6.309090860000005  21.02857136000001
6.309090860000005  62.08571423000001
52.78181814000001  62.08571423000001
52.78181814000001  130.51428568
110.87272724  130.51428568
110.87272724  198.94285713
17.92727268000001  198.94285713
17.92727268000001  335.80000003
168.96363634  335.80000003
168.96363634  472.65714293
227.05454544  472.65714293
227.05454544  198.94285713
343.23636364  198.94285713
343.23636364  335.80000003
447.80000002  335.80000003
447.80000002  472.65714293
471.03636366  472.65714293
471.03636366  335.80000003
633.69090914  335.80000003
633.69090914  267.37142858
471.03636366  267.37142858
471.03636366  198.94285713
529.12727276  198.94285713
529.12727276  198.94285713
563.98181822  198.94285713
563.98181822  157.88571426
598.83636368  157.88571426
598.83636368  7.342857070000008
447.80000002  7.342857070000008
447.80000002  198.94285713
401.32727274  198.94285713
401.32727274  103.1428571
354.85454546  103.1428571
354.85454546  157.88571426
203.8181818  157.88571426
203.8181818  75.77142852
378.0909091  75.77142852
378.0909091  34.71428565000001
168.96363634  34.71428565000001
168.96363634  75.77142852
99.25454542  75.77142852
99.25454542  21.02857136000001
52.78181814000001  21.02857136000001

A few notes to follow later. For now compile the demo and run the resulting exe. One thing that is very important however - the DAT files must be in the same folder as the exe. It will execute but it won't work.

TR
Reply


Messages In This Thread
Large 2D Graphics Library - by TarotRedhand - 05-16-2022, 09:10 AM
RE: Large 2D Graphics Library - by TarotRedhand - 05-16-2022, 09:20 AM
RE: Large 2D Graphics Library - by TarotRedhand - 05-16-2022, 09:29 AM
RE: Large 2D Graphics Library - by James D Jarvis - 05-16-2022, 11:56 AM
RE: Large 2D Graphics Library - by TarotRedhand - 05-16-2022, 10:38 PM
RE: Large 2D Graphics Library - by grymmjack - 12-05-2023, 05:17 AM



Users browsing this thread: 1 Guest(s)