Author Topic: Makes a Globe with Lines and Points  (Read 4470 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Makes a Globe with Lines and Points
« on: August 17, 2020, 11:01:10 pm »
Use the mouse wheel to keep adding more lines and more connections making the circle more circular and more lines connecting the points.

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(600, 600, 32)
  2. DIM xx(5000), yy(5000)
  3. _LIMIT 100
  4. points = 3
  5. GOSUB drawing:
  6.  
  7.     mouseWheel = 0
  8.         mouseWheel = mouseWheel + _MOUSEWHEEL
  9.     LOOP
  10.     IF mouseWheel = 1 THEN points = points + 1: CLS: GOSUB drawing
  11.     IF mouseWheel = -1 THEN points = points - 1: CLS: GOSUB drawing:
  12.     a$ = INKEY$
  13.     IF a$ = CHR$(27) THEN END
  14.  
  15. drawing:
  16. mouseWheel = 0
  17. IF points < 1 THEN points = 1
  18. IF points > 50 THEN points = 50
  19. FOR a = 1 TO 1200 * points STEP 20
  20.     seconds = seconds + 5 / points
  21.     sec = (60 - seconds) * 6 + 180
  22.     x = INT(SIN(sec / 180 * 3.141592) * 180) + 300
  23.     y = INT(COS(sec / 180 * 3.141592) * 180) + 300
  24.     t = t + 1
  25.     xx(t) = x
  26.     yy(t) = y
  27.     CIRCLE (x, y), 2, _RGB32(255, 255, 255)
  28. seconds = 0
  29.  
  30. FOR t2 = 1 TO points * 10
  31.     FOR tt = t2 TO (11 + t2) * points STEP t2
  32.         IF xx(tt + t2) < 10 OR yy(tt + t2) < 10 THEN GOTO skip:
  33.         LINE (xx(tt), yy(tt))-(xx(tt + t2), yy(tt + t2)), _RGB32(255, 255, 255)
  34.     NEXT tt
  35. NEXT t2
  36.  
  37. skip:
  38. FOR e = 1 TO t
  39.     xx(t) = 0
  40.     yy(t) = 0
  41. points$ = STR$(points)
  42. _TITLE "Use the mouse wheel (1-50): " + points$
  43. t = 0
  44. tt = 0
  45.  

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Makes a Globe with Lines and Points
« Reply #1 on: August 18, 2020, 01:03:33 am »
Mmmm..... Spider-web doughnut
Shuwatch!

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Makes a Globe with Lines and Points
« Reply #2 on: August 18, 2020, 01:13:16 am »
LOLOL :)

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Makes a Globe with Lines and Points
« Reply #3 on: August 18, 2020, 03:54:19 am »
Mmm... Donuts...
Logic is the beginning of wisdom.

Offline loudar

  • Newbie
  • Posts: 73
  • improve it bit by bit.
    • View Profile
