Page 1 of 1

Best way to draw a line Citro2d

Posted: Mon Feb 11, 2019 7:29 pm
by Magicrafter13
I want to draw lines in a program I am currently experimenting with. I notice that Citro2d has built in functions for rectangles, triangles, and ellipses, but not for basic lines. Is there an easy way to do this? I had one idea, where I took a 1x1 white png and I was going to draw it to the display and rotate and stretch it, and I was going to shade it different colors, but I don't know how to make a C2D_ImageTint.

So again, is there any easy way to draw lines from (x1, y1) to (x2, y2)? Preferably with different colors.

1x1 rectangles next to each other is not an option, as the lines will be dynamic (moveable), and I can't have that much of a performance hit.

Re: Best way to draw a line Citro2d

Posted: Mon Feb 11, 2019 9:24 pm
by fincs
Like I said on GitHub, lines cannot be drawn efficiently on the PICA200. You'd have to either draw degenerate triangles (I'm not sure if those work at all), or draw rotated rectangles. That is the reason why there is no DrawLine command. The main motivation for citro2d was creating a helper library that would allow users to perform common 2D tasks _efficiently_ on the PICA200. Adding a feature that is inefficient is against the design goals of citro2d.

Re: Best way to draw a line Citro2d

Posted: Mon Feb 11, 2019 9:32 pm
by Magicrafter13
fincs wrote: Mon Feb 11, 2019 9:24 pm Like I said on GitHub,
Yeah, I posted here before asking on GitHub. Also sorry for submitting 2 forum posts, I didn't read the message that it had to be reviewed first, and thought the first post hadn't gone through. :lol:

Re: Best way to draw a line Citro2d

Posted: Sat Feb 16, 2019 4:03 am
by Magicrafter13
fincs wrote: Mon Feb 11, 2019 9:24 pm DrawLine
https://github.com/Magicrafter13/BreakoutRedux

You should check out what I did. In just 2 days as well. Now, the rectangles and circles are just Citro2d rectangles and circles, however the tangent lines coming out from the "ball" at the bottom (which you can move by pushing left or right on the d-pad or joystick). It's a little hacked together, and the colors bug out occasionally, but it works relatively well, and as I've stated a few times, it's only for debugging.

I'd be interested to hear what you think.

Re: Best way to draw a line Citro2d

Posted: Fri Feb 22, 2019 3:29 am
by Nick777
fincs wrote: Mon Feb 11, 2019 9:24 pm Like I said on GitHub, lines cannot be drawn efficiently on the PICA200. You'd have to either draw degenerate triangles (I'm not sure if those work at all), or draw rotated rectangles. That is the reason why there is no DrawLine command. The main motivation for citro2d was creating a helper library that would allow users to perform common 2D tasks _efficiently_ on the PICA200. Adding a feature that is inefficient is against the design goals of citro2d.
How would you draw a rotated rectangle through citro2d?

Re: Best way to draw a line Citro2d

Posted: Fri Feb 22, 2019 4:19 pm
by fincs
Currently there's no function to do so. Therefore, you'll have to manually draw two triangles using C2D_DrawTriangle.

I'm starting to think that adding a helper function to draw a line (of configurable thickness) with a rotated rectangle (two tris) might not be such a bad idea after all. Stay tuned.