다음을 통해 공유


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

단색으로 영역을 그리려면 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.
            Dim myPredefinedBrushRectangle As New Rectangle()
            myPredefinedBrushRectangle.Width = 50
            myPredefinedBrushRectangle.Height = 50
            myPredefinedBrushRectangle.Fill = Brushes.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>
            Dim myRgbRectangle As New Rectangle()
            myRgbRectangle.Width = 50
            myRgbRectangle.Height = 50
            Dim mySolidColorBrush As 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
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 클래스에 대해 제공되는 보다 큰 예제의 일부입니다. 전체 샘플을 보려면 Brushes 샘플을 참조하십시오.

참고 항목

참조

Brushes