Exemple #1
0
    public static Grammar SimpleSquare()
    {
        var grammar = new Grammar();

        grammar.name            = "SimpleSquare";
        grammar.backgroundColor = new HsvColor()
        {
            h = 20, s = 0.7f, v = 0.9f
        };

        {
            var initRule = new Rule();
            initRule.name = "init";

            var s1 = new Replacement();
            s1.id    = "square";
            s1.color = new HsvColor()
            {
                h = 100, s = 0.5f, v = 0.5f
            };

            var s2 = new Replacement();
            s2.id    = "square";
            s2.color = new HsvColor()
            {
                h = 200, s = 0.7f, v = 0.7f, a = 0.5f
            };
            s2.transform *= Matrix4x4.Scale(new Vector3(0.5f, 0.5f, 1));

            /*
             * var s3 = new ShapeDesc();
             * s3.id = "square";
             * s3.color = new HsvColor() { a = 1, h = 150, s = 0.2f, v = 0.1f };
             * s3.transform *= Matrix4x4.Scale(new Vector3(0.2f, 0.2f, 0.2f));
             */

            initRule.replacements = new[] { s1, s2 };

            grammar.startShape = "init";
            grammar.AddRule(initRule);
        }

        {
            var squareRule = new Rule();
            squareRule.name = "square";
            var s1 = new Replacement();
            s1.SetSquare();
            s1.transform = Matrix4x4.Rotate(Quaternion.Euler(new Vector3(0, 0, 45)));
            s1.color     = new HsvColor()
            {
                h = 45
            };
            squareRule.replacements = new[] { s1 };

            grammar.AddRule(squareRule);
        }

        return(grammar);
    }
Exemple #2
0
    /*
     * rule rectangle {
     * SQUARE {  }
     * rectangle [ r -90 s 0.71 y 0.5 alpha -0.4 b -0.1 sat -0.2 hue -4]
     * rectangle [ r 90 s 0.71 y 0.5 alpha 0.02 b 0.2 sat 0.3 hue 4]
     * }
     */
    public static Grammar LotsOfSquarePattern()
    {
        var grammar = new Grammar();

        grammar.name = "LotsOfSquarePattern";

        {
            var initRule = new Rule();
            initRule.name = "scene";

            var s1 = new Replacement();
            s1.SetSquare();
            s1.transform *= Matrix4x4.Translate(new Vector3(0.5f, 0.5f, 0));
            s1.transform *= Matrix4x4.Scale(new Vector3(2.0f, 2f, 1));
            s1.color      = new HsvColor()
            {
                h = 240, s = 1f, v = 0.3f
            };

            var s2 = new Replacement();
            s2.id         = "rectangle";
            s2.transform *= Matrix4x4.Translate(new Vector3(0f, 0f, 0));
            s2.transform *= Matrix4x4.Scale(new Vector3(0.71f, 1f, 1));
            s2.color      = new HsvColor()
            {
                h = 0, s = 1f, v = 0f
            };

            var s3 = new Replacement();
            s3.id         = "rectangle";
            s3.transform *= Matrix4x4.Translate(new Vector3(1f, 0f, 0));
            s3.transform *= Matrix4x4.Scale(new Vector3(0.71f, 1f, 1));
            s3.color      = new HsvColor()
            {
                h = 0, s = 0f, v = 1f
            };

            var s4 = new Replacement();
            s4.id         = "rectangle";
            s4.transform *= Matrix4x4.Translate(new Vector3(0f, 1f, 0));
            s4.transform *= Matrix4x4.Scale(new Vector3(0.71f, 1f, 1));
            s4.color      = new HsvColor()
            {
                h = 0, s = 1f, v = 1f
            };

            var s5 = new Replacement();
            s5.id         = "rectangle";
            s5.transform *= Matrix4x4.Translate(new Vector3(1f, 1f, 0));
            s5.transform *= Matrix4x4.Scale(new Vector3(0.71f, 1f, 1));
            s5.color      = new HsvColor()
            {
                h = 0, s = 0.5f, v = 0.5f
            };

            initRule.replacements = new[] { s1, s2, s3, s4, s5 };

            grammar.startShape = "scene";
            grammar.AddRule(initRule);
        }

        {
            var squareRule = new Rule();
            squareRule.name = "rectangle";
            var s1 = new Replacement();
            s1.SetSquare();

            var s2 = new Replacement();
            s2.id         = "rectangle";
            s2.transform *= Matrix4x4.Rotate(Quaternion.Euler(new Vector3(0, 0, 90)));
            s2.transform *= Matrix4x4.Scale(new Vector3(0.71f, 0.71f, 1));
            s2.transform *= Matrix4x4.Translate(new Vector3(0f, 0.5f, 0));
            s2.color      = new HsvColor()
            {
                a = -0.4f, h = -4, s = -0.2f, v = -0.1f
            };

            var s3 = new Replacement();
            s3.id         = "rectangle";
            s3.transform *= Matrix4x4.Rotate(Quaternion.Euler(new Vector3(0, 0, -90)));
            s3.transform *= Matrix4x4.Scale(new Vector3(0.71f, 0.71f, 1));
            s3.transform *= Matrix4x4.Translate(new Vector3(0f, 0.5f, 0));
            s3.color      = new HsvColor()
            {
                a = 0.02f, h = 4, s = 0.3f, v = 0.2f
            };

            squareRule.replacements = new[] { s1, s2, s3 };

            grammar.AddRule(squareRule);
        }

        return(grammar);
    }
