Esempio n. 1
0
    private List <Shape> Evaluate()
    {
        var grammar = grammarStr == null?SampleGrammars.SimpleBubble() : CfdgCompiler.Compile(grammarStr);

        var evaluator = new Evaluator();

        evaluator.grammar = grammar;
        evaluator.Evaluate();

        m_BackgroundColor = new HsvColor()
        {
            h = 0, s = 0, v = 1, a = 1
        };
        m_BackgroundColor = Utils.AdjustColor(m_BackgroundColor, grammar.backgroundColor);

        m_MaxShapeCount = evaluator.shapes.Count;

        m_Extent = new Rect();
        foreach (var shape in evaluator.shapes)
        {
            var shapeRect = new Rect();
            shapeRect.center = new Vector2(shape.x, shape.y);
            shapeRect.width  = shape.width;
            shapeRect.height = shape.height;

            if (shapeRect.xMin < m_Extent.xMax)
            {
                m_Extent.xMin = shapeRect.xMin;
            }
            if (shapeRect.xMax > m_Extent.xMax)
            {
                m_Extent.xMax = shapeRect.xMax;
            }
            if (shapeRect.yMin < m_Extent.yMin)
            {
                m_Extent.yMin = shapeRect.yMin;
            }
            if (shapeRect.yMax > m_Extent.yMax)
            {
                m_Extent.yMax = shapeRect.yMax;
            }
        }

        return(evaluator.shapes);
    }
 public void UnitShapes()
 {
     CompareGrammar(SampleGrammars.UnitShapes(), "UnitShapes", SampleGrammars.UnitShapesGrammar);
 }
 public void SimpleSquare()
 {
     CompareGrammar(SampleGrammars.SimpleSquare(), "SimpleSquare", SampleGrammars.SimpleSquareGrammar);
 }
 public void NumberTest()
 {
     CompareGrammar(SampleGrammars.NumberTest(), "NumberTest", SampleGrammars.NumberTestGrammar);
 }
 public void LotsOfSquarePattern()
 {
     CompareGrammar(SampleGrammars.LotsOfSquarePattern(), "LotsOfSquarePattern", SampleGrammars.LotsOfSquarePatternGrammar);
 }
 public void SpiralSquares()
 {
     CompareGrammar(SampleGrammars.SimpleSpiralSquares(), "SimpleSpiralSquares", SampleGrammars.SimpleSpiralSquaresGrammar);
 }
 public void SimpleBubble()
 {
     CompareGrammar(SampleGrammars.SimpleBubble(), "SimpleBubble", SampleGrammars.SimpleBubbleGrammar);
 }
 public void FourCircles()
 {
     CompareGrammar(SampleGrammars.FourCircles(), "FourCircles", SampleGrammars.FourCirclesGrammar);
 }