Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

drawing error?

dave1707dave1707 Mod
edited February 2013 in Bugs Posts: 9,586

Can someone explain what's happening here. If I run this on my iPad 1, it prints the text 'drawing lines' every time, but it doesn't draw the lines every time. This is set up to draw and print every 3 seconds. If it works every time for you, try restarting the program or change the for loop to 10, 15, or 20 and try again. This is a small example of something similar that was happening in another program I was working on. I can't figure out why sometimes the lines are drawn and sometimes they not.

function setup()     et=0 end function draw()     background(40, 40, 50)          fill(255)     text(math.floor(ElapsedTime),300,800)          if ElapsedTime-et > 3 then    -- draw lines and print text every 3 seconds         stroke(255)         strokeWidth(2)                  for z=1,15 do                        -- change value to 10,15,or 20             line(200+z*5,200,200+z*5,600)    --draws 10, 15, 20 lines         end                  print("drawing lines")         et=ElapsedTime     end      end


  • Posts: 1,595

    Your setting the x coordinates on the line function to the same integer, try putting 250+z*5 for the x2 argument

  • Posts: 2,161

    How many iterations does it take for the non-drawing behaviour to show itself? I just tried it on my iPad4 (though I am running the beta) and it seemed to work as I would expect.

  • dave1707dave1707 Mod
    edited February 2013 Posts: 9,586

    .@Andrew_Stacey Sometimes it happens as soon as the program starts, sometimes after a few displays, and sometimes not at all. I think I have the answer. I just needed to sleep on it because when I woke up this morning I remembered a program I wrote a long time ago that might explain what's happening. As soon as I find my original program and the discussion, I'll share the answer if it's what I'm thinking.

    edit: I haven't found what I'm looking for yet and I don't have time right now. Here's what I think is happening. Codea uses 3 screens for it's display and 1 of those 3 screens is shown while the other 2 are being updated. My display is being drawn on 1 of the screens, but because the duration of the draw is so short, it isn't being shown and being erased before the screen I wrote it to is shown. Like I said, I wrote a program that shows this, I just have to find it.

  • dave1707dave1707 Mod
    Posts: 9,586

    I think this might be related to the problem I was having. The fix I made in my other program was just to make the display last longer than 1 cycle of the draw routine. Here is the link to what I was thinking of.

Sign In or Register to comment.