@@ -2856,6 +2856,20 @@ <h2 class="export__title">${paletteTitle}</h2>
28562856 let exStartHue = Math . random ( ) * 360 ;
28572857 let globalInterval = null ;
28582858
2859+ // Helper to generate well-spaced random anchor colors
2860+ function generateSpacedAnchorColors ( count , jitter = 20 ) {
2861+ const baseHue = Math . random ( ) * 360 ; // Random starting point
2862+ const hueStep = 360 / count ; // Even distribution
2863+
2864+ return Array . from ( { length : count } , ( _ , i ) => {
2865+ // Evenly spaced hue with random jitter
2866+ const hue = ( baseHue + i * hueStep + ( Math . random ( ) - 0.5 ) * jitter * 2 ) % 360 ;
2867+ const sat = 0.5 + Math . random ( ) * 0.5 ; // 0.5 to 1
2868+ const light = 0.3 + Math . random ( ) * 0.5 ; // 0.3 to 0.8
2869+ return [ hue , sat , light ] ;
2870+ } ) ;
2871+ }
2872+
28592873 // Code example generators - reusable for init and section updates
28602874 const codeExamples = {
28612875 summoning : ( anchors = poline . anchorPoints ) => `new Poline({
@@ -3075,15 +3089,17 @@ <h2 class="export__title">${paletteTitle}</h2>
30753089 {
30763090 section : 'UpdatingAnchors' ,
30773091 fn : ( section ) => {
3092+ // Generate well-spaced hues, keeping original saturation and lightness
3093+ const count = poline . anchorPoints . length ;
3094+ const baseHue = Math . random ( ) * 360 ;
3095+ const hueStep = 360 / count ;
3096+ const jitter = 20 ;
3097+
30783098 poline . anchorPoints . forEach ( ( anchor , i ) => {
3079- const hsl = anchor . color ;
3099+ const newHue = ( baseHue + i * hueStep + ( Math . random ( ) - 0.5 ) * jitter * 2 ) % 360 ;
30803100 poline . updateAnchorPoint ( {
30813101 point : anchor ,
3082- color : [
3083- hsl [ 0 ] + Math . random ( ) * 60 - 30 ,
3084- hsl [ 1 ] ,
3085- hsl [ 1 ] ,
3086- ] ,
3102+ color : [ newHue , anchor . color [ 1 ] , anchor . color [ 2 ] ] ,
30873103 } ) ;
30883104 } ) ;
30893105 updateCodeBlock ( 'UpdatingAnchors' ) ;
0 commit comments