Re: Makes a Globe with Lines and Points
« Reply #4 on: August 18, 2020, 10:37:41 am »
I modified it a little bit to be able to change the steps! The higher the steps, the more of a circle you get. With less steps it more and more looks like a donut. Tasty!

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(600, 600, 32)
  2. _LIMIT 100
  3. points = 3
  4. steps = 10
  5. DIM xx(1200 * points), yy(1200 * points)
  6. GOSUB drawing:
  7.  
  8.     mouseWheel = 0
  9.         mouseWheel = mouseWheel + _MOUSEWHEEL
  10.     LOOP
  11.     IF mouseWheel = 1 THEN points = points + 1: CLS: GOSUB drawing
  12.     IF mouseWheel = -1 THEN points = points - 1: CLS: GOSUB drawing:
  13.     a$ = INKEY$
  14.     IF a$ = CHR$(27) THEN END
  15.  
  16. drawing:
  17. mouseWheel = 0
  18. IF points < 1 THEN points = 1
  19. IF points > 50 THEN points = 50
  20. FOR a = 1 TO 1200 * points STEP steps
  21.     seconds = seconds + 5 / points
  22.     sec = (60 - seconds) * 6 + 180
  23.     x = INT(SIN(sec / 180 * 3.141592) * 180) + 300
  24.     y = INT(COS(sec / 180 * 3.141592) * 180) + 300
  25.     t = t + 1
  26.     xx(t) = x
  27.     yy(t) = y
  28.     'CIRCLE (x, y), 2, _RGB32(255, 255, 255)
  29. seconds = 0
  30.  
  31. bounces = steps + points - 1
  32. FOR t2 = 1 TO points * bounces
  33.     FOR tt = t2 TO ((bounces + 1) + t2) * points STEP t2
  34.         IF xx(tt + t2) < bounces OR yy(tt + t2) < bounces THEN GOTO skip:
  35.         LINE (xx(tt), yy(tt))-(xx(tt + t2), yy(tt + t2)), _RGB32(255, 255, 255)
  36.     NEXT tt
  37. NEXT t2
  38.  
  39. skip:
  40. FOR e = 1 TO t
  41.     xx(t) = 0
  42.     yy(t) = 0
  43. points$ = STR$(points)
  44. _TITLE "Use the mouse wheel (1-50): " + points$
  45. t = 0
  46. tt = 0
Check out what I do besides coding: http://loudar.myportfolio.com/

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Makes a Globe with Lines and Points
« Reply #5 on: August 18, 2020, 01:07:07 pm »
Pretty cool loudar, but I get line 38 is out of range when I go from 1 to 50. DIM probably just needs more added to it.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Makes a Globe with Lines and Points
« Reply #6 on: August 18, 2020, 01:08:11 pm »
Oh I see, DIM isn't in the loop so points on the DIM line will always only be 3. But you can't put DIM in the loop to begin with, so I suggest just making a very high value for the DIM line.
« Last Edit: August 18, 2020, 01:10:17 pm by SierraKen »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Makes a Globe with Lines and Points
« Reply #7 on: August 18, 2020, 01:15:13 pm »
Here is another design that is pretty far-out looking. All I did was add: * points at the end of the STEP line in line 35.
Move the mouse wheel slowly, you can see that it looks like a sci-fi portal. :) I added a picture below.

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(600, 600, 32)
  2. DIM xx(5000), yy(5000)
  3. _LIMIT 100
  4. points = 3
  5. GOSUB drawing:
  6.  
  7.     mouseWheel = 0
  8.         mouseWheel = mouseWheel + _MOUSEWHEEL
  9.     LOOP
  10.     IF mouseWheel = 1 THEN points = points + 1: CLS: GOSUB drawing
  11.     IF mouseWheel = -1 THEN points = points - 1: CLS: GOSUB drawing:
  12.     a$ = INKEY$
  13.     IF a$ = CHR$(27) THEN END
  14.  
  15. drawing:
  16. mouseWheel = 0
  17. IF points < 1 THEN points = 1
  18. IF points > 50 THEN points = 50
  19. FOR a = 1 TO 1200 * points STEP 20
  20.     seconds = seconds + 5 / points
  21.     sec = (60 - seconds) * 6 + 180
  22.     x = INT(SIN(sec / 180 * 3.141592) * 180) + 300
  23.     y = INT(COS(sec / 180 * 3.141592) * 180) + 300
  24.     t = t + 1
  25.     xx(t) = x
  26.     yy(t) = y
  27.     CIRCLE (x, y), 2, _RGB32(255, 255, 255)
  28. seconds = 0
  29.  
  30. FOR t2 = 1 TO points * 10
  31.     FOR tt = t2 TO (11 + t2) * points STEP t2 * points
  32.         IF xx(tt + t2) < 10 OR yy(tt + t2) < 10 THEN GOTO skip:
  33.         LINE (xx(tt), yy(tt))-(xx(tt + t2), yy(tt + t2)), _RGB32(255, 255, 255)
  34.     NEXT tt
  35. NEXT t2
  36.  
  37. skip:
  38. FOR e = 1 TO t
  39.     xx(t) = 0
  40.     yy(t) = 0
  41. points$ = STR$(points)
  42. _TITLE "Use the mouse wheel (1-50): " + points$
  43. t = 0
  44. tt = 0
  45.  
