Esempio n. 1
0
        public void MouseButton()
        {
            var tc = new TestCore();

            tc.Init();

            var font = Font.LoadDynamicFont("../../Core/TestData/Font/mplus-1m-regular.ttf", 100);

            Assert.NotNull(font);

            var node = new TextNode();

            node.Font = font;

            Engine.AddNode(node);

            tc.LoopBody(c =>
            {
                var left  = Engine.Mouse.GetMouseButtonState(MouseButtons.ButtonLeft);
                var right = Engine.Mouse.GetMouseButtonState(MouseButtons.ButtonRight);
                node.Text = $"左:{left}\n右{right}";
            }
                        , null);

            tc.End();
        }
Esempio n. 2
0
        public void Keyboard()
        {
            var tc = new TestCore();

            tc.Init();

            var font = Font.LoadDynamicFont("../../Core/TestData/Font/mplus-1m-regular.ttf", 100);

            Assert.NotNull(font);

            var node = new TextNode();

            node.Font = font;

            Engine.AddNode(node);

            tc.LoopBody(c =>
            {
                var sp    = Engine.Keyboard.GetKeyState(Keys.Space);
                node.Text = $"Spaceキー:{sp}";
            }
                        , null);

            tc.End();
        }
Esempio n. 3
0
        public void MousePosition()
        {
            var tc = new TestCore();

            tc.Init();

            var font = Font.LoadDynamicFont("../../Core/TestData/Font/mplus-1m-regular.ttf", 100);

            Assert.NotNull(font);

            var node = new TextNode();

            node.Font = font;

            Engine.AddNode(node);

            tc.LoopBody(c =>
            {
                var mp    = Engine.Mouse.Position;
                node.Text = $"{mp.X},{mp.Y}";
            }
                        , null);

            tc.End();
        }
Esempio n. 4
0
        public void RenderedCamera()
        {
            var tc = new TestCore();

            tc.Init();

            var texture = Altseed.RenderTexture.Create(new Vector2I(100, 100));

            Assert.NotNull(texture);

            var camera1 = Altseed.RenderedCamera.Create();

            Assert.NotNull(camera1);

            camera1.CenterOffset  = new Vector2F(10, 10);
            camera1.TargetTexture = texture;

            const string path = "Serialization/RenderedCamera.bin";

            Serialize(path, camera1);

            var camera2 = Deserialize <RenderedCamera>(path);

            Assert.NotNull(camera2);

            Assert.AreEqual(camera1.CenterOffset, camera2.CenterOffset);
            Assert.AreEqual(camera1.TargetTexture.Size, camera2.TargetTexture.Size);
            Assert.AreEqual(camera1.Transform, camera2.Transform);

            tc.End();
        }
Esempio n. 5
0
        public void TreeAdd()
        {
            var tc = new TestCore();

            tc.Init();

            var t1 = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png");

            Assert.NotNull(t1);

            var s = new SpriteNode();

            s.Src      = new RectF(new Vector2F(100, 100), new Vector2F(100, 100));
            s.Texture  = t1;
            s.Position = new Vector2F(100, 100);

            var s2 = new SpriteNode();

            s2.Src      = new RectF(new Vector2F(200, 200), new Vector2F(100, 100));
            s2.Texture  = t1;
            s2.Position = new Vector2F(200, 200);

            s.AddChildNode(s2);

            tc.LoopBody(c =>
            {
                if (c == 100)
                {
                    Engine.AddNode(s);
                }
            }, null);

            tc.End();
        }
