//helper methods private static void RenderGrid(CDrawer canvas, Color[,] colAr) { canvas.Clear(); for (int iR = 0; iR < canvas.ScaledHeight; iR++) for (int iC = 0; iC < canvas.ScaledWidth; iC++) canvas.SetBBScaledPixel(iC, iR, colAr[iR, iC]); for (int i = 0; i < canvas.ScaledWidth; i++) canvas.AddLine(i, 0, i, canvas.ScaledWidth, Color.Black, 1); for (int i = 0; i < canvas.ScaledHeight; i++) canvas.AddLine(0, i, canvas.ScaledWidth, i, Color.Black, 1); canvas.Render(); }
// DrawCannon(screen, x, y, angle(degrees), color, color) - Draws sprite with top left position (x,y) on screen // with specified colors and changes given the angle. private static void DrawCannon(CDrawer screen, int topLeftX, int topLeftY, int barrelAngle, Color wheel, Color barrel) { // Bulletproofing wheel center to be inside screen if (!(topLeftX + 10 >= 0 && topLeftX + 10 < screen.m_ciWidth) || !(topLeftY + 10 >= 0 && topLeftY - 10 < screen.m_ciHeight)) return; // Drawing wheel, clearing inside of wheel, and drawing cannon barrel // Note that the barrelAngle is relative to straight up = 0 degrees; positive x axis = 90 degrees; screen.AddCenteredEllipse(topLeftX + 10, topLeftY + 10, 20, 20, wheel); screen.AddCenteredEllipse(topLeftX + 10, topLeftY + 10, 18, 18, Color.Black); screen.AddLine(topLeftX + 10, topLeftY + 10, 20, barrelAngle * Math.PI / 180, barrel, 10); }
static void SLines() { CDrawer can = new CDrawer(800, 600, false); can.AddLine(10, 10, 790, 590, Color.Red, 2); for (double d = 0; d < Math.PI * 2; d += Math.PI / 32) can.AddLine(new Point (400, 300), 50 * d, d); for (int x = 0; x < 600; x += 5) { can.AddLine(0, 600 - x, x, 0, RandColor.GetColor(), 1); } can.Render(); Console.ReadKey(); }
public void Render(CDrawer dr) { if(parent!=null)dr.AddLine(position.X, position.Y, parent.position.X, parent.position.Y, Color.White); vRender(dr); }
static void Lines() { CDrawer can = new CDrawer(800, 600, false); can.Scale = 10; for (int i = -10; i < can.ScaledWidth + 1; i += 5) { for (int j = -10; j < can.ScaledHeight + 1; j += 5) { can.AddLine(i, j, can.ScaledWidth + 1 - i, can.ScaledHeight + 1 - j, RandColor.GetKnownColor(), 1); } } can.AddText("check...check.. ", 48); can.AddText("one two three", 12, -10, -10, 100, 50, Color.White); can.Render(); Console.ReadKey(); }