Kens Sci-Fi Portal.jpg
* Kens Sci-Fi Portal.jpg (Filesize: 118.58 KB, Dimensions: 601x626, Views: 213)
« Last Edit: August 18, 2020, 01:19:23 pm by SierraKen »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Makes a Globe with Lines and Points
« Reply #8 on: August 18, 2020, 02:34:07 pm »
I made an auto mode that opens and closes the portal automatically. Pressing Space Bar turns it on and off.
I also made a YouTube video of it:



Here is the code:
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(600, 600, 32)
  2. DIM xx(5000), yy(5000)
  3. _LIMIT 100
  4. points = 1
  5. dir = 1
  6. GOSUB drawing:
  7.  
  8.     mouseWheel = 0
  9.         mouseWheel = mouseWheel + _MOUSEWHEEL
  10.     LOOP
  11.     IF mouseWheel = 1 THEN
  12.         IF points = 40 THEN GOTO skipthis:
  13.         points = points + 1
  14.         CLS
  15.         GOSUB drawing
  16.     END IF
  17.     IF mouseWheel = -1 THEN
  18.         IF points = 1 THEN GOTO skipthis:
  19.         points = points - 1
  20.         CLS
  21.         GOSUB drawing:
  22.     END IF
  23.     IF auto / 2 <> INT(auto / 2) THEN
  24.         _DELAY .25
  25.         IF points = 40 THEN dir = 2
  26.         IF points = 1 THEN dir = 1
  27.         IF dir = 1 THEN points = points + 1
  28.         IF dir = 2 THEN points = points - 1
  29.         CLS
  30.         GOSUB drawing
  31.     END IF
  32.  
  33.     skipthis:
  34.     a$ = INKEY$
  35.     IF a$ = CHR$(27) THEN END
  36.     IF a$ = " " THEN auto = auto + 1
  37.  
  38. drawing:
  39. mouseWheel = 0
  40. IF points < 1 THEN points = 1
  41. IF points > 40 THEN points = 40
  42. FOR a = 1 TO 1200 * points STEP 20
  43.     seconds = seconds + 5 / points
  44.     sec = (60 - seconds) * 6 + 180
  45.     x = INT(SIN(sec / 180 * 3.141592) * 180) + 300
  46.     y = INT(COS(sec / 180 * 3.141592) * 180) + 300
  47.     t = t + 1
  48.     xx(t) = x
  49.     yy(t) = y
  50.     CIRCLE (x, y), 2, _RGB32(255, 255, 255)
  51. seconds = 0
  52.  
  53. FOR t2 = 1 TO points * 10
  54.     FOR tt = t2 TO (11 + t2) * points STEP t2 * points
  55.         IF xx(tt + t2) < 10 OR yy(tt + t2) < 10 THEN GOTO skip:
  56.         LINE (xx(tt), yy(tt))-(xx(tt + t2), yy(tt + t2)), _RGB32(255, 255, 255)
  57.     NEXT tt
  58. NEXT t2
  59.  
  60. skip:
  61. FOR e = 1 TO t
  62.     xx(t) = 0
  63.     yy(t) = 0
  64. points$ = STR$(points)
  65. _TITLE "Use the mouse wheel (1-40): " + points$ + "   Or press Space Bar for Auto Mode (On/Off)."
  66. t = 0
  67. tt = 0
  68.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Makes a Globe with Lines and Points
« Reply #9 on: August 18, 2020, 04:11:46 pm »
@SierraKen

You last posts are reminding me of this done Feb 2019:
https://www.qb64.org/forum/index.php?topic=2931.msg121891#msg121891