Esempio n. 6
0
        public void StreamFile()
        {
            var tc = new TestCore();

            tc.Init();

            var file1 = Altseed.StreamFile.CreateStrict("../../Core/TestData/IO/test.txt");

            const string path = "Serialization/StreamFile.bin";

            file1.Read(3);

            Serialize(path, file1);

            Assert.True(System.IO.File.Exists(path));

            var file2 = Deserialize <StreamFile>(path);

            file2.Save("Serialization/StreamFile.txt");

            Assert.AreEqual(file1.Path, file2.Path);
            Assert.AreEqual(file1.IsInPackage, file2.IsInPackage);
            Assert.AreEqual(file1.CurrentPosition, file2.CurrentPosition);
            Assert.AreEqual(file1.TempBufferSize, file2.TempBufferSize);
            Assert.AreEqual(file1.Size, file2.Size);
            Assert.True(Enumerable.SequenceEqual(file1.TempBuffer, file2.TempBuffer));

            tc.End();
        }
Esempio n. 7
0
        public void NoRenderTexture()
        {
            var tc = new TestCore();

            tc.Init();

            var texture = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png");

            Assert.NotNull(texture);

            var node = new SpriteNode();

            node.Src         = new RectF(new Vector2F(100, 100), new Vector2F(200, 200));
            node.Texture     = texture;
            node.Pivot       = texture.Size / 2;
            node.CameraGroup = 1 << 0;
            Engine.AddNode(node);

            var camera = new CameraNode();

            camera.Transform = Matrix44F.GetTranslation2D(new Vector2F(-200, -200));
            camera.Group     = 0;
            Engine.AddNode(camera);

            tc.LoopBody(c =>
            {
                node.Angle++;
            }
                        , null);

            tc.End();
        }
Esempio n. 8
0
        public void MassSpriteNode()
        {
            var tc = new TestCore(new Configuration()
            {
                WaitVSync = false
            });

            tc.Init();

            var texture = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink256.png");

            Assert.NotNull(texture);

            var ws   = Engine.WindowSize;
            var size = 10;

            for (var x = 0; x < ws.X / size; x++)
            {
                for (var y = 0; y < ws.Y / size; y++)
                {
                    var node = new SpriteNode();
                    node.Texture  = texture;
                    node.Src      = new RectF(new Vector2F(128 * (x % 2), 128 * (y % 2)), new Vector2F(128, 128));
                    node.Scale    = new Vector2F(1, 1) * size / 128f;
                    node.Position = new Vector2F(x, y) * size;
                    Engine.AddNode(node);
                }
            }

            tc.LoopBody(null, null);

            tc.End();
        }
Esempio n. 9
0
        public void PolygonNode_SetVertexesByVector2F()
        {
            var tc = new TestCore(new Configuration()
            {
                WaitVSync = false
            });

            tc.Init();

            var node = new PolygonNode();

            Engine.AddNode(node);

            tc.LoopBody(c =>
            {
                var sin = MathF.Sin(MathHelper.DegreeToRadian(c)) * 50;
                var cos = MathF.Cos(MathHelper.DegreeToRadian(c)) * 50;

                node.SetVertexes(new[] {
                    new Vector2F(100 + cos, 100 - sin),
                    new Vector2F(100 - sin, 100 - cos),
                    new Vector2F(100 - cos, 100 + sin),
                    new Vector2F(100 + sin, 100 + cos),
                }, new Color(255, c % 255, 255, 255));
            }, null);

            tc.End();
        }
Esempio n. 10
0
        public void ListBox()
        {
            var tc = new TestCore(new Configuration {
                ToolEnabled = true
            });

            tc.Init();

            int current = 1;

            tc.LoopBody(c =>
            {
                if (Engine.Tool.Begin("Test", ToolWindow.None))
                {
                    List <string> items = new List <string>()
                    {
                        "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon"
                    };

                    Engine.Tool.ListBox("ListBox", ref current, items, 3);
                    Engine.Tool.Combo("Combo", ref current, items, 3);

                    Engine.Tool.End();
                }
            }
                        , null);

            tc.End();
        }
