Isometric

介绍:

一个立方体绘制库。

运行效果:

使用说明:

绘制一个简单的立方体:

isometricView.add(
    new Prism(
        new Point(/* x */ 0, /* y */ 0, /* z */ 0), 
        /* width */ 1, /* length */ 1, /* height */ 1
    ), 
    new Color(33, 150, 243)
);

io.fabianterhorst.isometric.screenshot.IsometricViewTest_doScreenshotOne.png

绘制多个形状

有三种基本的控件:point,path和shape。一个shape需要一个原点和 x, y, z轴上的三个measurement。Prism的默认构造把所有的measurement设置为1.

isometricView.add(new Prism(new Point(0, 0, 0)), new Color(33, 150, 243));
isometricView.add(new Prism(new Point(-1, 1, 0), 1, 2, 1), new Color(33, 150, 243));
isometricView.add(new Prism(new Point(1, -1, 0), 2, 1, 1), new Color(33, 150, 243));

io.fabianterhorst.isometric.screenshot.IsometricViewTest_doScreenshotTwo.png

绘制多个Path

Path是二维的。你可以像shape那样绘制path和涂色。

isometricView.add(new Prism(Point.ORIGIN, 3, 3, 1), new Color(50, 60, 160));
isometricView.add(new Path(new Point\[\]{
    new Point(1, 1, 1),
    new Point(2, 1, 1),
    new Point(2, 2, 1),
    new Point(1, 2, 1)
}), new Color(50, 160, 60));

io.fabianterhorst.isometric.screenshot.IsometricViewTest_doScreenshotPath.png

网格

Here you can see how the grid looks like. The blue grid is the xy-plane. The z-line is the z-axis.

io.fabianterhorst.isometric.screenshot.IsometricViewTest_doScreenshotGrid.png

Supports complex structures

io.fabianterhorst.isometric.screenshot.IsometricViewTest_doScreenshotThree.png

Using JCenter

compile 'io.fabianterhorst:Isometric:0.0.6'

Available Shapes

CylinderKnotOctahedronPrismPyramid and Stairs

Translate

Traslate is translating an point, path or shape to the given x, y and z distance. Translate is returning a new point, path or shape.

Prism prism = new Prism(new Point(0, 0, 0));
isometricView.add(prism, new Color(33, 150, 243));
isometricView.add(prism.translate(0, 0, 1.1), new Color(33, 150, 243));

io.fabianterhorst.isometric.screenshot.IsometricViewTest_doScreenshotTranslate.png

Scale

Scale is scaling an point, path or shape with the given x, y and z scaling factors. Scale is returning a new point, path or shape.

Color blue = new Color(50, 60, 160);
Color red = new Color(160, 60, 50);
Prism cube = new Prism(Point.ORIGIN);
isometricView.add(cube.scale(Point.ORIGIN, 3.0, 3.0, 0.5), red);
isometricView.add(cube
    .scale(Point.ORIGIN, 3.0, 3.0, 0.5)
    .translate(0, 0, 0.6), blue);

io.fabianterhorst.isometric.screenshot.IsometricViewTest_doScreenshotScale.png

RotateZ

RotateZ is rotating an point, path or shape with the given angle in radians on the xy-plane (where an angle of 0 runs along the position x-axis). RotateZ is returning a new point, path or shape.

Color blue = new Color(50, 60, 160);
Color red = new Color(160, 60, 50);
Prism cube = new Prism(Point.ORIGIN, 3, 3, 1);
isometricView.add(cube, red);
isometricView.add(cube
    /* (1.5, 1.5) is the center of the prism */
    .rotateZ(new Point(1.5, 1.5, 0), Math.PI / 12)
    .translate(0, 0, 1.1), blue);

Shapes from Paths

The method Shape.extrude allows you to create a 3D model by popping out a 2D path along the z-axis.

Color blue = new Color(50, 60, 160);
Color red = new Color(160, 60, 50);
isometricView.add(new Prism(Point.ORIGIN, 3, 3, 1), blue);
isometricView.add(Shape.extrude(new Path(new Point\[\]{
    new Point(1, 1, 1),
    new Point(2, 1, 1),
    new Point(2, 3, 1)
}), 0.3), red);

io.fabianterhorst.isometric.screenshot.IsometricViewTest_doScreenshotExtrude.png

Available Shapes

Cylinder

io.fabianterhorst.isometric.screenshot.IsometricViewTest_doScreenshotCylinder.png

Knot

io.fabianterhorst.isometric.screenshot.IsometricViewTest_doScreenshotKnot.png

Octahedron

io.fabianterhorst.isometric.screenshot.IsometricViewTest_doScreenshotOctahedron.png

Prism

io.fabianterhorst.isometric.screenshot.IsometricViewTest_doScreenshotPrism.png

Pyramid

io.fabianterhorst.isometric.screenshot.IsometricViewTest_doScreenshotPyramid.png

Stairs

io.fabianterhorst.isometric.screenshot.IsometricViewTest_doScreenshotStairs.png

已下载
0