« Last Edit: August 18, 2020, 04:16:05 pm by bplus »

Marked as best answer by SierraKen on August 18, 2020, 12:50:55 pm

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Makes a Globe with Lines and Points
« Reply #10 on: August 18, 2020, 04:44:56 pm »
Here's an even better one than my portal I just made. Instead of a portal, it makes a heart. :)

(Note: I updated this one from about 3 minutes ago when I posted one not as good.)

Here is a different YouTube video showing this one:




Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(600, 600, 32)
  2. DIM xx(10000), yy(10000)
  3. _LIMIT 100
  4. points = 1
  5. dir = 1
  6. GOSUB drawing:
  7.  
  8.     mouseWheel = 0
  9.         mouseWheel = mouseWheel + _MOUSEWHEEL
  10.     LOOP
  11.     IF mouseWheel = 1 THEN
  12.         IF points = 50 THEN GOTO skipthis:
  13.         points = points + 1
  14.         CLS
  15.         GOSUB drawing
  16.     END IF
  17.     IF mouseWheel = -1 THEN
  18.         IF points = 1 THEN GOTO skipthis:
  19.         points = points - 1
  20.         CLS
  21.         GOSUB drawing:
  22.     END IF
  23.     IF auto / 2 <> INT(auto / 2) THEN
  24.         _DELAY .25
  25.         IF points = 50 THEN dir = 2
  26.         IF points = 1 THEN dir = 1
  27.         IF dir = 1 THEN points = points + 1
  28.         IF dir = 2 THEN points = points - 1
  29.         CLS
  30.         GOSUB drawing
  31.     END IF
  32.  
  33.     skipthis:
  34.     a$ = INKEY$
  35.     IF a$ = CHR$(27) THEN END
  36.     IF a$ = " " THEN auto = auto + 1
  37.  
  38. drawing:
  39. mouseWheel = 0
  40. IF points < 1 THEN points = 1
  41. IF points > 50 THEN points = 50
  42. FOR a = 1 TO 1200 * points STEP 10
  43.     seconds = seconds + 5 / points
  44.     sec = (60 - seconds) * 6 + 180
  45.     x = INT(SIN(sec / 180 * 3.141592) * 180) + 300
  46.     y = INT(COS(sec / 180 * 3.141592) * 180) + 300
  47.     t = t + 1
  48.     xx(t) = x
  49.     yy(t) = y
  50.     CIRCLE (x, y), 2, _RGB32(255, 255, 255)
  51. seconds = 0
  52.  
  53. FOR t2 = 1 TO points * 10
  54.     FOR tt = t2 TO (11 + t2) * points STEP t2 * (points * 2)
  55.          IF xx(tt * 2) < 10 OR yy(tt * 2) < 10 THEN GOTO skip:
  56.         IF xx(tt * 3) < 10 OR yy(tt * 3) < 10 THEN GOTO skip:
  57.         LINE (xx(tt * 2), yy(tt * 2))-(xx(tt * 3), yy(tt * 3)), _RGB32(255, 255, 255)
  58.     NEXT tt
  59. NEXT t2
  60.  
  61. skip:
  62. FOR e = 1 TO t
  63.     xx(t) = 0
  64.     yy(t) = 0
  65. points$ = STR$(points)
  66. _TITLE "Use the mouse wheel (1-50): " + points$ + "   Or press Space Bar for Auto Mode (On/Off)."
  67. t = 0
  68. tt = 0
  69.  
Kens Heart With Lines.jpg
* Kens Heart With Lines.jpg (Filesize: 132.43 KB, Dimensions: 602x627, Views: 181)
« Last Edit: August 18, 2020, 05:25:07 pm by SierraKen »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Makes a Globe with Lines and Points
« Reply #11 on: August 18, 2020, 04:51:41 pm »
Bplus, yours is really awesome too! Amazing how many designs you can make with sine and cosine!