Esempio n. 1
0
        static IntPtr bitmapset(IntPtr Self, IntPtr Args)
        {
            GuardDisposed(Self);
            Ruby.Array.Expect(Args, 1);
            if (Ruby.Array.Get(Args, 0) == Ruby.Nil)
            {
                SpriteDictionary[Self].Bitmap = null;
            }
            else
            {
                Ruby.Array.Expect(Args, 0, "Bitmap");
                SpriteDictionary[Self].Bitmap = Bitmap.BitmapDictionary[Ruby.Array.Get(Args, 0)];
            }
            int x = 0,
                y = 0,
                w = SpriteDictionary[Self].Bitmap == null ? 0 : SpriteDictionary[Self].Bitmap.Width,
                h = SpriteDictionary[Self].Bitmap == null ? 0 : SpriteDictionary[Self].Bitmap.Height;

            SpriteDictionary[Self].SrcRect.X      = 0;
            SpriteDictionary[Self].SrcRect.Y      = 0;
            SpriteDictionary[Self].SrcRect.Width  = w;
            SpriteDictionary[Self].SrcRect.Height = h;
            IntPtr src_rect = Ruby.GetIVar(Self, "@src_rect");

            Ruby.SetIVar(src_rect, "@x", Ruby.Integer.ToPtr(x));
            Ruby.SetIVar(src_rect, "@y", Ruby.Integer.ToPtr(y));
            Ruby.SetIVar(src_rect, "@width", Ruby.Integer.ToPtr(w));
            Ruby.SetIVar(src_rect, "@height", Ruby.Integer.ToPtr(h));
            return(Ruby.SetIVar(Self, "@bitmap", Ruby.Array.Get(Args, 0)));
        }
Esempio n. 2
0
 static IntPtr wait(IntPtr Self, IntPtr Args)
 {
     Ruby.Array.Expect(Args, 1);
     Ruby.Array.Expect(Args, 0, "Integer");
     odl.SDL2.SDL.SDL_Delay((uint)(1000d / Ruby.Integer.FromPtr(Ruby.GetIVar(Self, "@frame_rate")) * Ruby.Integer.FromPtr(Ruby.Array.Get(Args, 0))));
     return(Ruby.True);
 }
Esempio n. 3
0
 static void GuardDisposed(IntPtr Self)
 {
     if (Ruby.GetIVar(Self, "@disposed") == Ruby.True)
     {
         Ruby.Raise(Ruby.ErrorType.RuntimeError, "bitmap already disposed");
     }
 }
Esempio n. 4
0
        static IntPtr hide_overlay(IntPtr Self, IntPtr Args)
        {
            int frames = (int)Ruby.Integer.FromPtr(Ruby.GetIVar(Self, "@frame_rate")) / 4;

            if (Ruby.Array.Length(Args) != 0)
            {
                Ruby.Array.Expect(Args, 1);
                Ruby.Array.Expect(Args, 0, "Integer");
                frames = (int)Ruby.Integer.FromPtr(Ruby.Array.Get(Args, 0));
            }
            if (Ruby.Integer.FromPtr(Ruby.GetIVar(OverlaySprite, "@opacity")) == 0)
            {
                return(Ruby.False);
            }
            if (frames == 0)
            {
                Ruby.Funcall(OverlaySprite, "opacity=", Ruby.Integer.ToPtr(0));
                return(Ruby.True);
            }
            bool hasblock = Ruby.HasBlock();

            for (int i = 1; i <= frames; i++)
            {
                Ruby.Funcall(OverlaySprite, "opacity=", Ruby.Float.ToPtr(255 - 255d / frames * i));
                if (hasblock)
                {
                    Ruby.Yield(Ruby.Integer.ToPtr(i - 1));
                }
                update(Self, Ruby.Array.Create());
            }
            return(Ruby.True);
        }
