Created
August 7, 2015 19:52
-
-
Save kenmazaika/e9340f0e5353032aeadc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def blur | |
| @array.each_with_index do |row,x| | |
| row.each_with_index do |cell,y| | |
| last_x_pixel = # TODO: calculate the width of the image here. May need to subtract 1. | |
| if @array[x][y] == 1 | |
| @new_array[x][y] ||= 1 | |
| @new_array[x-1][y] = 1 if x != 0 # makes sense to go left, unless it's the left-most | |
| @new_array[x][y-1] = 1 | |
| @new_array[x][y+1] = 1 | |
| @new_array[x+1][y] = 1 if x != last_x_pixel # only go right if it's not the last x_pixel | |
| else | |
| @new_array[x][y] ||= @array[x][y] | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment