0
votes

I have a few drawing routines that I'm using to render a graphical representation of a simulation to the user. This simulation has periodic boundary conditions (if something leaves the top, it comes back in the bottom). As of now, the implementation effectively does all of the drawing options as draw(x%WIDTH,y%HEIGHT), which more-or less works--if I draw a line from <width-1,y> to <width+1,y>, this turns into a line all the way across the screen. I can put in a test for if the periodicity will be triggered, and use move_to instead of line_to, but this seems somewhat inefficient, and only works for polygons.

Is there a way to switch cairo to "periodic mode", where I could, for example, draw a circle extending off the top of the canvas, and it would appear partially on the bottom? It would be really nice to write to the actual coordinates of my objects, instead of doing a MOD per coordinate per frame.

Preemptive note: saying "draw two circles, one on the bottom and one on the top" is not what I'm looking for.

1

1 Answers

2
votes

No, there is no such mode.

One thing that may or may not work for you is to allocate a surface with an alpha channel, that is twice the size in both directions, then draw everything modulo WIDTH/HEIGHT, and then finally composite the four subsurfaces onto your real surface.