コード例 #1
0
        public static void ColorAdd(byte r, byte g, byte b, byte a)
        {
            if (!m_ready)
            {
                return;
            }

            fixed(byte *ptr = &MemoryMarshal.GetArrayDataReference(m_pixels))
            {
                for (int i = 0; i < m_pixels.Length / 4; ++i)
                {
                    byte *ptr_idx = ptr + (i * 4);

                    var sb = (*(ptr_idx) + b);
                    var sg = (*(ptr_idx + 1) + g);
                    var sr = (*(ptr_idx + 2) + r);
                    var sa = (*(ptr_idx + 3) + a);

                    *(ptr_idx)     = (byte)Calc.Clamp(sb, 0, 255);
                    *(ptr_idx + 1) = (byte)Calc.Clamp(sg, 0, 255);
                    *(ptr_idx + 2) = (byte)Calc.Clamp(sr, 0, 255);
                    *(ptr_idx + 3) = (byte)Calc.Clamp(sa, 0, 255);
                }
            }

            m_blitter_dirty = true;
        }
コード例 #2
0
        public static void ColorMult(float r, float g, float b, float a)
        {
            if (!m_ready)
            {
                return;
            }

            fixed(byte *ptr = &MemoryMarshal.GetArrayDataReference(m_pixels))
            {
                for (int i = 0; i < m_pixels.Length / 4; ++i)
                {
                    byte *ptr_idx = ptr + (i * 4);

                    if (*(ptr_idx + 3) == 0)
                    {
                        continue;
                    }

                    var sb = (*(ptr_idx) * b);
                    var sg = (*(ptr_idx + 1) * g);
                    var sr = (*(ptr_idx + 2) * r);
                    var sa = (*(ptr_idx + 3) * a);

                    *(ptr_idx)     = (byte)Calc.Clamp(sb, 0, 255);
                    *(ptr_idx + 1) = (byte)Calc.Clamp(sg, 0, 255);
                    *(ptr_idx + 2) = (byte)Calc.Clamp(sr, 0, 255);
                    *(ptr_idx + 3) = (byte)Calc.Clamp(sa, 0, 255);
                }
            }

            m_blitter_dirty = true;
        }
コード例 #3
0
 public static Vec3 Clamp(Vec3 value1, Vec3 min, Vec3 max)
 {
     return(new Vec3(
                Calc.Clamp(value1.X, min.X, max.X),
                Calc.Clamp(value1.Y, min.Y, max.Y),
                Calc.Clamp(value1.Z, min.Z, max.Z)));
 }
コード例 #4
0
 public static void Clamp(ref Vec4 value1, ref Vec4 min, ref Vec4 max, out Vec4 result)
 {
     result.X = Calc.Clamp(value1.X, min.X, max.X);
     result.Y = Calc.Clamp(value1.Y, min.Y, max.Y);
     result.Z = Calc.Clamp(value1.Z, min.Z, max.Z);
     result.W = Calc.Clamp(value1.W, min.W, max.W);
 }
コード例 #5
0
ファイル: AnimatedSprite.cs プロジェクト: parhelia512/OMEGA
        public void SetFrame(int index, bool pause = true)
        {
            index = Calc.Clamp(index, 0, m_frame_indices.Length - 1);

            m_index = index;

            Paused = pause;
        }
コード例 #6
0
 public static Vec4 Clamp(Vec4 value1, Vec4 min, Vec4 max)
 {
     return(new Vec4(
                Calc.Clamp(value1.X, min.X, max.X),
                Calc.Clamp(value1.Y, min.Y, max.Y),
                Calc.Clamp(value1.Z, min.Z, max.Z),
                Calc.Clamp(value1.W, min.W, max.W)));
 }
コード例 #7
0
        public void SetFrame(int index, bool pause = true)
        {
            index = Calc.Clamp(index, 0, _mFrameIndices.Length - 1);

            _mIndex = index;

            Paused = pause;
        }
コード例 #8
0
        internal void SetTexture(int slot, Texture2D texture)
        {
            slot = Calc.Clamp(slot, 0, 2);

            _textures[slot] = texture;

            if (slot > _textureIndex)
            {
                _textureIndex = slot;
            }
        }
コード例 #9
0
ファイル: Color.cs プロジェクト: parhelia512/OMEGA
        public Color(Color color, int alpha)
        {
            if ((alpha & 0xFFFFFF00) != 0)
            {
                var clampedA = (uint)Calc.Clamp(alpha, Byte.MinValue, Byte.MaxValue);

                _abgr = (color._abgr & 0x00FFFFFF) | (clampedA << 24);
            }
            else
            {
                _abgr = (color._abgr & 0x00FFFFFF) | ((uint)alpha << 24);
            }
        }
コード例 #10
0
ファイル: Platform_Gamepad.cs プロジェクト: parhelia512/OMEGA
        public static bool SetGamePadVibration(int index, float leftMotor, float rightMotor)
        {
            IntPtr device = gamepad_devices[index];

            if (device == IntPtr.Zero)
            {
                return(false);
            }

            return(SDL_GameControllerRumble(
                       device,
                       (ushort)(Calc.Clamp(leftMotor, 0.0f, 1.0f) * 0xFFFF),
                       (ushort)(Calc.Clamp(rightMotor, 0.0f, 1.0f) * 0xFFFF),
                       0
                       ) == 0);
        }
コード例 #11
0
ファイル: Color.cs プロジェクト: parhelia512/OMEGA
        public Color(int r, int g, int b, int alpha)
        {
            if (((r | g | b | alpha) & 0xFFFFFF00) != 0)
            {
                var clampedR = (uint)Calc.Clamp(r, Byte.MinValue, Byte.MaxValue);
                var clampedG = (uint)Calc.Clamp(g, Byte.MinValue, Byte.MaxValue);
                var clampedB = (uint)Calc.Clamp(b, Byte.MinValue, Byte.MaxValue);
                var clampedA = (uint)Calc.Clamp(alpha, Byte.MinValue, Byte.MaxValue);

                _abgr = (clampedA << 24) | (clampedB << 16) | (clampedG << 8) | (clampedR);
            }
            else
            {
                _abgr = ((uint)alpha << 24) | ((uint)b << 16) | ((uint)g << 8) | (uint)r;
            }
        }
コード例 #12
0
ファイル: Color.cs プロジェクト: parhelia512/OMEGA
        public Color(int r, int g, int b)
        {
            _abgr = 0xFF000000; // A = 255

            if (((r | g | b) & 0xFFFFFF00) != 0)
            {
                var clampedR = (uint)Calc.Clamp(r, Byte.MinValue, Byte.MaxValue);
                var clampedG = (uint)Calc.Clamp(g, Byte.MinValue, Byte.MaxValue);
                var clampedB = (uint)Calc.Clamp(b, Byte.MinValue, Byte.MaxValue);

                _abgr |= (clampedB << 16) | (clampedG << 8) | clampedR;
            }
            else
            {
                _abgr |= ((uint)b << 16) | ((uint)g << 8) | (uint)r;
            }
        }
コード例 #13
0
 public static void Clamp(ref Vec3 value1, ref Vec3 min, ref Vec3 max, out Vec3 result)
 {
     result.X = Calc.Clamp(value1.X, min.X, max.X);
     result.Y = Calc.Clamp(value1.Y, min.Y, max.Y);
     result.Z = Calc.Clamp(value1.Z, min.Z, max.Z);
 }