|
10 | 10 | import Screens.Screen; |
11 | 11 | import processing.core.PApplet; |
12 | 12 | import processing.core.PConstants; |
13 | | -import processing.core.PGraphics; |
14 | 13 |
|
15 | 14 | public class Main extends PApplet implements ButtonListener { |
16 | 15 |
|
@@ -168,51 +167,4 @@ public static void drawGameTitle(PApplet d) { |
168 | 167 | d.pop(); // Restore original settings |
169 | 168 | } |
170 | 169 |
|
171 | | - /** |
172 | | - * Blurs the existing drawing on the screen within the specified rectangle |
173 | | - * |
174 | | - * @param d PApplet |
175 | | - * @param x x-coordinate of the top-left corner of the rectangle |
176 | | - * @param y y-coordinate of the top-left corner of the rectangle |
177 | | - * @param width width of the rectangle |
178 | | - * @param height height of the rectangle |
179 | | - * @param blurStrength strength of the blur |
180 | | - */ |
181 | | - public static void blur(PApplet d, int x, int y, int width, int height, float blurStrength) { |
182 | | - float deadSpaceX = d.width - d.rwidth * d.ratioScale; |
183 | | - float deadSpaceY = d.height - d.rheight * d.ratioScale; |
184 | | - int realX = (int) ((1.0 * x * d.ratioScale) + (deadSpaceX / 2)); |
185 | | - int realY = (int) ((1.0 * y * d.ratioScale) + (deadSpaceY / 2)); |
186 | | - int realWidth = (int) (width * d.ratioScale); |
187 | | - int realHeight = (int) (height * d.ratioScale); |
188 | | - |
189 | | - PGraphics g = d.createGraphics(realWidth, realHeight); |
190 | | - g.beginDraw(); |
191 | | - g.loadPixels(); |
192 | | - |
193 | | - d.loadPixels(); |
194 | | - int graphicsIndex = 0; |
195 | | - |
196 | | - for (int pixY = 0; pixY < realHeight; pixY++) { |
197 | | - for (int pixX = 0; pixX < realWidth; pixX++) { |
198 | | - g.pixels[graphicsIndex] = getPixel(d, realX + pixX, realY + pixY); |
199 | | - graphicsIndex++; |
200 | | - } |
201 | | - } |
202 | | - d.updatePixels(); |
203 | | - |
204 | | - g.updatePixels(); |
205 | | - g.filter(PConstants.BLUR, blurStrength); |
206 | | - g.endDraw(); |
207 | | - d.image(g, x, y, width, height); |
208 | | - } |
209 | | - |
210 | | - private static int getPixel(PApplet d, int x, int y) { |
211 | | - int i = y * d.pixelWidth + x; |
212 | | - if (i < 0 || i >= d.pixels.length) { |
213 | | - return -1; |
214 | | - } |
215 | | - return d.pixels[i]; |
216 | | - } |
217 | | - |
218 | 170 | } |
0 commit comments