Author Topic: Circle Coordinate Text File Maker  (Read 3496 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Circle Coordinate Text File Maker
« on: December 27, 2019, 04:00:48 pm »
Some of the newer programmers or just programmers that aren't too great in math, might need this program sometime to find the coordinates of any circle they wish within the 800 x 600 window it uses. Of course you can always use the CIRCLE command to make an easy circle, but I made this in case you need the particular points without using much math. You can set the radius and X and Y center point of the circle as well as you can choose from 3 different choices of how many coordinates you want for that circle (61, 601, or 6001). Programmers can use the text file it creates of the coordinates to READ it or just copy/paste into code like with the DATA commands. This program might not ever be used by anyone but I thought why not toss it out there?
The text file it makes is called CircleCoordinates.txt which also can be opened with Notepad, etc. After it is made the program ends. If you run it again,  it will overwrite the old file.

Code: QB64: [Select]
  1. 'I made this program for programmers that don't know too much math and need the coordinates of a circle.
  2. 'Of course you can always use the CIRCLE command but this could be needed to find partcular points.
  3. 'The more coordinates you make of the circle, the lesser gaps between pixels..
  4. 'Programmers can use the CircleCoordinates.txt to either copy/paste it into code or use it as a data file to read with their program.
  5. 'Made on Dec. 27, 2019 by Ken G.
  6. 'Freeware
  7.  
  8. SCREEN _NEWIMAGE(800, 600, 32)
  9. again:
  10. PRINT "      Circle Coordinate Maker   by Ken G."
  11. PRINT "This program will create the file CircleCoordinates.txt"
  12. PRINT "which will have x and then y coordinates of a circle."
  13. PRINT "If this file already exists in this directory,"
  14. PRINT "it will be deleted to make a new one."
  15. PRINT "This screen is x=800 by y=600 coordinates big."
  16. INPUT "Center Point Horizon X (between 0 and 800): ", xx
  17. IF xx < 0 OR xx > 800 THEN GOTO again:
  18. INPUT "Center Point Vertical Y (between 0 and 600): ", yy
  19. IF yy < 0 OR yy > 600 THEN GOTO again:
  20. INPUT "Center To Middle (radius larger than zero): ", r
  21. IF r < 0 OR r = 0 THEN GOTO again:
  22. PRINT "Choose how many coordinates you want here."
  23. PRINT "(1) 61"
  24. PRINT "(2) 601"
  25. PRINT "(3) 6001"
  26. INPUT "->", co
  27. IF co = 1 THEN cco = 1
  28. IF co = 2 THEN cco = .1
  29. IF co = 3 THEN cco = .01
  30. IF co > 3 THEN GOTO again:
  31. OPEN "CircleCoordinates.txt" FOR OUTPUT AS #1
  32. one:
  33. _LIMIT 200
  34. seconds = seconds + cco
  35. s = (60 - seconds) * 6 + 180
  36. x = INT(SIN(s / 180 * 3.141592) * r) + xx
  37. y = INT(COS(s / 180 * 3.141592) * r) + yy
  38. WRITE #1, x, y
  39. PSET (x, y), _RGB32(255, 255, 255)
  40. IF seconds > 60 THEN
  41.     seconds = 0
  42.     GOTO two:
  43. GOTO one:
  44. two:
  45. PRINT "CircleCoordinates.txt has been created."
  46. PRINT "Goodbye."
  47.  


Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Circle Coordinate Text File Maker
« Reply #1 on: December 27, 2019, 05:12:13 pm »
Hi SierraKen it is interesting....
but do you use _OPTION EXPLICIT during your coding sessions?

however I have had some salt nuts that brought to me urticaria... so with so itch at hands I have typing something on your opera modding the shape but not the essence.

Code: QB64: [Select]
  1. ' TDB 27 12 2019 (it)/ 2019 12 27 (international) dd-mm-yyyy/yyyy-mm-dd
  2. 'Hi here I play with code translating it into a more modular shape
  3. 'like SUBs FUNCTIONs and loops
  4.  
  5. 'I made this program for programmers that don't know too much math and need the coordinates of a circle.
  6. 'Of course you can always use the CIRCLE command but this could be needed to find partcular points.
  7. 'The more coordinates you make of the circle, the lesser gaps between pixels..
  8. 'Programmers can use the CircleCoordinates.txt to either copy/paste it into code or use it as a data file to read with their program.
  9. 'Made on Dec. 27, 2019 by Ken G.
  10. 'Freeware
  11.  
  12. DIM AnyMaxX AS INTEGER, AnyMaxY AS INTEGER, r AS INTEGER, Again AS INTEGER
  13. DIM xx AS INTEGER, yy AS INTEGER, co AS INTEGER, cco AS SINGLE, seconds AS SINGLE
  14. AnyMaxX = 800
  15. AnyMaxY = 600
  16. SCREEN _NEWIMAGE(800, 600, 32)
  17. Again = -1
  18. DO WHILE Again
  19.     HelpScreen
  20.     PRINT "Center Point Horizon X (between 0 and "; STR$(AnyMaxX) + "): ": INPUT xx
  21.     IF xx < 0 OR xx > 800 THEN Again = -1 ELSE Again = 0
  22.     PRINT "Center Point Vertical Y (between 0 and " + STR$(AnyMaxY) + "): ": INPUT yy
  23.     IF yy < 0 OR yy > 600 THEN Again = -1 ELSE Again = 0
  24.     INPUT "Center To Middle (radius larger than zero): ", r
  25.     IF r < 0 OR r = 0 THEN Again = -1 ELSE Again = 0
  26.     PRINT
  27.     PRINT "Choose how many coordinates you want here."
  28.     PRINT "(1) 61"
  29.     PRINT "(2) 601"
  30.     PRINT "(3) 6001"
  31.     PRINT
  32.     INPUT "->", co
  33.     IF co = 1 THEN cco = 1
  34.     IF co = 2 THEN cco = .1
  35.     IF co = 3 THEN cco = .01
  36.     IF co > 3 THEN Again = -1 ELSE Again = 0
  37. OPEN "CircleCoordinates.txt" FOR OUTPUT AS #1
  38.  
  39.     _LIMIT 200
  40.     seconds = seconds + cco
  41.     s = (60 - seconds) * 6 + 180
  42.     x = INT(SIN(s / 180 * 3.141592) * r) + xx
  43.     y = INT(COS(s / 180 * 3.141592) * r) + yy
  44.     WRITE #1, x, y
  45.     PSET (x, y), _RGB32(255, 255, 255)
  46.     IF seconds > 60 THEN
  47.         seconds = 0
  48.         CLOSE #1
  49.         PRINT "CircleCoordinates.txt has been created."
  50.         PRINT
  51.         PRINT "Goodbye."
  52.         END
  53.     END IF
  54.  
  55. SUB HelpScreen
  56.     CLS
  57.     PRINT "      Circle Coordinate Maker   by Ken G."
  58.     PRINT
  59.     PRINT "This program will create the file CircleCoordinates.txt"
  60.     PRINT "which will have x and then y coordinates of a circle."
  61.     PRINT "If this file already exists in this directory,"
  62.     PRINT "it will be deleted to make a new one."
  63.     PRINT "This screen is x=800 by y=600 coordinates big."
  64.     PRINT
and I use this version to focus our attention on a glictch of QB64IDE. See new post in Discussion session,
Programming isn't difficult, only it's  consuming time and coffee

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Circle Coordinate Text File Maker
« Reply #2 on: December 27, 2019, 06:16:18 pm »
Hi TempodiBasic, thank you! I don't use OPTION EXPLICIT myself because I don't really know a specific need for it unless you just want to DIM all of your variables out of order and so you know what they all are. I've jumped around to different BASIC languages since the 80's and have never found a need for it.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Circle Coordinate Text File Maker
« Reply #3 on: December 28, 2019, 05:26:41 am »
Yes _OPTION EXPLICIT is a manner to force to think in Pascal like way,
first design,
second project modules,
thirt table of variable and constant,
forth write the code
:-)  a solid way that is not so suitable for C and C++ coders who like to be more free like we are in BASIC.

Do you have jumped also in TurboBasic?

PS
flow of my version is bugged but  Bplus have found and solved the issue!
Programming isn't difficult, only it's  consuming time and coffee

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Circle Coordinate Text File Maker
« Reply #4 on: December 28, 2019, 12:46:50 pm »
I've never tried TurboBasic. The ones I have done are: Texas Instruments BASIC from the 80's, Apple 2 Basic, BASICA (for IBM), QBasic, ASIC 5.0, a tiny bit of Visual Basic, and then of course QB64.