Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+7 votes

Anyone know of a method to get centerX and centerY to work with any pixelatedSize that could be entered by the user?

asked in CSC212_Spring2019 by (8 points)

1 Answer

+1 vote

It doesn't take a method. Just a little arithmetic.

If you used the variables in my strategy, then the variables row and col store the row and column indices of element A. You should be able to write an expression to calculate the row and column indices of element B (ie. centerX and centerY) by adding a value to row and col. That expression should use the pixelating size received as a parameter to the method.

Look at my 3 diagrams with pixelating size 2, 5, 7 and see how much you need to add in each case.

answered by (4.4k points)
...