Esempio n. 5
0
        static IntPtr set(IntPtr Self, IntPtr Args)
        {
            Ruby.Array.Expect(Args, 4);
            int x = 0,
                y = 0,
                w = 0,
                h = 0;

            if (Ruby.Array.Is(Args, 0, "Float"))
            {
                x = Ruby.Float.RoundFromPtr(Ruby.Array.Get(Args, 0));
            }
            else
            {
                Ruby.Array.Expect(Args, 0, "Integer");
                x = (int)Ruby.Integer.FromPtr(Ruby.Array.Get(Args, 0));
            }
            if (Ruby.Array.Is(Args, 1, "Float"))
            {
                y = Ruby.Float.RoundFromPtr(Ruby.Array.Get(Args, 1));
            }
            else
            {
                Ruby.Array.Expect(Args, 1, "Integer");
                y = (int)Ruby.Integer.FromPtr(Ruby.Array.Get(Args, 1));
            }
            if (Ruby.Array.Is(Args, 2, "Float"))
            {
                w = Ruby.Float.RoundFromPtr(Ruby.Array.Get(Args, 2));
            }
            else
            {
                Ruby.Array.Expect(Args, 2, "Integer");
                w = (int)Ruby.Integer.FromPtr(Ruby.Array.Get(Args, 2));
            }
            if (Ruby.Array.Is(Args, 3, "Float"))
            {
                h = Ruby.Float.RoundFromPtr(Ruby.Array.Get(Args, 3));
            }
            else
            {
                Ruby.Array.Expect(Args, 3, "Integer");
                h = (int)Ruby.Integer.FromPtr(Ruby.Array.Get(Args, 3));
            }
            Ruby.SetIVar(Self, "@x", Ruby.Array.Get(Args, 0));
            Ruby.SetIVar(Self, "@y", Ruby.Array.Get(Args, 1));
            Ruby.SetIVar(Self, "@width", Ruby.Array.Get(Args, 2));
            Ruby.SetIVar(Self, "@height", Ruby.Array.Get(Args, 3));
            if (Ruby.GetIVar(Self, "@__sprite__") != Ruby.Nil)
            {
                Sprite.SpriteDictionary[Ruby.GetIVar(Self, "@__sprite__")].SrcRect.X      = x;
                Sprite.SpriteDictionary[Ruby.GetIVar(Self, "@__sprite__")].SrcRect.Y      = y;
                Sprite.SpriteDictionary[Ruby.GetIVar(Self, "@__sprite__")].SrcRect.Width  = w;
                Sprite.SpriteDictionary[Ruby.GetIVar(Self, "@__sprite__")].SrcRect.Height = h;
            }
            return(Self);
        }
Esempio n. 6
0
 static IntPtr AutoLock(IntPtr Self)
 {
     if (Ruby.GetIVar(Self, "@autolock") == Ruby.True)
     {
         BitmapDictionary[Self].Lock();
         return(Ruby.True);
     }
     return(Ruby.True);
 }
Esempio n. 7
0
 static IntPtr dispose(IntPtr Self, IntPtr Args)
 {
     GuardDisposed(Self);
     Ruby.Array.Expect(Args, 0);
     ViewportDictionary[Self].Dispose();
     ViewportDictionary.Remove(Self);
     Ruby.SetIVar(Ruby.GetIVar(Self, "@color"), "@__viewport__", Ruby.Nil);
     return(Ruby.SetIVar(Self, "@disposed", Ruby.True));
 }
Esempio n. 8
0
 static IntPtr colorset(IntPtr Self, IntPtr Args)
 {
     GuardDisposed(Self);
     Ruby.Array.Expect(Args, 1);
     Ruby.Array.Expect(Args, 0, "Color");
     Ruby.SetIVar(Ruby.GetIVar(Self, "@color"), "@__sprite__", Ruby.Nil);
     SpriteDictionary[Self].Color = Color.CreateColor(Ruby.Array.Get(Args, 0));
     Ruby.SetIVar(Ruby.Array.Get(Args, 0), "@__sprite__", Self);
     return(Ruby.SetIVar(Self, "@color", Ruby.Array.Get(Args, 0)));
 }
