Exemplo n.º 1
0
        //Grid自体を変換した結果を返す。基本0..1の範囲
        public LDGridTransform transform(LDGridTransform grid, bool clip = false)
        {
            LDGridTransform result = grid;

            for (int i = 0; i < grid.getRow() + 1; i++)
            {
                for (int j = 0; j < grid.getColumn() + 1; ++j)
                {
                    LDPoint newPt = transform(grid.getPoint(i, j), clip);
                    result.setPoint(i, j, newPt);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public void getQuadTest()
        {
            {
                LDGridTransform grid = new LDGridTransform(20, 20, 60, 60, 3, 3);
                var outline = grid.getOutlineQuadTransform();

                TestUtil.COMPARE(outline.getTopLeft(), new LDPoint(20, 20));
                TestUtil.COMPARE(outline.getTopRight(), new LDPoint(80, 20));
                TestUtil.COMPARE(outline.getBottomRight(), new LDPoint(80, 80));
                TestUtil.COMPARE(outline.getBottomLeft(), new LDPoint(20, 80));

                //0行0列目(左上)の四角変形
                var quad00 = grid.getQuadTransform(0, 0);
                TestUtil.COMPARE(quad00.getTopLeft(), new LDPoint(20, 20));
                TestUtil.COMPARE(quad00.getTopRight(), new LDPoint(40, 20));
                TestUtil.COMPARE(quad00.getBottomRight(), new LDPoint(40, 40));
                TestUtil.COMPARE(quad00.getBottomLeft(), new LDPoint(20, 40));

                //0行1列目の四角変形
                var quad01 = grid.getQuadTransform(0, 1);
                TestUtil.COMPARE(quad01.getTopLeft(), new LDPoint(40, 20));
                TestUtil.COMPARE(quad01.getTopRight(), new LDPoint(60, 20));
                TestUtil.COMPARE(quad01.getBottomRight(), new LDPoint(60, 40));
                TestUtil.COMPARE(quad01.getBottomLeft(), new LDPoint(40, 40));

                //0行2列目の四角変形
                var quad02 = grid.getQuadTransform(0, 2);
                TestUtil.COMPARE(quad02.getTopLeft(), new LDPoint(60, 20));
                TestUtil.COMPARE(quad02.getTopRight(), new LDPoint(80, 20));
                TestUtil.COMPARE(quad02.getBottomRight(), new LDPoint(80, 40));
                TestUtil.COMPARE(quad02.getBottomLeft(), new LDPoint(60, 40));

                //1行1列目(中央)の四角変形
                var quad11 = grid.getQuadTransform(1, 1);
                TestUtil.COMPARE(quad11.getTopLeft(), new LDPoint(40, 40));
                TestUtil.COMPARE(quad11.getTopRight(), new LDPoint(60, 40));
                TestUtil.COMPARE(quad11.getBottomRight(), new LDPoint(60, 60));
                TestUtil.COMPARE(quad11.getBottomLeft(), new LDPoint(40, 60));

                //2行2列目(右下)の四角変形
                var quad22 = grid.getQuadTransform(2, 2);
                TestUtil.COMPARE(quad22.getTopLeft(), new LDPoint(60, 60));
                TestUtil.COMPARE(quad22.getTopRight(), new LDPoint(80, 60));
                TestUtil.COMPARE(quad22.getBottomRight(), new LDPoint(80, 80));
                TestUtil.COMPARE(quad22.getBottomLeft(), new LDPoint(60, 80));
            }

            {
                LDGridTransform grid = new LDGridTransform(20, 20, 60, 60, 3, 3);
                //列の幅を変更
                grid.setPoint(0, 1, new LDPoint(35, 20));
                grid.setPoint(1, 1, new LDPoint(35, 40));
                grid.setPoint(2, 1, new LDPoint(35, 60));
                grid.setPoint(3, 1, new LDPoint(35, 80));

                grid.setPoint(0, 2, new LDPoint(50, 20));
                grid.setPoint(1, 2, new LDPoint(50, 40));
                grid.setPoint(2, 2, new LDPoint(50, 60));
                grid.setPoint(3, 2, new LDPoint(50, 80));

                var outline = grid.getOutlineQuadTransform();

                TestUtil.COMPARE(outline.getTopLeft(), new LDPoint(20, 20));
                TestUtil.COMPARE(outline.getTopRight(), new LDPoint(80, 20));
                TestUtil.COMPARE(outline.getBottomRight(), new LDPoint(80, 80));
                TestUtil.COMPARE(outline.getBottomLeft(), new LDPoint(20, 80));

                //0行0列目(左上)の四角変形
                var quad00 = grid.getQuadTransform(0, 0);
                TestUtil.COMPARE(quad00.getTopLeft(), new LDPoint(20, 20));
                TestUtil.COMPARE(quad00.getTopRight(), new LDPoint(35, 20));
                TestUtil.COMPARE(quad00.getBottomRight(), new LDPoint(35, 40));
                TestUtil.COMPARE(quad00.getBottomLeft(), new LDPoint(20, 40));

                //1行1列目(中央)の四角変形
                var quad11 = grid.getQuadTransform(1, 1);
                TestUtil.COMPARE(quad11.getTopLeft(), new LDPoint(35, 40));
                TestUtil.COMPARE(quad11.getTopRight(), new LDPoint(50, 40));
                TestUtil.COMPARE(quad11.getBottomRight(), new LDPoint(50, 60));
                TestUtil.COMPARE(quad11.getBottomLeft(), new LDPoint(35, 60));

                //2行2列目(右下)の四角変形
                var quad22 = grid.getQuadTransform(2, 2);
                TestUtil.COMPARE(quad22.getTopLeft(), new LDPoint(50, 60));
                TestUtil.COMPARE(quad22.getTopRight(), new LDPoint(80, 60));
                TestUtil.COMPARE(quad22.getBottomRight(), new LDPoint(80, 80));
                TestUtil.COMPARE(quad22.getBottomLeft(), new LDPoint(50, 80));
            }
            {
                LDGridTransform grid = new LDGridTransform(20, 20, 60, 60, 3, 3);
                //行の幅を変更
                grid.setPoint(1, 0, new LDPoint(20, 35));
                grid.setPoint(1, 1, new LDPoint(40, 35));
                grid.setPoint(1, 2, new LDPoint(60, 35));
                grid.setPoint(1, 3, new LDPoint(80, 35));

                grid.setPoint(2, 0, new LDPoint(20, 50));
                grid.setPoint(2, 1, new LDPoint(40, 50));
                grid.setPoint(2, 2, new LDPoint(60, 50));
                grid.setPoint(2, 3, new LDPoint(80, 50));

                var outline = grid.getOutlineQuadTransform();

                TestUtil.COMPARE(outline.getTopLeft(), new LDPoint(20, 20));
                TestUtil.COMPARE(outline.getTopRight(), new LDPoint(80, 20));
                TestUtil.COMPARE(outline.getBottomRight(), new LDPoint(80, 80));
                TestUtil.COMPARE(outline.getBottomLeft(), new LDPoint(20, 80));

                //0行0列目(左上)の四角変形
                var quad00 = grid.getQuadTransform(0, 0);
                TestUtil.COMPARE(quad00.getTopLeft(), new LDPoint(20, 20));
                TestUtil.COMPARE(quad00.getTopRight(), new LDPoint(40, 20));
                TestUtil.COMPARE(quad00.getBottomRight(), new LDPoint(40, 35));
                TestUtil.COMPARE(quad00.getBottomLeft(), new LDPoint(20, 35));

                //1行1列目(中央)の四角変形
                var quad11 = grid.getQuadTransform(1, 1);
                TestUtil.COMPARE(quad11.getTopLeft(), new LDPoint(40, 35));
                TestUtil.COMPARE(quad11.getTopRight(), new LDPoint(60, 35));
                TestUtil.COMPARE(quad11.getBottomRight(), new LDPoint(60, 50));
                TestUtil.COMPARE(quad11.getBottomLeft(), new LDPoint(40, 50));

                //2行2列目(右下)の四角変形
                var quad22 = grid.getQuadTransform(2, 2);
                TestUtil.COMPARE(quad22.getTopLeft(), new LDPoint(60, 50));
                TestUtil.COMPARE(quad22.getTopRight(), new LDPoint(80, 50));
                TestUtil.COMPARE(quad22.getBottomRight(), new LDPoint(80, 80));
                TestUtil.COMPARE(quad22.getBottomLeft(), new LDPoint(60, 80));
            }
            {
                LDGridTransform grid = new LDGridTransform(20, 20, 60, 60, 3, 3);

                grid.setPoint(0, 1, new LDPoint(35, 25));
                grid.setPoint(1, 0, new LDPoint(10, 35));
                grid.setPoint(1, 1, new LDPoint(30, 40));

                //0行0列目(左上)の四角変形
                var quad00 = grid.getQuadTransform(0, 0);
                TestUtil.COMPARE(quad00.getTopLeft(), new LDPoint(20, 20));
                TestUtil.COMPARE(quad00.getTopRight(), new LDPoint(35, 25));
                TestUtil.COMPARE(quad00.getBottomRight(), new LDPoint(30, 40));
                TestUtil.COMPARE(quad00.getBottomLeft(), new LDPoint(10, 35));

                //1行1列目(中央)の四角変形
                var quad11 = grid.getQuadTransform(1, 1);
                TestUtil.COMPARE(quad11.getTopLeft(), new LDPoint(30, 40));
                TestUtil.COMPARE(quad11.getTopRight(), new LDPoint(60, 40));
                TestUtil.COMPARE(quad11.getBottomRight(), new LDPoint(60, 60));
                TestUtil.COMPARE(quad11.getBottomLeft(), new LDPoint(40, 60));

            }
        }
Exemplo n.º 3
0
        public void getQuadTest()
        {
            {
                LDGridTransform grid    = new LDGridTransform(20, 20, 60, 60, 3, 3);
                var             outline = grid.getOutlineQuadTransform();

                TestUtil.COMPARE(outline.getTopLeft(), new LDPoint(20, 20));
                TestUtil.COMPARE(outline.getTopRight(), new LDPoint(80, 20));
                TestUtil.COMPARE(outline.getBottomRight(), new LDPoint(80, 80));
                TestUtil.COMPARE(outline.getBottomLeft(), new LDPoint(20, 80));

                //0行0列目(左上)の四角変形
                var quad00 = grid.getQuadTransform(0, 0);
                TestUtil.COMPARE(quad00.getTopLeft(), new LDPoint(20, 20));
                TestUtil.COMPARE(quad00.getTopRight(), new LDPoint(40, 20));
                TestUtil.COMPARE(quad00.getBottomRight(), new LDPoint(40, 40));
                TestUtil.COMPARE(quad00.getBottomLeft(), new LDPoint(20, 40));

                //0行1列目の四角変形
                var quad01 = grid.getQuadTransform(0, 1);
                TestUtil.COMPARE(quad01.getTopLeft(), new LDPoint(40, 20));
                TestUtil.COMPARE(quad01.getTopRight(), new LDPoint(60, 20));
                TestUtil.COMPARE(quad01.getBottomRight(), new LDPoint(60, 40));
                TestUtil.COMPARE(quad01.getBottomLeft(), new LDPoint(40, 40));

                //0行2列目の四角変形
                var quad02 = grid.getQuadTransform(0, 2);
                TestUtil.COMPARE(quad02.getTopLeft(), new LDPoint(60, 20));
                TestUtil.COMPARE(quad02.getTopRight(), new LDPoint(80, 20));
                TestUtil.COMPARE(quad02.getBottomRight(), new LDPoint(80, 40));
                TestUtil.COMPARE(quad02.getBottomLeft(), new LDPoint(60, 40));

                //1行1列目(中央)の四角変形
                var quad11 = grid.getQuadTransform(1, 1);
                TestUtil.COMPARE(quad11.getTopLeft(), new LDPoint(40, 40));
                TestUtil.COMPARE(quad11.getTopRight(), new LDPoint(60, 40));
                TestUtil.COMPARE(quad11.getBottomRight(), new LDPoint(60, 60));
                TestUtil.COMPARE(quad11.getBottomLeft(), new LDPoint(40, 60));

                //2行2列目(右下)の四角変形
                var quad22 = grid.getQuadTransform(2, 2);
                TestUtil.COMPARE(quad22.getTopLeft(), new LDPoint(60, 60));
                TestUtil.COMPARE(quad22.getTopRight(), new LDPoint(80, 60));
                TestUtil.COMPARE(quad22.getBottomRight(), new LDPoint(80, 80));
                TestUtil.COMPARE(quad22.getBottomLeft(), new LDPoint(60, 80));
            }

            {
                LDGridTransform grid = new LDGridTransform(20, 20, 60, 60, 3, 3);
                //列の幅を変更
                grid.setPoint(0, 1, new LDPoint(35, 20));
                grid.setPoint(1, 1, new LDPoint(35, 40));
                grid.setPoint(2, 1, new LDPoint(35, 60));
                grid.setPoint(3, 1, new LDPoint(35, 80));

                grid.setPoint(0, 2, new LDPoint(50, 20));
                grid.setPoint(1, 2, new LDPoint(50, 40));
                grid.setPoint(2, 2, new LDPoint(50, 60));
                grid.setPoint(3, 2, new LDPoint(50, 80));

                var outline = grid.getOutlineQuadTransform();

                TestUtil.COMPARE(outline.getTopLeft(), new LDPoint(20, 20));
                TestUtil.COMPARE(outline.getTopRight(), new LDPoint(80, 20));
                TestUtil.COMPARE(outline.getBottomRight(), new LDPoint(80, 80));
                TestUtil.COMPARE(outline.getBottomLeft(), new LDPoint(20, 80));

                //0行0列目(左上)の四角変形
                var quad00 = grid.getQuadTransform(0, 0);
                TestUtil.COMPARE(quad00.getTopLeft(), new LDPoint(20, 20));
                TestUtil.COMPARE(quad00.getTopRight(), new LDPoint(35, 20));
                TestUtil.COMPARE(quad00.getBottomRight(), new LDPoint(35, 40));
                TestUtil.COMPARE(quad00.getBottomLeft(), new LDPoint(20, 40));

                //1行1列目(中央)の四角変形
                var quad11 = grid.getQuadTransform(1, 1);
                TestUtil.COMPARE(quad11.getTopLeft(), new LDPoint(35, 40));
                TestUtil.COMPARE(quad11.getTopRight(), new LDPoint(50, 40));
                TestUtil.COMPARE(quad11.getBottomRight(), new LDPoint(50, 60));
                TestUtil.COMPARE(quad11.getBottomLeft(), new LDPoint(35, 60));

                //2行2列目(右下)の四角変形
                var quad22 = grid.getQuadTransform(2, 2);
                TestUtil.COMPARE(quad22.getTopLeft(), new LDPoint(50, 60));
                TestUtil.COMPARE(quad22.getTopRight(), new LDPoint(80, 60));
                TestUtil.COMPARE(quad22.getBottomRight(), new LDPoint(80, 80));
                TestUtil.COMPARE(quad22.getBottomLeft(), new LDPoint(50, 80));
            }
            {
                LDGridTransform grid = new LDGridTransform(20, 20, 60, 60, 3, 3);
                //行の幅を変更
                grid.setPoint(1, 0, new LDPoint(20, 35));
                grid.setPoint(1, 1, new LDPoint(40, 35));
                grid.setPoint(1, 2, new LDPoint(60, 35));
                grid.setPoint(1, 3, new LDPoint(80, 35));

                grid.setPoint(2, 0, new LDPoint(20, 50));
                grid.setPoint(2, 1, new LDPoint(40, 50));
                grid.setPoint(2, 2, new LDPoint(60, 50));
                grid.setPoint(2, 3, new LDPoint(80, 50));

                var outline = grid.getOutlineQuadTransform();

                TestUtil.COMPARE(outline.getTopLeft(), new LDPoint(20, 20));
                TestUtil.COMPARE(outline.getTopRight(), new LDPoint(80, 20));
                TestUtil.COMPARE(outline.getBottomRight(), new LDPoint(80, 80));
                TestUtil.COMPARE(outline.getBottomLeft(), new LDPoint(20, 80));

                //0行0列目(左上)の四角変形
                var quad00 = grid.getQuadTransform(0, 0);
                TestUtil.COMPARE(quad00.getTopLeft(), new LDPoint(20, 20));
                TestUtil.COMPARE(quad00.getTopRight(), new LDPoint(40, 20));
                TestUtil.COMPARE(quad00.getBottomRight(), new LDPoint(40, 35));
                TestUtil.COMPARE(quad00.getBottomLeft(), new LDPoint(20, 35));

                //1行1列目(中央)の四角変形
                var quad11 = grid.getQuadTransform(1, 1);
                TestUtil.COMPARE(quad11.getTopLeft(), new LDPoint(40, 35));
                TestUtil.COMPARE(quad11.getTopRight(), new LDPoint(60, 35));
                TestUtil.COMPARE(quad11.getBottomRight(), new LDPoint(60, 50));
                TestUtil.COMPARE(quad11.getBottomLeft(), new LDPoint(40, 50));

                //2行2列目(右下)の四角変形
                var quad22 = grid.getQuadTransform(2, 2);
                TestUtil.COMPARE(quad22.getTopLeft(), new LDPoint(60, 50));
                TestUtil.COMPARE(quad22.getTopRight(), new LDPoint(80, 50));
                TestUtil.COMPARE(quad22.getBottomRight(), new LDPoint(80, 80));
                TestUtil.COMPARE(quad22.getBottomLeft(), new LDPoint(60, 80));
            }
            {
                LDGridTransform grid = new LDGridTransform(20, 20, 60, 60, 3, 3);

                grid.setPoint(0, 1, new LDPoint(35, 25));
                grid.setPoint(1, 0, new LDPoint(10, 35));
                grid.setPoint(1, 1, new LDPoint(30, 40));

                //0行0列目(左上)の四角変形
                var quad00 = grid.getQuadTransform(0, 0);
                TestUtil.COMPARE(quad00.getTopLeft(), new LDPoint(20, 20));
                TestUtil.COMPARE(quad00.getTopRight(), new LDPoint(35, 25));
                TestUtil.COMPARE(quad00.getBottomRight(), new LDPoint(30, 40));
                TestUtil.COMPARE(quad00.getBottomLeft(), new LDPoint(10, 35));

                //1行1列目(中央)の四角変形
                var quad11 = grid.getQuadTransform(1, 1);
                TestUtil.COMPARE(quad11.getTopLeft(), new LDPoint(30, 40));
                TestUtil.COMPARE(quad11.getTopRight(), new LDPoint(60, 40));
                TestUtil.COMPARE(quad11.getBottomRight(), new LDPoint(60, 60));
                TestUtil.COMPARE(quad11.getBottomLeft(), new LDPoint(40, 60));
            }
        }