Created
November 5, 2015 08:05
-
-
Save catatonicTrepidation/11b62a19bb5337b8cd08 to your computer and use it in GitHub Desktop.
Polka
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
| public void behindPolka(int xRadius, int yRadius, int xPeriod, int yPeriod, int[] color, int gradiant) | |
| { | |
| double i = 1.0; | |
| Pixel[][] pixels = getPixels2D(); | |
| //int[][] colors = {{10,0,0},{0,10,0},{0,0,10}}; | |
| double xDistance = 0; | |
| double yDistance = 0; | |
| //int finalEdgeRow = 0; | |
| int finalEdgeCol = -1; | |
| boolean paintable = true; | |
| double d = 0; | |
| /* if(color == 0) | |
| { | |
| for (int row = 0; row < pixels.length; row++) | |
| { | |
| for(int col = 0; col < pixels[0].length; col++) | |
| { | |
| //Use modulo to see distance of pixel to nearest period/checkpoint | |
| xDistance = row%((yRadius+yPeriod)/2); | |
| yDistance = col%((xRadius+xPeriod)/2); | |
| d = Math.sqrt(Math.pow(xDistance, 2) + Math.pow(yDistance, 2)); | |
| if(d <= xRadius) | |
| pixels[row][col].setColor(Color.RED); | |
| } | |
| } | |
| }*/ | |
| for (int row = 0; row < pixels.length; row++) | |
| { | |
| paintable = true; | |
| finalEdgeCol = -1; | |
| for(int col = 0; col < pixels[0].length; col++) | |
| { | |
| if(gradiant == 1) | |
| i += 0.001; | |
| if(pixels[row][col].getBlue() <= 160 && pixels[row][col].getGreen() <= 165 && pixels[row][col].getRed() <= 190) | |
| { | |
| paintable = false; | |
| finalEdgeCol = col; | |
| } | |
| if(paintable) | |
| { | |
| //Use modulo to see distance of pixel to nearest period/checkpoint | |
| yDistance = yRadius - row%(yPeriod + yRadius*2); | |
| xDistance = xRadius - col%(xPeriod + xRadius*2); | |
| d = Math.sqrt(Math.pow(xDistance, 2) + Math.pow(yDistance, 2)); | |
| //System.out.println((row%((yRadius+yPeriod)))); | |
| //if(d <= xRadius) | |
| //pixels[row][col].setColor(Color.RED); | |
| /*if(xDistance == 0) | |
| { | |
| pixels[row][col].setColor(Color.PINK); | |
| } | |
| if(yDistance == 0) | |
| { | |
| pixels[row][col].setColor(Color.GREEN); | |
| }*/ | |
| /* if(d <= 30) | |
| { | |
| pixels[row][col].setColor(Color.ORANGE); | |
| }*/ | |
| if(d <= yRadius) | |
| { | |
| pixels[row][col].setRed((int)(pixels[row][col].getRed() + color[0] * i)); | |
| pixels[row][col].setGreen((int)(pixels[row][col].getGreen() + color[1] * i)); | |
| pixels[row][col].setBlue((int)(pixels[row][col].getBlue() + color[2] * i)); | |
| } | |
| } | |
| if(col == pixels[0].length - 1 && finalEdgeCol >= 0) | |
| { | |
| for(int col2 = finalEdgeCol; col2 < pixels[0].length; col2++) | |
| { | |
| //Use modulo to see distance of pixel to nearest period/checkpoint | |
| yDistance = yRadius - row%(yPeriod + yRadius*2); | |
| xDistance = xRadius - col2%(xPeriod + xRadius*2); | |
| d = Math.sqrt(Math.pow(xDistance, 2) + Math.pow(yDistance, 2)); | |
| if(d <= yRadius) | |
| { | |
| pixels[row][col2].setRed((int)(pixels[row][col2].getRed() + color[0] * i)); | |
| pixels[row][col2].setGreen((int)(pixels[row][col2].getGreen() + color[1] * i)); | |
| pixels[row][col2].setBlue((int)(pixels[row][col2].getBlue() + color[2] * i)); | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| public void betweenPolka(int sRow, int sCol, int xRadius, int yRadius, int xPeriod, int yPeriod, int[] color, int gradiant) | |
| { | |
| double i = 1.0 + 0.001*sRow; | |
| Pixel[][] pixels = getPixels2D(); | |
| //int[][] colors = {{10,0,0},{0,10,0},{0,0,10}}; | |
| double xDistance = 0; | |
| double yDistance = 0; | |
| //int finalEdgeRow = 0; | |
| int finalEdgeCol = -1; | |
| double d = 0; | |
| /* if(color == 0) | |
| { | |
| for (int row = 0; row < pixels.length; row++) | |
| { | |
| for(int col = 0; col < pixels[0].length; col++) | |
| { | |
| //Use modulo to see distance of pixel to nearest period/checkpoint | |
| xDistance = row%((yRadius+yPeriod)/2); | |
| yDistance = col%((xRadius+xPeriod)/2); | |
| d = Math.sqrt(Math.pow(xDistance, 2) + Math.pow(yDistance, 2)); | |
| if(d <= xRadius) | |
| pixels[row][col].setColor(Color.RED); | |
| } | |
| } | |
| }*/ | |
| for (int row = sRow; row < pixels.length - 30; row++) | |
| { | |
| if(gradiant == 1) | |
| i += 0.001; | |
| for(int col = sCol; col < pixels[0].length; col++) | |
| { | |
| if(pixels[row][col].getBlue() <= 160 && pixels[row][col].getGreen() <= 195 && pixels[row][col].getRed() <= 240) | |
| { | |
| break; | |
| } | |
| //Use modulo to see distance of pixel to nearest period/checkpoint | |
| yDistance = yRadius - row%(yPeriod + yRadius*2); | |
| xDistance = xRadius - col%(xPeriod + xRadius*2); | |
| d = Math.sqrt(Math.pow(xDistance, 2) + Math.pow(yDistance, 2)); | |
| //System.out.println((row%((yRadius+yPeriod)))); | |
| //if(d <= xRadius) | |
| //pixels[row][col].setColor(Color.RED); | |
| /*if(xDistance == 0) | |
| { | |
| pixels[row][col].setColor(Color.PINK); | |
| } | |
| if(yDistance == 0) | |
| { | |
| pixels[row][col].setColor(Color.GREEN); | |
| }*/ | |
| /* if(d <= 30) | |
| { | |
| pixels[row][col].setColor(Color.ORANGE); | |
| }*/ | |
| if(d <= yRadius) | |
| { | |
| pixels[row][col].setRed((int)(pixels[row][col].getRed() + color[0] * i)); | |
| pixels[row][col].setGreen((int)(pixels[row][col].getGreen() + color[1] * i)); | |
| pixels[row][col].setBlue((int)(pixels[row][col].getBlue() + color[2] * i)); | |
| } | |
| } | |
| for(int col = sCol-1; col >= 0; col--) | |
| { | |
| if(pixels[row][col].getBlue() <= 160 && pixels[row][col].getGreen() <= 195 && pixels[row][col].getRed() <= 240) | |
| { | |
| break; | |
| } | |
| //Use modulo to see distance of pixel to nearest period/checkpoint | |
| yDistance = yRadius - row%(yPeriod + yRadius*2); | |
| xDistance = xRadius - col%(xPeriod + xRadius*2); | |
| d = Math.sqrt(Math.pow(xDistance, 2) + Math.pow(yDistance, 2)); | |
| //System.out.println((row%((yRadius+yPeriod)))); | |
| //if(d <= xRadius) | |
| //pixels[row][col].setColor(Color.RED); | |
| /*if(xDistance == 0) | |
| { | |
| pixels[row][col].setColor(Color.PINK); | |
| } | |
| if(yDistance == 0) | |
| { | |
| pixels[row][col].setColor(Color.GREEN); | |
| }*/ | |
| /* if(d <= 30) | |
| { | |
| pixels[row][col].setColor(Color.ORANGE); | |
| }*/ | |
| if(d <= yRadius) | |
| { | |
| pixels[row][col].setRed((int)(pixels[row][col].getRed() + color[0] * i)); | |
| pixels[row][col].setGreen((int)(pixels[row][col].getGreen() + color[1] * i)); | |
| pixels[row][col].setBlue((int)(pixels[row][col].getBlue() + color[2] * i)); | |
| } | |
| } | |
| } | |
| i = 1.0 + 0.001*sRow; | |
| for (int row = sRow-1; row >= 400; row--) | |
| { | |
| if(gradiant == 1) | |
| i -= 0.001; | |
| for(int col = sCol; col < pixels[0].length; col++) | |
| { | |
| if(pixels[row][col].getBlue() <= 160 && pixels[row][col].getGreen() <= 195 && pixels[row][col].getRed() <= 240) | |
| { | |
| break; | |
| } | |
| //Use modulo to see distance of pixel to nearest period/checkpoint | |
| yDistance = yRadius - row%(yPeriod + yRadius*2); | |
| xDistance = xRadius - col%(xPeriod + xRadius*2); | |
| d = Math.sqrt(Math.pow(xDistance, 2) + Math.pow(yDistance, 2)); | |
| //System.out.println((row%((yRadius+yPeriod)))); | |
| //if(d <= xRadius) | |
| //pixels[row][col].setColor(Color.RED); | |
| /*if(xDistance == 0) | |
| { | |
| pixels[row][col].setColor(Color.PINK); | |
| } | |
| if(yDistance == 0) | |
| { | |
| pixels[row][col].setColor(Color.GREEN); | |
| }*/ | |
| /* if(d <= 30) | |
| { | |
| pixels[row][col].setColor(Color.ORANGE); | |
| }*/ | |
| if(d <= yRadius) | |
| { | |
| pixels[row][col].setRed((int)(pixels[row][col].getRed() + color[0] * i)); | |
| pixels[row][col].setGreen((int)(pixels[row][col].getGreen() + color[1] * i)); | |
| pixels[row][col].setBlue((int)(pixels[row][col].getBlue() + color[2] * i)); | |
| } | |
| } | |
| for(int col = sCol-1; col >= 0; col--) | |
| { | |
| if(pixels[row][col].getBlue() <= 160 && pixels[row][col].getGreen() <= 195 && pixels[row][col].getRed() <= 240) | |
| { | |
| break; | |
| } | |
| //Use modulo to see distance of pixel to nearest period/checkpoint | |
| yDistance = yRadius - row%(yPeriod + yRadius*2); | |
| xDistance = xRadius - col%(xPeriod + xRadius*2); | |
| d = Math.sqrt(Math.pow(xDistance, 2) + Math.pow(yDistance, 2)); | |
| //System.out.println((row%((yRadius+yPeriod)))); | |
| //if(d <= xRadius) | |
| //pixels[row][col].setColor(Color.RED); | |
| /*if(xDistance == 0) | |
| { | |
| pixels[row][col].setColor(Color.PINK); | |
| } | |
| if(yDistance == 0) | |
| { | |
| pixels[row][col].setColor(Color.GREEN); | |
| }*/ | |
| /* if(d <= 30) | |
| { | |
| pixels[row][col].setColor(Color.ORANGE); | |
| }*/ | |
| if(d <= yRadius) | |
| { | |
| pixels[row][col].setRed((int)(pixels[row][col].getRed() + color[0] * i)); | |
| pixels[row][col].setGreen((int)(pixels[row][col].getGreen() + color[1] * i)); | |
| pixels[row][col].setBlue((int)(pixels[row][col].getBlue() + color[2] * i)); | |
| } | |
| } | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment