[Resolved] Bug in display.newLine / line:append ?

(Sent via email as well.)

I’ve been working with a line-draw demo that I think Carlos wrote. It draws lines segments as you move your finger around the screen. After a certain point it stops drawing more line segments. Sometimes after just a second or two, sometimes after over 1000 segments are added.

It looked like a bug in the Lua code, so I spent some time narrowing it down. Eventually I boiled it down to this test program:

local pts = {}  
  
table.insert(pts, {x=200, y=200}) -----MOVE THIS-----  
table.insert(pts, {x=65, y=65})  
table.insert(pts, {x=62, y=68})  
table.insert(pts, {x=63, y=67})  
  
local line = display.newLine(pts[1].x, pts[1].y, pts[2].x, pts[2].y)  
for i = 3, #pts, 1 do   
 line:append(pts[i].x, pts[i].y)  
end  
line:setColor(255,128,0)  
line.width=4  

The version above works. BUT…

If I move the “MOVE THIS” line down by one (below the 65,65 point), I get something very different. The line extends beyond 200,200 - beyond the right side of the screen.

If I move the “MOVE THIS” line down once more, the line extends off both the left and right sides. That’s a weird one.

Finally, if I move it down again so it’s the last of the four table.insert lines, it doesn’t draw to the last point at all. Only the first three points are drawn.

Unless there’s an error in the Lua code, this looks like a bug in Corona.
[import]uid: 9659 topic_id: 5132 reply_id: 305132[/import]

No response yet? OK here are four screenshots that illustrate what’s happening.

The first is with the “MOVE THIS” line as the 1st line, then as the 2nd, the 3rd, and the 4th. All I’m doing is moving one line of code, and the lines are obviously being drawn incorrectly.

I hope this helps.
[import]uid: 9659 topic_id: 5132 reply_id: 17259[/import]

Thanks for the report. This is a bug in our rendering engine, which I’ve filed for an engineer to investigate. The issue, as it was explained to me, has to do with how our rendering engine computes/draws the miter joint when the angle created by the path is very small.

To better explain (not that it will necessarily be helpful to you) here’s an interactive version of your bug sample w/three points, where the touch position on the screen determines the line’s middle/second point. As the touch point approaches the same y-coordinate plane as the other two points (~65) the miter gets drawn way off stage.

local pts = {} table.insert(pts, {x=5, y=65})table.insert(pts, {x=62, y=68})function drawLine(event) if event.phase == "began" or event.phase == "moved" then if line then line:removeSelf() end line = display.newLine(pts[1].x, pts[1].y, event.x, event.y) line:append(pts[2].x, pts[2].y) line:setColor(255,128,0) line.width=4 endendRuntime:addEventListener("touch", drawLine)[/code] [import]uid: 8196 topic_id: 5132 reply_id: 18709[/import]

Thanks for the reply, Tim, much appreciated. How can I track this? Right now I have a project that’s on hold until this is fixed.
[import]uid: 9659 topic_id: 5132 reply_id: 18710[/import]

I added an issue to our issues database, and provided the number to our internal bug case for tracking.

http://developer.anscamobile.com/issues/5565

Eventually, we plan to make our bug base public so developers can more easily track bugs.

Tim [import]uid: 8196 topic_id: 5132 reply_id: 18872[/import]

Thanks a bunch, Tim!
[import]uid: 9659 topic_id: 5132 reply_id: 18875[/import]

Hello,

I can’t access the issue link.
Is is fixed?

I’m getting the same problem with this sample:

-- LINES DEBUG  
 pts = {  
 {10,10},  
 {50,10},  
 {100,10},  
 {200,10},  
 {90,10}, -- THIS POINT BREAK THE LINE, COMMENT TO MAKE WORK  
 {200,100}  
 }  
 l = display.newLine(pts[1][1], pts[1][2], pts[2][1], pts[2][2])  
 for i = 3, #pts, 1 do  
 l:append(pts[i][1], pts[i][2])  
 end  
 l.width = 4  

Can’t I make a line go back?

Thank you [import]uid: 6732 topic_id: 5132 reply_id: 32940[/import]

I can’t see the issue link.
Please, someone can say what is the status of this bug? [import]uid: 6732 topic_id: 5132 reply_id: 33954[/import]

I’m with the same problem. My project is waiting this issue be fixed, and I can’t check the link …

Do you get any solution?
I’m trying to develop a way to avoid this problem by stoping the line and creating other lines until corona can fix this bug, someone can help with an idea? [import]uid: 6732 topic_id: 5132 reply_id: 36884[/import]

This is in the queue, our internal tracking # is 3032. Currently it is marked as having high priority so there is a fair chance it will be addressed by the next release. [import]uid: 6787 topic_id: 5132 reply_id: 37206[/import]

After a certain point it stops drawing more line segments. Sometimes after just a second or two, sometimes after over 1000 segments are added.

Is this totally unrelated to the miter bug?

c. [import]uid: 24 topic_id: 5132 reply_id: 37225[/import]

Thanks Tim,

I have a one year subscription but still can’t see the linked page (bug track page). When you will make those pages public? I really need to see this bug fixed.

regards,
Mehran [import]uid: 84304 topic_id: 5132 reply_id: 51962[/import]

Is this bug solved or not yet. I am also stuck in here ? [import]uid: 69481 topic_id: 5132 reply_id: 63090[/import]

is there any update on this bug? i’m seeing sharp razor like lines being created when trying to have the user draw on screen. Thanks! [import]uid: 6317 topic_id: 5132 reply_id: 66326[/import]

The issue was raised more than a year ago. So we can’t draw lines with Corona?
Ummm… [import]uid: 72230 topic_id: 5132 reply_id: 88425[/import]

This bug (mitre) was fixed a few weeks back.

and @plaush69, you can draw lines in corona, even bezier, catmull-rom splines, etc.

http://www.youtube.com/watch?v=up5fdLARei4

c [import]uid: 24 topic_id: 5132 reply_id: 88457[/import]

thanks carlos for the reply

I’m doing a simple drawing app.
See the code below. If I draw horizontally back and forth the newLine is not drawn correctly.
During the touch phase I’m drawing several lines (display.newLine()) to follow the user’s finger.
And at the same time I’m appending to just one line the same points (newLine:append()) after the user releases his finger I remove the created lines and just show the one which was filled by appending the points. The points are not correctly shown (a lot of them are missing)
As soon horizontal or almost horizontal lines are drawn with the finger the line is not corretly drawn.
Do you see a mistake in the code?
UPDATE: which build-number will have the fix in?

[code]
local lines = {}
local newLine = nil
local tmpLine = nil
local tmpLines = {}
function main()

display.setStatusBar(display.HiddenStatusBar) --hide status bar
–define line values
lineR = 255 --the R value of the line
lineG = 15 --the G value of the line
lineB = 44 --the B value of the line
lineAlpha = 155 --the size of the line
lineSize = 10 --the size of line

–add the eventlisteners
Runtime:addEventListener(“touch”, paint) --the function to paint the screen

end
function paint(event)

if event.phase == “began” then
beganX, beganY = event.x, event.y --save beganX and begaY for the newLine
newLine = display.newLine(event.x,event.y,event.x+1,event.y+1) --creates the line
table.insert( lines, newLine);
print("Nof lines: " … #lines)

newLine:setColor(lineR, lineG, lineB, lineAlpha) --set color of the line
newLine.width = lineSize --set the size of the line
newLine.isVisible = false;
end
if event.phase == “moved” then
if( newLine ~= nil) then
print(“appending point (” … event.x … “,” … event.y … “)”);
newLine:append(event.x, event.y)
end

tmpLine = display.newLine(beganX,beganY,event.x,event.y) --creates the line
tmpLine:setColor(lineR, lineG, lineB, lineAlpha) --set color of the line
tmpLine.width = lineSize
table.insert(tmpLines, tmpLine)
print("Nof tmplines: " … #tmpLines)
beganX, beganY = event.x, event.y

end
if event.phase == “ended” then
for k, v in pairs(tmpLines) do
v:removeSelf();
end
tmpLines = {}
if( newLine ~= nil) then
newLine.isVisible = true;
end
end

end
main()
[/code] [import]uid: 72230 topic_id: 5132 reply_id: 88466[/import]

daily build. a few weeks back.

c [import]uid: 24 topic_id: 5132 reply_id: 88470[/import]

I just run this example which I found in the beginning of the topic.
And still did not see any progress in this bug. I am using latest daily build 2012.777
And the code from the first topic work similar to pictures.
can I assume that nothing was fixed and this bug is not going to be fixed?

– LINES DEBUG
pts = {
{10,10},
{50,10},
{100,10},
{200,10},
{90,10}, – THIS POINT BREAK THE LINE, COMMENT TO MAKE WORK
{200,100}
}
l = display.newLine(pts[1][1], pts[1][2], pts[2][1], pts[2][2])
for i = 3, #pts, 1 do
l:append(pts[i][1], pts[i][2])
end
l.width = 4 [import]uid: 70928 topic_id: 5132 reply_id: 98975[/import]

exactly…I subscribed to Corona SDK because Carlos stated that linedrawing was fixed…actually it IS better…but still horizontal lines back and forth are not working. And still there are very strange artefacts coming while drawing with the finger…

!actually this means that Corona SDK can not be used to make any drawing apps unless you use circles instead of lines which decreases speed extremely!

ansca is doing great sometimes and sometimes just not…I understand that there are a lot of requirements to cover though so we are used to be patient. [import]uid: 72230 topic_id: 5132 reply_id: 98982[/import]