GREEN 64 1 208 1.91 KB 86

/puzzle/ Custom Voronoi

By Trixie_Voronoi
Created: 2026-08-29 04:03:33
Updated: 2026-08-29 04:03:54

  1. 1.
    //Diamond Patchwork
  2. 2.
    function generateSites(width, height, count) {
  3. 3.
    const ratio = width / height;
  4. 4.
    const cols = Math.max(1, Math.round(Math.sqrt((count / 1.25) * ratio)));
  5. 5.
    const rows = Math.max(1, Math.round((count / 1.25) / cols));
  6. 6.
     
  7. 7.
    const sites = [];
  8. 8.
    const stepX = width / cols;
  9. 9.
    const stepY = height / rows;
  10. 10.
     
  11. 11.
    for (let y = 0; y < rows; y++) {
  12. 12.
    for (let x = 0; x < cols; x++) {
  13. 13.
    sites.push([
  14. 14.
    (x + 0.5) * stepX,
  15. 15.
    (y + 0.5) * stepY
  16. 16.
    ]);
  17. 17.
     
  18. 18.
    if (x % 2 === 1 && y % 2 === 1) {
  19. 19.
    sites.push([
  20. 20.
    x * stepX,
  21. 21.
    y * stepY
  22. 22.
    ]);
  23. 23.
    }
  24. 24.
    }
  25. 25.
    }
  26. 26.
     
  27. 27.
    return sites;
  28. 28.
    }
  29. 29.
     
  30. 30.
    //Double Diamond Patchwork
  31. 31.
    function generateSites(width, height, count) {
  32. 32.
    const ratio = width / height;
  33. 33.
    const cols = Math.max(1, Math.round(Math.sqrt((count / 1.5) * ratio)));
  34. 34.
    const rows = Math.max(1, Math.round((count / 1.5) / cols));
  35. 35.
     
  36. 36.
    const sites = [];
  37. 37.
    const stepX = width / cols;
  38. 38.
    const stepY = height / rows;
  39. 39.
     
  40. 40.
    for (let y = 0; y < rows; y++) {
  41. 41.
    for (let x = 0; x < cols; x++) {
  42. 42.
    sites.push([
  43. 43.
    (x + 0.5) * stepX,
  44. 44.
    (y + 0.5) * stepY
  45. 45.
    ]);
  46. 46.
     
  47. 47.
    if (x > 0 && y > 0 && x % 2 === y % 2) {
  48. 48.
    sites.push([
  49. 49.
    x * stepX,
  50. 50.
    y * stepY
  51. 51.
    ]);
  52. 52.
    }
  53. 53.
    }
  54. 54.
    }
  55. 55.
     
  56. 56.
    return sites;
  57. 57.
    }
  58. 58.
     
  59. 59.
    //Oops! All Diamonds
  60. 60.
    function generateSites(width, height, count) {
  61. 61.
    const ratio = width / height;
  62. 62.
    const cols = Math.max(1, Math.round(Math.sqrt((count / 2) * ratio)));
  63. 63.
    const rows = Math.max(1, Math.round((count / 2) / cols));
  64. 64.
     
  65. 65.
    const sites = [];
  66. 66.
    const stepX = width / cols;
  67. 67.
    const stepY = height / rows;
  68. 68.
     
  69. 69.
    for (let y = 0; y < rows; y++) {
  70. 70.
    for (let x = 0; x < cols; x++) {
  71. 71.
    sites.push([
  72. 72.
    (x + 0.5) * stepX,
  73. 73.
    (y + 0.5) * stepY
  74. 74.
    ]);
  75. 75.
     
  76. 76.
    if (x > 0 && y > 0) {
  77. 77.
    sites.push([
  78. 78.
    x * stepX,
  79. 79.
    y * stepY
  80. 80.
    ]);
  81. 81.
    }
  82. 82.
    }
  83. 83.
    }
  84. 84.
     
  85. 85.
    return sites;
  86. 86.
    }

/puzzle/ Custom Voronoi

by Trixie_Voronoi