How can one implement this?
Joining lines with circles?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Joining lines with circles?
.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙
Re: Joining lines with circles?
This is typically called a rounded join.
Doesn't seem to be supported according to the love2d documentation.
Doesn't seem to be supported according to the love2d documentation.
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Joining lines with circles?
You could fake it by drawing filled circles at the end-points of line segments yourself, with love.graphics.circle.
(And make sure to optimize it so only one gets drawn between two segments, not two because of the end-points.)
(And make sure to optimize it so only one gets drawn between two segments, not two because of the end-points.)
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Joining lines with circles?
Beware: lines (may?) have antialiasing applied to them, filled circles do not. The result might look unsatisfactory.zorg wrote: ↑Mon Jan 22, 2018 12:52 pm You could fake it by drawing filled circles at the end-points of line segments yourself, with love.graphics.circle.
You achieve better results if you draw both filled and line circles:
Code: Select all
function love.draw()
local w = 40
love.graphics.setColor(255, 255, 255)
love.graphics.setLineWidth(w)
love.graphics.setLineJoin('none')
love.graphics.line(100, 200, 240, 100, 300, 200, 320, 100)
love.graphics.setLineWidth(2)
love.graphics.circle('line', 240, 100, w * .5 - 1)
love.graphics.circle('line', 300, 200, w * .5 - 1)
love.graphics.circle('fill', 240, 100, w * .5 - 1)
love.graphics.circle('fill', 300, 200, w * .5 - 1)
end
Re: Joining lines with circles?
Thanks for responding!
Well, i've actually tried this solution and it worked for drawing lines.
The problem is in the way how love handles line rendering internally.
Say, if you draw an outline of a slim ellipse (1:10, for example) you may notice how outline kinda 'breaks' on the ends of an ellipse
(To clarify: calling " love.graphics.ellipse( "line" , x,y , 50 , 5 ) " will draw an ellipse strerched along x-axis. So, the outline will break on the left and right side of the shape.)
The effect gets more visible if strokes are wide.
So, clarifying the question, is there a way to add some new kind of linejoin to love?
--
This isn't crucial actually, I know that might appear way too hard to implement. Just curious.
Well, i've actually tried this solution and it worked for drawing lines.
The problem is in the way how love handles line rendering internally.
Say, if you draw an outline of a slim ellipse (1:10, for example) you may notice how outline kinda 'breaks' on the ends of an ellipse
(To clarify: calling " love.graphics.ellipse( "line" , x,y , 50 , 5 ) " will draw an ellipse strerched along x-axis. So, the outline will break on the left and right side of the shape.)
The effect gets more visible if strokes are wide.
So, clarifying the question, is there a way to add some new kind of linejoin to love?
--
This isn't crucial actually, I know that might appear way too hard to implement. Just curious.
.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Joining lines with circles?
But here's what i don't understand... both with a single line or multiple line segments joined, you still never would have to draw an ellipse, only circles.ffive wrote: ↑Mon Jan 22, 2018 6:50 pm Well, i've actually tried this solution and it worked for drawing lines.
The problem is in the way how love handles line rendering internally.
Say, if you draw an outline of a slim ellipse (1:10, for example) you may notice how outline kinda 'breaks' on the ends of an ellipse
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Joining lines with circles?
There's this library: viewtopic.php?f=5&t=83841 which reimplements Löve's line drawing algorithm. That one you can modify to add a new kind of linejoin.
Who is online
Users browsing this forum: Google [Bot] and 2 guests