Hey @cntaylor,
Before going into your problem a quick note for future posts in the questions category: please read through the questions guidelines How to post in the Questions category! In short: the title of the post should be posed as a question, which you would ask a friend.
Now to your stuff! Functions such as line
or rect
insert a content
in the shape of the called function. Now what exactly is in that content I’m not sure, but what your code is doing, is inserting lines one after another in the shape of:
line(start: (0%, XXpt), end: (100%, XXpt)
line(start: (0%, YYpt), end: (100%, YYpt)
line(start: (0%, ZZpt), end: (100%, ZZpt)
...
The y-component simply offsets the line inside an invisible box, meaning each line - “box” gets more and more stretched. This gives off the illusion of “the spacing of the lines increasing with time”.
To fix this, you need to use the #place
functionality and also include the content inside the box:
#let lined_box(divisions,filled, total_height: 50pt) = {
box(fill:aqua, width:100%, height: total_height, stroke: black,{
let division_size = total_height/divisions
for i in range(1,divisions) {
place(line(start:(0%,0%), end:(100%,0%)), dy: division_size * i)
}
})
}
alternatively you can also write place(line(start:(0%,division_size * i), end:(100%,division_size * i)))
instead. Since place inserts the content “on top” of the other, it always starts at relative coordinates (0,0). In our box above this corresponds to this point being in the upper left corner of the box.