X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Frenderer%2Fraster%2Fshapes%2Fcomposite%2Fwireframe%2FGrid2D.java;h=c05f3f35964530273b73940d0f15e4a75dfafa3e;hb=a3ff3683bd0a025061667b26b6fcf56fe20f0afc;hp=d469ecf6f3938af28e4e015b1bed437f66f6083e;hpb=59baa428fb2d9e7f0fe5423f4cea47f2d6245914;p=sixth-3d.git 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 d469ecf..c05f3f3 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 @@ -1,12 +1,7 @@ /* - * Sixth 3D engine. Copyright ©2012-2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 3 of the GNU Lesser General Public License - * or later as published by the Free Software Foundation. - * + * Sixth 3D engine. Author: Svjatoslav Agejenko. + * This project is released under Creative Commons Zero (CC0) license. */ - package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe; import eu.svjatoslav.sixth.e3d.geometry.Point3D; @@ -17,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)); }