Esempio n. 1
0
        public void Hsb2rgb(float h, float s, float b, Color expectedColor)
        {
            var rgb      = ColorSystems.Hsb2rgb(h, s, b);
            var expected = expectedColor.ToVector3();

            Assert.AreEqual(expected, rgb);
        }
Esempio n. 2
0
        public void Hsb2rgbMagenta()
        {
            var rgb      = ColorSystems.Hsb2rgb(5.0f / 6.0f, 1, 1);
            var expected = new Vector3(1, 0, 1);

            Assert.AreEqual(expected, rgb);
        }
Esempio n. 3
0
        public void Hsb2rgbTestBlack1()
        {
            var rgb      = ColorSystems.Hsb2rgb(0, 0, 0);
            var expected = Vector3.Zero;             //black

            Assert.AreEqual(expected, rgb);
        }
Esempio n. 4
0
        public void Hsb2rgbBlue()
        {
            var rgb      = ColorSystems.Hsb2rgb(4.0f / 6.0f, 1, 1);
            var expected = new Vector3(0, 0, 1);

            Assert.AreEqual(expected, rgb);
        }
Esempio n. 5
0
        public void Hsb2rgbTestYellow()
        {
            var rgb      = ColorSystems.Hsb2rgb(1.0f / 6.0f, 1, 1);
            var expected = new Vector3(1, 1, 0);

            Assert.AreEqual(expected, rgb);
        }
Esempio n. 6
0
        public void Hsb2rgbTestGreen()
        {
            var rgb      = ColorSystems.Hsb2rgb(2.0f / 6.0f, 1, 1);
            var expected = Vector3.UnitY;

            Assert.AreEqual(expected, rgb);
        }
Esempio n. 7
0
        public void Hsb2rgbTestRed()
        {
            var rgb      = ColorSystems.Hsb2rgb(0, 1, 1);
            var expected = Vector3.UnitX;             //red

            Assert.AreEqual(expected, rgb);
        }
Esempio n. 8
0
        public void Hsb2rgbTestColor()
        {
            var rgb      = ColorSystems.Hsb2rgb(0, 0.2f, 1);
            var expected = new Vector3(1, 0.8f, 0.8f);

            Assert.AreEqual(expected, rgb);
        }
Esempio n. 9
0
        public void Hsb2rgbTestWhite()
        {
            var rgb      = ColorSystems.Hsb2rgb(0, 0, 1);
            var expected = Vector3.One;             //white

            Assert.AreEqual(expected, rgb);
        }
Esempio n. 10
0
        public Collider(float x, float y, float sizeX, float sizeY)
        {
            Box = new Box2D(x, y, sizeX, sizeY);
            //make a hsb color sweep in polar coordinates
            var polar = MathHelper.ToPolar(new Vector2(x, y));
            var rgb   = ColorSystems.Hsb2rgb(polar.X / MathHelper.TWO_PI + 0.5f, polar.Y, 1);

            Color    = ColorSystems.ToSystemColor(rgb);
            Velocity = Vector2.Zero;
        }
Esempio n. 11
0
        public override void Render()
        {
            GL.Clear(ClearBufferMask.ColorBufferBit);
            const int count   = 16;
            var       boxSize = 1.9f / count;

            for (int xI = 0; xI < count; ++xI)
            {
                float x          = xI * 2f / count - 1f;
                float brightness = xI / (float)count;
                for (int yI = 0; yI < count; ++yI)
                {
                    float y          = yI * 2f / count - 1f;
                    float saturation = yI / (float)count;
                    var   color      = ColorSystems.Hsb2rgb(Hue, saturation, brightness);
                    DrawRect(new Box2D(x, y, boxSize, boxSize), color);
                }
            }
        }
Esempio n. 12
0
        private void InitParticles()
        {
            var          rnd      = new Random(12);
            Func <float> Rnd01    = () => (float)rnd.NextDouble();
            Func <float> RndCoord = () => (Rnd01() - 0.5f) * 2.0f;
            Func <float> RndSpeed = () => (Rnd01() - 0.5f) * 0.1f;

            bufferParticles = new BufferObject(BufferTarget.ShaderStorageBuffer);

            var data = new Particle[particelCount];

            for (int i = 0; i < particelCount; ++i)
            {
                data[i].position = new Vector2(RndCoord(), RndCoord());
                data[i].velocity = new Vector2(RndSpeed(), RndSpeed());
                var polar     = MathHelper.ToPolar(data[i].position);
                var color     = ColorSystems.Hsb2rgb(polar.X / MathHelper.TWO_PI + 0.5f, polar.Y, 1);
                var byteColor = ColorSystems.ToSystemColor(color);
                data[i].color = color;
                data[i].size  = (Rnd01() + 1) * 10;
            }
            bufferParticles.Set(data, BufferUsageHint.StaticCopy);
        }