Transform and RotateTransform in a loop

image_pdfimage_print

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

public class Form1 : Form {

protected override void OnPaint(PaintEventArgs e) {
Graphics g = e.Graphics;
g.FillRectangle(Brushes.White, this.ClientRectangle);
Font f = new Font(“Times New Roman”, 16);
for (float angle = 0; angle < 360; angle += 45) { g.ResetTransform(); g.TranslateTransform(ClientRectangle.Width / 2, ClientRectangle.Height / 2); g.RotateTransform(angle); g.DrawString("Hello, World", f, Brushes.Black, 50, 0); } } public static void Main() { Application.Run(new Form1()); } } [/csharp]

This entry was posted in 2D Graphics. Bookmark the permalink.