コード例 #1
0
ファイル: Rewriter.cs プロジェクト: anamendes23/KochSnowflake
    /**
     * Perform the rewriting for the given number of generations.
     * @param seed starting word
     * @param numGenerations how many times to rewrite the word with our rules
     * @return the nth-generation word
     */
    public RenderQueue rewrite(RenderQueue seed, int numGenerations)
    {
        // Implementation is just to treat the seed as the "previous" output
        // queue and then move the output queue to be the input queue for
        // the next generation, apply the rules to any axioms for which we
        // have rules (the other axioms are copied over to the output
        // directly). Repeat this process for the given number of generations.
        RenderQueue output = seed.copy();
        RenderQueue input;

        for (int gen = 0; gen < numGenerations; gen++)
        {
            input  = output; // last generation's output is this one's input
            output = new RenderQueue();
            while (!input.empty())
            {
                RenderCommand nextInput = input.dequeue();
                // look through the from-list to find a rule to invoke
                bool ruleFound = false;
                for (int i = 0; !ruleFound && i < from.Length; i++)
                {
                    if (from[i] == nextInput)
                    {
                        ruleFound = true;
                        // append a copy of this rule's right side onto the
                        // end of the output queue
                        output.append(to[i]);
                    }
                }
                // if no rule was found, then just copy this command to output
                if (!ruleFound)
                {
                    output.enqueue(nextInput);
                }
            }
        }
        return(output);
    }
コード例 #2
0
 private char getChar(RenderCommand command)
 {
     //If else statements checking input and returning corresponding char
     if (command == RenderCommand.FORWARD)
     {
         return('F');
     }
     else if (command == RenderCommand.FORWARD2)
     {
         return('R');
     }
     else if (command == RenderCommand.IGNORE)
     {
         return('X');
     }
     else if (command == RenderCommand.RIGHT)
     {
         return('-');
     }
     else if (command == RenderCommand.LEFT)
     {
         return('+');
     }
     else if (command == RenderCommand.PUSH)
     {
         return('[');
     }
     else if (command == RenderCommand.POP)
     {
         return(']');
     }
     else
     {
         //If input is unknown, throw an exception
         throw new ArgumentException("Command not supported.");
     }
 }
コード例 #3
0
        public MainViewModel()
        {
            BitmapSource     = BitmapManager.SaveToBmp(10, 10, new byte[400]);
            RenderCommand    = new RenderCommand(this);
            SafeImageCommand = new SafeImageCommand(this);
            TextBoxInput     =
                //Test Input String (Cube of 3x3 Spheres)
                @"1440, 1440
S([400;-600;600], 300, [255;0;0])
S([400;0;600], 300, [255;0;0])
S([400;600;600], 300, [255;0;0])
S([400;-600;0], 300, [255;0;0])
S([400;0;0], 300, [255;0;0])
S([400;600;0], 300, [255;0;0])
S([400;-600;-600], 300, [255;0;0])
S([400;0;-600], 300, [255;0;0])
S([400;600;-600], 300, [255;0;0])
S([800;-600;600], 300, [255;0;0])
S([800;0;600], 300, [255;0;0])
S([800;600;600], 300, [255;0;0])
S([800;-600;0], 300, [255;0;0])
S([800;0;0], 300, [255;0;0])
S([800;600;0], 300, [255;0;0])
S([800;-600;-600], 300, [255;0;0])
S([800;0;-600], 300, [255;0;0])
S([800;600;-600], 300, [255;0;0])
S([1200;-600;600], 300, [255;0;0])
S([1200;0;600], 300, [255;0;0])
S([1200;600;600], 300, [255;0;0])
S([1200;-600;0], 300, [255;0;0])
S([1200;0;0], 300, [255;0;0])
S([1200;600;0], 300, [255;0;0])
S([1200;-600;-600], 300, [255;0;0])
S([1200;0;-600], 300, [255;0;0])
S([1200;600;-600], 300, [255;0;0])";
        }
コード例 #4
0
 public CommandNode(RenderCommand val, CommandNode prev, CommandNode next)
 {
     value     = val;
     this.prev = prev;
     this.next = next;
 }
コード例 #5
0
 private static GameObject HandleRenderCommand(GameObject gameObject, RenderCommand renderCommand)
 {
     Im.Maybe((render, _) => render(gameObject, renderCommand), renderCommand.Type, renderers);
     return(gameObject);
 }
コード例 #6
0
 /// <summary>
 /// Issues the player event.
 /// </summary>
 /// <param name="evt">The event to send to the video player
 ///     instance.
 /// </param>
 private void IssuePlayerEvent(RenderCommand evt) {
   if (renderEventFunction != IntPtr.Zero && evt != RenderCommand.None) {
     GL.IssuePluginEvent(renderEventFunction,
       videoPlayerEventBase + (int) evt);
   }
 }