From 7e3faa91462a3639b58e83b766b9d5a01bb9cfd2 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Sun, 17 May 2020 02:53:29 +0300 Subject: [PATCH] Code refactoring --- .../shapes/composite/wireframe/Grid2D.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/wireframe/Grid2D.java b/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/wireframe/Grid2D.java index abcc8e4..cd4f4a2 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/wireframe/Grid2D.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/wireframe/Grid2D.java @@ -12,29 +12,36 @@ import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.base.AbstractCom public class Grid2D extends AbstractCompositeShape { + /** + * @param transform Grid location + * @param rectangle Grid dimensions + * @param xDivisionCount Division count along X axis + * @param yDivisionCount Division count along Y axis + * @param appearance Grid lines appearance + */ public Grid2D(final Transform transform, final Rectangle rectangle, - final int divisionsX, final int divisionsY, + final int xDivisionCount, final int yDivisionCount, final LineAppearance appearance) { super(transform); - final double stepY = rectangle.getHeight() / divisionsY; - final double stepX = rectangle.getWidth() / divisionsX; + final double stepY = rectangle.getHeight() / yDivisionCount; + final double stepX = rectangle.getWidth() / xDivisionCount; - for (int yslice = 0; yslice <= divisionsY; yslice++) { - final double y = (yslice * stepY) + rectangle.getLowerY(); + for (int ySlice = 0; ySlice <= yDivisionCount; ySlice++) { + final double y = (ySlice * stepY) + rectangle.getLowerY(); - for (int xslice = 0; xslice <= divisionsX; xslice++) { - final double x = (xslice * stepX) + rectangle.getLowerX(); + for (int xSlice = 0; xSlice <= xDivisionCount; xSlice++) { + final double x = (xSlice * stepX) + rectangle.getLowerX(); final Point3D p1 = new Point3D(x, y, 0); final Point3D p2 = new Point3D(x + stepX, y, 0); final Point3D p3 = new Point3D(x, y + stepY, 0); - if (xslice < divisionsX) + if (xSlice < xDivisionCount) addShape(appearance.getLine(p1, p2)); - if (yslice < divisionsY) + if (ySlice < yDivisionCount) addShape(appearance.getLine(p1, p3)); } -- 2.20.1