Sorceress

Untitled

Jan 7th, 2021
99
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DEFDBL A-Z
  2. DIM col AS LONG, i AS LONG
  3.  
  4. SCREEN _NEWIMAGE(800, 600, 32)
  5. cx = 400: cy = 300
  6.  
  7. WHILE INKEY$ <> CHR$(27)
  8. a = -7: b = 10
  9. CLS
  10.  
  11. FOR u = 1 TO 7000
  12. xr = RND * 12 - 6: xi = RND * 12 - 6
  13. GOSUB ECfunc
  14. col = _RGB(128 + xr * 16, 128 - xi * 16, 128 + yi * 16)
  15. GOSUB plot
  16. yr = -yr: yi = -yi 'negative root
  17. col = _RGB(128 + xr * 16, 128 - xi * 16, 128 + yi * 16)
  18. GOSUB plot
  19. NEXT
  20.  
  21. _DISPLAY
  22. _LIMIT 15
  23. WEND
  24. SYSTEM
  25.  
  26. ECfunc: 'inputs (xr,xi) outputs (yr,yi)
  27. 'y^2 = q = x^3 +a*x + b 'elliptic curve over complex x
  28. qr = xr * (xr * xr - 3 * xi * xi + a) + b
  29. qi = xi * (3 * xr * xr - xi * xi + a)
  30. modq = SQR(qr * qr + qi * qi)
  31. yr = 0.707107 * SQR(modq + qr): yi = qi / (2 * yr)
  32. RETURN
  33.  
  34. plot: 'projects point to R2 and plots it
  35. px = cx + 25 * xr
  36. py = cy + 25 * yr
  37. PSET (px, py), col
  38. RETURN
  39.  
  40.  
RAW Paste Data