예제 #1
0
    internal static void ImageRotated(IntPtr texId, Vector2 center, Vector2 size, float angle, Vector2 uv, Vector2 uv1, ImDrawListPtr drawList)
    {
        var cosA = MathF.Cos(angle);
        var sinA = MathF.Sin(angle);

        drawList.AddImageQuad(
            texId,
            center + Util.Rotate(new Vector2(-size.X * 0.5f, -size.Y * 0.5f), cosA, sinA),
            center + Util.Rotate(new Vector2(+size.X * 0.5f, -size.Y * 0.5f), cosA, sinA),
            center + Util.Rotate(new Vector2(+size.X * 0.5f, +size.Y * 0.5f), cosA, sinA),
            center + Util.Rotate(new Vector2(-size.X * 0.5f, +size.Y * 0.5f), cosA, sinA),
            new Vector2(uv.X, uv.Y),
            new Vector2(uv1.X, uv.Y),
            new Vector2(uv1.X, uv1.Y),
            new Vector2(uv.X, uv1.Y)
            );
    }
예제 #2
0
        public static void ImageRotated(ImDrawListPtr d, IntPtr tex_id, Vector2 position, Vector2 size, float angle, uint col = UInt32.MaxValue)
        {
            float cos_a = (float)Math.Cos(angle);
            float sin_a = (float)Math.Sin(angle);

            Vector2[] pos =
            {
                position + ImRotate(new Vector2(-size.X * 0.5f, -size.Y * 0.5f), cos_a, sin_a),
                position + ImRotate(new Vector2(+size.X * 0.5f, -size.Y * 0.5f), cos_a, sin_a),
                position + ImRotate(new Vector2(+size.X * 0.5f, +size.Y * 0.5f), cos_a, sin_a),
                position + ImRotate(new Vector2(-size.X * 0.5f, +size.Y * 0.5f), cos_a, sin_a)
            };
            Vector2[] uvs =
            {
                new Vector2(0.0f, 0.0f),
                new Vector2(1.0f, 0.0f),
                new Vector2(1.0f, 1.0f),
                new Vector2(0.0f, 1.0f)
            };

            d.AddImageQuad(tex_id, pos[0], pos[1], pos[2], pos[3], uvs[0], uvs[1], uvs[2], uvs[3], col);
        }