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.
Best way to draw a line Citro2d
Re: Best way to draw a line Citro2d
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.
Donate to devkitPro - help us stay alive!
-
- Posts: 3
- Joined: Mon Feb 11, 2019 6:48 pm
-
- Posts: 3
- Joined: Mon Feb 11, 2019 6:48 pm
Re: Best way to draw a line Citro2d
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
How would you draw a rotated rectangle through citro2d?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.
Re: Best way to draw a line Citro2d
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.
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.
Donate to devkitPro - help us stay alive!
Who is online
Users browsing this forum: No registered users and 2 guests