Click here to Skip to main content
15,886,851 members
Articles / Containers / Virtual Machine

Twiggery Scripting Language

Rate me:
Please Sign up or sign in to vote.
4.82/5 (14 votes)
12 Aug 2010LGPL313 min read 63.9K   1.1K   36  
Twiggery Scripting Language
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Windows.Forms;
using System.Drawing;
using num = System.Single;
using arguments = System.Collections.Generic.List<object>;

namespace Twiggery.Plugin.Graphics
{
    internal abstract class Sprite
    {
        protected int x;
        protected int y;
        protected Pen p;
        protected Color c;
        protected bool visable = true;

        public abstract void Render(System.Drawing.Graphics g);

        public abstract void SetSize(arguments args);

        public virtual void GetVisible(arguments args)
        {
            args.Add(visable ? (num)1 : (num)0);
        }

        public virtual void SetVisible(arguments args)
        {
            int vs = (int)(num)args[0];
            visable = vs == 1;
        }

        public virtual void Remove()
        {
            // Do nothing
        }

        public virtual void SetAttribute(arguments args)
        {
            // Do nothing
        }

        public virtual void SetPosition(int _x, int _y)
        {
            x = _x;
            y = _y;
        }

        public virtual void SetColor(Color _c)
        {
            c = _c;

            p = new Pen(c);
        }

        public virtual void SetColor(int _ch, int _v)
        {
            Color _c = Color.Black;
            switch (_ch)
            {
                case 1://"R":
                    _c = Color.FromArgb(_v, c.G, c.B);
                    break;
                case 2://"G":
                    _c = Color.FromArgb(c.R, _v, c.B);
                    break;
                case 3://"B":
                    _c = Color.FromArgb(c.R, c.G, _v);
                    break;
            }
            c = _c;

            p = new Pen(c);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


Written By
Architect
China China
Video game player & creator; Hardware geek & maker.

Comments and Discussions