마스크, 블렌드 효과, 색조 적용

GroupPart* 요소는 시계 화면 섹션의 모양을 조정하는 강력한 방법인 tintColor, renderModeblendMode 속성도 제공합니다.

렌더링 모드에서 클리핑 마스크 사용

renderMode는 클리핑 마스크를 구현하기 위해 WFF 버전 1에서 도입되었습니다.

renderMode는 장면 계층 구조의 GroupPart* 요소에 적용할 수 있습니다. 작동 방식을 가장 잘 이해하려면 장면 그래프가 렌더링되는 방식을 고려해 보세요.

<Group>
  <Group>
    <PartDraw />
    <PartText />
  </Group>
  <PartImage />
</Group>
여기에 대체 텍스트 삽입

시계 화면 렌더러는 장면 트리를 탐색하는 동안 요소를 순서대로 그립니다.

renderMode가 노드에 적용되면 효과는 해당 노드의 상위 Group 내에만 적용됩니다. 그래프의 다른 위치에 있는 다른 노드는 영향을 받지 않습니다.

renderMode를 지정하지 않으면 기본값은 SOURCE이므로 요소가 화면에 직접 그려집니다. 그러나 상위 노드에 MASK (또는 ALL)가 지정된 요소가 하나 이상 있는 경우 다른 접근 방식이 사용됩니다.

  1. 오프스크린 캔버스가 생성됩니다.
  2. SOURCE가 설정된 모든 하위 요소 (기본값)가 그려집니다.
    1. 마스크 (MASK, ALL)의 일부인 모든 하위 요소가 캔버스에 적용되어 결과 이미지를 자릅니다.

즉, 상위 노드의 요소 순서는 고려되지 않습니다.

다음 예에서 Scene 상위 요소에는 세 개의 하위 요소가 포함되어 있습니다.

  • 첫 번째와 세 번째 요소는 MASK 요소이므로 함께 결합되어 마스킹 레이어를 형성합니다.
  • 두 번째 요소는 유일한 마스킹되지 않는 레이어입니다.
<WatchFace width="450" height="450">
  <Scene>
    <PartDraw x="175" y="50" width="100" height="100" renderMode="MASK">
      <Ellipse x="0" y="0" width="100" height="100">
        <Fill color="#FFFFFF"></Fill>
      </Ellipse>
    </PartDraw>

    <PartDraw x="0" y="0" width="450" height="450">
      <Rectangle x="0" y="0" width="450" height="450">
        <Fill color="#ff0000">
          <LinearGradient startX="0" startY="0" endX="450" endY="450"
            colors="..." positions="..." />
        </Fill>
      </Rectangle>
    </PartDraw>

    <PartText x="75" y="250" width="300" height="80" renderMode="MASK">
      <Text align="CENTER">
        <Font family="pacifico" size="72" weight="BOLD" color="#FFFFFF">Hello!</Font>
      </Text>
    </PartText>
  </Scene>
</WatchFace>

SOURCEMASK 외에 renderMode의 세 번째 옵션은 ALL입니다. ALL는 요소가 SOURCEMASK로 모두 취급되어야 함을 지정합니다. 이는 일부 시나리오에서 유용할 수 있습니다.

블렌딩 모드 사용

참고: 이 기능은 워치 페이스 형식 버전 3 이상에서 사용할 수 있습니다.

버전 3부터 워치 페이스 형식은 Part* 요소를 컴포지션할 때 혼합 모드를 적용하는 기능을 제공합니다.

소스와 마스크를 각각 구성하기 위한 특수 메커니즘을 도입하는 renderMode와 달리 blendMode는 모든 Android 그래픽 혼합 모드 효과에 대한 일반 액세스를 제공하고 요소가 장면 그래프에 표시되는 순서대로 효과를 적용합니다.

정상 작동 중에는 두 개의 Part* 요소가 장면에 배치되면 기본 blendModeSRC_OVER이므로 최상위 요소가 하위 요소를 가리키거나 부분적으로 가립니다.

<PartDraw x="25" y="15" width="150" height="150">
  <Rectangle x="0" y="0" width="150" height="150">
    <Fill color="#ffd3ba" />
  </Rectangle>
</PartDraw>
<PartText x="35" y="60" width="300" height="120">
  <Text align="START">
    <Font family="pacifico" size="96" weight="BOLD" color="#fb5607">Hello!</Font>
  </Text>
</PartText>

혼합 모드 사용을 보여주기 위해 SRC_ATOP를 선택하면 대상 픽셀을 가리지 않는 소스 픽셀이 삭제됩니다. 즉, PartText은 소스이고 대상은 PartDraw입니다.

따라서 텍스트가 시계 화면의 다른 부분이 아닌 직사각형 위에만 그려집니다.

<PartDraw x="25" y="15" width="150" height="150">
  <Rectangle x="0" y="0" width="150" height="150">
    <Fill color="#ffd3ba" />
  </Rectangle>