Esempio n. 9
0
        static IntPtr text_size(IntPtr Self, IntPtr Args)
        {
            GuardDisposed(Self);
            Ruby.Array.Expect(Args, 1);
            Ruby.Array.Expect(Args, 0, "String");
            string text = Ruby.String.FromPtr(Ruby.Array.Get(Args, 0));

            BitmapDictionary[Self].Font = Font.CreateFont(Ruby.GetIVar(Self, "@font"));
            return(Rect.CreateRect(new odl.Rect(BitmapDictionary[Self].TextSize(text))));
        }
Esempio n. 10
0
 static IntPtr toneset(IntPtr Self, IntPtr Args)
 {
     GuardDisposed(Self);
     Ruby.Array.Expect(Args, 1);
     Ruby.Array.Expect(Args, 0, "Tone");
     Ruby.SetIVar(Ruby.GetIVar(Self, "@tone"), "@__sprite__", Ruby.Nil);
     SpriteDictionary[Self].Tone = Tone.CreateTone(Ruby.Array.Get(Args, 0));
     Ruby.SetIVar(Ruby.Array.Get(Args, 0), "@__sprite__", Self);
     return(Ruby.SetIVar(Self, "@tone", Ruby.Array.Get(Args, 0)));
 }
Esempio n. 11
0
 static IntPtr src_rectset(IntPtr Self, IntPtr Args)
 {
     GuardDisposed(Self);
     Ruby.Array.Expect(Args, 1);
     Ruby.Array.Expect(Args, 0, "Rect");
     Ruby.SetIVar(Ruby.GetIVar(Self, "@src_rect"), "@__sprite__", Ruby.Nil);
     SpriteDictionary[Self].SrcRect = Rect.CreateRect(Ruby.Array.Get(Args, 0));
     Ruby.SetIVar(Ruby.Array.Get(Args, 0), "@__sprite__", Self);
     return(Ruby.SetIVar(Self, "@src_rect", Ruby.Array.Get(Args, 0)));
 }
Esempio n. 12
0
 public static IntPtr CreateFont()
 {
     if (Ruby.GetIVar(Class, "@default_name") == Ruby.Nil)
     {
         Ruby.Raise(Ruby.ErrorType.RuntimeError, "no default font name defined");
     }
     if (Ruby.GetIVar(Class, "@default_size") == Ruby.Nil)
     {
         Ruby.Raise(Ruby.ErrorType.RuntimeError, "no default font size defined");
     }
     return(Ruby.Funcall(Class, "new", Ruby.GetIVar(Class, "@default_name"), Ruby.GetIVar(Class, "@default_size")));
 }
Esempio n. 13
0
 static IntPtr AutoUnlock(IntPtr Self)
 {
     if (Ruby.GetIVar(Self, "@autolock") == Ruby.True)
     {
         BitmapDictionary[Self].Unlock();
         return(Ruby.True);
     }
     else if (BitmapDictionary[Self].Locked)
     {
         Ruby.Raise(Ruby.ErrorType.RuntimeError, "bitmap locked for writing");
     }
     return(Ruby.True);
 }
