public Image drawChart(List<Polar> pValues, Polar max, Polar min, int type) { // Setup Graphics Image image = new Bitmap((int)(DIAGRAMWIDTH * 1.4), (int)(DIAGRAMHEIGHT * 1.4)); // compute scale xScale = (float)((DIAGRAMWIDTH - XBORDER) / 90.0); top = NextHigher.get(max.r); bot = 0; if (min.r < 0) { bot = - NextHigher.get(-min.r); } yScale = (DIAGRAMHEIGHT - YTOPBORDER - YBOTBORDER) / (top + Math.Abs(bot)); Graphics graphics = Graphics.FromImage(image); graphics.PageUnit = GraphicsUnit.Point; g = new GGraphics(graphics, 1, 0, 0); drawBakground(type); foreach (Polar p in pValues) { float x = transposeX(p.aDeg); float y = transposeY(p.r); g.drawPointAbsolute(pointBrush, x, y); } return image; }
private void setup(bool zoomed) { CompGeometry cg = new CompGeometry(); F = Data.dFlankRadius; // flank radius B = Data.dBaseRadius; // base radius L = Data.dLift; // lift N = Data.dNoseRadius; // nose radius if (zoomed) { unitsPerInch = 72; diagramSize = 10f * unitsPerInch; image = new Bitmap(962, 962); } else { unitsPerInch = 72; diagramSize = 4f * unitsPerInch; //image = new Bitmap(480, 480); image = new Bitmap(385, 385); } // Compute diagram height float camHeight = (float)(2 * (B + L)); float camRoundedHeight = NextHigher.get(camHeight * 1.1); float scale = diagramSize / camRoundedHeight; gridSize = diagramSize / 10 / scale; // OriginX/Y is centre of base circle float originX = gridSize * 5; // Number grid squares to accomodate base radius float baseSquares = (float)(Math.Ceiling(B / gridSize)); float originY = gridSize * 5; // (float)((10 - baseSquares) * gridSize); Graphics graphics = Graphics.FromImage(image); graphics.PageUnit = GraphicsUnit.Point; g = new GGraphics(graphics, scale, originX, originY); }