Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

My coordinates are out of bounds?

+11 votes
I keep getting an error that the coordinates for my dots are out of bounds. No matter what I plug into my variables though, it isn't greater than the dimensions of the drawing panel.

Any ideas of what is going on?
asked Jan 18, 2016 in (Winter 15-16) by Natalie Brown (100 points)

2 Answers

+5 votes
It could be that you are starting your srcX and srcY out of bounds?? It should be that you start them at 0.. Not really sure? If there is a way you could screen shot your code I would try and debug it for you?

Is it saying that your art drawing is out of bounds or that image is out of bounds?
answered Jan 18, 2016 by Kyle Cluver (100 points)
+2 votes
There aren't any errors for drawing graphics out of bounds... when that happens, they just don't show up.  So it's most likely the error is that the coordinates that you're feeding in to your getColorAtPixel(...) method are indeed greater than OR EQUAL TO the dimension of the PHOTO drawing panel (not the canvas panel).  

If your image is bird2.jpg, then the width is 300 and the height is 200.  You are ONLY allowed to request Color from the image's pixels, for which the x-coordinates are number 0 to 299, and the y-coordinates are numbered 0 to 199.

Hope that helps!
answered Jan 18, 2016 by Forrest Stonedahl (100 points)
...