Exemple #3
0
    public static Grammar SimpleSpiralSquares()
    {
        var grammar = new Grammar();

        grammar.name = "SimpleSpiralSquares";

        {
            var initRule = new Rule();
            initRule.name = "START";

            var s1 = new Replacement();
            s1.id = "SPIRAL";

            var s2 = new Replacement();
            s2.id         = "SPIRAL";
            s2.transform *= Matrix4x4.Rotate(Quaternion.Euler(new Vector3(0, 0, 120)));

            var s3 = new Replacement();
            s3.id         = "SPIRAL";
            s3.transform *= Matrix4x4.Rotate(Quaternion.Euler(new Vector3(0, 0, 240)));

            initRule.replacements = new[] { s1, s2, s3 };

            grammar.startShape = "START";
            grammar.AddRule(initRule);
        }

        {
            var squareRule = new Rule();
            squareRule.name = "SPIRAL";
            var s1 = new Replacement();
            s1.id = "F_SQUARES";

            var s2 = new Replacement();
            s2.id         = "F_TRIANGLES";
            s2.transform *= Matrix4x4.Translate(new Vector3(0.5f, 0.5f, 0));
            s2.transform *= Matrix4x4.Rotate(Quaternion.Euler(new Vector3(0, 0, 45)));

            squareRule.replacements = new[] { s1, s2 };

            grammar.AddRule(squareRule);
        }

        {
            var squareRule = new Rule();
            squareRule.name = "F_SQUARES";
            var s1 = new Replacement();
            s1.SetSquare();
            s1.color = new HsvColor()
            {
                h = 220, s = 0.9f, v = 0.33f
            };

            var s2 = new Replacement();
            s2.SetSquare();
            s2.transform *= Matrix4x4.Scale(new Vector3(0.9f, 0.9f, 1f));
            s2.color      = new HsvColor()
            {
                s = 0.75f, v = 1
            };

            squareRule.replacements = new[] { s1, s2 };

            grammar.AddRule(squareRule);
        }

        {
            var squareRule = new Rule();
            squareRule.name = "F_TRIANGLES";
            var s1 = new Replacement();
            s1.SetSquare();
            s1.transform *= Matrix4x4.Scale(new Vector3(1.9f, 0.4f, 1f));
            s1.color      = new HsvColor()
            {
                s = 0.7f, v = 1f
            };

            squareRule.replacements = new[] { s1 };

            grammar.AddRule(squareRule);
        }

        return(grammar);
    }
Exemple #4
0
    public static Grammar UnitShapes()
    {
        var grammar = new Grammar();

        grammar.name = "UnitShapes";

        {
            var initRule = new Rule();
            initRule.name = "init";

            var s1 = new Replacement();
            s1.id         = "layer";
            s1.transform *= Matrix4x4.Translate(new Vector3(0f, 0, 0));

            var s2 = new Replacement();
            s2.id         = "layer";
            s2.transform *= Matrix4x4.Translate(new Vector3(0f, 1, 0));

            var s3 = new Replacement();
            s3.id         = "layer";
            s3.transform *= Matrix4x4.Translate(new Vector3(0f, 2, 0));

            initRule.replacements = new[] { s1, s2, s3 };

            grammar.startShape = "init";
            grammar.AddRule(initRule);
        }

        {
            var initRule = new Rule();
            initRule.name = "layer";

            var s1 = new Replacement();
            s1.SetSquare();
            s1.transform *= Matrix4x4.Translate(new Vector3(0f, 0, 0));
            s1.color      = new HsvColor()
            {
                h = 160, s = 1, v = 1
            };

            var s2 = new Replacement();
            s2.SetCircle();
            s2.transform *= Matrix4x4.Translate(new Vector3(0f, 0.25f, 0));
            s2.color      = new HsvColor()
            {
                h = 100, s = 1, v = 1
            };

            var s3 = new Replacement();
            s3.SetTriangle();
            s3.transform *= Matrix4x4.Translate(new Vector3(0f, 0.5f, 0));
            s3.color      = new HsvColor()
            {
                h = 60, s = 1, v = 1
            };

            initRule.replacements = new[] { s1, s2, s3 };
            grammar.AddRule(initRule);
        }

        return(grammar);
    }