Esempio n. 11
0
        public void CircleCollider()
        {
            var tc = new TestCore();

            tc.Init();

            var collider1 = new CircleCollider
            {
                Position = new Vector2F(30f, 30f),
                Rotation = 10.0f,
                Radius   = 30.0f
            };

            const string path = "Serialization/CircleCollider.bin";

            Serialize(path, collider1);

            var collider2 = Deserialize <CircleCollider>(path);

            Assert.NotNull(collider2);

            Assert.AreEqual(collider1.Position, collider2.Position);
            Assert.AreEqual(collider1.Rotation, collider2.Rotation);
            Assert.AreEqual(collider1.Radius, collider2.Radius);

            tc.End();
        }
Esempio n. 12
0
        public void Pivot()
        {
            var tc = new TestCore();

            tc.Init();

            var font  = Font.LoadDynamicFont("../../Core/TestData/Font/mplus-1m-regular.ttf", 100);
            var font2 = Font.LoadDynamicFont("../../Core/TestData/Font/GenYoMinJP-Bold.ttf", 100);

            Assert.NotNull(font);

            var rotated = new TextNode()
            {
                Font = font, Text = "中心で回転します", Position = new Vector2F(300.0f, 300.0f), Pivot = new Vector2F(0.5f, 0.5f)
            };

            rotated.AdjustSize();
            Engine.AddNode(rotated);

            tc.LoopBody(c =>
            {
                rotated.Angle += 1.0f;
            }
                        , null);

            tc.End();
        }
Esempio n. 13
0
        public void RenderedSprite()
        {
            var tc = new TestCore();

            tc.Init();

            var texture = Altseed.Texture2D.LoadStrict(@"../../Core/TestData/IO/AltseedPink.png");

            Assert.NotNull(texture);

            var sprite1 = Altseed.RenderedSprite.Create();

            Assert.NotNull(sprite1);

            sprite1.Src     = new RectF(100, 100, 200, 200);
            sprite1.Texture = texture;

            const string path = "Serialization/RenderedSprite.bin";

            Serialize(path, sprite1);

            var sprite2 = Deserialize <RenderedSprite>(path);

            Assert.NotNull(sprite2);

            Assert.AreEqual(sprite1.Color, sprite2.Color);
            Assert.AreEqual(sprite1.Material, sprite2.Material);
            Assert.AreEqual(sprite1.Src, sprite2.Src);
            Assert.AreEqual((sprite1.Texture as Texture2D).Path, (sprite1.Texture as Texture2D).Path);
            Assert.AreEqual(sprite1.Texture.Size, sprite2.Texture.Size);
            Assert.AreEqual(sprite1.Transform, sprite2.Transform);

            tc.End();
        }
Esempio n. 14
0
        public void Joystick()
        {
            var tc = new TestCore();

            tc.Init();

            var font = Font.LoadDynamicFont("../../Core/TestData/Font/mplus-1m-regular.ttf", 100);

            Assert.NotNull(font);

            var node = new TextNode();

            node.Font = font;

            Engine.AddNode(node);

            Engine.Joystick.RefreshConnectedState();

            for (int i = 0; i < Engine.Joystick.MaxCount; i++)
            {
                if (!Engine.Joystick.IsPresent(i))
                {
                    continue;
                }

                var name = Engine.Joystick.GetJoystickName(i);
                tc.LoopBody(c =>
                {
                    var leftup = Engine.Joystick.GetButtonStateByType(i, JoystickButtonType.LeftUp);
                    node.Text  = $"{name}:LeftUp = {leftup}";
                }
                            , null);
            }
            tc.End();
        }
Esempio n. 15
0
        public void FloatArray()
        {
            var tc = new TestCore();

            tc.Init();

            var netArray1 = new float[] { 1, 2, 3, 4, 5 };

            var array1 = Altseed.FloatArray.Create(netArray1.Length);

            Assert.NotNull(array1);
            array1.FromArray(netArray1);

            const string path = "Serialization/FloatArray.bin";

            Serialize(path, array1);

            var array2 = Deserialize <FloatArray>(path);

            Assert.NotNull(array2);

            var netArray2 = array2.ToArray();

            Assert.AreEqual(netArray1.Length, netArray2.Length);
            Assert.True(Enumerable.SequenceEqual(netArray1, netArray2));

            tc.End();
        }
