Esempio n. 1
0
        public static void DoAnimation(ScratchControl ctl, string rawCode, string prefix)
        {
            if (rawCode.Contains(","))
            {
                rawCode = rawCode.Split(',')[1].TrimStart();
            }
            string    codeString = prefix + "," + rawCode;
            Code      code       = RasterLib.RasterApi.CreateCode(codeString);
            TokenList tokens     = RasterLib.RasterApi.CodeToTokens(code);

            int tokenId     = 0;
            int actualCount = 1;

            while (tokenId < tokens.Count)
            {
                Console.WriteLine(tokenId + " / " + tokens.Count);

                //Skip pen changes, they are boring
                string str = tokens.GetToken(tokenId).ToString();

                if (str.StartsWith("Pen") == false)
                {
                    //Get clean triple-# padded numbering for filenames
                    string prependNumber = "";
                    if (actualCount < 100)
                    {
                        prependNumber += "0";
                    }
                    if (actualCount < 10)
                    {
                        prependNumber += "0";
                    }

                    string curCode = prefix + "-" + prependNumber + actualCount + ",";
                    for (int i = 0; i <= tokenId; i++)
                    {
                        curCode += tokens.GetToken(i) + ";";
                    }
                    if (tokenId > 1)
                    {
                        //Console.WriteLine("Token " + curCode);
                        ExecuteCodeToPng(ctl, curCode);
                        actualCount++;
                    }
                }
                tokenId++;
            }
        }