Example #1
0
            public static RiderVertex NoTexture(Vector2 position, int color)
            {
                RiderVertex ret = new RiderVertex();

                ret.color        = color;
                ret.Position     = (Vector2)position;
                ret.texture_unit = (float)Tex.None;
                return(ret);
            }
Example #2
0
        private void DrawTexture(
            Tex tex,
            DoubleRect rect,
            FloatRect uv,
            Vector2d origin,
            Vector2d rotationAnchor,
            float opacity,
            bool pretty = false
            )
        {
            var angle     = Angle.FromLine(origin, rotationAnchor);
            var t         = Utility.RotateRect(rect, Vector2d.Zero, angle);
            var transform = new Vector2d[] {
                (t[0] + origin), // 0 tl
                (t[1] + origin), // 1 tr
                (t[2] + origin), // 2 br
                (t[3] + origin), // 3 bl
            };
            var texrect = GameDrawingMatrix.ScreenCoords(transform);
            var color   = Color.FromArgb((int)(255f * opacity), Color.White);

            Color[] colors = new Color[] { color, color, color, color };
            if (pretty)
            {
                var random = new Random((Environment.TickCount / 100) % 255);
                for (int i = 0; i < colors.Length; i++)
                {
                    bool redness  = random.Next() % 2 == 0;
                    bool blueness = random.Next() % 2 == 0;
                    var  random1  = Math.Max(200, random.Next() % 255);
                    int  red      = Math.Min(255, redness ? (random1 * 2) : (random1 / 2));
                    int  green    = Math.Min(255, (blueness && redness) ? (random1) : (random1 / 2));
                    int  blue     = Math.Min(255, blueness ? (random1 * 2) : (random1 / 2));

                    colors[i] = Color.FromArgb((int)(255f * opacity), red, green, blue);
                }
            }
            var u1    = uv.Left;
            var v1    = uv.Top;
            var u2    = uv.Right;
            var v2    = uv.Bottom;
            var verts = new RiderVertex[] {
                new RiderVertex(texrect[0], new Vector2(uv.Left, uv.Top), tex, colors[0]),
                new RiderVertex(texrect[1], new Vector2(uv.Right, uv.Top), tex, colors[1]),
                new RiderVertex(texrect[2], new Vector2(uv.Right, uv.Bottom), tex, colors[2]),
                new RiderVertex(texrect[3], new Vector2(uv.Left, uv.Bottom), tex, colors[3])
            };

            Array.Add(verts[0]);
            Array.Add(verts[1]);
            Array.Add(verts[2]);

            Array.Add(verts[3]);
            Array.Add(verts[2]);
            Array.Add(verts[0]);
        }
Example #3
0
        private void DrawScarf(Line[] lines, float opacity)
        {
            if (scarfColors.Count == 0)
            {
                scarfColors.Add(0xffffff);
            }
            if (scarfOpacity.Count == 0)
            {
                scarfOpacity.Add((byte)0xff);
            }

            var c         = Utility.ColorToRGBA_LE(0xD10101, (byte)(255 * opacity)); //Scarf color
            var alt       = Utility.ColorToRGBA_LE(0xff6464, (byte)(255 * opacity)); //Scarf color
            var scarfPart = 0;

            List <Vector2> altvectors = new List <Vector2>();

            for (int i = 0; i < lines.Length; i += 2)
            {
                scarfPart = (((i % scarfColors.Count) + (scarfColors.Count - 1)) % scarfColors.Count);
                c         = Utility.ColorToRGBA_LE(scarfColors[scarfPart], (byte)(scarfOpacity[scarfPart] * opacity));

                var verts = DrawLine(lines[i].Position, lines[i].Position2, c, 2);

                if (i != 0)
                {
                    altvectors.Add(verts[0]);
                    altvectors.Add(verts[1]);
                }
                altvectors.Add(verts[2]);
                altvectors.Add(verts[3]);
            }
            for (int i = 0; i < altvectors.Count - 4; i += 4)
            {
                scarfPart = (i / 2 % scarfColors.Count);
                alt       = Utility.ColorToRGBA_LE(scarfColors[scarfPart], (byte)(scarfOpacity[scarfPart] * opacity));
                var verts = new RiderVertex[] {
                    RiderVertex.NoTexture(altvectors[i + 0], alt),
                    RiderVertex.NoTexture(altvectors[i + 1], alt),
                    RiderVertex.NoTexture(altvectors[i + 2], alt),
                    RiderVertex.NoTexture(altvectors[i + 3], alt)
                };
                Array.Add(verts[0]);
                Array.Add(verts[1]);
                Array.Add(verts[2]);

                Array.Add(verts[3]);
                Array.Add(verts[2]);
                Array.Add(verts[0]);
            }
        }
Example #4
0
        private void DrawScarf(Line[] lines, float opacity)
        {
            int scarfPart;
            int currentColor;

            if (scarfColorList == null || scarfColorList.Count == 0) //If for some reason this is empty use the default LRL colors
            {
                scarfColorList = new List <Color>();
                scarfColorList.Add(Color.FromArgb((int)(255 * opacity), Color.FromArgb(0x94fbab)));
                scarfColorList.Add(Color.FromArgb((int)(127 * opacity), Color.FromArgb(0xbcfbdf)));
            }

            List <Vector2> altvectors = new List <Vector2>();

            for (int i = 0; i < lines.Length; i += 2)
            {
                scarfPart    = (i % scarfColorList.Count);
                currentColor = Utility.ColorToRGBA_LE(Color.FromArgb((int)(scarfColorList[scarfPart].A * opacity), scarfColorList[scarfPart]));
                var verts = DrawLine(lines[i].Position, lines[i].Position2, currentColor, 2);

                if (i != 0)
                {
                    altvectors.Add(verts[0]);
                    altvectors.Add(verts[1]);
                }
                altvectors.Add(verts[2]);
                altvectors.Add(verts[3]);
            }
            for (int i = 0; i < altvectors.Count - 4; i += 4)
            {
                scarfPart    = (((i + 2) / 2) % scarfColorList.Count);
                currentColor = Utility.ColorToRGBA_LE(Color.FromArgb((int)(scarfColorList[scarfPart].A * opacity), scarfColorList[scarfPart]));

                var verts = new RiderVertex[] {
                    RiderVertex.NoTexture(altvectors[i + 0], currentColor),
                    RiderVertex.NoTexture(altvectors[i + 1], currentColor),
                    RiderVertex.NoTexture(altvectors[i + 2], currentColor),
                    RiderVertex.NoTexture(altvectors[i + 3], currentColor)
                };
                Array.Add(verts[0]);
                Array.Add(verts[1]);
                Array.Add(verts[2]);

                Array.Add(verts[3]);
                Array.Add(verts[2]);
                Array.Add(verts[0]);
            }
        }
        private Vector2[] DrawLine(Vector2d p1, Vector2d p2, int color, float size)
        {
            var calc = Utility.GetThickLine(p1, p2, Angle.FromLine(p1, p2), size);
            var t = GameDrawingMatrix.ScreenCoords(calc);
            var verts = new RiderVertex[] {
                RiderVertex.NoTexture(t[0],color),
                RiderVertex.NoTexture(t[1],color),
                RiderVertex.NoTexture(t[2],color),
                RiderVertex.NoTexture(t[3],color)
            };
            Array.Add(verts[0]);
            Array.Add(verts[1]);
            Array.Add(verts[2]);

            Array.Add(verts[3]);
            Array.Add(verts[2]);
            Array.Add(verts[0]);
            return t;
        }