Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
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 (1 point)

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 (1 point)
...