From a3c4d590c471ddf79b204c7039a597b4be264ad9 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Tue, 28 Apr 2015 13:36:51 +0200 Subject: Initial commit w11 --- Week11 Mandelbrot/src/fractals/GridFiller.java | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Week11 Mandelbrot/src/fractals/GridFiller.java (limited to 'Week11 Mandelbrot/src/fractals/GridFiller.java') diff --git a/Week11 Mandelbrot/src/fractals/GridFiller.java b/Week11 Mandelbrot/src/fractals/GridFiller.java new file mode 100644 index 0000000..1fbb676 --- /dev/null +++ b/Week11 Mandelbrot/src/fractals/GridFiller.java @@ -0,0 +1,40 @@ +package fractals; + +/** + * + * @author Sjaak Smetsers +** @version 1.0, 13-03-2013 + */ + +/** + * A skeleton class illustrating the use of the grid interface + * + */ +public class GridFiller { + private Grid grid; // the grid to be filled + private ColorTable colorTable; // a table for converting indexes to + // rgb values + + /** + * The constructor + * @param grid to be filled + */ + public GridFiller (Grid grid) { + colorTable = new ColorTable (20); // some random value, needs to be adjusted + this.grid = grid; + } + + /** + * fills the whole grid with some arbitrarily chosen color + * + */ + public void fill () { + int grid_w = grid.getWidth(), grid_h = grid.getHeight(); + for (int i = 0; i < grid_w; i++) { + for (int j = 0; j < grid_h; j++) { + int color_index = i/5 * grid_w/5 + j/5; + grid.setPixel(i, j, colorTable.getColor(color_index)); + } + } + } +} -- cgit v1.2.3