Esempio n. 16
0
        public void Vector2FArray()
        {
            var tc = new TestCore();

            tc.Init();

            var netArray1 = new Vector2F[]
            {
                new Vector2F(10, 10),
                new Vector2F(20, 20),
                new Vector2F(30, 30)
            };

            var array1 = Altseed.Vector2FArray.Create(netArray1.Length);

            Assert.NotNull(array1);
            array1.FromArray(netArray1);

            const string path = "Serialization/Vector2FArray.bin";

            Serialize(path, array1);

            var array2 = Deserialize <Vector2FArray>(path);

            Assert.NotNull(array2);

            var netArray2 = array2.ToArray();

            Assert.AreEqual(netArray1.Length, netArray2.Length);
            Assert.True(Enumerable.SequenceEqual(netArray1, netArray2));

            tc.End();
        }
Esempio n. 17
0
        public void Sound()
        {
            var tc = new TestCore();

            tc.Init();

            var sound1 = Altseed.Sound.LoadStrict(@"../../Core/TestData/Sound/se1.wav", true);

            Assert.NotNull(sound1);

            const string path = "Serialization/Sound.bin";

            Serialize(path, sound1);

            Assert.True(System.IO.File.Exists(path));

            var font2 = Deserialize <Altseed.Sound>(path);

            Assert.NotNull(font2);

            Assert.AreEqual(sound1.Path, font2.Path);
            Assert.AreEqual(sound1.IsDecompressed, font2.IsDecompressed);
            Assert.AreEqual(sound1.IsLoopingMode, font2.IsLoopingMode);
            Assert.AreEqual(sound1.Length, font2.Length);
            Assert.AreEqual(sound1.LoopEndPoint, font2.LoopEndPoint);
            Assert.AreEqual(sound1.LoopStartingPoint, font2.LoopStartingPoint);

            tc.End();
        }
Esempio n. 18
0
        public void RenderTexture()
        {
            var tc = new TestCore();

            tc.Init();

            var size     = new Vector2I(100, 100);
            var texture1 = Altseed.RenderTexture.Create(size);

            Assert.NotNull(texture1);

            const string path = "Serialization/RenderTexture.bin";

            Serialize(path, texture1);

            Assert.True(System.IO.File.Exists(path));

            var texture2 = Deserialize <RenderTexture>(path);

            Assert.NotNull(texture2);

            Assert.AreEqual(texture1.Size, texture2.Size);

            tc.End();
        }
Esempio n. 19
0
        public void GetPosition()
        {
            var tc = new TestCore();

            tc.Init();

            var bgm = Altseed.Sound.Load(@"../../Core/TestData/Sound/bgm1.ogg", false);

            Assert.NotNull(bgm);

            int bgm_id = Engine.Sound.Play(bgm);

            var font = Font.LoadDynamicFont("../../Core/TestData/Font/mplus-1m-regular.ttf", 100);

            Assert.NotNull(font);

            var textNode = new TextNode();

            textNode.Font = font;

            Engine.AddNode(textNode);

            tc.LoopBody(c =>
            {
                textNode.Text = $"{Engine.Sound.GetPlaybackPosition(bgm_id)}";
            }, null);

            Engine.Sound.StopAll();

            tc.End();
        }
