728x90
반응형
728x170
▶ MainForm.cs
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Windows.Forms;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : Form
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
ResizeRedraw = true;
#region 이벤트를 설정한다.
Paint += Form_Paint;
#endregion
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
//////////////////////////////////////////////////////////////////////////////// Event
#region 폼 페인트시 처리하기 - Form_Paint(sender, e)
/// <summary>
/// 폼 페인트시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void Form_Paint(object sender, PaintEventArgs e)
{
string text = "TEST";
int count = 150;
e.Graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
e.Graphics.Clear(this.BackColor);
using(Font font = new Font("Times New Roman", 150, FontStyle.Bold, GraphicsUnit.Pixel))
{
using(GraphicsPath graphicsPath = new GraphicsPath())
{
using(StringFormat stringFormat = new StringFormat())
{
stringFormat.Alignment = StringAlignment.Center;
stringFormat.LineAlignment = StringAlignment.Center;
int width = ClientSize.Width / 2;
int height = ClientSize.Height / 2;
graphicsPath.AddString
(
text,
font.FontFamily,
(int)font.Style,
font.Size,
new Point(width, height),
stringFormat
);
}
using(Region region = new Region(graphicsPath))
{
e.Graphics.Clip = region;
Random rand = new Random();
int x0;
int y0;
int x1;
int y1;
x0 = 0;
x1 = ClientSize.Width;
for(int i = 1; i < count; i++)
{
y0 = rand.Next(0, ClientSize.Height);
y1 = rand.Next(0, ClientSize.Height);
e.Graphics.DrawLine(Pens.Black, x0, y0, x1, y1);
}
y0 = 0;
y1 = ClientSize.Height;
for(int i = 1; i < count; i++)
{
x0 = rand.Next(0, ClientSize.Width);
x1 = rand.Next(0, ClientSize.Width);
e.Graphics.DrawLine(Pens.Black, x0, y0, x1, y1);
}
e.Graphics.ResetClip();
}
}
}
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > WinForm' 카테고리의 다른 글
[C#/WINFORM] PathGradientBrush 클래스 사용하기 (0) | 2018.12.09 |
---|---|
[C#/WINFORM] 비교차 스타 그리기 (0) | 2018.12.09 |
[C#/WINFORM] GroupBox 클래스 : 체크 그룹 박스 사용하기 (0) | 2018.12.09 |
[C#/WINFORM] ToolStripButton 클래스 : 라디오 버튼 사용하기 (0) | 2018.12.09 |
[C#/WINFORM] ListView 클래스 : 그룹 사용하기 (0) | 2018.12.08 |
[C#/WINFORM] 외곽선 텍스트 그리기 (0) | 2018.12.08 |
[C#/WINFORM] 부드러운 소용돌이 프랙탈(Smooth Vortex Fractal) 그리기 (0) | 2018.12.08 |
[C#/WINFORM] 소용돌이 프랙탈(Vortex Fractal) 그리기 (0) | 2018.12.08 |
[C#/WINFORM] 소용돌이 모양 프랙탈(Curlicue Fractal) 그리기 (0) | 2018.12.08 |
[C#/WINFORM] 폰트 메트릭(Font Metrics) 구하기 (0) | 2018.12.08 |
댓글을 달아 주세요