Esempio n. 14
0
        public static void Start()
        {
            odl.Viewport.DefaultWindow = Program.MainWindow;
            MainViewport = Ruby.Funcall(Viewport.Class, "new", Ruby.Integer.ToPtr(0), Ruby.Integer.ToPtr(0), Ruby.GetIVar(Module, "@width"), Ruby.GetIVar(Module, "@height"));
            Ruby.Pin(MainViewport);
            Ruby.Funcall(MainViewport, "z=", Ruby.Integer.ToPtr(999999998));

            Ruby.SetIVar(Font.Class, "@default_name", Ruby.String.ToPtr("arial"));
            Ruby.SetIVar(Font.Class, "@default_size", Ruby.Integer.ToPtr(32));
            Ruby.SetIVar(Font.Class, "@default_color", Color.CreateColor(odl.Color.WHITE));
            Ruby.SetIVar(Font.Class, "@default_outline", Ruby.False);
            Ruby.SetIVar(Font.Class, "@default_outline_color", Color.CreateColor(odl.Color.BLACK));

            OverlayViewport = Ruby.Funcall(Viewport.Class, "new", Ruby.Integer.ToPtr(0), Ruby.Integer.ToPtr(0), Ruby.GetIVar(Module, "@width"), Ruby.GetIVar(Module, "@height"));
            Ruby.Pin(OverlayViewport);
            Ruby.Funcall(OverlayViewport, "z=", Ruby.Integer.ToPtr(999999999));

            OverlaySprite = Ruby.Funcall(Sprite.Class, "new", OverlayViewport);
            Ruby.Pin(OverlaySprite);

            IntPtr OverlayBitmap = Ruby.Funcall(Bitmap.Class, "new", Ruby.GetIVar(Module, "@width"), Ruby.GetIVar(Module, "@height"));

            Ruby.Pin(OverlayBitmap);

            Ruby.Funcall(OverlaySprite, "bitmap=", OverlayBitmap);
            Ruby.Funcall(OverlaySprite, "opacity=", Ruby.Integer.ToPtr(0));
            Ruby.Funcall(OverlaySprite, "z=", Ruby.Integer.ToPtr(999999999));
            Ruby.Funcall(OverlayBitmap, "fill_rect", Ruby.Integer.ToPtr(0), Ruby.Integer.ToPtr(0), Ruby.GetIVar(Module, "@width"), Ruby.GetIVar(Module, "@height"), Color.CreateColor(odl.Color.BLACK));

            Ruby.SetGlobal("$PERIDOT", Ruby.True);

            Ruby.SetIVar(Module, "@brightness", Ruby.Integer.ToPtr(255));
            Ruby.SetIVar(Module, "@frame_count", Ruby.Integer.ToPtr(0));

            int fps = Config.FrameRate;

            if (Config.VSync)
            {
                odl.SDL2.SDL.SDL_DisplayMode mode = new odl.SDL2.SDL.SDL_DisplayMode();
                odl.SDL2.SDL.SDL_GetWindowDisplayMode(Program.MainWindow.SDL_Window, out mode);
                fps = mode.refresh_rate;
            }
            else
            {
                ManualSync           = true;
                MillisecondsPerFrame = (int)Math.Ceiling(1d / fps);
                FPSTimer.Start();
            }
            Ruby.SetIVar(Module, "@frame_rate", Ruby.Integer.ToPtr(fps));
            Ruby.SetIVar(Module, "@render_speed", Ruby.Float.ToPtr(1));
        }
Esempio n. 15
0
        static IntPtr alphaset(IntPtr Self, IntPtr Args)
        {
            Ruby.Array.Expect(Args, 1);
            IntPtr A;
            byte   reala = 0;

            if (Ruby.Array.Is(Args, 0, "Float"))
            {
                double v = Ruby.Float.FromPtr(Ruby.Array.Get(Args, 0));
                if (v < 0)
                {
                    v = 0; A = Ruby.Float.ToPtr(0);
                }
                else if (v > 255)
                {
                    v = 255; A = Ruby.Float.ToPtr(255);
                }
                else
                {
                    A = Ruby.Array.Get(Args, 0);
                }
                reala = (byte)Math.Round(v);
            }
            else
            {
                Ruby.Array.Expect(Args, 0, "Integer");
                int v = (int)Ruby.Integer.FromPtr(Ruby.Array.Get(Args, 0));
                if (v < 0)
                {
                    A = Ruby.Integer.ToPtr(0);
                }
                else if (v > 255)
                {
                    A = Ruby.Integer.ToPtr(255);
                }
                else
                {
                    A = Ruby.Array.Get(Args, 0);
                }
                reala = (byte)v;
            }
            if (Ruby.GetIVar(Self, "@__viewport__") != Ruby.Nil)
            {
                Viewport.ViewportDictionary[Ruby.GetIVar(Self, "@__viewport__")].Color.Alpha = reala;
            }
            if (Ruby.GetIVar(Self, "@__sprite__") != Ruby.Nil)
            {
                Sprite.SpriteDictionary[Ruby.GetIVar(Self, "@__sprite__")].Color.Alpha = reala;
            }
            return(Ruby.SetIVar(Self, "@alpha", A));
        }
