728x90
반응형
Color 구조체
- 구조체 정의
Color Struct
Represents an ARGB (alpha, red, green, blue) color.
public struct Color
Inheritance Object → ValueType → Color
- 사용 용도
펜, 브러시의 색상 설정에 사용
- Color 속성 사용하여 색상 설정
AliceBlue, AntiqueWhite, Aqua 등... 속성을 통한 색상 설정, Color 리턴
public static System.Drawing.Color Aqua { get; }
Returns
Color
A color representing a system-defined color.
- 사용자 정의할 수 있는 색상
FromArgb()
FromArgb (int alpha, int red, int green, int blue);
Overloads
FromArgb(Int32, Int32, Int32, Int32)
FromArgb(Int32, Int32, Int32)
FromArgb(Int32)
FromArgb(Int32, Color)
- 시스템 색상에서 A, R, G, B 가져오기
→ Color.색상.A, Color.색상.R, Color.색상.G, Color.색상.B
public byte A { get; }
public byte R { get; }
public byte G { get; }
public byte B { get; }
- Blue Color의 A, R, G, B 출력
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
string str = "Alpha " + Color.Blue.A + " Red " + Color.Blue.R + " Green " + Color.Blue.G + " Blue " + Color.Blue.B;
e.Graphics.DrawString(str, Font, Brushes.Black, 10, 10);
}
}
}

728x90
반응형
'C# > C#으로 살아남기_나우캠퍼스_이태성강사' 카테고리의 다른 글
[C# Winform 8강] GDI+ Brush (0) | 2022.02.10 |
---|---|
[C# Winform 7강] GDI+ Pen (0) | 2022.02.10 |
[C# Winform 5강] GDI+ Graphics (0) | 2022.02.09 |
[C# Winform 4강] 마우스 (0) | 2022.01.10 |
[C# Winform 3강] 키보드(2) KeyPress (0) | 2022.01.10 |