public static Bitmap PrintCar(Bitmap bitmap, Section section, int x, int y, int compass) { if (Data.CurrentRace != null) { Graphics g = Graphics.FromImage(bitmap); SectionData sd = Data.CurrentRace.GetSectionData(section); int xLeft, yLeft, xRight, yRight; xLeft = yLeft = xRight = yRight = 0; DeterminePos(ref xLeft, ref yLeft, ref xRight, ref yRight, compass); if (sd.Left != null) { string leftColour = GetTeamColour(sd.Left.TeamColor, sd.Left.Equipment.IsBroken); Bitmap leftCar = new Bitmap(ImageCache.GetImgBitmap(leftColour)); g.DrawImage(RotateAsset(leftCar, compass, "straight"), new Point(x * trackSizePx + xLeft, y * trackSizePx + yLeft)); } if (sd.Right != null) { string rightColour = GetTeamColour(sd.Right.TeamColor, sd.Right.Equipment.IsBroken); Bitmap rightCar = new Bitmap(ImageCache.GetImgBitmap(rightColour)); g.DrawImage(RotateAsset(rightCar, compass, "straight"), new Point(x * trackSizePx + xRight, y * trackSizePx + yRight)); } return(bitmap); } else { return(null); } }
public static Bitmap PutTrack(Bitmap bitmap, Track track) { int currentX, currentY; currentX = -minX; currentY = -minY; int compass = 1; Graphics g = Graphics.FromImage(bitmap); foreach (Section section in track.Sections) { switch (section.SectionType) { case SectionTypes.StartGrid: Bitmap startGrid = new Bitmap(ImageCache.GetImgBitmap(_start)); g.DrawImage(RotateAsset(startGrid, compass, "straight"), new Point(currentX * trackSizePx, currentY * trackSizePx)); break; case SectionTypes.Finish: Bitmap finish = new Bitmap(ImageCache.GetImgBitmap(_finish)); g.DrawImage(RotateAsset(finish, compass, "straight"), new Point(currentX * trackSizePx, currentY * trackSizePx)); break; case SectionTypes.LeftCorner: Bitmap leftCorner = new Bitmap(ImageCache.GetImgBitmap(_corner)); g.DrawImage(RotateAsset(leftCorner, compass, "leftCorner"), new Point(currentX * trackSizePx, currentY * trackSizePx)); compass = (compass < 1) ? 3 : compass -= 1; break; case SectionTypes.RightCorner: Bitmap rightCorner = new Bitmap(ImageCache.GetImgBitmap(_corner)); g.DrawImage(RotateAsset(rightCorner, compass, "rightCorner"), new Point(currentX * trackSizePx, currentY * trackSizePx)); compass = (compass > 2) ? 0 : compass += 1; break; case SectionTypes.Straight: Bitmap straight = new Bitmap(ImageCache.GetImgBitmap(_straight)); g.DrawImage(RotateAsset(straight, compass, "straight"), new Point(currentX * trackSizePx, currentY * trackSizePx)); break; default: throw new ArgumentOutOfRangeException(); } switch (compass) { case 0: currentY--; break; case 1: currentX++; break; case 2: currentY++; break; case 3: currentX--; break; } } return(bitmap); }