Esempio n. 16
0
 static IntPtr lockbmp(IntPtr Self, IntPtr Args)
 {
     GuardDisposed(Self);
     Ruby.Array.Expect(Args, 0);
     if (Ruby.GetIVar(Self, "@autolock") == Ruby.True)
     {
         Ruby.Raise(Ruby.ErrorType.RuntimeError, "manual locking disallowed with autolock enabled");
     }
     else if (BitmapDictionary[Self].Locked)
     {
         Ruby.Raise(Ruby.ErrorType.RuntimeError, "bitmap already locked");
     }
     BitmapDictionary[Self].Lock();
     return(Ruby.True);
 }
Esempio n. 17
0
        static IntPtr greyset(IntPtr Self, IntPtr Args)
        {
            Ruby.Array.Expect(Args, 1);
            IntPtr Grey     = Ruby.Integer.ToPtr(0);
            byte   realgrey = 0;

            if (Ruby.Array.Is(Args, 0, "Float"))
            {
                double v = Ruby.Float.FromPtr(Ruby.Array.Get(Args, 0));
                if (v < 0)
                {
                    v = 0; Grey = Ruby.Float.ToPtr(0);
                }
                else if (v > 255)
                {
                    v = 255; Grey = Ruby.Float.ToPtr(255);
                }
                else
                {
                    Grey = Ruby.Array.Get(Args, 0);
                }
                realgrey = (byte)Math.Round(v);
            }
            else
            {
                Ruby.Array.Expect(Args, 0, "Integer");
                int v = (int)Ruby.Integer.FromPtr(Ruby.Array.Get(Args, 0));
                if (v < 0)
                {
                    Grey = Ruby.Integer.ToPtr(0);
                }
                else if (v > 255)
                {
                    Grey = Ruby.Integer.ToPtr(255);
                }
                else
                {
                    Grey = Ruby.Array.Get(Args, 0);
                }
                realgrey = (byte)v;
            }
            if (Ruby.GetIVar(Self, "@__sprite__") != Ruby.Nil)
            {
                Sprite.SpriteDictionary[Ruby.GetIVar(Self, "@__sprite__")].Tone.Gray = realgrey;
            }
            return(Ruby.SetIVar(Self, "@grey", Grey));
        }
Esempio n. 18
0
        static IntPtr blueset(IntPtr Self, IntPtr Args)
        {
            Ruby.Array.Expect(Args, 1);
            IntPtr B     = Ruby.Integer.ToPtr(0);
            short  realb = 0;

            if (Ruby.Array.Is(Args, 0, "Float"))
            {
                double v = Ruby.Float.FromPtr(Ruby.Array.Get(Args, 0));
                if (v < -255)
                {
                    v = -255; B = Ruby.Float.ToPtr(-255);
                }
                else if (v > 255)
                {
                    v = 255; B = Ruby.Float.ToPtr(255);
                }
                else
                {
                    B = Ruby.Array.Get(Args, 0);
                }
                realb = (short)Math.Round(v);
            }
            else
            {
                Ruby.Array.Expect(Args, 0, "Integer");
                int v = (int)Ruby.Integer.FromPtr(Ruby.Array.Get(Args, 0));
                if (v < -255)
                {
                    v = -255; B = Ruby.Integer.ToPtr(-255);
                }
                else if (v > 255)
                {
                    v = 255; B = Ruby.Integer.ToPtr(255);
                }
                else
                {
                    B = Ruby.Array.Get(Args, 0);
                }
                realb = (short)v;
            }
            if (Ruby.GetIVar(Self, "@__sprite__") != Ruby.Nil)
            {
                Sprite.SpriteDictionary[Ruby.GetIVar(Self, "@__sprite__")].Tone.Blue = realb;
            }
            return(Ruby.SetIVar(Self, "@blue", B));
        }