</PartDraw>
<PartText x="35" y="60" width="300" height="120" blendMode="SRC_ATOP">
  <Text align="START">
    <Font family="pacifico" size="96" weight="BOLD" color="#fb5607">Hello!</Font>
  </Text>
</PartText>

SRC_ATOP 대신 COLOR_DODGE를 사용하여 소스를 반영하도록 대상을 더 밝게 만드는 등 더 복잡한 효과를 적용할 수 있습니다.

HUECOLOR_BURN 블렌딩 모드를 사용하여 여러 Part* 요소를 결합하는 예는 다음과 같습니다.

<Group name="container" x="75" y="100" width="300" height="300">
  <PartDraw x="25" y="15" width="150" height="150">
    <Rectangle x="0" y="0" width="150" height="150">
      <Fill color="#ffd3ba" />
    </Rectangle>
  </PartDraw>
  <PartDraw x="100" y="15" width="150" height="150" blendMode="HUE">
    <Ellipse x="0" y="0" width="150" height="150">
      <Fill color="#219ebc" />
    </Ellipse>
  </PartDraw>
  <PartText x="35" y="60" width="300" height="120" blendMode="COLOR_BURN">
    <Text align="START">
      <Font family="pacifico" size="96" weight="BOLD" color="#fb5607">Hello!</Font>
    </Text>
  </PartText>
</Group>
여기에 대체 텍스트 삽입

blendMode 효과 없음

여기에 대체 텍스트 삽입

blendMode 효과 포함

고려사항

다음 섹션에서는 클리핑 및 혼합 효과를 사용할 때 유의해야 할 몇 가지 고려사항을 설명합니다.

혼합 모드가 렌더링 모드 전에 적용됨

노드에 blendMode를 사용하는 Part 요소와 MASK (또는 ALL)로 설정된 renderMode를 사용하는 Part 요소가 모두 포함된 경우 다음 접근 방식이 사용됩니다.

  1. 소스가 blendMode 모드 적용을 포함하여 컴포지션됩니다.
  2. 그런 다음 rendermode="MASK를 지정하는 요소에서 마스크가 적용됩니다."

예를 들어 이전에 사용한 예시를 고려하고 직사각형 마스크를 추가합니다. 마스크된 요소의 순서는 중요하지 않습니다.

<Group name="container" x="75" y="100" width="300" height="300">
  <PartDraw x="25" y="15" width="150" height="150">
    <Rectangle x="0" y="0" width="150" height="150">
      <Fill color="#ffd3ba" />
    </Rectangle>
  </PartDraw>
  <PartDraw x="100" y="15" width="150" height="150" blendMode="HUE">
    <Ellipse x="0" y="0" width="150" height="150">
      <Fill color="#219ebc" />
    </Ellipse>
  </PartDraw>
  <PartDraw x="100" y="15" width="150" height="150" renderMode="MASK">
    <Rectangle x="0" y="0" width="150" height="150">
      <Fill color="#ffffff" />
    </Rectangle>
  </PartDraw>
  <PartText x="35" y="60" width="300" height="120" blendMode="COLOR_BURN">
    <Text align="START">
      <Font family="pacifico" size="96" weight="BOLD" color="#fb5607">Hello!</Font>
    </Text>
  </PartText>
</Group>

성능

renderMode 또는 blendMode를 사용하려면 추가 계산 및 그리기 단계가 필요합니다. 시계 화면이 실행되는 기기에 따라 지원되는 하드웨어에서 일부가 효율적으로 실행될 수 있지만 이전 기기에서는 불가능할 수 있습니다.

따라서 renderModeblendMode를 신중하게 사용하고 시계 화면의 전반적인 성능에 미칠 수 있는 영향을 고려하세요.

색조 사용

tintColor는 전체 Part* 요소, Group 또는 HourHandMinuteHand와 같은 개별 시곗바늘에 적용할 수 있습니다. 예를 들면 다음과 같습니다.

<WatchFace width="450" height="450">
  <Scene>
    <Group x="75" y="100" width="350" height="350" name="group1" tintColor="#ffd3ba">
      <PartDraw x="25" y="0" width="100" height="100">
        <Rectangle x="0" y="0" width="100" height="100">
          <Fill color="#ffffff" />
        </Rectangle>
      </PartDraw>
      <PartDraw x="150" y="0" width="100" height="100">
        <Ellipse x="25" y="0" width="100" height="100">
          <Fill color="#ffffff" />
        </Ellipse>
      </PartDraw>
      <PartText x="0" y="150" width="300" height="80">
        <Text align="CENTER">
          <Font family="pacifico" size="72" weight="BOLD" color="#ffffff">Hello!</Font>
        </Text>
      </PartText>
    </Group>
  </Scene>
</WatchFace>

이는 사용자 설정의 스타일을 적용하는 것을 비롯하여 시계 화면의 전체 섹션에 스타일을 지정하는 데 유용할 수 있습니다(예: tintcolor="[CONFIGURATION.myThemeColor.0]").