javascript - Equidistant points on canvas -
i want draw variable number of equidistant points on html5 canvas element, using javascript. how calculate x/y position of each point?
edit:
i want distance 1 point direct neighbours , edges of canvas same.
if had 8px x 8px canvas , 4 points, distace point it's direct neighbours , edges of canvas 2px.
if had uneven number of points , not square canvas?
(i think image might understand problem little better)
i'd recommend building simple constraint solver - using relaxation arrive @ answer want. similar technique used visio-like applications. basically, can add spring forces between pairs of points , boundaries of canvas. simulate short amount of time, , 'settle' place.
you try box2djs - simple javascript physics system. or read on verlet integration / constraints - it's pretty simple , running, , great these kinds of applications.
Comments
Post a Comment