Esempio n. 19
0
        static IntPtr initialize(IntPtr Self, IntPtr Args)
        {
            Ruby.Array.Expect(Args, 0, 1, 2);
            IntPtr Name = IntPtr.Zero,
                   Size = IntPtr.Zero;
            long len    = Ruby.Array.Length(Args);

            if (len == 0)
            {
                if (Ruby.GetIVar(Class, "@default_name") == Ruby.Nil)
                {
                    Ruby.Raise(Ruby.ErrorType.RuntimeError, "no default font name defined");
                }
                if (Ruby.GetIVar(Class, "@default_size") == Ruby.Nil)
                {
                    Ruby.Raise(Ruby.ErrorType.RuntimeError, "no default font size defined");
                }
                Name = Ruby.GetIVar(Class, "@default_name");
                Size = Ruby.GetIVar(Class, "@default_size");
            }
            else if (len == 1)
            {
                Ruby.Array.Expect(Args, 0, "String");
                Name = Ruby.Array.Get(Args, 0);
                if (Ruby.GetIVar(Class, "@default_size") == Ruby.Nil)
                {
                    Ruby.Raise(Ruby.ErrorType.RuntimeError, "no default font size defined");
                }
                Size = Ruby.GetIVar(Class, "@default_size");
            }
            else if (len == 2)
            {
                Ruby.Array.Expect(Args, 0, "String");
                Ruby.Array.Expect(Args, 1, "Integer");
                Name = Ruby.Array.Get(Args, 0);
                Size = Ruby.Array.Get(Args, 1);
            }
            Ruby.SetIVar(Self, "@name", Name);
            Ruby.SetIVar(Self, "@size", Size);
            Ruby.SetIVar(Self, "@color", Ruby.GetIVar(Class, "@default_color"));
            Ruby.SetIVar(Self, "@outline", Ruby.GetIVar(Class, "@default_outline"));
            Ruby.SetIVar(Self, "@outline_color", Ruby.GetIVar(Class, "@default_outline_color"));
            return(Self);
        }
Esempio n. 20
0
        public static odl.Font CreateFont(IntPtr Self)
        {
            string folder = null;

            if (Ruby.GetIVar(Class, "@default_folder") != Ruby.Nil)
            {
                folder = Ruby.String.FromPtr(Ruby.GetIVar(Class, "@default_folder"));
            }
            string name = Ruby.String.FromPtr(Ruby.GetIVar(Self, "@name"));
            int    size = (int)Ruby.Integer.FromPtr(Ruby.GetIVar(Self, "@size"));

            if (!string.IsNullOrEmpty(folder) && odl.Font.Exists(folder + "/" + name))
            {
                return(odl.Font.Get(folder + "/" + name, size));
            }
            else
            {
                return(odl.Font.Get(name, size));
            }
        }
Esempio n. 21
0
        static IntPtr xset(IntPtr Self, IntPtr Args)
        {
            Ruby.Array.Expect(Args, 1);
            int x = 0;

            if (Ruby.Array.Is(Args, 0, "Float"))
            {
                x = Ruby.Float.RoundFromPtr(Ruby.Array.Get(Args, 0));
            }
            else
            {
                Ruby.Array.Expect(Args, 0, "Integer");
                x = (int)Ruby.Integer.FromPtr(Ruby.Array.Get(Args, 0));
            }
            if (Ruby.GetIVar(Self, "@__sprite__") != Ruby.Nil)
            {
                Sprite.SpriteDictionary[Ruby.GetIVar(Self, "@__sprite__")].SrcRect.X = x;
            }
            return(Ruby.SetIVar(Self, "@x", Ruby.Array.Get(Args, 0)));
        }
