Best way to draw a line Citro2d

Post Reply
Magicrafter13
Posts: 3
Joined: Mon Feb 11, 2019 6:48 pm

Best way to draw a line Citro2d

Post by Magicrafter13 » Mon Feb 11, 2019 7:29 pm

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.

User avatar
fincs
( ͡° ͜ʖ ͡°)
Posts: 103
Joined: Mon Jul 12, 2010 9:45 pm
Location: Seville, Spain
Contact:

Re: Best way to draw a line Citro2d

Post by fincs » 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.
Donate to devkitPro - help us stay alive!

Magicrafter13
Posts: 3
Joined: Mon Feb 11, 2019 6:48 pm

Re: Best way to draw a line Citro2d

Post by Magicrafter13 » Mon Feb 11, 2019 9:32 pm

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:

Magicrafter13
Posts: 3
Joined: Mon Feb 11, 2019 6:48 pm

Re: Best way to draw a line Citro2d

Post by Magicrafter13 » Sat Feb 16, 2019 4:03 am

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.

Nick777
Posts: 2
Joined: Sun Feb 17, 2019 7:44 pm

Re: Best way to draw a line Citro2d

Post by Nick777 » Fri Feb 22, 2019 3:29 am

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?

User avatar
fincs
( ͡° ͜ʖ ͡°)
Posts: 103
Joined: Mon Jul 12, 2010 9:45 pm
Location: Seville, Spain
Contact:

Re: Best way to draw a line Citro2d

Post by fincs » Fri Feb 22, 2019 4:19 pm

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.
Donate to devkitPro - help us stay alive!

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests