방법: 단색으로 영역 그리기

단색으로 영역을 그리려면 Red 또는 Blue 같이 미리 정의된 시스템 브러시를 사용하거나 새로운 SolidColorBrush를 만들고 알파, 빨강, 초록, 파랑 값을 사용해 Color를 설명하면 됩니다. XAML에서 16진수 표기법을 사용하여 단색으로 영역을 그릴 수도 있습니다.

다음 예에서는 이러한 기술을 활용해 파란 Rectangle을 그립니다.

예제

미리 정의된 브러시 사용

다음 예에서는 미리 정의된 브러시인 Blue를 사용해 파란 사각형을 그립니다.

<Rectangle Width="50" Height="50" Fill="Blue" />
// Create a rectangle and paint it with
// a predefined brush.
Rectangle myPredefinedBrushRectangle = new Rectangle();
myPredefinedBrushRectangle.Width = 50;
myPredefinedBrushRectangle.Height = 50;
myPredefinedBrushRectangle.Fill = Brushes.Blue;

16진수 표기법 사용

다음 예제에서는 8자리 16진수 표기법을 사용하여 파란색 사각형을 그립니다.

<!-- Note that the first two characters "FF" of the 8-digit
     value is the alpha which controls the transparency of 
     the color. Therefore, to make a completely transparent
     color (invisible), use "00" for those digits (e.g. #000000FF). -->
<Rectangle Width="50" Height="50" Fill="#FF0000FF" />

ARGB 값 사용

다음 예에서는 SolidColorBrush를 만들고 파란색의 ARGB 색을 사용해 Color를 설명합니다.

<Rectangle Width="50" Height="50">
  <Rectangle.Fill>
    <SolidColorBrush>
     <SolidColorBrush.Color>

        <!-- Describes the brush's color using
             RGB values. Each value has a range of 0-255.  
             R is for red, G is for green, and B is for blue.
             A is for alpha which controls transparency of the
             color. Therefore, to make a completely transparent
             color (invisible), use a value of 0 for Alpha. -->
        <Color A="255" R="0" G="0" B="255" />
     </SolidColorBrush.Color>
    </SolidColorBrush>
  </Rectangle.Fill>
</Rectangle>
Rectangle myRgbRectangle = new Rectangle();
myRgbRectangle.Width = 50;
myRgbRectangle.Height = 50;
SolidColorBrush mySolidColorBrush = new SolidColorBrush();

// Describes the brush's color using RGB values.
// Each value has a range of 0-255.
mySolidColorBrush.Color = Color.FromArgb(255, 0, 0, 255);
myRgbRectangle.Fill = mySolidColorBrush;

색상을 설명하는 다른 방법은 Color 구조를 참조하세요.

관련 항목

SolidColorBrush에 대한 자세한 내용과 추가 예제를 보려면 단색 및 그라데이션을 사용한 그리기 개요를 참조하세요.

이 코드 예제는에 대해 제공 된 큰 예제의 일부는 SolidColorBrush 클래스입니다. 전체 샘플을 보려면 브러시 샘플을 참조하세요.

참고 항목