728x90
반응형

Color 구조체

 

  • 구조체 정의

Color Struct

 

Represents an ARGB (alpha, red, green, blue) color.

public struct Color

 

Inheritance ObjectValueType → 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
반응형

+ Recent posts