Esempio n. 22
0
        static IntPtr vsyncset(IntPtr Self, IntPtr Args)
        {
            Ruby.Array.Expect(Args, 1);
            Ruby.Array.Expect(Args, 0, "TrueClass", "FalseClass");
            bool vsync = Ruby.Array.Get(Args, 0) == Ruby.True;

            Program.MainWindow.SetVSync(vsync);
            if (vsync)
            {
                ManualSync           = false;
                MillisecondsPerFrame = -1;
            }
            else
            {
                ManualSync = true;
                double speed = Ruby.Float.FromPtr(Ruby.GetIVar(Self, "@render_speed"));
                MillisecondsPerFrame = (int)Math.Ceiling(1000d / speed / Config.FrameRate);
            }
            return(Ruby.Array.Get(Args, 0));
        }
Esempio n. 23
0
 static IntPtr dispose(IntPtr Self, IntPtr Args)
 {
     GuardDisposed(Self);
     Ruby.Array.Expect(Args, 0);
     SpriteDictionary[Self].Dispose();
     Ruby.SetIVar(Ruby.GetIVar(Self, "@src_rect"), "@__sprite__", Ruby.Nil);
     Ruby.SetIVar(Ruby.GetIVar(Self, "@color"), "@__sprite__", Ruby.Nil);
     Ruby.SetIVar(Ruby.GetIVar(Self, "@tone"), "@__sprite__", Ruby.Nil);
     foreach (KeyValuePair <IntPtr, odl.Bitmap> kvp in Bitmap.BitmapDictionary)
     {
         if (kvp.Value == SpriteDictionary[Self].Bitmap)
         {
             Bitmap.BitmapDictionary.Remove(kvp.Key);
             break;
         }
     }
     SpriteDictionary.Remove(Self);
     Ruby.SetIVar(Self, "@disposed", Ruby.True);
     return(Ruby.True);
 }
Esempio n. 24
0
        public static odl.Rect CreateRect(IntPtr Self)
        {
            int x = 0,
                y = 0,
                w = 0,
                h = 0;

            if (Ruby.IVarIs(Self, "@x", "Float"))
            {
                x = (byte)Ruby.Float.RoundFromPtr(Ruby.GetIVar(Self, "@x"));
            }
            else
            {
                x = (int)Ruby.Integer.FromPtr(Ruby.GetIVar(Self, "@x"));
            }
            if (Ruby.IVarIs(Self, "@y", "Float"))
            {
                y = (byte)Ruby.Float.RoundFromPtr(Ruby.GetIVar(Self, "@y"));
            }
            else
            {
                y = (int)Ruby.Integer.FromPtr(Ruby.GetIVar(Self, "@y"));
            }
            if (Ruby.IVarIs(Self, "@width", "Float"))
            {
                w = (byte)Ruby.Float.RoundFromPtr(Ruby.GetIVar(Self, "@width"));
            }
            else
            {
                w = (int)Ruby.Integer.FromPtr(Ruby.GetIVar(Self, "@width"));
            }
            if (Ruby.IVarIs(Self, "@height", "Float"))
            {
                h = (byte)Ruby.Float.RoundFromPtr(Ruby.GetIVar(Self, "@height"));
            }
            else
            {
                h = (int)Ruby.Integer.FromPtr(Ruby.GetIVar(Self, "@height"));
            }
            return(new odl.Rect(x, y, w, h));
        }