Esempio n. 20
0
        public void StaticFont()
        {
            var tc = new TestCore();

            tc.Init();

            Assert.IsTrue(Font.GenerateFontFile("../../Core/TestData/Font/mplus-1m-regular.ttf", "test.a2f", 100, "Hello, world! こんにちは"));

            var font  = Font.LoadDynamicFont("../../Core/TestData/Font/mplus-1m-regular.ttf", 100);
            var font2 = Font.LoadStaticFont("test.a2f");

            Assert.NotNull(font);
            Assert.NotNull(font2);
            var imageFont = Font.CreateImageFont(font);

            imageFont.AddImageGlyph('〇', Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png"));

            Engine.AddNode(new TextNode()
            {
                Font = font, Text = "Hello, world! こんにちは"
            });
            Engine.AddNode(new TextNode()
            {
                Font = font2, Text = "Hello, world! こんにちは", Position = new Vector2F(0.0f, 100.0f), Color = new Color(0, 0, 255)
            });

            tc.LoopBody(c => { }, null);

            tc.End();
        }
Esempio n. 21
0
        public void RectangleCollider()
        {
            var tc = new TestCore();

            tc.Init();

            var collider1 = new RectangleCollider
            {
                CenterPosition = new Vector2F(15f, 15f),
                Position       = new Vector2F(30f, 30f),
                Rotation       = 10.0f,
                Size           = new Vector2F(20f, 20f)
            };

            const string path = "Serialization/RectangleCollider.bin";

            Serialize(path, collider1);

            var collider2 = Deserialize <RectangleCollider>(path);

            Assert.NotNull(collider2);

            Assert.AreEqual(collider1.CenterPosition, collider2.CenterPosition);
            Assert.AreEqual(collider1.Position, collider2.Position);
            Assert.AreEqual(collider1.Rotation, collider2.Rotation);
            Assert.AreEqual(collider1.Size, collider2.Size);

            tc.End();
        }
Esempio n. 22
0
        public void Base()
        {
            var tc = new TestCore();

            tc.Init();

            tc.LoopBody(null, null);

            tc.End();
        }
Esempio n. 23
0
        public void TextNode()
        {
            var tc = new TestCore();

            tc.Init();

            var font  = Font.LoadDynamicFont("../../Core/TestData/Font/mplus-1m-regular.ttf", 100);
            var font2 = Font.LoadDynamicFont("../../Core/TestData/Font/GenYoMinJP-Bold.ttf", 100);

            Assert.NotNull(font);
            Assert.NotNull(font2);
            var imageFont = Font.CreateImageFont(font);

            imageFont.AddImageGlyph('〇', Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png"));

            Engine.AddNode(new TextNode()
            {
                Font = font, Text = "Hello, world! こんにちは"
            });
            Engine.AddNode(new TextNode()
            {
                Font = font, Text = "色を指定します。", Position = new Vector2F(0.0f, 100.0f), Color = new Color(0, 0, 255)
            });
            Engine.AddNode(new TextNode()
            {
                Font = font, Text = "太さを指定します。", Position = new Vector2F(0.0f, 200.0f), Weight = 1.0f
            });
            Engine.AddNode(new TextNode()
            {
                Font = font, Text = "太さを指定します。", Position = new Vector2F(0.0f, 200.0f), Weight = 1.0f
            });
            Engine.AddNode(new TextNode()
            {
                Font = font2, Text = "𠀋 𡈽 𡌛 𡑮 𡢽 𠮟 𡚴 𡸴 𣇄 𣗄 𣜿 𣝣 𣳾", Position = new Vector2F(0.0f, 300.0f)
            });
            Engine.AddNode(new TextNode()
            {
                Font = imageFont, Text = "Altseed〇Altseed", Position = new Vector2F(0.0f, 500.0f)
            });
            var rotated = new TextNode()
            {
                Font = font, Text = "太さを指定します。", Position = new Vector2F(400.0f, 400.0f)
            };

            Engine.AddNode(rotated);

            tc.LoopBody(c =>
            {
                rotated.Angle += 1.0f;
            }
                        , null);

            tc.End();
        }
Esempio n. 24
0
        public void Input()
        {
            var tc = new TestCore(new Configuration {
                ToolEnabled = true
            });

            tc.Init();
            Engine.Tool.AddFontFromFileTTF("../../Core/TestData/Font/mplus-1m-regular.ttf", 20, ToolGlyphRanges.Japanese);
            string str0 = "";
            string str1 = "";
            string str2 = "";

            int[]   intArray   = new int[] { 0, 1, 2, 3, 4 };
            float[] floatArray = new float[] { 0, 1, 2, 3, 4 };
            tc.Duration = 10000;
            tc.LoopBody(c =>
            {
                if (Engine.Tool.Begin("Test", ToolWindow.None))
                {
                    var tmp = Engine.Tool.InputText("InputText", str0, 1024, ToolInputText.None);
                    if (tmp != null)
                    {
                        str0 = tmp;
                    }

                    tmp = Engine.Tool.InputTextMultiline("InputTextMultiline", str1, 1024, new Vector2F(), ToolInputText.None);
                    if (tmp != null)
                    {
                        str1 = tmp;
                    }

                    tmp = Engine.Tool.InputTextWithHint("InputTextWithHint", "hint", str2, 1024, ToolInputText.None);
                    if (tmp != null)
                    {
                        str2 = tmp;
                    }

                    Engine.Tool.InputInt2("InputInt2", intArray);
                    Engine.Tool.InputInt4("InputInt4", intArray);
                    Engine.Tool.InputFloat3("InputFloat3", floatArray);
                    Engine.Tool.InputFloat2("InputFloat2", floatArray);

                    Engine.Tool.SliderInt2("SliderInt2", intArray, 0.1f, 0, 100);
                    Engine.Tool.SliderInt4("SliderInt4", intArray, 0.1f, 0, 100);
                    Engine.Tool.SliderFloat3("SliderFloat3", floatArray, 0.1f, 0, 100);
                    Engine.Tool.SliderFloat2("SliderFloat2", floatArray, 0.1f, 0, 100);

                    Engine.Tool.End();
                }
            }
                        , null);

            tc.End();
        }
Esempio n. 25
0
        public void AutoCollisionSystem()
        {
            var tc = new TestCore()
            {
                Duration = int.MaxValue
            };

            tc.Init();

            var texture = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png");

            Assert.NotNull(texture);

            var scene   = new Altseed.Node();
            var manager = new CollisionManagerNode();

            scene.AddChildNode(manager);

            Engine.AddNode(scene);

            var player = new Player(texture);

            scene.AddChildNode(player);

            var comparison = new SpriteNode()
            {
                Texture  = texture,
                Position = new Vector2F(300f, 300f)
            };
            var colliderNode = new CircleColliderNode()
            {
                Radius   = texture.Size.X / 2,
                Position = comparison.Position
            };

            comparison.AddChildNode(colliderNode);

            scene.AddChildNode(comparison);

            tc.LoopBody(null, x =>
            {
                if (Engine.Keyboard.GetKeyState(Keys.Escape) == ButtonState.Push)
                {
                    tc.Duration = 0;
                }
                if (x == 10)
                {
                    Assert.True(manager.ContainsCollider(colliderNode));
                    Assert.AreEqual(manager.ColliderCount, 2);
                }
            });
            tc.End();
        }
Esempio n. 26
0
        public void OpenDialog()
        {
            var tc = new TestCore(new Configuration {
                ToolEnabled = true
            });

            tc.Init();

            Engine.Tool.OpenDialog("png;jpg,jpeg", "");

            tc.End();
        }
Esempio n. 27
0
        public void SpriteNode()
        {
            var tc = new TestCore();

            tc.Duration = 2000;
            tc.Init();

            var texture = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png");

            Assert.NotNull(texture);

            var node = new SpriteNode();

            //node.Src = new RectF(new Vector2F(100, 100), new Vector2F(200, 200));
            node.Texture = texture;
            node.AdjustSize();
            node.Position       = new Vector2F(200, 200);
            node.CenterPosition = texture.Size / 2;
            node.Scale          = new Vector2F(0.2f, 0.2f);
            Engine.AddNode(node);

            var col = new CircleCollider();

            col.Radius   = 200 * 0.2f;
            col.Position = node.Position;

            var node2 = new SpriteNode();

            //node.Src = new RectF(new Vector2F(100, 100), new Vector2F(200, 200));
            node2.Texture = texture;
            node2.AdjustSize();
            node2.Position       = new Vector2F(200, 200);
            node2.CenterPosition = texture.Size / 2;
            node2.Scale          = new Vector2F(0.2f, 0.2f);
            Engine.AddNode(node2);
            var col2 = new CircleCollider();

            col2.Radius   = 200 * 0.2f;
            col2.Position = node.Position;

            tc.LoopBody(c =>
            {
                node2.Position = col2.Position = Engine.Mouse.Position;
                if (col.GetIsCollidedWith(col2))
                {
                    node2.Angle++;
                }
            }
                        , null);

            tc.End();
        }
Esempio n. 28
0
        public void FullScreen()
        {
            var tc = new TestCore(new Configuration()
            {
                IsFullscreen = true
            });

            tc.Init();

            tc.LoopBody(null, null);

            tc.End();
        }
Esempio n. 29
0
        public void Texture2D()
        {
            var tc = new TestCore()
            {
                Duration = int.MaxValue
            };

            tc.Init();

            var texture1 = Altseed.Texture2D.LoadStrict(@"../../Core/TestData/IO/AltseedPink.png");

            Assert.NotNull(texture1);

            const string path = "Serialization/Texture2D.bin";

            Serialize(path, texture1);

            Assert.True(System.IO.File.Exists(path));

            var texture2 = Deserialize <Texture2D>(path);

            Assert.NotNull(texture2);

            Assert.AreEqual(texture1.Size, texture2.Size);
            Assert.AreEqual(texture1.Path, texture2.Path);

            var obj1 = new SpriteNode()
            {
                Position = new Vector2F(100, 100),
                Texture  = texture1
            };
            var obj2 = new SpriteNode()
            {
                Position = new Vector2F(100, 500),
                Texture  = texture2
            };

            Engine.AddNode(obj1);
            Engine.AddNode(obj2);

            tc.LoopBody(null, c =>
            {
                if (Engine.Keyboard.GetKeyState(Keys.Escape) == ButtonState.Push)
                {
                    tc.Duration = 0;
                }
            });

            tc.End();
        }
Esempio n. 30
0
        public void Color()
        {
            var tc = new TestCore(new Configuration {
                ToolEnabled = true
            });

            tc.Init();

            var texture = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png");

            Assert.NotNull(texture);

            var node = new SpriteNode();

            node.Src     = new RectF(new Vector2F(100, 100), new Vector2F(200, 200));
            node.Texture = texture;
            node.AdjustSize();
            node.CenterPosition = texture.Size / 2;
            Engine.AddNode(node);

            var font = Font.LoadDynamicFont("../../Core/TestData/Font/mplus-1m-regular.ttf", 100);
            var text = new TextNode()
            {
                Font = font, Text = "色テスト", Position = new Vector2F(0.0f, 0.0f)
            };

            Engine.AddNode(text);

            Color col1 = new Color(10, 20, 50, 100);
            Color col2 = new Color(10, 20, 50, 100);

            tc.LoopBody(c =>
            {
                if (Engine.Tool.Begin("Test", ToolWindow.None))
                {
                    Engine.Tool.ColorEdit3("Color1", ref col1, ToolColorEdit.None);  // RGB
                    Engine.Tool.ColorEdit4("Color2", ref col2, ToolColorEdit.None);  // RGBAのアルファ付き

                    var flag = ToolColorEdit.Float | ToolColorEdit.NoInputs | ToolColorEdit.NoLabel;

                    Engine.Tool.ColorEdit3("Color ID", ref col1, flag);
                    Engine.Tool.End();
                }

                text.Color = col1;
            }
                        , null);

            tc.End();
        }