private void BuildCurvesPage( Document document ) { // 1. Add the page to the document! Page page = new Page(document); // Instantiates the page inside the document context. document.Pages.Add(page); // Puts the page in the pages collection. SizeF pageSize = page.Size; // 2. Create a content composer for the page! PrimitiveComposer composer = new PrimitiveComposer(page); // 3. Drawing the page contents... composer.SetFont( new fonts::StandardType1Font( document, fonts::StandardType1Font.FamilyEnum.Courier, true, false ), 32 ); { BlockComposer blockComposer = new BlockComposer(composer); blockComposer.Begin(new RectangleF(30, 0, pageSize.Width - 60, 50), XAlignmentEnum.Center, YAlignmentEnum.Middle); blockComposer.ShowText("Curves"); blockComposer.End(); } // 3.1. Arcs. { float y = 100; for ( int rowIndex = 0; rowIndex < 4; rowIndex++ ) { int angleStep = 45; int startAngle = 0; int endAngle = angleStep; float x = 100; float diameterX; float diameterY; switch (rowIndex) { case 0: default: diameterX = 40; diameterY = 40; break; case 1: diameterX = 40; diameterY = 20; break; case 2: diameterX = 20; diameterY = 40; break; case 3: diameterX = 40; diameterY = 40; break; } for ( int index = 0, length = 360 / angleStep; index < length; index++ ) { RectangleF arcFrame = new RectangleF((float)x, (float)y, (float)diameterX, (float)diameterY); // Drawing the arc frame... composer.BeginLocalState(); composer.SetLineWidth(0.25f); composer.SetLineDash(new LineDash(new double[] { 5, 5 }, 3)); composer.DrawRectangle(arcFrame); composer.Stroke(); composer.End(); // Draw the arc! composer.DrawArc(arcFrame, startAngle, endAngle); composer.Stroke(); endAngle += angleStep; switch (rowIndex) { case 3: startAngle += angleStep; break; } x += 50; } y += diameterY + 10; } } // 3.2. Circle. { RectangleF arcFrame = new RectangleF(100, 300, 100, 100); // Drawing the circle frame... composer.BeginLocalState(); composer.SetLineWidth(0.25f); composer.SetLineDash(new LineDash(new double[] { 5, 5 }, 3)); composer.DrawRectangle(arcFrame); composer.Stroke(); composer.End(); // Drawing the circle... composer.SetFillColor(DeviceRGBColor.Get(System.Drawing.Color.Red)); composer.DrawEllipse(arcFrame); composer.FillStroke(); } // 3.3. Horizontal ellipse. { RectangleF arcFrame = new RectangleF(210, 300, 100, 50); // Drawing the ellipse frame... composer.BeginLocalState(); composer.SetLineWidth(0.25f); composer.SetLineDash(new LineDash(new double[] { 5, 5 }, 3)); composer.DrawRectangle(arcFrame); composer.Stroke(); composer.End(); // Drawing the ellipse... composer.SetFillColor(DeviceRGBColor.Get(System.Drawing.Color.Green)); composer.DrawEllipse(arcFrame); composer.FillStroke(); } // 3.4. Vertical ellipse. { RectangleF arcFrame = new RectangleF(320, 300, 50, 100); // Drawing the ellipse frame... composer.BeginLocalState(); composer.SetLineWidth(0.25f); composer.SetLineDash(new LineDash(new double[] { 5, 5 }, 3)); composer.DrawRectangle(arcFrame); composer.Stroke(); composer.End(); // Drawing the ellipse... composer.SetFillColor(DeviceRGBColor.Get(System.Drawing.Color.Blue)); composer.DrawEllipse(arcFrame); composer.FillStroke(); } // 3.5. Spirals. { float y = 500; float spiralWidth = 100; composer.SetLineWidth(.5f); for ( int rowIndex = 0; rowIndex < 3; rowIndex++ ) { float x = 150; float branchWidth = .5f; float branchRatio = 1; for ( int spiralIndex = 0; spiralIndex < 4; spiralIndex++ ) { float spiralTurnsCount; switch (rowIndex) { case 0: default: spiralTurnsCount = spiralWidth / (branchWidth * 8); break; case 1: spiralTurnsCount = (float)(spiralWidth / (branchWidth * 8 * (spiralIndex * 1.15 + 1))); break; } switch (rowIndex) { case 2: composer.SetLineDash(new LineDash(new double[] { 10, 5 })); composer.SetLineCap(LineCapEnum.Round); break; default: break; } composer.DrawSpiral( new PointF((float)x, (float)y), 0, 360 * spiralTurnsCount, branchWidth, branchRatio ); composer.Stroke(); x += spiralWidth + 10; switch (rowIndex) { case 0: default: branchWidth += 1; break; case 1: branchRatio += .035f; break; } switch (rowIndex) { case 2: composer.SetLineWidth(composer.State.LineWidth + .5f); break; } } y += spiralWidth + 10; } } // 4. Flush the contents into the page! composer.Flush(); }
private void BuildCurvesPage( Document document ) { // 1. Add the page to the document! Page page = new Page(document); // Instantiates the page inside the document context. document.Pages.Add(page); // Puts the page in the pages collection. SizeF pageSize = page.Size; // 2. Create a content composer for the page! PrimitiveComposer composer = new PrimitiveComposer(page); // 3. Drawing the page contents... composer.SetFont( new fonts::StandardType1Font( document, fonts::StandardType1Font.FamilyEnum.Courier, true, false ), 32 ); { BlockComposer blockComposer = new BlockComposer(composer); blockComposer.Begin(new RectangleF(30,0,pageSize.Width-60,50),XAlignmentEnum.Center,YAlignmentEnum.Middle); blockComposer.ShowText("Curves"); blockComposer.End(); } // 3.1. Arcs. { float y = 100; for( int rowIndex = 0; rowIndex < 4; rowIndex++ ) { int angleStep = 45; int startAngle = 0; int endAngle = angleStep; float x = 100; float diameterX; float diameterY; switch(rowIndex) { case 0: default: diameterX = 40; diameterY = 40; break; case 1: diameterX = 40; diameterY = 20; break; case 2: diameterX = 20; diameterY = 40; break; case 3: diameterX = 40; diameterY = 40; break; } for( int index = 0, length = 360/angleStep; index < length; index++ ) { RectangleF arcFrame = new RectangleF((float)x,(float)y,(float)diameterX,(float)diameterY); // Drawing the arc frame... composer.BeginLocalState(); composer.SetLineWidth(0.25f); composer.SetLineDash(new LineDash(new double[]{5,5}, 3)); composer.DrawRectangle(arcFrame); composer.Stroke(); composer.End(); // Draw the arc! composer.DrawArc(arcFrame,startAngle,endAngle); composer.Stroke(); endAngle += angleStep; switch(rowIndex) { case 3: startAngle += angleStep; break; } x += 50; } y += diameterY + 10; } } // 3.2. Circle. { RectangleF arcFrame = new RectangleF(100, 300, 100, 100); // Drawing the circle frame... composer.BeginLocalState(); composer.SetLineWidth(0.25f); composer.SetLineDash(new LineDash(new double[]{5,5}, 3)); composer.DrawRectangle(arcFrame); composer.Stroke(); composer.End(); // Drawing the circle... composer.SetFillColor(DeviceRGBColor.Get(System.Drawing.Color.Red)); composer.DrawEllipse(arcFrame); composer.FillStroke(); } // 3.3. Horizontal ellipse. { RectangleF arcFrame = new RectangleF(210, 300, 100, 50); // Drawing the ellipse frame... composer.BeginLocalState(); composer.SetLineWidth(0.25f); composer.SetLineDash(new LineDash(new double[]{5,5}, 3)); composer.DrawRectangle(arcFrame); composer.Stroke(); composer.End(); // Drawing the ellipse... composer.SetFillColor(DeviceRGBColor.Get(System.Drawing.Color.Green)); composer.DrawEllipse(arcFrame); composer.FillStroke(); } // 3.4. Vertical ellipse. { RectangleF arcFrame = new RectangleF(320, 300, 50, 100); // Drawing the ellipse frame... composer.BeginLocalState(); composer.SetLineWidth(0.25f); composer.SetLineDash(new LineDash(new double[]{5,5}, 3)); composer.DrawRectangle(arcFrame); composer.Stroke(); composer.End(); // Drawing the ellipse... composer.SetFillColor(DeviceRGBColor.Get(System.Drawing.Color.Blue)); composer.DrawEllipse(arcFrame); composer.FillStroke(); } // 3.5. Spirals. { float y = 500; float spiralWidth = 100; composer.SetLineWidth(.5f); for( int rowIndex = 0; rowIndex < 3; rowIndex++ ) { float x = 150; float branchWidth = .5f; float branchRatio = 1; for( int spiralIndex = 0; spiralIndex < 4; spiralIndex++ ) { float spiralTurnsCount; switch(rowIndex) { case 0: default: spiralTurnsCount = spiralWidth/(branchWidth*8); break; case 1: spiralTurnsCount = (float)(spiralWidth/(branchWidth*8*(spiralIndex*1.15+1))); break; } switch(rowIndex) { case 2: composer.SetLineDash(new LineDash(new double[]{10,5})); composer.SetLineCap(LineCapEnum.Round); break; default: break; } composer.DrawSpiral( new PointF((float)x,(float)y), 0, 360*spiralTurnsCount, branchWidth, branchRatio ); composer.Stroke(); x += spiralWidth + 10; switch(rowIndex) { case 0: default: branchWidth += 1; break; case 1: branchRatio += .035f; break; } switch(rowIndex) { case 2: composer.SetLineWidth(composer.State.LineWidth+.5f); break; } } y += spiralWidth + 10; } } // 4. Flush the contents into the page! composer.Flush(); }