[ New messages · Members · Forum rules · Search · RSS ]
  • Page 1 of 1
  • 1
Forum » General category » BASIC programming » Prime Number fractal
Prime Number fractal
ZlatkoDate: Saturday, 2019-10-19, 8:38 PM | Message # 1
Lieutenant
Group: Administrators
Messages: 62
Reputation: 0
Status: Offline
Just to start with something and to show good hope.
here is the one from QB64 forum



  • 'Prime Number Fractal By Ashish
  • '19 Oct, 2019
  • _TITLE "Prime Number Fractal By Ashish"
  • SCREEN _NEWIMAGE(700, 700, 32)
  • s = 1
  • DO
  •     s = s + 25
  •     FOR i = 1 TO s
  •         IF isPrime(i) THEN
  •             xx = map(COS(i) * i, 0, s, 0, s / 16) * COS(z) + _WIDTH / 2
  •             yy = map(SIN(i) * i, 0, s, 0, s / 16) * SIN(z) + _HEIGHT / 2
  •             r = map(ABS(xx - 350), 0, 350, 255, 50)
  •             g = map(ABS(yy - 350), 0, 350, 255, 50)
  •             PSET (xx, yy), _RGB32(r, g, (r + g) / 2, 100)
  •         END IF
  •     NEXT
  •     _DISPLAY
  •     _LIMIT 48
  •     z = z + .1
  • LOOP UNTIL s > 10000
  • FUNCTION isPrime (n AS INTEGER)
  •     k = 0
  •     IF n < 2 THEN EXIT FUNCTION
  •     FOR i = 2 TO n
  •         IF n MOD i = 0 THEN k = k + 1
  •         IF k > 1 THEN EXIT FUNCTION
  •     NEXT
  •     IF k = 1 THEN isPrime = -1
  • END FUNCTION
  • 'from p5js.bas
  • 'https://bit.ly/p5jsbas
  • FUNCTION map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
  •     map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
  • END FUNCTION
  •  
    Forum » General category » BASIC programming » Prime Number fractal
    • Page 1 of 1
    • 1
    Search: