$$ S=K\sum_{\langle i,j\rangle} \cos(\theta_i-\theta_j) $$
where the \(\theta_i \in [0,2\pi) \) is the orientation of local spin.
visulization of \(\theta_i\):
pseudo-code:
Red-Green-Blue system: light, used for TV or computer screen.
Cyan-Magenta-Yellow-(Key) system: printing on the paper, check your ink color.
Red-Yellow-Blue system: artists, painters. blending pigment.
since I'm using a computer screen, RGB color is my choice. However, it is not natural to draw a color wheel using RGB parameter. HSL or HSV is better.
Hue(色相) ranges from 0,1,2,3 to 359. Saturation(饱和度) and Light(亮度) can be set to 50%. \[ \text{hue}= \frac{\theta}{2\pi}\times 360 \] the javascript syntax is: (don't forget the quotation marks)
context.fillStyle='hsl(220.7, 50%, 50%)'; context.fillStyle='hsl('+ 360*Math.random() +', 50%, 50%)';