Esempio n. 25
0
        public static odl.Color CreateColor(IntPtr Self)
        {
            byte R = 0,
                 G = 0,
                 B = 0,
                 A = 0;

            if (Ruby.IVarIs(Self, "@red", "Float"))
            {
                R = (byte)Ruby.Float.RoundFromPtr(Ruby.GetIVar(Self, "@red"));
            }
            else
            {
                R = (byte)Ruby.Integer.FromPtr(Ruby.GetIVar(Self, "@red"));
            }
            if (Ruby.IVarIs(Self, "@green", "Float"))
            {
                G = (byte)Ruby.Float.RoundFromPtr(Ruby.GetIVar(Self, "@green"));
            }
            else
            {
                G = (byte)Ruby.Integer.FromPtr(Ruby.GetIVar(Self, "@green"));
            }
            if (Ruby.IVarIs(Self, "@blue", "Float"))
            {
                B = (byte)Ruby.Float.RoundFromPtr(Ruby.GetIVar(Self, "@blue"));
            }
            else
            {
                B = (byte)Ruby.Integer.FromPtr(Ruby.GetIVar(Self, "@blue"));
            }
            if (Ruby.IVarIs(Self, "@alpha", "Float"))
            {
                A = (byte)Ruby.Float.RoundFromPtr(Ruby.GetIVar(Self, "@alpha"));
            }
            else
            {
                A = (byte)Ruby.Integer.FromPtr(Ruby.GetIVar(Self, "@alpha"));
            }
            return(new odl.Color(R, G, B, A));
        }
Esempio n. 26
0
        public static odl.Tone CreateTone(IntPtr Self)
        {
            short R   = 0,
                  G   = 0,
                  B   = 0;
            byte Grey = 0;

            if (Ruby.IVarIs(Self, "@red", "Float"))
            {
                R = (short)Ruby.Float.RoundFromPtr(Ruby.GetIVar(Self, "@red"));
            }
            else
            {
                R = (short)Ruby.Integer.FromPtr(Ruby.GetIVar(Self, "@red"));
            }
            if (Ruby.IVarIs(Self, "@green", "Float"))
            {
                G = (short)Ruby.Float.RoundFromPtr(Ruby.GetIVar(Self, "@green"));
            }
            else
            {
                G = (short)Ruby.Integer.FromPtr(Ruby.GetIVar(Self, "@green"));
            }
            if (Ruby.IVarIs(Self, "@blue", "Float"))
            {
                B = (short)Ruby.Float.RoundFromPtr(Ruby.GetIVar(Self, "@blue"));
            }
            else
            {
                B = (short)Ruby.Integer.FromPtr(Ruby.GetIVar(Self, "@blue"));
            }
            if (Ruby.IVarIs(Self, "@grey", "Float"))
            {
                Grey = (byte)Ruby.Float.RoundFromPtr(Ruby.GetIVar(Self, "@grey"));
            }
            else
            {
                Grey = (byte)Ruby.Integer.FromPtr(Ruby.GetIVar(Self, "@grey"));
            }
            return(new odl.Tone(R, G, B, Grey));
        }
Esempio n. 27
0
 static IntPtr volumeget(IntPtr Self, IntPtr Args)
 {
     Ruby.Array.Expect(Args, 0);
     return(Ruby.GetIVar(Self, "@volume"));
 }
Esempio n. 28
0
 static IntPtr fade_out_lengthget(IntPtr Self, IntPtr Args)
 {
     Ruby.Array.Expect(Args, 0);
     return(Ruby.GetIVar(Self, "@fade_out_length"));
 }
Esempio n. 29
0
 static IntPtr length(IntPtr Self, IntPtr Args)
 {
     Ruby.Array.Expect(Args, 0);
     return(Ruby.GetIVar(Self, "@length"));
 }
Esempio n. 30
0
 static IntPtr loop_endget(IntPtr Self, IntPtr Args)
 {
     Ruby.Array.Expect(Args, 0);
     return(Ruby.GetIVar(Self, "@loop_end"));
 }