Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Degrees Graph Plotter
#1
I put this together in just 1 1/2 hours tonight without knowing any equations, just some knowledge about the Circle command's radians that I've used before. This doesn't make circles, except for the line it makes using circles. What it does is make a graph of the degrees you punch in. For example, if you punch in 90, it will make a thick line going straight up. If you punch in 180 it will make a thick line going to the left, and so on. It also writes out the degrees next to the line. Plus I added printer support so you can print out the picture if you wish to on your printer. When it uses the printer, I made it so the background is white and the graphics are black and the thick line is blue. I've wanted to make this since I started programming in BASIC in the 1980's. Smile Amazing I figured it out all by myself this time. Feel free to use any of this in your own code of course. I might try some artwork with it sometime. Everything in the app is self-explanatory. Enjoy. 

[Image: Degrees-Plotter-by-Sierra-Ken.jpg]

picture sharing



Code: (Select All)
'Degrees Graph Plotter by SierraKen
'Made on July 11, 2022

Screen _NewImage(800, 800, 32)
Dim img As Long
start:
_Title "Degrees Graph Plotter by SierraKen"
Cls
Print "Degrees Graph Plotter"
Print: Print
Print "By SierraKen"
Print: Print: Print
Print "This app will plot a graph from the degrees you give it."
Print "It can also print it on a printer by pressing P."
Print "To do another one, just press the Space Bar."
Print "To quit, press the Esc key."
Print: Print: Print: Print
Input "Type Degrees Here: ", deg
start2:
Color _RGB32(255, 255, 255), _RGB32(0, 0, 0)
Cls
'Vertical and Horizontal dashes.
For vert = 0 To 780 Step 20
    Line (400, vert)-(400, vert + 10), _RGB32(255, 255, 255)
Next vert
For horiz = 0 To 800 Step 20
    Line (horiz, 400)-(horiz + 10, 400), _RGB32(255, 255, 255)
Next horiz

'Add 90 degrees to your amount for degrees to radians below.
deg = 90 + deg

'Plot 300 points with equations.
For t = 0 To 300
    x = (Sin(_D2R(deg)) * t) + 400
    y = (Cos(_D2R(deg)) * t) + 400
    Circle (x, y), 2, _RGB32(0, 255, 0)
Next t
deg$ = Str$(deg - 90) + " Degrees"
_PrintString (x + 10, y + 20), deg$

'Wait to see if you want more.
_Title "Press P to Print on Paper, Space Bar for another Degree, or Esc to Quit,"
Do
    a$ = InKey$
    If a$ = Chr$(27) Then End
    If a$ = " " Then GoTo start:

    'Printing on the Printer
    If a$ = "p" Or a$ = "P" Then
        If img& <> 0 Then _FreeImage (img&)
        Cls
        Paint (0, 0), _RGB32(255, 255, 255)
        'Vertical and Horizontal dashes.
        For vert = 0 To 780 Step 20
            Line (400, vert)-(400, vert + 10), _RGB32(0, 0, 0)
        Next vert
        For horiz = 0 To 800 Step 20
            Line (horiz, 400)-(horiz + 10, 400), _RGB32(0, 0, 0)
        Next horiz
        'Plot 300 points with equations.
        For t = 0 To 300
            x = (Sin(_D2R(deg)) * t) + 400
            y = (Cos(_D2R(deg)) * t) + 400
            Circle (x, y), 2, _RGB32(0, 0, 255)
        Next t
        Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
        deg$ = Str$(deg - 90) + " Degrees"
        _PrintString (x + 10, y + 20), deg$
        img& = _CopyImage(0)
        _PrintImage img&
        _Delay 5
        deg = deg - 90
        GoTo start2:
    End If
Loop
GoTo start:
Reply
#2
Mouse Angle in a Basic Screen from center in Degrees:
Code: (Select All)
Screen _NewImage(600, 600, 32)
_ScreenMove 300, 0
Do
    Cls
    Line (150, 300)-(450, 300)
    Line (300, 150)-(300, 450)
    _PrintString (120, 292), "180"
    _PrintString (460, 292), "0"
    _PrintString (288, 130), "270"
    _PrintString (292, 455), "90"
    While _MouseInput: Wend
    mx = _MouseX: my = _MouseY
    Line (300, 300)-(mx, my)
    a = Int(100 * _R2D(_Atan2(my - 300, mx - 300))) / 100
    If a < 0 Then a = a + 360
    Print "Mouse Angle in a Basic Screen from center is:"; a
    _Display
    _Limit 60
Loop Until _KeyDown(27) 'escape
b = b + ...
Reply
#3
Awesome B+! But I noticed your angles go clockwise, mine go counter-clockwise because that's the geometric way. Neat idea though.
Reply
#4
Yeah that is the way Sin and Cos go as you go from 0 upwards in degrees or Radians. Not like you learned in math but you need to know that to do Basic graphics with Basic Trig functions.

From the start on printouts Y, vertical measure and locating, advances downward not upward. Someone tried to fix that with Circle parameters beyond the radius, but made a mess with COS and SIN going the opposite direction.
b = b + ...
Reply
#5
Wow that's wild. I don't know much about all that so I'll just keep my app here as it is.
Reply




Users browsing this thread: 1 Guest(s)