I have an array (populated from a database) $dna_segment_length
, in this case:
{50, 75, 20, 90}
Each value represents a line length. The lines are being drawn on canvas like:
To make the line segments join into a continuous horizontal line, I need to create another array, say $start_points
, which represent the starting points for each line. In the above example, this array would be like the following with a set starting point for the first line:
{100, 150, 225, 245}
The first value in the starting points array always needs to be 100. Successive values are created by adding the line length and the previous value in the new array. The question is how should I do this using a loop?