none
Beginner Question RRS feed

  • Question

  • Hey, I just started learning programming 2 days ago. I've been trying to come up with some simple ideas and use the knowledge I've gained to make them happen. I created a program -- JPS324 -- that draws magenta circles and rectangles every second depending on where your cursor is. I wanted to add on a little bit, so I tried to create a subroutine that would make a large black circle that would delete the magenta shapes when you click your mouse down, but I can't seem to get it to work :/ Can someone take a look at the last bit of my program and see what I'm doing wrong? Thanks :] By the way, I'm sure there are plenty of ways to simplify what I've wrote, but that isn't a concern of mine now. I'm just trying to put ideas into this program and make them happen. I'll worry about simplifying as I learn more and progress in my knowledge of programming.

    Saturday, May 1, 2010 9:11 PM

Answers

  • In general your program looks good, the problem is:

    GraphicsWindow.FillEllipse(a,b,1000000,1000000)

    This doesn't work as you expect here. The reason is that the coordinates for a circle drawn are the upper left corner of the rectangle bounding the circle (ellipse) as you are using for the magenta circles/squares (offset by 25 pixels there).  For the very large circle, with the top left at (a,b), the actual circle doesn't start until it is well outside the viewing area of the GraphicsWindow.

    Try (the last 2 are best really):

    GraphicsWindow.FillEllipse(a-500000,b-500000,1000000,1000000)

    Or

    GraphicsWindow.Clear()

    Or

    GraphicsWindows.FillRectangle(0,0,500,500)
    Sunday, May 2, 2010 1:55 PM
    Moderator

All replies

  • I didn't even bother to try and figure out what was wrong, I didn't have enough time. But I got it to work.

    1. Instead of Drawing a giant shape over it all, you can just use 'GraphicsWindow.Clear'. Which maintains the background color but deletes or 'erases' everything else

    And

    2. In you mousedown sub is where I changed all that, I then moved the Timer.Resume() after the GraphicsWindow.Clear() which works perfectly fine because when they hold it down it keeps running through that if i'm not mistaken. I Then just deleted the resume sub as it was no longer deleted.

    Import~JPS324-0~

    Hope it helped,

    The Hacker2

    • Proposed as answer by The Hacker2 Sunday, May 2, 2010 3:19 AM
    Sunday, May 2, 2010 3:19 AM
  • In general your program looks good, the problem is:

    GraphicsWindow.FillEllipse(a,b,1000000,1000000)

    This doesn't work as you expect here. The reason is that the coordinates for a circle drawn are the upper left corner of the rectangle bounding the circle (ellipse) as you are using for the magenta circles/squares (offset by 25 pixels there).  For the very large circle, with the top left at (a,b), the actual circle doesn't start until it is well outside the viewing area of the GraphicsWindow.

    Try (the last 2 are best really):

    GraphicsWindow.FillEllipse(a-500000,b-500000,1000000,1000000)

    Or

    GraphicsWindow.Clear()

    Or

    GraphicsWindows.FillRectangle(0,0,500,500)
    Sunday, May 2, 2010 1:55 PM
    Moderator
  • Ants,

    Possibly what you are looking for is to change your FillEllipse command in your Erase sub to something like this...

    GraphicsWindow.FillEllipse(GraphicsWindow.MouseX - 50,GraphicsWindow.MouseY - 50,100,100)

     

    Or maybe I misunderstand and you simply want to clear all of the circles in one go. If so, just use the graphicsWindow.clear() as others have suggested.

    Sunday, May 2, 2010 6:30 PM
  • Ahh, thanks. I didn't realize there was a clear function haha :]
    Sunday, May 2, 2010 9:50 PM