← 수업 제작 도구
홈 › Components › Sketch (그림판) › 화면 29

화면 29. Sketch.resetOnChange [sink]

원본: Computation Layer 문서(Sketch (그림판)) · Try It (원본 화면)

화면 번호29 / 34
문서 항목 설명 (원문)resetOnChange Specify a string value. If that value changes, the component resets.

1. 화면 캡처 (빨간 번호 = 아래 표의 번호)

화면 29 캡처

2. CL이 입력된 곳

코드 안의 회색 줄은 원문 영어 주석이고, 파란 줄은 그 영어 주석의 번역이며, 연분홍 줄은 코드가 하는 일의 설명이다.

번호이름종류CL 코드 원문, 번역, 설명
1master CL
(화면 전체)
SCREEN
# Creates a subtitle to display some instructions
# for the student without using a note.
▷ 메모 없이 학생에게 안내를 보여 주는 부제목을 만든다.
subtitle: "Trace the figure using a single sketch stroke."
▶ 화면 제목 아래에 표시할 부제목(subtitle)은 "Trace the figure using a single sketch stroke."(한 번의 스케치 획으로 도형을 따라 그리시오.)로 한다.
subtitle은 화면 제목 아래 가운데에 부제목을 붙인다.
2레이블 없는 그림판그림판
# Merges the current sketch and the existing sketch into
# a single sketch layer.
▷ 현재 스케치와 기존 스케치를 하나의 스케치 레이어로 합친다.
totalSketch = mergeSketches(this.sketch,this.currentStroke)
▶ 변수 totalSketch는 mergeSketches(this.sketch,this.currentStroke), 즉 지금까지의 스케치와 그리는 중인 획을 하나로 합친 스케치로 한다.
mergeSketches(…)는 다른 스케치들로 하나의 스케치를 만든다. sketch는 그림판에 그려진 모든 것을 나타내는 스케치를 가져오고, currentStroke는 지금 그리는 중인 획을 나타내는 스케치를 가져온다.
# Resets the sketch when the total number of strokes is greater than one ▷ 전체 획 수가 1보다 크면 스케치를 재설정한다. resetOnChange: when totalSketch.strokeCount < 2 "0" otherwise "1" ▶ 그림판의 변경 시 자동 재설정(resetOnChange)은 totalSketch의 획 수가 2보다 작으면 "0", 그렇지 않으면 "1"로 한다.
resetOnChange는 글자 값을 받아 그 값이 바뀌면 구성요소를 재설정한다. strokeCount는 스케치를 받아 획의 수를 숫자로 돌려준다. when은 조건을 차례로 확인해 처음 맞는 값을 쓴다. 획이 둘 이상이 되면 값이 바뀌어 그림판이 재설정된다.