# core/graphic (vanilla-engine 0.4.0)

> https://vanillapunch.com/docs/vanilla-engine/0.4.0/api/core/graphic/

그래픽.
- GL 컨텍스트로 출력하는 렌더러. 원본(WebGL2)과 같은 셰이더와 같은 상태 모델을 쓴다.
- Canvas2D 시절의 좌표계(좌상 원점, 픽셀 단위)와 상태 모델(변환/알파 스택)을 그대로 재현한다.
- 모든 드로우는 draw_vertices() 한 지점으로 수렴한다. 단색 도형도 1x1 흰색 텍스처로 텍스처 경로와 통일.
- 클리핑은 스텐실 버퍼 기반. 텍스트는 문자열 텍스처로 구워 출력.
- 묶어 그리기(기본 켬): 같은 텍스처를 잇달아 그리면 정점을 CPU 에서 변환해 모았다가 한 번에 그린다.
  원본과 같은 묶음 셰이더로 정점마다 색과 틴트를 실어, 틴트가 걸린 그리기도 묶는다. 클립 영역 기록은 묶지 않는다.
  블렌드, 클립, 파티클 그리기, 프레임 끝에서 모은 것을 먼저 내보낸다(flush_batch). 원본도 기본으로 켠다. (setSpriteBatchingEnabled)
- 화면 밖 거르기(기본 켬): NodeTree 가 노드를 그리기 전에 is_local_rect_visible 로 묻는다. 원본도 기본으로 켜고 WorldNode 가 같은 함수로 묻는다. (setCullingEnabled)
- 셰이더 바꿔 끼우기(set_shader_program_override): ShaderSprite 같은 효과가 기본 프로그램 대신 제 프로그램으로 그린다. 바꿔 끼운 동안은 묶지 않는다.
  바꿔 끼울 프로그램은 resolve_shader_program 이 이름으로 담아 두고, 어트리뷰트 위치를 기본 프로그램과 같게 고정해 기본 버텍스 어레이를 같이 쓴다.
- 마지막으로 건 셰이더 프로그램과 텍스처 유닛 0 의 텍스처를 기억해, 같은 것을 다시 거는 GL 호출을 건너뛴다. (원본도 같다)
  GL 을 밖에서 만질 수 있는 때(get_gl 로 컨텍스트를 내줄 때, restore_render_state, 프레임 시작과 끝)에는 잊고 다음에 다시 건다.
- 밉맵 단계 보정(set_image_mipmap_bias)은 기본, 묶음, 파티클 셰이더의 textureLodBias 유니폼으로 건다. 바꿔 끼운 셰이더는 그 유니폼이 있으면 받는다. (원본과 같음)
- 글자 방향(set_text_direction, 원본 setTextDirection)은 상태에 들고, 구운 문자열을 그 문단 방향으로 모양 짓는다. (textshaping.rs 의 양방향 정렬과 모양 짓기)
- 블렌드 모드 26 가지(원본과 같음): 13 가지는 고정 블렌딩, 13 가지는 그릴 영역 아래를 지금 프레임버퍼에서 blit_framebuffer 로 떠 와 W3C 공식대로 셰이더로 섞는다.
  Multiply 는 기본 프레임버퍼에서는 고정 블렌딩, 렌더 타겟에 그릴 때는 셰이더로 섞는다. (바탕이 반투명하면 고정 블렌딩이 W3C 식과 달라서, 원본과 같음)
  셰이더 글은 원본과 한 글자도 다르지 않다. 바꿔 끼운 셰이더는 덧그림 칸(데스크탑은 늘 RGBA16F, 웹은 원본처럼 EXT_color_buffer_float 가 있을 때 RGBA16F)에 먼저 그리고 섞어 옮긴다.
- 기본 프레임버퍼에 그릴 때는 알파를 쓰지 않는다(apply_color_mask). 원본과 웹은 캔버스가 alpha: false 라 화면 알파가 늘 1 인데, 데스크탑 기본 프레임버퍼는 알파가 있어
  알파를 낮추는 모드 뒤에 DST_ALPHA 를 쓰는 모드와 셰이더 섞기가 웹과 달랐다. 렌더 타겟에는 알파도 쓴다.

## GlTexture (type)

GL 객체 타입. (데스크탑은 glow::Native*, 웹은 WebGL 객체. glow 컨텍스트가 정한 것을 그대로 쓴다)

```rust
pub type GlTexture = <glow::Context as glow::HasContext>::Texture
```

## GlBuffer (type)

GL 버퍼 객체. (버텍스 버퍼 같은 것)

```rust
pub type GlBuffer = <glow::Context as glow::HasContext>::Buffer
```

## GlVertexArray (type)

GL 버텍스 어레이 객체.

```rust
pub type GlVertexArray = <glow::Context as glow::HasContext>::VertexArray
```

## GlProgram (type)

GL 셰이더 프로그램 객체.

```rust
pub type GlProgram = <glow::Context as glow::HasContext>::Program
```

## GlShader (type)

GL 셰이더 객체. (버텍스나 프래그먼트 셰이더 하나)

```rust
pub type GlShader = <glow::Context as glow::HasContext>::Shader
```

## GlUniformLocation (type)

GL 유니폼 위치. (데스크탑은 정수 하나를 감싼 값, 웹은 WebGL 위치 객체)

```rust
pub type GlUniformLocation = <glow::Context as glow::HasContext>::UniformLocation
```

## GlFramebuffer (type)

GL 프레임버퍼 객체. (렌더 타겟)

```rust
pub type GlFramebuffer = <glow::Context as glow::HasContext>::Framebuffer
```

## GeometryKey (struct) (Clone, Debug, Default)

기하 캐시 열쇠. (Component::write_geometry_key 가 그리기 입력을 적는 곳, 원본 GeometryKey)
- add 로 적은 값을 지난번에 적은 값과 차례대로 견준다. 하나라도 다르거나 수가 다르면 바뀐 것으로 본다.
- 견주며 바로 덮어 적으므로 프레임마다 배열을 새로 만들지 않는다. (글은 바뀐 때만 새로 담는다)

예제: 그리기 입력을 적고 바뀌었는지 보기

```rust
use vanilla::GeometryKey;

let mut geometry_key = GeometryKey::new();
geometry_key.begin();
geometry_key.add(10.0);
geometry_key.add("#ff0000");
println!("{}", geometry_key.end());
geometry_key.begin();
geometry_key.add(10.0);
geometry_key.add("#ff0000");
println!("{}", geometry_key.end());
geometry_key.begin();
geometry_key.add(12.0);
geometry_key.add("#ff0000");
println!("{}", geometry_key.end());
```

- `pub fn new() -> GeometryKey` (constructor, since 0.4.0): 생성.
  - returns GeometryKey: 빈 열쇠. (처음 end 는 false)
- `pub fn begin(&mut self)` (method, since 0.4.0): 적기 시작. (Graphic 이 write_geometry_key 앞에 부른다)
- `pub fn add(&mut self, value: impl GeometryKeyValue)` (method, since 0.4.0): 값 하나 적기. (수, 참거짓, 글, 색, 벡터, 사각형, 공유 객체(Rc), Option)
  - `value` impl GeometryKeyValue: 그리기가 읽는 값. (Rc 는 가리키는 자리로 견준다, 원본의 객체 참조 견주기)
- `pub fn end(&mut self) -> bool` (method, since 0.4.0): 적기 끝. (지난번과 같으면 true)
  - returns bool: 이번에 적은 값이 지난번과 모두 같으면 true. (처음 적은 때는 false)

## GeometryKeyValue (trait)

GeometryKey::add 로 적을 수 있는 값. (원본 add 가 받는 수, 글, 참거짓, 객체 참조, null)

예제: 수와 참거짓을 적어 지난번과 같은지 보기

```rust
use vanilla::GeometryKey;

let mut geometry_key = GeometryKey::new();
geometry_key.begin();
geometry_key.add(1.5_f64);
geometry_key.add(true);
geometry_key.end();
geometry_key.begin();
geometry_key.add(1.5_f64);
geometry_key.add(true);
assert!(geometry_key.end());
```

- `fn add_to_geometry_key(self, geometry_key: &mut GeometryKey)` (method, since 0.4.0): 열쇠에 이 값을 적기.
  - `geometry_key` &mut GeometryKey: 적을 열쇠.

## Graphic (struct)

그래픽. (원본 Graphic, GL 컨텍스트에 Canvas2D 처럼 그리는 2D 렌더러)
- 엔진이 하나 들어 씬과 노드의 그리기 함수에 `&mut Graphic` 으로 넘기고, 그리기 밖에서는 `engine.get_graphic()`, `get_graphic_mut()` 로 꺼낸다. 좌표는 좌상 원점, 픽셀 단위다.
- 상태(변환, 전역 투명도, 블렌드 모드, 색, 글꼴, 정렬, 글자 방향)는 push_state, pop_state 로 쌓고 되돌린다. 프레임 첫머리(apply_settings)에 변환, 전역 투명도, 틴트, 블렌드 모드가 처음 값으로 돌아간다.

예제: 씬의 draw 에서 도형과 글자 그리기

```rust
use vanilla::{Colors, Engine, EngineConfiguration, Graphic, Rect, Scene, SceneBase, TextAlign, TextBaseline, Vector2};

struct MainScene {
	scene_base: SceneBase,
}

impl Scene for MainScene {
	fn get_scene_base(&self) -> &SceneBase {
		&self.scene_base
	}

	fn get_scene_base_mut(&mut self) -> &mut SceneBase {
		&mut self.scene_base
	}

	fn draw(&mut self, graphic: &mut Graphic) {
		graphic.push_state();
		graphic.translate(640.0, 360.0);
		graphic.rotate(0.25);
		graphic.set_fill_color(Colors::WHITE);
		graphic.draw_rect(Rect::create(-100.0, -60.0, 200.0, 120.0));
		graphic.pop_state();
		graphic.set_stroke_color("#ff8800");
		graphic.draw_stroke_circle(Vector2::create(200.0, 200.0), 50.0, 4.0);
		graphic.set_font_string("24px sans-serif");
		graphic.set_text_align(TextAlign::Center);
		graphic.set_text_baseline(TextBaseline::Middle);
		graphic.set_fill_color(Colors::VANILLA);
		graphic.draw_fill_text("Hello", 640.0, 620.0);
	}
}

fn main() {
	let mut engine_configuration = EngineConfiguration::new();
	engine_configuration.reference_resolution_size = Vector2::create(1280.0, 720.0);
	let engine = Engine::new(engine_configuration);
	let main_scene = MainScene {
		scene_base: SceneBase::new(),
	};
	if let Err(error) = engine.run(Box::new(main_scene)) {
		eprintln!("{}", error);
	}
}
```

- `pub fn new(gl: glow::Context, preserve_drawing_buffer: bool, color_space: crate::core::colorspace::ColorSpace) -> Result<Graphic, String>` (constructor, since 0.3.2): 생성. (preserve_drawing_buffer 는 원본 생성 인자 preserveDrawingBuffer, 엔진 설정의 같은 이름 값을 넘긴다)
  - `gl` glow::Context: 그릴 GL 컨텍스트. (Graphic 이 가진다)
  - `preserve_drawing_buffer` bool: 프레임이 끝난 뒤에도 그린 것을 남길지. (켜면 프레임 첫머리에 색을 비우지 않는다)
  - `color_space` crate::core::colorspace::ColorSpace: 3D 색 공간. (원본 생성 인자 colorSpace, 엔진 설정의 color_space 를 넘긴다, 2D 는 어느 값이든 감마 공간)
  - returns Result<Graphic, String>: 만든 그래픽. 기본 셰이더의 컴파일이나 링크, GL 객체(버텍스 어레이, 버퍼, 텍스처) 만들기에 실패하면 그 오류 글을 담은 Err.
- `pub fn is_drawing_buffer_preserved(&self) -> bool` (method, since 0.4.0): 프레임이 끝난 뒤에도 그린 것을 남기는지. (원본 preserveDrawingBuffer)
  - returns bool: 생성 인자 preserve_drawing_buffer 의 값.
- `pub fn apply_settings(&mut self, drawing_buffer_width: i32, drawing_buffer_height: i32)` (method, since 0.3.2): 설정 반영. (매 프레임 시작 시 엔진이 호출)
  - 드로잉 버퍼 크기 변화 감지 및 뷰포트/프로젝션 갱신.
  - 프레임 시작 기준 상태로 리셋.
  - 브라우저는 preserveDrawingBuffer 가 꺼져 있으면 화면에 낸 뒤 드로잉 버퍼를 비워 준다. 창은 화면을 넘긴 뒤의 뒷 버퍼가 정해져 있지 않아 여기서 직접 비운다.
    켜져 있으면 원본처럼 색을 비우지 않는다. (원본 applySettings 는 스텐실만 비운다. 지난 프레임 그림 위에 그리고, 데스크탑은 플랫폼이 지난 프레임 그림을 되살려 둔다)
  - `drawing_buffer_width` i32: 드로잉 버퍼 너비. (픽셀, 뷰포트와 프로젝션에 쓴다)
  - `drawing_buffer_height` i32: 드로잉 버퍼 높이. (픽셀)
- `pub fn end_frame(&mut self)` (method, since 0.3.2): 프레임 마무리. (엔진이 화면을 넘기기 전에 호출)
- `pub fn clear_depth_buffer(&mut self)` (method, since 0.4.0): 깊이 버퍼 비우기. (원본 clearDepthBuffer, 2D 그리기 사이에 3D 를 끼우기 전에)
  - 자르기(begin_clip_rect, 스텐실)를 건 뒤 그리는 도중에 깊이를 비우면 갤럭시 폴드3(Adreno 660)의 드라이버가 3D 를 하나도 그리지 못한 일이 있다. (원본 게임)
    자르기 안에 3D 를 그릴 노드는 begin_clip_rect 앞에서 이것을 부르고, run_external_pass 에는 is_depth_cleared 를 false 로 준다.
- `pub fn run_external_pass<R>(&mut self, is_depth_cleared: bool, pass: impl FnOnce(&GlContext) -> R) -> R` (method, since 0.4.0): 2D 그리기 사이에 GL 패스 끼우기. (원본 runExternalPass)
  - 앞의 2D 묶음을 내보내고, is_depth_cleared 면 깊이를 비운 뒤 pass 를 부르고, 끝나면 restore_render_state 를 부른다.
  - pass 는 GL 컨텍스트를 받아 프로그램, 버텍스 어레이, 뷰포트, 섞기, 깊이, 면 가리기를 바꿔도 된다. (스텐실 자르기는 그대로 걸려 있고, 끝나면 스텐실 자르기 상태를 되돌린다)
  - 받은 컨텍스트(GlContext)의 상태 함수는 GL 상태 캐시를 거치므로, pass 안에서 상태를 바꾼 뒤 엔진 그리기를 이어 불러도 엔진이 바뀐 상태를 안다.
  - 이 함수 밖에서 같은 컨텍스트로 GL 을 써도 다음 2D 그리기가 프로그램, 버텍스 어레이, 정점 버퍼, 텍스처 유닛, 섞기, 깊이, 면 가리기, 가위, 뷰포트를 상태 캐시에 견주어 다시 건다.
    남는 약속은 둘이다. 2D 는 지금 묶인 프레임 버퍼에 그리므로 게임 프레임 버퍼를 묶었으면 들어올 때 것으로 돌려 두고, 스텐실 상태는 바꾸지 않는다.
  - pass 가 돌려준 값을 그대로 돌려준다. pass 가 패닉해도 풀리는 동안 가드가 restore_render_state 를 부른다. (원본은 던져도 되돌린다)
  - `is_depth_cleared` bool: pass 앞에서 깊이 버퍼를 비울지. (자르기 안에 3D 를 그릴 때는 false 로 주고 begin_clip_rect 앞에서 clear_depth_buffer 를 부른다)
  - `pass` impl FnOnce(&GlContext) -> R: GL 컨텍스트를 받아 그리는 함수.
  - returns R: pass 가 돌려준 값.

  예제: GL 로 직접 그리고 값 돌려받기

  ```rust
  use vanilla::Graphic;
  
  fn draw(graphic: &mut Graphic) {
  	let maximum_texture_size = graphic.run_external_pass(true, |gl| {
  		unsafe {
  			gl.enable(glow::DEPTH_TEST);
  			gl.get_parameter_i32(glow::MAX_TEXTURE_SIZE)
  		}
  	});
  	assert!(maximum_texture_size > 0);
  }
  ```

- `pub fn set_image_smoothing_enabled(&mut self, value: bool)` (method, since 0.3.2): 이미지 스무딩 활성화 여부 설정.
  - 도트(픽셀) 스프라이트 게임은 false 로 설정해 선명하게 렌더링.
  - `value` bool: true 면 LINEAR 로 부드럽게, false 면 NEAREST 로 픽셀 그대로. (처음 true)
- `pub fn is_image_smoothing_enabled(&self) -> bool` (method, since 0.3.2): 이미지 스무딩 활성화 여부 반환.
  - returns bool: 스무딩이 켜져 있으면 true.
- `pub fn set_image_smoothing_quality(&mut self, value: ImageSmoothingQuality)` (method, since 0.4.0): 이미지 스무딩 퀄리티 설정. (GL 은 LINEAR / NEAREST 이분법이라 보관만 한다, 처음은 High)
  - `value` ImageSmoothingQuality: 스무딩 퀄리티. (보관만 하고 그리기에는 쓰지 않는다)
- `pub fn get_image_smoothing_quality(&self) -> ImageSmoothingQuality` (method, since 0.4.0): 이미지 스무딩 퀄리티 반환.
  - returns ImageSmoothingQuality: 설정한 퀄리티. (처음 High)
- `pub fn set_image_mipmap_enabled(&mut self, value: bool)` (method, since 0.3.2): 이미지 밉맵 사용 여부 설정. (크게 줄여 그리는 이미지의 자글거림을 줄인다)
  - `value` bool: true 면 이미지 텍스처를 줄일 때 밉맵 필터를 쓴다. (처음 false)
- `pub fn is_image_mipmap_enabled(&self) -> bool` (method, since 0.3.2): 이미지 밉맵 사용 여부 반환.
  - returns bool: 밉맵을 쓰면 true.
- `pub fn set_image_mipmap_bias(&mut self, value: f64)` (method, since 0.4.0): 이미지 밉맵 단계 보정 설정. (기본 0, 원본 setImageMipmapBias)
  - 밉맵 단계를 고를 때 더하는 값. 음수면 한 단계 큰 그림 쪽을 골라 또렷해지고, 너무 작으면 다시 자글거린다. (-0.5 안팎)
  - 기본 셰이더(낱장, 묶어 그리기, 파티클)에 적용한다. 바꿔 끼운 셰이더는 textureLodBias 유니폼이 있으면 받는다.
  - `value` f64: 밉맵 단계에 더할 값. (음수면 또렷하게, 0 이면 보정 없음)
- `pub fn get_image_mipmap_bias(&self) -> f64` (method, since 0.4.0): 이미지 밉맵 단계 보정 반환.
  - returns f64: 설정한 보정 값. (처음 0)
- `pub fn set_force_gizmos_visible(&mut self, is_force_gizmos_visible: bool)` (method, since 0.3.2): 모든 노드의 기즈모를 강제로 보일지 설정.
  - `is_force_gizmos_visible` bool: true 면 노드마다 기즈모 보이기 설정과 상관없이 그린다. (처음 false)
- `pub fn is_force_gizmos_visible(&self) -> bool` (method, since 0.3.2): 모든 노드의 기즈모를 강제로 보일지 반환.
  - returns bool: 강제로 보이게 했으면 true.
- `pub fn push_state(&mut self)` (method, since 0.3.2): 상태 저장. (Canvas2D save 대응)
  - 한 번 쓴 칸은 남겨 두고 다시 쓴다. 폰트 문자열은 칸의 저장소에 옮겨 적어 매번 새로 잡지 않는다.
- `pub fn pop_state(&mut self)` (method, since 0.3.2): 상태 복원. (Canvas2D restore 대응)
  - 폰트 문자열은 칸의 저장소와 맞바꾼다.
- `pub fn translate(&mut self, x: f64, y: f64)` (method, since 0.3.2): 이동 변환 누적.
  - `x` f64: 가로 이동. (지금 좌표계 단위, 픽셀)
  - `y` f64: 세로 이동. (아래가 +)
- `pub fn rotate(&mut self, radian: f64)` (method, since 0.3.2): 회전 변환 누적.
  - `radian` f64: 회전 각도. (라디안, 화면에서 시계 방향이 +)
- `pub fn scale(&mut self, x: f64, y: f64)` (method, since 0.3.2): 크기 변환 누적.
  - `x` f64: 가로 배율. (1 이면 그대로, 음수면 뒤집힌다)
  - `y` f64: 세로 배율.
- `pub fn set_transform(&mut self, a: f64, b: f64, c: f64, d: f64, e: f64, f: f64)` (method, since 0.3.2): 변환 행렬 직접 설정. (Canvas2D setTransform(a, b, c, d, e, f) 대응)
  - 지금 행렬에 곱하지 않고 바꿔 넣는다. 점 (x, y) 는 (a x + c y + e, b x + d y + f) 로 옮겨진다.
  - `a` f64: 가로 배율. (x 에 곱해 새 x 에 더한다)
  - `b` f64: 세로 기울임. (x 에 곱해 새 y 에 더한다)
  - `c` f64: 가로 기울임. (y 에 곱해 새 x 에 더한다)
  - `d` f64: 세로 배율. (y 에 곱해 새 y 에 더한다)
  - `e` f64: 가로 이동. (픽셀)
  - `f` f64: 세로 이동. (픽셀)
- `pub fn reset_transform(&mut self)` (method, since 0.3.2): 변환 행렬 초기화.
- `pub fn get_transform_matrix(&self) -> TransformMatrix` (method, since 0.3.2): 현재 변환 행렬 반환.
  - returns TransformMatrix: 지금 변환 행렬의 복사본.
- `pub fn set_global_alpha(&mut self, value: f64)` (method, since 0.3.2): 전역 투명도 설정.
  - `value` f64: 전역 투명도. (0 ~ 1 로 자른다, 처음 1)
- `pub fn get_global_alpha(&self) -> f64` (method, since 0.3.2): 전역 투명도 반환.
  - returns f64: 지금 전역 투명도. (0 ~ 1)
- `pub fn multiply_global_alpha(&mut self, value: f64)` (method, since 0.3.2): 전역 투명도 곱셈 누적. (노드 트리의 투명도 상속용)
  - `value` f64: 지금 전역 투명도에 곱할 값. (곱한 결과를 0 ~ 1 로 자른다)
- `pub fn set_blend_mode(&mut self, blend_mode: BlendMode)` (method, since 0.3.2): 블렌드 모드 설정. (원본 setBlendMode)
  - 고정 블렌딩으로 되는 13 가지는 blend_func 로 건다.
  - 나머지 13 가지(Overlay, Darken, Lighten, ColorDodge, ColorBurn, HardLight, SoftLight, Difference, Exclusion, Hue, Saturation, Color, Luminosity)는
    그리기마다 그릴 영역 아래를 떠 와 셰이더로 섞는다. 이 모드에서는 묶어 그리지 않고, 그리기 하나에 영역 복사 한 번과 드로우 콜 한 번이 든다.
    (바꿔 끼운 셰이더로 그릴 때는 덧그림 칸에 먼저 그리고 옮기므로 드로우 콜이 두 번)
  - Multiply 는 렌더 타겟(기본 프레임버퍼가 아닌 것)에 그릴 때만 셰이더로 섞는다. (get_draw_shader_blend_mode_index)
  - `blend_mode` BlendMode: 다음 그리기부터 쓸 블렌드 모드. (지금과 같으면 아무것도 하지 않는다, 바뀌면 모아 둔 묶음을 먼저 내보낸다)
- `pub fn get_blend_mode(&self) -> BlendMode` (method, since 0.3.2): 블렌드 모드 반환.
  - returns BlendMode: 지금 블렌드 모드. (프레임 첫머리에 Normal)
- `pub fn set_image_tint_color(&mut self, color: Option<Color>)` (method, since 0.3.2): 이미지 틴트 색상 설정. (None 이면 해제)
  - 이미지 실루엣(알파) 안쪽에만 tint.alpha 비율로 색을 덮는다.
  - `color` Option<Color>: 덮을 색. (알파가 덮는 비율, None 이면 틴트를 끈다, 프레임 첫머리에 None)
- `pub fn get_image_tint_color(&self) -> Option<Color>` (method, since 0.3.2): 이미지 틴트 색상 반환.
  - returns Option<Color>: 지금 틴트 색. 걸려 있지 않으면 None.
- `pub fn set_fill_color(&mut self, color: impl Into<Color>)` (method, since 0.3.2): 채우기 색상 설정. (Color 또는 "#rrggbb" 같은 문자열)
  - `color` impl Into<Color>: 채우기 색. (Color 나 "#rrggbb" 같은 글, 처음 검정)
- `pub fn get_fill_color(&self) -> Color` (method, since 0.3.2): 채우기 색상 반환.
  - returns Color: 지금 채우기 색.
- `pub fn set_stroke_color(&mut self, color: impl Into<Color>)` (method, since 0.3.2): 선 색상 설정. (Color 또는 "#rrggbb" 같은 문자열)
  - `color` impl Into<Color>: 선 색. (Color 나 "#rrggbb" 같은 글, 처음 검정)
- `pub fn get_stroke_color(&self) -> Color` (method, since 0.3.2): 선 색상 반환.
  - returns Color: 지금 선 색.
- `pub fn write_quad(&mut self, offset: usize, left_x: f64, top_y: f64, right_x: f64, bottom_y: f64, left_u: f64, top_v: f64, right_u: f64, bottom_v: f64) -> usize` (method, since 0.3.2): 버텍스 데이터에 쿼드(삼각형 2개, 버텍스 6개) 기록.
  - 기록 후의 오프셋(플로트 단위)을 반환.
  - 스크래치 배열(get_vertex_data, 정점 4096 개, 플로트 16384 개)을 넘게 쓰면 패닉한다.
  - `offset` usize: 기록을 시작할 자리. (스크래치 배열의 플로트 번호, 정점 하나에 x, y, u, v 플로트 4 개)
  - `left_x` f64: 왼쪽 x. (지금 변환 전의 좌표, 픽셀)
  - `top_y` f64: 위쪽 y. (픽셀)
  - `right_x` f64: 오른쪽 x. (픽셀)
  - `bottom_y` f64: 아래쪽 y. (픽셀)
  - `left_u` f64: 왼쪽 텍스처 좌표. (0 ~ 1)
  - `top_v` f64: 위쪽 텍스처 좌표. (0 ~ 1, 0 이 그림의 위)
  - `right_u` f64: 오른쪽 텍스처 좌표. (0 ~ 1)
  - `bottom_v` f64: 아래쪽 텍스처 좌표. (0 ~ 1)
  - returns usize: 기록한 뒤의 오프셋. (offset + 24, 4 로 나누면 그때까지의 정점 수)
- `pub fn draw_vertices(&mut self, vertex_count: usize, texture: GlTexture, color: Color)` (method, since 0.3.2): 기록된 버텍스 출력. (모든 드로우가 수렴하는 단일 지점)
  - `vertex_count` usize: 그릴 정점 수. (스크래치 배열 앞에서부터, 삼각형마다 3 개, 0 이면 아무것도 하지 않는다)
  - `texture` GlTexture: 입힐 텍스처. (단색은 get_white_texture)
  - `color` Color: 텍스처 색에 곱할 색. (그림 그대로는 get_white_color)

  예제: 쿼드 두 개를 써서 한 번에 그리기

  ```rust
  use vanilla::core::graphic::FLOATS_PER_VERTEX;
  use vanilla::{Color, Graphic};
  
  fn draw(graphic: &mut Graphic) {
  	let mut offset = graphic.write_quad(0, 10.0, 10.0, 110.0, 60.0, 0.0, 0.0, 1.0, 1.0);
  	offset = graphic.write_quad(offset, 10.0, 80.0, 110.0, 130.0, 0.0, 0.0, 1.0, 1.0);
  	let white_texture = graphic.get_white_texture();
  	graphic.draw_vertices(offset / FLOATS_PER_VERTEX, white_texture, Color::create(1.0, 0.5, 0.0, 1.0));
  }
  ```

- `pub fn set_geometry_caching_enabled(&mut self, is_geometry_caching_enabled: bool)` (method, since 0.4.0): 기하 캐시 켜기 / 끄기. (기본 켜짐, 원본 setGeometryCachingEnabled)
  - 켜져 있으면 write_geometry_key 로 그리기 입력을 알리는 컴포넌트(Paint, UIView, Text, Sprite 등)가 그린 정점을 컴포넌트마다 캐시해 둔다.
    입력, 변환, 투명도가 그대로면 draw 를 부르지 않고 캐시를 묶음에 옮기고, 이동(스크롤 등)만 바뀌면 캐시한 지역 정점에 새 행렬만 곱한다.
  - 캐시 조각만으로 찬 묶음은 프레임의 그리기 차례마다 GPU 버퍼에 남겨, 바뀐 것이 없으면 정점을 올리지 않고 드로 콜만 낸다.
  - 끄면 늘 draw 를 부른다. (화면은 같다)
  - `is_geometry_caching_enabled` bool: 켤지.

  예제: 기하 캐시를 켜고 지난 프레임에 캐시로 그린 수 보기

  ```rust
  use vanilla::Graphic;
  
  fn draw(graphic: &mut Graphic) {
  	graphic.set_geometry_caching_enabled(true);
  	println!("{} {}", graphic.is_geometry_caching_enabled(), graphic.get_last_frame_geometry_cache_hit_count());
  }
  ```

- `pub fn is_geometry_caching_enabled(&self) -> bool` (method, since 0.4.0): 기하 캐시가 켜져 있는지.
  - returns bool: 켜져 있으면 true. (처음 true)
- `pub fn get_last_frame_geometry_cache_hit_count(&self) -> u32` (method, since 0.4.0): 지난 프레임에 기하 캐시로 그린 컴포넌트 수. (draw 를 부르지 않은 것)
  - returns u32: 캐시한 정점을 옮기거나 행렬만 다시 걸어 그린 컴포넌트 수.
- `pub fn get_last_frame_geometry_rebuild_count(&self) -> u32` (method, since 0.4.0): 지난 프레임에 기하 캐시를 다시 적은 컴포넌트 수. (캐시하는 컴포넌트 가운데 draw 를 부른 것)
  - returns u32: 입력이나 배율, 회전 등이 바뀌어 draw 를 다시 부른 컴포넌트 수.
- `pub fn get_last_frame_retained_batch_count(&self) -> u32` (method, since 0.4.0): 지난 프레임에 정점을 다시 올리지 않고 GPU 에 남겨 둔 버퍼로 그린 묶음 수.
  - 기하 캐시 조각만으로 찬 묶음이 지난 프레임 같은 차례의 묶음과 조각까지 같으면 정점을 옮기지도 올리지도 않고 드로 콜만 낸다.
  - returns u32: 남긴 버퍼로 그린 묶음 수.

  예제: 멈춘 UI 가 남긴 묶음으로 그려지는지 보기

  ```rust
  use vanilla::Graphic;
  
  fn draw(graphic: &mut Graphic) {
  	println!("{} {}", graphic.get_last_frame_retained_batch_count(), graphic.get_last_frame_draw_call_count());
  }
  ```

- `pub fn draw_component(&mut self, component: &mut dyn Component, transform: &NodeTransform)` (method, since 0.4.0): 컴포넌트 그리기. (노드가 컴포넌트마다 부른다, 기하 캐시를 거친다, 원본 drawComponent)
  - 컴포넌트가 write_geometry_key 로 입력을 알리지 않거나, 캐시가 꺼졌거나, 묶어 그리지 않는 상태면 draw 를 그대로 부른다.
  - 입력과 그리는 상태(배율, 회전, 섞기, 틴트, 글 방향)가 지난번과 같으면:
    이동과 투명도도 같으면 캐시한 디바이스 정점을 묶음에 그대로 옮기고, 다르면 캐시한 지역 정점에 지금 행렬과 투명도를 다시 건다.
    (스크롤은 부모의 이동만 바뀌므로 자식 컴포넌트는 draw 없이 행렬 곱만 한다, 글은 픽셀 스냅까지 같게 다시 셈한다)
  - 그 밖에는 draw 를 불러 캐시를 다시 적는다. 그리기 중에 자르기, 층, 섞기 바꾸기 등 묶음 밖의 일을 하면 그 컴포넌트는 캐시하지 않는다.
  - `component` &mut dyn Component: 그릴 컴포넌트. (캐시는 컴포넌트가 쥔다)
  - `transform` &NodeTransform: 컴포넌트가 붙은 노드의 트랜스폼.
- `pub fn flush_batch(&mut self)` (method, since 0.3.2): 모아 둔 묶음 내보내기. (GL 상태를 바꾸기 전, 프레임 끝, GL 을 직접 쓰기 전에 부른다)
  - 묶음의 텍스처를 0 번부터의 유닛에 묶는다. 쓰지 않는 칸의 유닛에는 흰 텍스처를 묶어, 지난 그리기의 텍스처가 지금 그리는 칸(렌더 타겟)이어도 되먹임이 생기지 않게 한다. (원본과 같음)
- `pub fn set_batching_enabled(&mut self, is_batching_enabled: bool)` (method, since 0.3.2): 묶어 그리기 켜고 끄기. (기본 켬. 끄면 원본처럼 그리기 하나에 드로우 콜 하나)
  - 켜면 연이은 드로우(이미지, 도형, 글자, 정점 색 쿼드)를 정점에 변환과 색을 실어 쌓아 두었다가 한 번의 드로우 콜로 그린다.
  - 텍스처는 한 묶음에 여러 장(기기 텍스처 유닛 수와 16 가운데 작은 것)까지 묶어 텍스처가 바뀌어도 이어진다. (PixiJS 와 같은 꼴)
  - 축에 맞고 화소 경계에 놓인 자르기(begin_clip_rect)는 정점의 자르기 사각형으로 셰이더가 잘라 묶음을 끊지 않는다. (돌아갔거나 둥근 자르기는 스텐실)
  - 텍스처 칸이 차거나, 블렌드, 스텐실 자르기, 바꿔 끼운 셰이더가 바뀌거나 버퍼가 차면 그때까지 쌓인 것을 그리고, 프레임 끝에 엔진이 남은 것을 그린다.
  - `is_batching_enabled` bool: true 면 연이은 그리기를 모아 한 번에 그린다. (끌 때 모아 둔 것을 먼저 내보낸다)
- `pub fn is_batching_enabled(&self) -> bool` (method, since 0.3.2): 묶어 그리기 여부.
  - returns bool: 묶어 그리기가 켜져 있으면 true. (처음 true)
- `pub fn set_culling_enabled(&mut self, is_culling_enabled: bool)` (method, since 0.3.2): 화면 밖 거르기 켜고 끄기. (기본 켬)
  - `is_culling_enabled` bool: true 면 화면 밖 노드의 그리기를 건너뛴다.
- `pub fn is_culling_enabled(&self) -> bool` (method, since 0.3.2): 화면 밖 거르기 여부.
  - returns bool: 화면 밖 거르기가 켜져 있으면 true. (처음 true)
- `pub fn is_local_rect_visible(&self, rect: Rect) -> bool` (method, since 0.3.2): 현재 변환 기준의 사각형이 화면(드로잉 버퍼)과 걸린 자르기 안에 걸치는지. (네 꼭짓점을 변환한 경계 상자로 본다)
  - begin_clip_rect 로 건 자르기(겹친 것 모두)의 경계 상자 밖이면 보이지 않는 것으로 본다. (유니티 RectMask2D 처럼 스크롤 칸 밖 줄을 그리지 않는다)
  - `rect` Rect: 지금 변환 기준의 사각형. (로컬 좌표, 픽셀)
  - returns bool: 변환한 네 꼭짓점의 경계 상자가 드로잉 버퍼(0, 0 에서 너비, 높이까지)와 걸린 자르기의 경계 상자 안에 걸치면 true. (경계에 닿기만 해도 true)
- `pub fn set_subtree_culling_enabled(&mut self, is_subtree_culling_enabled: bool)` (method, since 0.4.0): 하위 트리째 그리기 건너뛰기 켜고 끄기. (기본 켬, 원본 setSubtreeCullingEnabled)
  - 켜면 노드와 자손이 그리는 곳을 모두 품는 하위 트리 그리기 경계(NodeTree::read_subtree_draw_bounds)가 화면과 걸린 자르기 밖일 때 그 노드와 자손의 그리기를 통째로 건너뛴다. tick 은 그대로 돈다.
  - 화면 밖 거르기(set_culling_enabled)가 꺼져 있으면 이것도 하지 않는다. 기즈모를 모두 그리게 했으면 건너뛰지 않는다.
  - `is_subtree_culling_enabled` bool: true 면 화면 밖 하위 트리를 통째로 건너뛴다.

  예제: 끄고 켜기

  ```rust
  use vanilla::Graphic;
  
  fn compare_culling(graphic: &mut Graphic) {
  	assert!(graphic.is_subtree_culling_enabled());
  	graphic.set_subtree_culling_enabled(false);
  	assert!(!graphic.is_subtree_culling_enabled());
  	let culled_subtree_count = graphic.get_last_frame_culled_subtree_count();
  	assert!(culled_subtree_count < u32::MAX);
  }
  ```

- `pub fn is_subtree_culling_enabled(&self) -> bool` (method, since 0.4.0): 하위 트리째 그리기 건너뛰기 여부. (원본 isSubtreeCullingEnabled)
  - returns bool: 켜져 있으면 true. (처음 true)
- `pub fn get_last_frame_culled_subtree_count(&self) -> u32` (method, since 0.4.0): 지난 프레임에 화면 밖이라 그리기를 통째로 건너뛴 하위 트리 수. (원본 getLastFrameCulledSubtreeCount)
  - returns u32: 지난 프레임에 건너뛴 하위 트리 수. (begin_frame_statistics 가 넘겨 둔 값, 건너뛴 노드의 자손은 세지 않는다)
- `pub fn add_culled_subtree_count(&mut self, culled_subtree_count: u32)` (method, since 0.4.0): 이번 프레임에 화면 밖이라 그리기를 통째로 건너뛴 하위 트리 수 더하기. (원본 addCulledSubtreeCount, NodeTree::draw_children 이 보이는 범위 밖 자식을 한꺼번에 건너뛰고 부른다)
  - `culled_subtree_count` u32: 더할 하위 트리 수.
- `pub fn read_local_visible_bounds(&mut self) -> Option<Rect>` (method, since 0.4.0): 보이는 사각형(화면과 걸린 자르기, is_local_rect_visible 과 같은 것)을 지금 변환의 지역 좌표로 거꾸로 옮긴 경계 상자 읽기. (원본 readLocalVisibleBounds)
  - 돌림이나 기울임이 있으면 넉넉하다(네 꼭짓점의 경계 상자, 디바이스 사각형을 한 픽셀씩 넓혀 옮김). 이 사각형 밖에 그리는 것은 보이지 않는다.
  - 노드가 많은 자식 가운데 보이는 범위를 찾을 때 쓴다(NodeTree::draw_children). 변환과 자르기가 같으면 다시 셈하지 않는다.
  - returns Option<Rect>: 지역 좌표의 보이는 경계 상자. 화면 밖 거르기나 하위 트리 거르기가 꺼졌거나, 기즈모를 모두 그리거나, 뷰포트를 아직 정하지 않았거나, 변환을 거꾸로 걸 수 없으면(배율 0) None.

  예제: 두 배로 키운 변환에서는 보이는 사각형이 반이 된다

  ```rust
  use vanilla::Graphic;
  
  fn read_scaled(graphic: &mut Graphic) {
  	if let Some(visible_rect) = graphic.read_local_visible_bounds() {
  		graphic.push_state();
  		graphic.scale(2.0, 2.0);
  		let scaled_rect = graphic.read_local_visible_bounds().expect("visible");
  		assert!((scaled_rect.size.x * 2.0 - visible_rect.size.x).abs() < 1e-9);
  		graphic.pop_state();
  	}
  }
  ```

- `pub fn is_inside_visible_bounds(&self) -> bool` (method, since 0.4.0): 하위 트리가 보이는 사각형(화면과 걸린 자르기) 안에 다 든 노드를 그리는 중인지. (원본 Graphic.isInsideVisibleBounds)
  - 참이면 그 노드의 자손은 화면 밖 견주기 없이 그려도 된다. 그 아래에서 자르기를 새로 걸면 그 자르기 안에서는 거짓이다(다시 견준다).
  - 화면 밖 거르기나 하위 트리 거르기가 꺼졌거나 기즈모를 모두 그리면 거짓.
  - returns bool: 다 안이면 true.

  예제: 그리는 컴포넌트에서 '다 안' 인지 보기

  ```rust
  use vanilla::Graphic;
  
  fn draw_marker(graphic: &mut Graphic) {
  	if graphic.is_inside_visible_bounds() {
  		assert!(graphic.is_subtree_culling_enabled());
  	}
  }
  ```

- `pub fn add_culled_node_count(&mut self, culled_node_count: u32)` (method, since 0.3.2): 이번 프레임에 거른 노드 수 더하기. (NodeTree 가 부른다)
  - `culled_node_count` u32: 더할 노드 수.
- `pub fn get_last_frame_culled_node_count(&self) -> u32` (method, since 0.3.2): 지난 프레임에 화면 밖이라 거른 노드 수.
  - returns u32: 지난 프레임에 거른 노드 수. (begin_frame_statistics 가 넘겨 둔 값)
- `pub fn begin_frame_statistics(&mut self)` (method, since 0.3.2): 프레임 그리기 통계 시작.
  - 엔진이 매 프레임 씬을 그리기 전에 부른다. 지난 프레임의 드로우 콜 / 정점 수를 넘겨 두고 이번 프레임 값을 비운다.
- `pub fn get_last_frame_draw_call_count(&self) -> u32` (method, since 0.3.2): 지난 프레임의 드로우 콜 수.
  - returns u32: 지난 프레임의 드로우 콜 수. (begin_frame_statistics 가 넘겨 둔 값)
- `pub fn get_last_frame_vertex_count(&self) -> u32` (method, since 0.3.2): 지난 프레임에 그린 정점 수.
  - returns u32: 지난 프레임에 그린 정점 수.
- `pub fn get_last_frame_triangle_count(&self) -> u32` (method, since 0.3.2): 지난 프레임에 그린 삼각형 수.
  - returns u32: 지난 프레임의 정점 수를 3 으로 나눈 값.
- `pub fn get_particle_vertex_data(&mut self, minimum_float_count: usize) -> &mut [f32]` (method, since 0.3.2): 파티클 버텍스 기록용 배열 반환. (minimum_float_count 이상, 용량을 넘으면 용량까지)
  - `minimum_float_count` usize: 쓸 플로트 수. (정점 하나에 PARTICLE_FLOATS_PER_VERTEX 개: x, y, u, v, r, g, b, a)
  - returns &mut [f32]: 앞에서부터 minimum_float_count 개의 배열. (용량 정점 8192 개를 넘게 달라면 용량까지, 지난번 값이 남아 있을 수 있다)
- `pub fn draw_colored_quads(&mut self, vertex_count: usize, texture: GlTexture)` (method, since 0.3.2): 정점마다 색을 실은 쿼드 출력. (get_particle_vertex_data 에 기록한 것)
  - `vertex_count` usize: 그릴 정점 수. (쿼드마다 6 개, 용량과 get_particle_vertex_data 로 받은 길이까지만 그린다, 0 이면 아무것도 하지 않는다)
  - `texture` GlTexture: 입힐 텍스처. (get_soft_disc_texture, get_image_texture 같은 것)

  예제: 정점마다 색을 실은 부드러운 원 두 개

  ```rust
  use vanilla::core::graphic::PARTICLE_FLOATS_PER_VERTEX;
  use vanilla::Graphic;
  
  fn draw(graphic: &mut Graphic) {
  	let soft_disc_texture = graphic.get_soft_disc_texture();
  	let particle_list: [(f64, f64, [f64; 4]); 2] = [(100.0, 100.0, [1.0, 0.5, 0.0, 1.0]), (140.0, 120.0, [0.2, 0.6, 1.0, 0.5])];
  	let half_size = 24.0;
  	let corner_list: [[f64; 4]; 6] = [[-half_size, -half_size, 0.0, 0.0], [half_size, -half_size, 1.0, 0.0], [half_size, half_size, 1.0, 1.0], [-half_size, -half_size, 0.0, 0.0], [half_size, half_size, 1.0, 1.0], [-half_size, half_size, 0.0, 1.0]];
  	let vertex_data = graphic.get_particle_vertex_data(particle_list.len() * 6 * PARTICLE_FLOATS_PER_VERTEX);
  	let mut offset = 0;
  	for (center_x, center_y, color) in particle_list {
  		for corner in corner_list {
  			let vertex = [center_x + corner[0], center_y + corner[1], corner[2], corner[3], color[0], color[1], color[2], color[3]];
  			vertex_data[offset..offset + PARTICLE_FLOATS_PER_VERTEX].copy_from_slice(&vertex.map(|value| value as f32));
  			offset += PARTICLE_FLOATS_PER_VERTEX;
  		}
  	}
  	graphic.draw_colored_quads(offset / PARTICLE_FLOATS_PER_VERTEX, soft_disc_texture);
  }
  ```

- `pub fn get_soft_disc_texture(&mut self) -> GlTexture` (method, since 0.3.2): 부드러운 원 텍스처 반환. (가장자리가 잦아드는 64x64 원, 파티클 기본 스프라이트. 지연 생성)
  - GL 텍스처를 만들지 못하면 패닉한다.
  - returns GlTexture: 64 x 64 픽셀 텍스처. (반지름 0.7 까지 꽉 차고 0.7 에서 1 까지 smoothstep 으로 사라지는 흰 원, 프리멀티플라이드)
- `pub fn prepare_image(&mut self, image: &Rc<Image>) -> bool` (method, since 0.4.0): 그림을 GPU 에 미리 올리기. (원본 prepareImage, 처음 그리는 프레임에 올리기가 몰리지 않게 씬을 불러오는 동안 부른다)
  - 지금 이미지 스무딩과 밉맵 설정으로 올린다. (그릴 때 설정이 다르면 그때 거르기만 바꾼다)
  - 이미 올린 그림이면 아무것도 하지 않는다. 크기가 0 인 그림은 올리지 않는다.
  - 코드로 지은 그림(Image::create_from_pixels 같은 것)처럼 ImageAsset 으로 읽지 않은 그림을 씬의 load 에서 올려 둘 때 쓴다.
  - `image` &Rc<Image>: 올릴 그림.
  - returns bool: 텍스처가 있으면 true. (크기가 0 이거나 GL 텍스처를 만들지 못하면 false)

  예제: 씬을 불러오는 동안 코드로 지은 그림을 올려 두기

  ```rust
  use std::rc::Rc;
  use vanilla::{Engine, Image};
  
  fn load(engine: &Engine) -> Rc<Image> {
  	let dot_image = Image::create_from_pixels(32, 32, [255u8, 102, 0, 255].repeat(32 * 32));
  	if let Some(mut graphic) = engine.get_graphic_mut() {
  		let is_prepared = graphic.prepare_image(&dot_image);
  		println!("{}", is_prepared);
  	}
  	dot_image
  }
  ```

- `pub fn prepare_loaded_images(&mut self, time_limit_milliseconds: f64) -> usize` (method, since 0.4.0): 읽었지만 아직 올리지 않은 그림 올리기. (원본 prepareLoadedImages, ImageAsset 과 AssetLoader 가 읽어 푼 그림, 푼 차례로)
  - 엔진이 씬의 맡긴 애셋이 다 읽힌 뒤(로딩 화면 동안) 프레임마다 나눠 부른다. 씬이 따로 부를 일은 없다.
  - 시간 한도를 주면 그 시간을 넘긴 뒤에는 멈추고 남은 수를 돌려준다. (한 번에 적어도 하나는 올린다, 유니티의 asyncUploadTimeSlice 와 같다)
  - 제 것(이 Graphic 을 든 엔진으로 읽은 그림)만 올린다. 주인을 모르는 그림은 Graphic 이 하나뿐일 때만 올린다. (원본과 같음)
  - `time_limit_milliseconds` f64: 이번에 쓸 시간 한도. (밀리초, f64::INFINITY 면 모두)
  - returns usize: 아직 올리지 않고 남은 그림 수. (0 이면 다 올렸다)

  예제: 그림을 읽은 뒤 바로 올리기

  ```rust
  use vanilla::{Engine, ImageAsset};
  
  async fn load(engine: &Engine, image_asset: &mut ImageAsset) {
  	let _ = image_asset.load(engine, "examples/assets/spritesheet.png").await;
  	if let Some(mut graphic) = engine.get_graphic_mut() {
  		let remaining_count = graphic.prepare_loaded_images(f64::INFINITY);
  		println!("{}", remaining_count);
  	}
  }
  ```

- `pub fn get_image_texture(&mut self, image: &Rc<Image>) -> Option<GlTexture>` (method, since 0.3.2): 이미지의 텍스처 반환. (파티클처럼 직접 쿼드를 쓰는 곳에서)
  - `image` &Rc<Image>: 텍스처를 받을 이미지. (처음이면 올리고 CPU 픽셀을 놓는다)
  - returns Option<GlTexture>: 지금 스무딩과 밉맵 설정을 건 텍스처. GL 텍스처를 만들지 못하면 None.
- `pub fn draw_line(&mut self, positions: &[Vector2], size: f64)` (method, since 0.3.2): 선 출력.
  - set_stroke_color()
  - `positions` &[Vector2]: 이을 점들. (2 개 미만이면 그리지 않는다)
  - `size` f64: 선 두께. (픽셀)
- `pub fn draw_line_loop(&mut self, positions: &[Vector2], size: f64)` (method, since 0.3.2): 닫힌 선 출력. (마지막 점과 첫 점을 잇는 루프)
  - set_stroke_color()
  - `positions` &[Vector2]: 이을 점들. (2 개 미만이면 그리지 않는다)
  - `size` f64: 선 두께. (픽셀)
- `pub fn draw_polyline(&mut self, positions: &[Vector2], size: f64, is_closed: bool)` (method, since 0.3.2): 폴리라인 출력. (세그먼트별 두께 확장 쿼드)
  - 내부 조인트는 반두께 연장으로 이음새를 메운다.
  - `positions` &[Vector2]: 이을 점들. (2 개 미만이면 그리지 않는다, 스크래치 배열에 들어가는 선분 682 개까지만 그린다)
  - `size` f64: 선 두께. (픽셀)
  - `is_closed` bool: true 면 마지막 점과 첫 점도 잇는다.
- `pub fn draw_rect(&mut self, rect: Rect)` (method, since 0.3.2): 사각형 출력.
  - set_fill_color()
  - `rect` Rect: 칠할 사각형. (지금 변환 전의 좌표, 픽셀)
- `pub fn draw_stroke_rect(&mut self, rect: Rect, line_width: f64)` (method, since 0.3.2): 사각형 외곽선 출력. (Canvas2D strokeRect 대응, 선 중심이 경계선 위)
  - set_stroke_color()
  - `rect` Rect: 외곽선을 그을 사각형. (픽셀)
  - `line_width` f64: 선 두께. (픽셀, 경계선 양쪽으로 절반씩)
- `pub fn build_round_rect_positions(&self, rect: Rect, round_size: f64) -> [Vector2; ROUND_RECT_POSITION_COUNT]` (method, since 0.3.2): 라운드 사각형 경로 좌표 목록 생성. (시계 방향, 볼록 다각형)
  - `rect` Rect: 사각형. (픽셀)
  - `round_size` f64: 모서리 반지름. (가로세로 가운데 짧은 쪽의 절반을 넘으면 그 값으로 줄인다)
  - returns [Vector2; ROUND_RECT_POSITION_COUNT]: 모서리마다 9 개씩 36 개의 점. (우상, 우하, 좌하, 좌상 모서리 차례)
- `pub fn draw_convex_polygon(&mut self, positions: &[Vector2], color: Color)` (method, since 0.3.2): 볼록 다각형 채움 출력. (첫 점 기준 팬 분할)
  - 정점 버퍼가 차면 쌓인 삼각형을 그리고 비운 뒤 이어 적는다. (점이 많아도 삼각형을 버리지 않는다)
  - `positions` &[Vector2]: 볼록 다각형의 꼭짓점. (3 개 미만이면 그리지 않는다)
  - `color` Color: 칠할 색. (채우기 색은 쓰지 않는다)
- `pub fn draw_round_rect(&mut self, rect: Rect, round_size: f64)` (method, since 0.3.2): 라운드 사각형 출력.
  - set_fill_color()
  - `rect` Rect: 칠할 사각형. (픽셀)
  - `round_size` f64: 모서리 반지름. (0 이하면 draw_rect 와 같다)
- `pub fn draw_stroke_round_rect(&mut self, rect: Rect, round_size: f64, line_width: f64)` (method, since 0.3.2): 라운드 사각형 외곽선 출력.
  - set_stroke_color()
  - `rect` Rect: 외곽선을 그을 사각형. (픽셀)
  - `round_size` f64: 모서리 반지름. (0 이하면 draw_stroke_rect 와 같다)
  - `line_width` f64: 선 두께. (픽셀)
- `pub fn draw_circle(&mut self, center: Vector2, radius: f64)` (method, since 0.3.2): 원 출력.
  - set_fill_color()
  - `center` Vector2: 가운데. (픽셀)
  - `radius` f64: 반지름. (픽셀, 0 이하면 그리지 않는다)
- `pub fn draw_stroke_circle(&mut self, center: Vector2, radius: f64, line_width: f64)` (method, since 0.3.2): 원 외곽선 출력.
  - set_stroke_color()
  - `center` Vector2: 가운데. (픽셀)
  - `radius` f64: 반지름. (픽셀, 0 이하면 그리지 않는다)
  - `line_width` f64: 선 두께. (픽셀, 반지름 양쪽으로 절반씩)
- `pub fn draw_ring(&mut self, center: Vector2, inner_radius: f64, outer_radius: f64, start_radian: f64, end_radian: f64)` (method, since 0.4.0): 고리(띠) 출력. (안쪽 반지름과 바깥 반지름 사이를 start_radian 부터 end_radian 까지 칠한다)
  - set_fill_color()
  - 각도는 라디안, 0 이 오른쪽이고 화면에서 시계 방향으로 는다. (12 시에서 시작하려면 -PI / 2, 한 바퀴는 0 에서 PI * 2)
  - 조각마다 네모 하나를 겹치지 않게 이어 붙여 한 번에 그리므로, 반투명 색이어도 조각의 이음매가 짙어지지 않는다.
  - 조각 수는 draw_circle 처럼 화면에서의 바깥 반지름을 따라 정하고(한 바퀴 16 ~ 64), 그리는 각도만큼만 쓴다.
  - `center` Vector2: 가운데. (픽셀)
  - `inner_radius` f64: 안쪽 반지름. (픽셀, 0 이면 부채꼴)
  - `outer_radius` f64: 바깥 반지름. (픽셀, 0 이하거나 inner_radius 이하면 그리지 않는다)
  - `start_radian` f64: 시작 각도. (라디안)
  - `end_radian` f64: 끝 각도. (라디안, 시작과 같으면 그리지 않는다, 차이는 한 바퀴까지만 쓴다)

  예제: 12 시부터 시계 방향으로 차오르는 진행 고리

  ```rust
  use vanilla::{math, Graphic, Vector2};
  
  fn draw_progress(graphic: &mut Graphic, progress: f64) {
  	let start_radian = -math::PI / 2.0;
  	graphic.set_fill_color("#40c057");
  	graphic.draw_ring(Vector2::create(200.0, 200.0), 40.0, 50.0, start_radian, start_radian + math::PI * 2.0 * progress);
  }
  ```

- `pub fn draw_arc(&mut self, center: Vector2, radius: f64, start_radian: f64, end_radian: f64, line_width: f64)` (method, since 0.4.0): 호 출력. (반지름을 따라 line_width 두께의 선으로 start_radian 부터 end_radian 까지)
  - set_stroke_color()
  - 각도와 조각 수는 draw_ring 과 같다. 선의 두께 가운데가 반지름에 온다.
  - `center` Vector2: 가운데. (픽셀)
  - `radius` f64: 반지름. (픽셀, 선 두께의 가운데)
  - `start_radian` f64: 시작 각도. (라디안)
  - `end_radian` f64: 끝 각도. (라디안)
  - `line_width` f64: 선 두께. (픽셀)
- `pub fn draw_ring_with_color(&mut self, center: Vector2, inner_radius: f64, outer_radius: f64, start_radian: f64, end_radian: f64, color: Color)` (method, since 0.4.0): 고리 출력의 셈. (draw_ring, draw_arc 가 부른다)
  - `center` Vector2: 가운데. (픽셀)
  - `inner_radius` f64: 안쪽 반지름. (픽셀)
  - `outer_radius` f64: 바깥 반지름. (픽셀, 0 이하거나 inner_radius 이하면 그리지 않는다)
  - `start_radian` f64: 시작 각도. (라디안, 0 이 오른쪽)
  - `end_radian` f64: 끝 각도. (라디안, 시작과 같으면 그리지 않는다, 차이는 한 바퀴까지만 쓴다)
  - `color` Color: 칠할 색.
- `pub fn draw_line_segments(&mut self, position_values: &[f64], size: f64)` (method, since 0.4.0): 선분 여럿 출력. (위치 배열 하나에 선분마다 x0, y0, x1, y1 넷씩, 한 번에 그린다)
  - set_stroke_color()
  - 선분마다 두께만큼 넓힌 네모 하나다. (draw_line 과 달리 이음새를 메우지 않는다, 따로 떨어진 선분 용)
  - Vector2 배열을 만들지 않고 숫자 배열을 그대로 읽는다. 길이가 0 인 선분은 건너뛴다.
  - 정점 버퍼가 차면 거기까지 그리고 이어서 담는다. (묶어 그리기가 켜져 있으면 같은 텍스처라 한 번의 드로우 콜로 이어진다)
  - `position_values` &[f64]: 선분마다 x0, y0, x1, y1 넷씩 놓인 숫자 배열. (픽셀, 넷이 안 되는 끝은 버린다, 4 개 미만이면 그리지 않는다)
  - `size` f64: 선 두께. (픽셀)

  예제: 격자 선을 한 번에 그리기

  ```rust
  use vanilla::{Colors, Graphic};
  
  fn draw_grid(graphic: &mut Graphic) {
  	let mut position_values: Vec<f64> = Vec::new();
  	for line_index in 0..=10 {
  		let offset = line_index as f64 * 32.0;
  		position_values.extend_from_slice(&[offset, 0.0, offset, 320.0]);
  		position_values.extend_from_slice(&[0.0, offset, 320.0, offset]);
  	}
  	graphic.set_stroke_color(Colors::WHITE);
  	graphic.draw_line_segments(&position_values, 1.0);
  }
  ```

- `pub fn draw_image(&mut self, image: &Rc<Image>, position: Vector2, content_size: Vector2)` (method, since 0.3.2): 이미지 출력.
  - `image` &Rc<Image>: 그릴 이미지. (채우기 색은 쓰지 않고 틴트와 전역 투명도만 먹는다)
  - `position` Vector2: 왼쪽 위. (픽셀)
  - `content_size` Vector2: 그릴 크기. (픽셀, 이미지 전체를 이 크기로 늘린다)
- `pub fn draw_image_with_image_rect(&mut self, image: &Rc<Image>, position: Vector2, content_size: Vector2, image_rect: Rect)` (method, since 0.3.2): 이미지의 일부만 출력. (image_rect 가 비었으면 전체)
  - `image` &Rc<Image>: 그릴 이미지.
  - `position` Vector2: 왼쪽 위. (픽셀)
  - `content_size` Vector2: 그릴 크기. (픽셀)
  - `image_rect` Rect: 그릴 이미지 영역. (이미지 픽셀, 네 값이 모두 0 이면 전체)
- `pub fn draw_image_with_source_and_destination(&mut self, image: &Rc<Image>, source_x: f64, source_y: f64, source_width: f64, source_height: f64, destination_x: f64, destination_y: f64, destination_width: f64, destination_height: f64)` (method, since 0.3.2): 이미지의 소스 영역을 지정 영역에 출력. (Canvas2D drawImage 9인자 대응)
  - 이미지의 텍스처를 얻지 못하면 그리지 않는다.
  - `image` &Rc<Image>: 그릴 이미지.
  - `source_x` f64: 소스 영역 왼쪽. (이미지 픽셀)
  - `source_y` f64: 소스 영역 위. (이미지 픽셀)
  - `source_width` f64: 소스 영역 너비. (이미지 픽셀)
  - `source_height` f64: 소스 영역 높이. (이미지 픽셀)
  - `destination_x` f64: 그릴 자리 왼쪽. (픽셀)
  - `destination_y` f64: 그릴 자리 위. (픽셀)
  - `destination_width` f64: 그릴 너비. (픽셀)
  - `destination_height` f64: 그릴 높이. (픽셀)
- `pub fn draw_image_with_nine_slice(&mut self, image: &Rc<Image>, position: Vector2, size: Vector2, nine_slice: Rect)` (method, since 0.3.2): 이미지 나인패치 출력.
  - nine_slice 의 position.x / position.y / size.x / size.y 가 각각 왼쪽 / 위 / 오른쪽 / 아래 두께.
  - `image` &Rc<Image>: 그릴 이미지.
  - `position` Vector2: 왼쪽 위. (픽셀, 내림한다)
  - `size` Vector2: 그릴 크기. (픽셀, 올림하고, 양쪽 두께의 합보다 작으면 그 합)
  - `nine_slice` Rect: 네 테두리 두께. (이미지 픽셀이자 그릴 픽셀, 두께가 모두 0 이면 그냥 늘려 그린다)

  예제: 테두리 16 픽셀은 그대로 두고 가운데만 늘린 판

  ```rust
  use std::rc::Rc;
  use vanilla::{Graphic, Image, Rect, Vector2};
  
  fn draw_panel(graphic: &mut Graphic, panel_image: &Rc<Image>) {
  	graphic.draw_image_with_nine_slice(panel_image, Vector2::create(20.0, 20.0), Vector2::create(300.0, 120.0), Rect::create(16.0, 16.0, 16.0, 16.0));
  }
  ```

- `pub fn set_font_string(&mut self, font_string: &str)` (method, since 0.3.2): 폰트 문자열 설정. (Canvas2D font 대응, 예: "16px DOSGothic")
  - `font_string` &str: Canvas2D font 꼴 글. ("bold 16px sans-serif" 처럼, 빈 글이면 바꾸지 않는다)
- `pub fn get_font_string(&self) -> &str` (method, since 0.3.2): 폰트 문자열 반환.
  - returns &str: 지금 폰트 문자열. (처음 "10px sans-serif")
- `pub fn set_text_align(&mut self, text_align: TextAlign)` (method, since 0.3.2): 가로 정렬 설정.
  - `text_align` TextAlign: 가로 정렬. (처음 Start)
- `pub fn get_text_align(&self) -> TextAlign` (method, since 0.3.2): 가로 정렬 반환.
  - returns TextAlign: 지금 가로 정렬.
- `pub fn set_text_direction(&mut self, text_direction: TextDirection)` (method, since 0.4.0): 글자 방향 설정. (원본 setTextDirection, Canvas2D direction 대응)
  - 문단의 방향이다. 글자 안의 순서(양방향 알고리즘)와 정렬 Start / End 의 왼쪽, 오른쪽이 이것을 따른다.
  - Inherit 는 Ltr 로 본다. (기본) Auto 는 문자열마다 처음 나오는 방향이 강한 글자로 정한다. 사용자가 쓴 글(닉네임 등)에 쓴다.
  - `text_direction` TextDirection: 글자 방향. (처음 Inherit)
- `pub fn get_text_direction(&self) -> TextDirection` (method, since 0.4.0): 글자 방향 반환.
  - returns TextDirection: 설정한 글자 방향. (Inherit, Auto 를 풀지 않은 그대로, 실제 방향은 resolve_text_direction)
- `pub fn resolve_text_direction(&self, text: &str) -> TextDirection` (method, since 0.4.0): 문자열의 실제 방향 계산. (Ltr 또는 Rtl, 원본 resolveTextDirection)
  - `text` &str: Auto 일 때 방향을 볼 문자열.
  - returns TextDirection: 설정이 Rtl 이면 Rtl, Auto 면 detect_text_direction(text), 그 밖(Inherit, Ltr)은 Ltr.
- `pub fn resolve_text_align(&self, text_align: TextAlign, text_direction: TextDirection) -> TextAlign` (method, since 0.3.2): 실제 가로 정렬 계산. (Start / End 를 방향에 따라 Left / Right 로, 원본 resolveTextAlign)
  - `text_align` TextAlign: 풀 정렬.
  - `text_direction` TextDirection: 글자 방향. (Rtl 만 오른쪽에서 왼쪽으로 본다)
  - returns TextAlign: Start 는 Rtl 이면 Right, 아니면 Left. End 는 그 반대. 그 밖은 그대로.
- `pub fn set_text_baseline(&mut self, text_baseline: TextBaseline)` (method, since 0.3.2): 세로 기준선 설정.
  - `text_baseline` TextBaseline: 세로 기준선. (처음 Alphabetic)
- `pub fn get_text_baseline(&self) -> TextBaseline` (method, since 0.3.2): 세로 기준선 반환.
  - returns TextBaseline: 지금 세로 기준선.
- `pub fn measure_text(&self, text: &str) -> TextMetrics` (method, since 0.3.2): 문자열 측정. (현재 폰트 문자열 기준)
  - `text` &str: 잴 문자열.
  - returns TextMetrics: 잰 값. (픽셀, 지금 변환은 보지 않는다) 데스크탑에서 그릴 얼굴이 하나도 없으면 모두 0 이다.

  예제: 글 너비에 맞춘 이름표

  ```rust
  use vanilla::{Colors, Graphic, Rect, TextAlign, TextBaseline};
  
  fn draw_label(graphic: &mut Graphic, text: &str) {
  	graphic.set_font_string("20px sans-serif");
  	let text_metrics = graphic.measure_text(text);
  	let padding = 8.0;
  	let box_width = text_metrics.width + padding * 2.0;
  	let box_height = text_metrics.font_ascent + text_metrics.font_descent + padding * 2.0;
  	graphic.set_fill_color(Colors::BLACK);
  	graphic.draw_rect(Rect::create(20.0, 20.0, box_width, box_height));
  	graphic.set_text_align(TextAlign::Left);
  	graphic.set_text_baseline(TextBaseline::Top);
  	graphic.set_fill_color(Colors::WHITE);
  	graphic.draw_fill_text(text, 20.0 + padding, 20.0 + padding);
  }
  ```

- `pub fn measure_text_with_font_string(&self, font_string: &str, text: &str) -> TextMetrics` (method, since 0.4.0): 문자열 측정. (주어진 폰트 문자열 기준, 현재 폰트 문자열은 바꾸지 않는다)
  - `font_string` &str: 잴 때 쓸 폰트 문자열. (Canvas2D font 꼴)
  - `text` &str: 잴 문자열.
  - returns TextMetrics: 잰 값. (픽셀, 지금 변환은 보지 않는다) 데스크탑에서 그릴 얼굴이 하나도 없으면 모두 0 이다.
- `pub fn set_text_bake_scale_step(&mut self, text_bake_scale_step: f64)` (method, since 0.3.2): 텍스트 베이크 스케일 양자화 단위 설정.
  - 기본 0.25. 확대 축소가 잦은 글자가 스케일마다 새로 구워지지 않게 묶는다.
  - 0 이면 양자화하지 않고 실제 스케일 그대로 굽는다.
  - `text_bake_scale_step` f64: 양자화 단위. (0 미만은 0)
- `pub fn get_text_bake_scale_step(&self) -> f64` (method, since 0.3.2): 텍스트 베이크 스케일 양자화 단위 반환.
  - returns f64: 양자화 단위. (처음 0.25)
- `pub fn set_text_bake_motion_scale_step(&mut self, text_bake_motion_scale_step: f64)` (method, since 0.4.0): 배율이 움직이는 노드의 텍스트 베이크 스케일 양자화 단위 설정. (기본 0.25)
  - 양자화 단위(set_text_bake_scale_step)가 0 일 때, 그리는 노드의 변환 배율이 지난 프레임과 다르면(확대 움직임, 팝업, 트윈, 카메라 확대)
    이 단위로 묶은 배율로 굽는다. 프레임마다 다른 배율로 새로 굽지 않는다.
  - 배율이 멈추면(지난 프레임과 같으면) 정확한 배율로 다시 구워 1:1 로 또렷하다.
  - 0 이면 움직이는 동안에도 묶지 않는다. (지금까지와 같다)
  - `text_bake_motion_scale_step` f64: 배율이 움직이는 동안의 양자화 단위. (0 미만은 0)
- `pub fn get_text_bake_motion_scale_step(&self) -> f64` (method, since 0.4.0): 배율이 움직이는 노드의 텍스트 베이크 스케일 양자화 단위 반환.
  - returns f64: 배율이 움직이는 동안의 양자화 단위. (처음 0.25)
- `pub fn set_text_bake_scale_moving(&mut self, is_text_bake_scale_moving: bool)` (method, since 0.4.0): 지금 그리는 노드의 배율이 움직이는 중인지 설정. (NodeTree 가 정한다, 노드 밖에서 직접 그릴 때 부르는 쪽이 정할 수 있다)
  - `is_text_bake_scale_moving` bool: 배율이 움직이는 중이면 true.
- `pub fn is_text_bake_scale_moving(&self) -> bool` (method, since 0.4.0): 지금 그리는 노드의 배율이 움직이는 중인지 반환.
  - returns bool: 움직이는 중으로 정해져 있으면 true.
- `pub fn update_text_bake_scale_moving(&mut self, last_drawn_maximum_scale: f64) -> f64` (method, since 0.4.0): 노드의 변환 배율이 지난 프레임과 달라 움직이는 중인지 셈해 정하고, 노드에 기억할 배율을 돌려준다. (NodeTree 가 push_transform 뒤에 부른다)
  - last_drawn_maximum_scale 은 그 노드를 지난번 그릴 때의 값이다. (0 이면 아직 모른다, 처음 그리는 노드는 움직이지 않는 것으로 본다)
  - 양자화 단위가 0 이 아니면 늘 묶어 굽으므로 셈하지 않고 받은 값을 그대로 돌려준다.
  - `last_drawn_maximum_scale` f64: 그 노드를 지난번 그릴 때 돌려받은 배율. (0 이면 처음)
  - returns f64: 노드에 기억할 배율. (지금 변환의 가장 큰 배율, 양자화 단위가 0 이 아니거나 움직임 단위가 0 이면 받은 값 그대로)
- `pub fn set_text_pixel_snap_enabled(&mut self, is_text_pixel_snap_enabled: bool)` (method, since 0.3.2): 텍스트 픽셀 스냅 설정.
  - 켜면 회전 / 기울임이 없는 변환에서 글자 쿼드의 왼쪽 위를 디바이스 픽셀 격자에 맞춘다.
  - `is_text_pixel_snap_enabled` bool: true 면 글자를 디바이스 픽셀에 맞춘다. (처음 false)
- `pub fn is_text_pixel_snap_enabled(&self) -> bool` (method, since 0.3.2): 텍스트 픽셀 스냅 여부 반환.
  - returns bool: 픽셀 스냅이 켜져 있으면 true.
- `pub fn set_text_antialias_enabled(&mut self, is_text_antialias_enabled: bool)` (method, since 0.4.0): 글자 안티앨리어싱 켬 / 끔. (원본 Graphic.setTextAntialiasEnabled)
  - 끄면 구운 글자의 알파를 문턱값 128 로 0 과 255 로 가르고 텍스처를 NEAREST 로 뽑는다. (도트 글꼴용)
  - 켜고 끈 다음에 굽는 글자부터 적용된다. 이미 구워 둔 글자는 그대로다.
  - `is_text_antialias_enabled` bool: true 면 켠다. (처음 true)
- `pub fn is_text_antialias_enabled(&self) -> bool` (method, since 0.4.0): 글자 안티앨리어싱이 켜져 있는지. (원본 Graphic.isTextAntialiasEnabled)
  - returns bool: 켜져 있으면 true.
- `pub fn calculate_text_bake_scale(&self) -> f64` (method, since 0.3.2): 텍스트 베이크 스케일 계산. (현재 변환 행렬 기반, 양자화 단위는 set_text_bake_scale_step)
  - returns f64: 지금 변환의 가장 큰 배율을 양자화 단위로 반올림한 값. (0.25 ~ 8 로 자른다, 단위가 0 이고 움직이는 중이면 움직임 단위로, 둘 다 0 이면 반올림하지 않는다)
- `pub fn draw_text_entry(&mut self, entry: TextEntry, x: f64, y: f64, color: Option<Color>, text_direction: TextDirection)` (method, since 0.3.2): 글 배치 엔트리를 정렬/베이스라인에 맞춰 글리프 쿼드로 출력.
  - 문자열을 통째로 구웠을 때의 사각형 자리(픽셀 스냅 포함)를 셈하고, 그 안의 글리프 사각형을 아틀라스에서 뽑아 그린다.
  - text_direction 은 정렬 Start / End 를 가를 방향이다. (Ltr 또는 Rtl, 원본 drawTextEntry 의 textDirection)
  - `entry` TextEntry: 글 배치 엔트리. (TextStringTextureCache::get_entry)
  - `x` f64: 기준 x. (가로 정렬의 기준점, 픽셀)
  - `y` f64: 기준 y. (세로 기준선의 기준점, 픽셀)
  - `color` Option<Color>: 곱할 색. (None 이면 흰색, 구운 그대로)
  - `text_direction` TextDirection: 정렬 Start, End 를 가를 방향.
- `pub fn draw_fill_text(&mut self, text: &str, x: f64, y: f64)` (method, since 0.3.2): 텍스트 채움 출력. (Canvas2D fillText 대응)
  - set_fill_color() / set_font_string() / set_text_align() / set_text_baseline()
  - `text` &str: 그릴 문자열. (빈 글이면 그리지 않는다)
  - `x` f64: 기준 x. (set_text_align 의 기준점, 픽셀)
  - `y` f64: 기준 y. (set_text_baseline 의 기준점, 픽셀)
- `pub fn draw_stroke_text(&mut self, text: &str, x: f64, y: f64, line_width: f64)` (method, since 0.3.2): 텍스트 외곽선 출력. (Canvas2D strokeText 대응)
  - set_stroke_color() / set_font_string() / set_text_align() / set_text_baseline()
  - `text` &str: 그릴 문자열. (빈 글이면 그리지 않는다)
  - `x` f64: 기준 x. (set_text_align 의 기준점, 픽셀)
  - `y` f64: 기준 y. (set_text_baseline 의 기준점, 픽셀)
  - `line_width` f64: 외곽선 두께. (픽셀)
- `pub fn begin_clip_rect(&mut self, rect: Rect, round_size: f64)` (method, since 0.3.2): 출력 영역 제한 시작.
  - 스텐실 버퍼 기반이라 회전/스케일이 걸린 영역도 정확히 잘린다.
  - round_size 를 주면 둥근 사각형으로 잘린다.
  - 상태를 push_state 로 쌓으므로 end_clip_rect 와 짝을 맞춰 부른다. (end_clip_rect 가 pop_state 로 되돌린다) 겹쳐 걸면 교집합으로 잘린다.
  - `rect` Rect: 자를 사각형. (지금 변환 기준, 픽셀)
  - `round_size` f64: 모서리 반지름. (0 이하면 네모)

  예제: 둥근 칸 안에만 원 그리기

  ```rust
  use vanilla::{Colors, Graphic, Rect, Vector2};
  
  fn draw(graphic: &mut Graphic) {
  	graphic.begin_clip_rect(Rect::create(100.0, 100.0, 200.0, 100.0), 12.0);
  	graphic.set_fill_color(Colors::WHITE);
  	graphic.draw_circle(Vector2::create(100.0, 100.0), 80.0);
  	graphic.end_clip_rect();
  }
  ```

- `pub fn begin_opacity_layer(&mut self)` (method, since 0.4.0): 투명도 층 시작. (CSS opacity, 어도비 투명도 묶음처럼 end_opacity_layer 까지 그린 것을 따로 칸에 모았다가 지금 전역 알파로 한 번에 얹는다)
  - 층 안의 그림은 서로 겹친 자리가 비치지 않는다. (노드마다 투명도를 곱해 따로 얹으면 겹친 자리에서 아래 그림이 비친다)
  - 층 안은 전역 알파 1 에서 시작한다. 층 칸은 화면과 같은 크기의 RGBA8 이고 깊이를 비우고 스텐실을 지금 자르기 깊이로 채워 둬 층 안의 자르기와 3D 패스(run_external_pass 의 is_depth_cleared 거짓)도 그대로 된다.
    바깥 자르기는 얹을 때 걸린다. 층은 겹쳐 열 수 있다. 칸을 지을 수 없으면 층 없이 그대로 그린다.
  - NodeTree 는 set_opacity_layer 를 켠 노드의 투명도가 1 보다 작으면 그 노드와 자손을 층으로 그린다.

  예제: 겹친 두 사각형을 묶어 반투명하게 (겹친 자리에서 아래 사각형이 비치지 않는다)

  ```rust
  use vanilla::{Graphic, Rect};
  
  fn draw(graphic: &mut Graphic) {
  	graphic.push_state();
  	graphic.set_global_alpha(0.5);
  	graphic.begin_opacity_layer();
  	graphic.set_fill_color("#ff0000");
  	graphic.draw_rect(Rect::create(100.0, 100.0, 200.0, 100.0));
  	graphic.set_fill_color("#0000ff");
  	graphic.draw_rect(Rect::create(200.0, 150.0, 200.0, 100.0));
  	graphic.end_opacity_layer();
  	graphic.pop_state();
  }
  ```

- `pub fn end_opacity_layer(&mut self)` (method, since 0.4.0): 투명도 층 끝. (begin_opacity_layer 뒤에 그린 것을 앞 프레임버퍼에 층을 열 때의 전역 알파로 얹는다)
- `pub fn end_clip_rect(&mut self)` (method, since 0.3.2): 출력 영역 제한 종료.
- `pub fn get_shader_program(&self) -> &ShaderProgram` (method, since 0.3.2): 셰이더 프로그램 반환. (바꿔 끼운 것이 있으면 그것, 없으면 기본 프로그램)
  - returns &ShaderProgram: 바꿔 끼운 프로그램이 있으면 그것, 없으면 기본 프로그램.
- `pub fn set_shader_program_override(&mut self, shader_program: Option<Rc<ShaderProgram>>)` (method, since 0.3.2): 셰이더 프로그램 바꿔 끼우기. (None 이면 기본 프로그램으로 복귀)
  - 기본 프로그램과 같은 어트리뷰트 위치 / 유니폼 이름(projectionMatrix, modelMatrix, mainColor, tintColor, globalAlpha, mainTexture)을 갖춰야 한다.
  - 바꿔 끼운 프로그램이 쓰이는 동안 그 프로그램이 사용 중이다. 효과 유니폼은 바꿔 끼운 바로 뒤에 GL 로 직접 올린다.
  - `shader_program` Option<Rc<ShaderProgram>>: 바꿔 끼울 프로그램. (resolve_shader_program 으로 받는다, None 이면 기본 프로그램)
- `pub fn resolve_shader_program(&mut self, program_group_name: &'static str, program_name: &'static str, create_shader_source: impl FnOnce() -> (String, String)) -> Option<Rc<ShaderProgram>>` (method, since 0.3.2): 이름으로 담아 둔 바꿔 끼울 셰이더 프로그램 반환. (없으면 create_shader_source 가 준 버텍스 / 프래그먼트 소스로 만들어 담는다)
  - 원본 ShaderSprite 의 컨텍스트별 프로그램 캐시 자리. 러스트 판은 GL 컨텍스트를 든 Graphic 이 담는다.
  - 어트리뷰트 위치를 기본 프로그램과 같게 고정해 링크하므로 기본 버텍스 어레이를 그대로 쓴다.
  - 만들기에 실패하면 한 번만 알리고 None 을 담아 두어 다시 만들지 않는다.
  - `program_group_name` &'static str: 묶음 이름. (효과 종류 같은 것, 열쇠의 앞)
  - `program_name` &'static str: 프로그램 이름. (열쇠의 뒤)
  - `create_shader_source` impl FnOnce() -> (String, String): 담긴 것이 없을 때만 부르는 함수. ((버텍스 소스, 프래그먼트 소스), GLSL ES 3.00)
  - returns Option<Rc<ShaderProgram>>: 담아 둔 프로그램. 만들기에 실패했으면 None. (그 뒤로도 None)

  예제: 흑백 셰이더로 바꿔 끼워 그림 그리기

  ```rust
  use std::rc::Rc;
  use vanilla::{Graphic, Image, Vector2};
  
  const GRAY_VERTEXSHADER_SOURCE: &str = "#version 300 es
  in vec2 vertexPosition;
  in vec2 vertexTextureCoordinate;
  uniform mat3 projectionMatrix;
  uniform mat3 modelMatrix;
  out vec2 fragmentTextureCoordinate;
  void main() {
  	vec3 transformedPosition = projectionMatrix * (modelMatrix * vec3(vertexPosition, 1.0));
  	gl_Position = vec4(transformedPosition.xy, 0.0, 1.0);
  	fragmentTextureCoordinate = vertexTextureCoordinate;
  }
  ";
  
  const GRAY_FRAGMENTSHADER_SOURCE: &str = "#version 300 es
  precision highp float;
  in vec2 fragmentTextureCoordinate;
  uniform sampler2D mainTexture;
  uniform vec4 mainColor;
  uniform float globalAlpha;
  out vec4 outputColor;
  void main() {
  	vec4 textureColor = texture(mainTexture, fragmentTextureCoordinate);
  	float gray = dot(textureColor.rgb, vec3(0.299, 0.587, 0.114));
  	float alpha = textureColor.a * mainColor.a * globalAlpha;
  	outputColor = vec4(vec3(gray) * mainColor.a * globalAlpha, alpha);
  }
  ";
  
  fn draw_gray(graphic: &mut Graphic, image: &Rc<Image>) {
  	let shader_program = graphic.resolve_shader_program("example", "gray", || (GRAY_VERTEXSHADER_SOURCE.to_string(), GRAY_FRAGMENTSHADER_SOURCE.to_string()));
  	graphic.set_shader_program_override(shader_program);
  	graphic.draw_image(image, Vector2::create(0.0, 0.0), Vector2::create(128.0, 128.0));
  	graphic.set_shader_program_override(None);
  }
  ```

- `pub fn restore_render_state(&mut self)` (method, since 0.3.2): 렌더 상태 복구. (외부 GL 패스가 프로그램 / 버텍스 어레이 / 뷰포트 / 블렌드를 바꾼 뒤 Graphic 출력을 이어갈 때, 원본 restoreRenderState)
  - 스텐실 자르기 상태는 되돌리지 않는다. (run_external_pass 가 끝에 되돌린다, 원본과 같음)
- `pub fn get_drawing_buffer_width(&self) -> i32` (method, since 0.3.2): 드로잉 버퍼 너비 반환. (픽셀, 원본 webGL2RenderingContext.drawingBufferWidth)
  - returns i32: 마지막 apply_settings 의 드로잉 버퍼 너비. (픽셀)
- `pub fn get_drawing_buffer_height(&self) -> i32` (method, since 0.3.2): 드로잉 버퍼 높이 반환. (픽셀, 원본 webGL2RenderingContext.drawingBufferHeight)
  - returns i32: 마지막 apply_settings 의 드로잉 버퍼 높이. (픽셀)
- `pub fn read_framebuffer_pixels(&self) -> (u32, u32, Vec<u8>)` (method, since 0.3.2): 지금 그린 화면 읽기. (너비, 높이, 위에서 아래로 놓인 RGBA. 화면을 넘기기 전에 부른다)
  - 원본 캔버스처럼 불투명으로 본다. (알파 255)
  - returns (u32, u32, Vec<u8>): (너비, 높이, 픽셀). 픽셀은 위 줄부터 놓인 RGBA 바이트(너비 x 높이 x 4)이고 알파는 모두 255 다. (지금 읽기 프레임버퍼에서 읽는다)
- `pub fn get_color_space(&self) -> crate::core::colorspace::ColorSpace` (method, since 0.4.0): 3D 색 공간 반환. (원본 getColorSpace, 생성 때 정한 값, 엔진 설정의 color_space)
  - returns crate::core::colorspace::ColorSpace: ColorSpace::Gamma 나 ColorSpace::Linear. (2D 묶음은 어느 값이든 감마 공간에서 합성한다)
- `pub fn get_gl(&self) -> &GlContext` (method, since 0.3.2): GL 컨텍스트 반환. (원본 getWebGL2RenderingContext)
  - 받은 컨텍스트(GlContext)의 상태 함수는 GL 상태 캐시를 거치므로, 받은 뒤 바꾼 상태를 엔진이 안다.
    Graphic 은 묶음과 2D 상태를 따로 기억하지 않고 그리기 앞에 상태 캐시에 견주므로, 받은 쪽이 프로그램, 텍스처, 섞기 같은 것을 바꿔도 다음 2D 그리기가 다시 건다.
  - 색 쓰기 마스크는 모든 채널로 되돌려 준다. (데스크탑 기본 프레임버퍼에 알파를 쓰지 않으려 Graphic 이 끈 것)
  - GL 상태 캐시는 잊지 않는다. (원본과 같음, 안의 glow::Context 는 꺼낼 수 없어 받은 쪽이 상태 캐시를 건너뛰지 못한다)
  - returns &GlContext: Graphic 이 든 GL 컨텍스트. 엔진 함수의 `&GlContext` 인자로 그대로 넘긴다. (안의 glow::Context 는 꺼낼 수 없다)
- `pub fn get_current_framebuffer(&self) -> Option<GlFramebuffer>` (method, since 0.4.0): 지금 그리는 프레임 버퍼 반환. (원본 getCurrentFramebuffer, 상태 캐시가 기억한 값, 그리는 중 GL 에 묻지 않는다)
  - returns Option<GlFramebuffer>: 지금 묶인 그리기 프레임 버퍼. 기본 프레임 버퍼(창, 캔버스)면 None.

  예제: 장면에서 지금 프레임 버퍼와 뷰포트 읽기

  ```rust
  use vanilla::Graphic;
  
  fn draw(graphic: &mut Graphic) {
  	let framebuffer = graphic.get_current_framebuffer();
  	let viewport = graphic.get_current_viewport();
  	println!("{} {} {}", framebuffer.is_none(), viewport.get_width(), viewport.get_height());
  	graphic.reset_gl_state_cache();
  }
  ```

- `pub fn get_current_viewport(&self) -> Rect` (method, since 0.4.0): 지금 뷰포트 반환. (원본 getCurrentViewport, 픽셀, 왼쪽 아래가 원점, 상태 캐시가 기억한 값)
  - returns Rect: 뷰포트 사각형. (x, y, 너비, 높이)
- `pub fn reset_gl_state_cache(&self)` (method, since 0.4.0): GL 상태 캐시 잊기. (원본 resetGLStateCache, 상태 캐시를 거치지 않고 GL 상태를 바꾼 뒤 부른다, 다음에 읽을 때 GL 에 한 번씩 묻는다)
  - get_gl, run_external_pass, 툰 렌더러의 콜백이 주는 GlContext 는 상태 함수가 상태 캐시를 거치므로, 같은 콜백 안에서 엔진 그리기를 이어 불러도 부를 것 없다.
  - GlContext 는 안의 glow::Context 를 꺼낼 길이 없어 게임 코드로는 상태 캐시를 건너뛰지 못한다.
    다른 라이브러리가 같은 GL 컨텍스트의 상태를 바꾼 뒤 같은 콜백 안에서 엔진 그리기를 이어 부를 때 부른다.
  - 엔진은 GL 을 넘기는 자리(get_gl, run_external_pass, 툰 렌더러의 콜백)에서 스스로 잊지 않는다. (원본과 같음)
  - 상태 캐시를 거치지 않은 호출을 찾으려면 환경 변수 VANILLA_GL_STATE_CHECK=1 로 돌린다. (엔진 그리기 앞마다 기억한 값과 진짜 GL 을 견주어 어긋난 곳과 앞의 상태 호출을 표준 오류에 남긴다)
- `pub fn is_context_lost(&self) -> bool` (method, since 0.4.0): WebGL 컨텍스트를 잃은 상태인지. (원본 isContextLost, 웹이 webglcontextlost 에서 참이 되고 엔진이 기본 자원을 다시 지은 뒤 거짓이 된다)
  - 잃은 동안 엔진은 그리지 않고 씬 갱신만 한다. 데스크탑은 컨텍스트를 잃지 않아 늘 false 다.
  - returns bool: 잃은 동안 true.

  예제: 잃은 동안 게임이 하던 그리기 건너뛰기

  ```rust
  use vanilla::{Colors, Graphic, Rect};
  
  fn draw(graphic: &mut Graphic) {
  	if graphic.is_context_lost() {
  		return;
  	}
  	graphic.set_fill_color(Colors::WHITE);
  	graphic.draw_rect(Rect::create(8.0, 8.0, 32.0, 32.0));
  }
  ```

- `pub fn enable_gpu_memory_tracking(&self)` (method, since 0.4.0): GPU 메모리 셈 켜기. (원본 Graphic.enableGpuMemoryTracking, 개발용)
  - 켠 뒤에 지은 텍스처, 렌더버퍼, 버퍼부터 센다. 이미 켰으면 아무것도 하지 않는다.
    켜기 전에는 GL 짓기와 크기 정하기 호출이 깃발 하나만 보고 지나가 프레임에 드는 일이 없다. 엔진이 처음 짓는 자원까지 세려면 EngineConfiguration::track_gpu_memory.

  예제: GPU 메모리 셈 켜기

  ```rust
  use vanilla::Graphic;
  
  fn enable(graphic: &Graphic) {
  	graphic.enable_gpu_memory_tracking();
  	assert!(graphic.is_gpu_memory_tracking_enabled());
  }
  ```

- `pub fn is_gpu_memory_tracking_enabled(&self) -> bool` (method, since 0.4.0): GPU 메모리 셈이 켜져 있는지. (원본 Graphic.isGpuMemoryTrackingEnabled)
  - returns bool: 켜져 있으면 true.

  예제: 켜져 있는지 읽기

  ```rust
  use vanilla::Graphic;
  
  fn check(graphic: &Graphic) -> bool {
  	graphic.is_gpu_memory_tracking_enabled()
  }
  ```

- `pub fn read_gpu_memory_usage(&self) -> crate::core::gpumemorytracker::GpuMemoryUsage` (method, since 0.4.0): GPU 메모리 읽기. (원본 Graphic.readGpuMemoryUsage, 개발용)
  - 텍스처, 렌더버퍼, 버퍼가 쓰는 GPU 메모리를 종류별과 주인별로 읽는다. (형식과 크기로 셈한 이름값, 멀티샘플 렌더버퍼는 샘플 수를 곱한다)
    셈이 꺼져 있으면 이 호출이 켜고 그 뒤에 지은 것부터 센다. 처음부터 다 세려면 EngineConfiguration::track_gpu_memory 를 true 로 둔다.
  - returns crate::core::gpumemorytracker::GpuMemoryUsage: 합(캔버스 기본 프레임 버퍼 몫 포함), 캔버스 몫, 종류별 몫, 주인별 몫(큰 것부터, 주인은 지은 호출 스택의 위쪽 세 칸).

  예제: GPU 메모리 합 읽기

  ```rust
  use vanilla::Graphic;
  
  fn read(graphic: &Graphic) {
  	let usage = graphic.read_gpu_memory_usage();
  	println!("{} {}", usage.total_bytes, usage.owner_list.len());
  }
  ```

- `pub fn get_vertex_array(&self) -> GlVertexArray` (method, since 0.4.0): 버텍스 어레이 반환. (기본 그리기의 것, GL 을 만지려면 get_gl 로 컨텍스트를 받는다)
  - returns GlVertexArray: 기본 버텍스 어레이.
- `pub fn get_vertex_buffer(&self) -> GlBuffer` (method, since 0.4.0): 버텍스 버퍼 반환.
  - returns GlBuffer: 기본 버텍스 버퍼.
- `pub fn get_vertex_data(&mut self) -> &mut [f32]` (method, since 0.4.0): 스크래치 버텍스 데이터 반환. (write_quad 와 draw_vertices 가 쓰는 배열)
  - returns &mut [f32]: 스크래치 버텍스 배열. (정점 4096 개, 정점마다 x, y, u, v 플로트 4 개)
- `pub fn get_white_texture(&self) -> GlTexture` (method, since 0.3.2): 흰색 텍스처 반환.
  - returns GlTexture: 1 x 1 흰색 텍스처. (단색 그리기에 쓴다)
- `pub fn get_white_color(&self) -> Color` (method, since 0.3.2): 흰색 반환.
  - returns Color: 흰색. (draw_vertices 에 텍스처 색 그대로 그릴 때 넘긴다)
- `pub fn get_image_texture_cache(&self) -> &ImageTextureCache` (method, since 0.3.2): 이미지 텍스처 캐시 반환.
  - returns &ImageTextureCache: 이미지 텍스처 캐시.
- `pub fn get_text_string_texture_cache(&mut self) -> &mut TextStringTextureCache` (method, since 0.3.2): 문자열 텍스처 캐시 반환. (폰트 등록)
  - returns &mut TextStringTextureCache: 문자열 텍스처 캐시.

## Functions and constants

- `pub const FLOATS_PER_VERTEX: usize = 4` (field, since 0.3.2): 버텍스 1개당 float 수. (x, y, u, v)
  - returns usize
- `pub const PARTICLE_FLOATS_PER_VERTEX: usize = 8` (field, since 0.3.2): 파티클 버텍스 1개당 float 수. (x, y, u, v, r, g, b, a)
  - returns usize
- `pub fn is_right_to_left_character(character: char) -> bool` (method, since 0.4.0): 오른쪽에서 왼쪽으로 쓰는 글자인지. (원본 RIGHT_TO_LEFT_CHARACTER_PATTERN: 히브리어, 아랍어, 시리아어, 타나, 은코 등과 그 표현형)
  - `character` char: 볼 글자.
  - returns bool: 코드 포인트가 U+0590 ~ U+08FF, U+FB1D ~ U+FDFF, U+FE70 ~ U+FEFF, U+10800 ~ U+10FFF, U+1E800 ~ U+1EFFF 안이면 true.
- `pub fn detect_text_direction(text: &str) -> TextDirection` (method, since 0.4.0): 글의 첫 강한 방향. (원본 resolveTextDirection 의 "auto": 글자 갈래 문자와 LRM, RLM, ALM 가운데 처음 것, 없으면 Ltr)
  - `text` &str: 볼 문자열.
  - returns TextDirection: 처음 나오는 강한 글자(글자 갈래 문자와 LRM, RLM, ALM)가 오른쪽에서 왼쪽 글자나 RLM(U+200F), ALM(U+061C)이면 Rtl, 그 밖이면 Ltr. 강한 글자가 없으면 Ltr.

  예제: 숫자와 기호는 건너뛰고 첫 글자로 정한다

  ```rust
  use vanilla::{detect_text_direction, TextDirection};
  
  assert_eq!(detect_text_direction("Hello"), TextDirection::Ltr);
  assert_eq!(detect_text_direction("123 \u{05E9}\u{05DC}\u{05D5}\u{05DD}"), TextDirection::Rtl);
  assert_eq!(detect_text_direction("\u{200F}abc"), TextDirection::Rtl);
  assert_eq!(detect_text_direction("2024!"), TextDirection::Ltr);
  ```

## BlendMode (enum) (Clone, Copy, Debug, PartialEq, Eq, Hash)

블렌드 모드. (원본 SpriteBlendMode, Canvas2D globalCompositeOperation 대응)
- 26 가지 모두 그린다. 13 가지(포터 더프 연산자, Lighter, Multiply, Screen)는 고정 블렌딩, 나머지 13 가지는 그릴 영역 아래를 떠 와 셰이더로 섞는다. (원본과 같음)
- Canvas2D 는 SourceIn, SourceOut, DestinationIn, DestinationAtop, Copy 가 그린 도형 밖(자르기 안 전체)도 지우지만, Graphic 은 그린 도형 안만 바꾼다. (원본과 같음)

- `Normal`: 기본 알파 합성. ("source-over", 고정 블렌딩)
- `SourceIn`: 바탕과 겹친 곳만 그린다. ("source-in", 바탕 알파를 마스크로, 고정 블렌딩)
- `SourceOut`: 바탕과 겹치지 않은 곳만 그린다. ("source-out", 고정 블렌딩)
- `SourceAtop`: 바탕 위의 겹친 곳에만 합성한다. ("source-atop", 고정 블렌딩)
- `DestinationOver`: 바탕 아래에 합성한다. ("destination-over", 고정 블렌딩)
- `DestinationIn`: 바탕에서 겹친 곳만 남긴다. ("destination-in", 고정 블렌딩)
- `DestinationOut`: 바탕에서 겹치지 않은 곳만 남긴다. ("destination-out", 고정 블렌딩)
- `DestinationAtop`: 겹친 곳은 바탕을 남기고, 바탕이 없는 곳은 그린 것을 둔다. ("destination-atop", 고정 블렌딩)
- `Lighter`: 색을 더한다. ("lighter", 고정 블렌딩)
- `Copy`: 바탕을 보지 않고 그린 것만 둔다. ("copy", 고정 블렌딩)
- `Xor`: 겹친 곳을 빼고 둘 다 둔다. ("xor", 고정 블렌딩)
- `Multiply`: 곱하기 합성. ("multiply", 어두워진다, 기본 프레임버퍼는 고정 블렌딩, 렌더 타겟은 셰이더 섞기)
- `Screen`: 스크린 합성. ("screen", 밝아진다, 고정 블렌딩)
- `Overlay`: 오버레이. ("overlay", 명암을 키운다, 셰이더 섞기)
- `Darken`: 어두운 쪽을 고른다. ("darken", 셰이더 섞기)
- `Lighten`: 밝은 쪽을 고른다. ("lighten", 셰이더 섞기)
- `ColorDodge`: 컬러 닷지. ("color-dodge", 밝아진다, 셰이더 섞기)
- `ColorBurn`: 컬러 번. ("color-burn", 어두워진다, 셰이더 섞기)
- `HardLight`: 하드 라이트. ("hard-light", 셰이더 섞기)
- `SoftLight`: 소프트 라이트. ("soft-light", 셰이더 섞기)
- `Difference`: 차이 합성. ("difference", 셰이더 섞기)
- `Exclusion`: 대비가 낮은 차이 합성. ("exclusion", 셰이더 섞기)
- `Hue`: 그린 것의 색조에 바탕의 채도와 밝기. ("hue", 셰이더 섞기)
- `Saturation`: 그린 것의 채도에 바탕의 색조와 밝기. ("saturation", 셰이더 섞기)
- `Color`: 그린 것의 색조와 채도에 바탕의 밝기. ("color", 셰이더 섞기)
- `Luminosity`: 그린 것의 밝기에 바탕의 색조와 채도. ("luminosity", 셰이더 섞기)

- `pub fn get_name(&self) -> &'static str` (method, since 0.3.2): 원본 이름 반환. ("source-over" 같은 문자열)
  - returns &'static str: 원본 globalCompositeOperation 이름. (Normal 은 "source-over")
- `pub fn from_name(name: &str) -> Option<BlendMode>` (static, since 0.3.2): 원본 이름으로 찾기. (모르는 이름이면 None. 타임라인, 파티클 서술처럼 JSON 에서 읽을 때 쓴다)
  - `name` &str: 원본 globalCompositeOperation 이름. ("multiply" 처럼 소문자와 하이픈, 대소문자를 가린다)
  - returns Option<BlendMode>: 이름에 맞는 블렌드 모드. 모르는 이름이면 None.

  예제: JSON 의 이름 글을 블렌드 모드로

  ```rust
  use vanilla::BlendMode;
  
  assert_eq!(BlendMode::from_name("multiply"), Some(BlendMode::Multiply));
  assert_eq!(BlendMode::from_name("source-over"), Some(BlendMode::Normal));
  assert_eq!(BlendMode::from_name("unknown"), None);
  assert_eq!(BlendMode::ColorDodge.get_name(), "color-dodge");
  ```

## TextAlign (enum) (Clone, Copy, Debug, PartialEq, Eq)

가로 정렬.

- `Left`: 왼쪽 맞춤. (x 가 글의 왼쪽 끝)
- `Center`: 가운데 맞춤. (x 가 글의 가로 가운데)
- `Right`: 오른쪽 맞춤. (x 가 글의 오른쪽 끝)
- `Start`: 글 방향의 시작 쪽 맞춤. (Ltr 은 왼쪽, Rtl 은 오른쪽, Graphic 의 처음 값)
- `End`: 글 방향의 끝 쪽 맞춤. (Ltr 은 오른쪽, Rtl 은 왼쪽)

## TextBaseline (enum) (Clone, Copy, Debug, PartialEq, Eq)

세로 기준선.

- `Top`: 위 끝 기준. (y 가 글꼴 어센트의 위 끝)
- `Middle`: 가운데 기준. (y 가 어센트 위 끝과 디센트 아래 끝의 가운데)
- `Bottom`: 아래 끝 기준. (y 가 글꼴 디센트의 아래 끝)
- `Ideographic`: 표의 문자 기준선. (Bottom 과 같이 y 가 디센트의 아래 끝)
- `Hanging`: 매달린 기준선. (y 가 기준선에서 어센트의 0.8 배 위)
- `Alphabetic`: 알파벳 기준선. (y 가 기준선, Graphic 의 처음 값)

## TextDirection (enum) (Clone, Copy, Debug, PartialEq, Eq, Hash)

글자 방향. (원본 "inherit" | "ltr" | "rtl" | "auto", Canvas2D direction)
- Inherit 는 Graphic 에서는 왼쪽에서 오른쪽으로 본다. 글자 컴포넌트에서는 그리는 때의 Graphic 방향을 따른다는 뜻이다.
- Auto 는 문자열마다 처음 나오는 방향이 강한 글자로 정한다. (HTML 의 dir="auto", 없으면 왼쪽에서 오른쪽)

- `Inherit`: 물려받기. (Graphic 의 처음 값, Graphic 에서는 Ltr 로 본다)
- `Ltr`: 왼쪽에서 오른쪽.
- `Rtl`: 오른쪽에서 왼쪽.
- `Auto`: 문자열마다 처음 나오는 방향이 강한 글자로 정한다. (없으면 Ltr)

- `pub fn from_name(name: &str) -> TextDirection` (static, since 0.4.0): 원본 글로 읽기. ("ltr", "rtl", "auto", 그 밖은 Inherit)
  - `name` &str: 원본 글. ("inherit", "ltr", "rtl", "auto", 대소문자를 가린다)
  - returns TextDirection: 읽은 방향. 모르는 글이면 Inherit.
- `pub fn get_name(&self) -> &'static str` (method, since 0.4.0): 원본 글. ("inherit", "ltr", "rtl", "auto")
  - returns &'static str: 원본 글. ("inherit", "ltr", "rtl", "auto" 가운데 하나)
- `pub fn to_shaping_direction(&self) -> ShapingDirection` (method, since 0.4.0): 모양 짓기 방향. (Rtl 만 오른쪽에서 왼쪽, 실제 방향으로 푼 뒤에 쓴다)
  - returns ShapingDirection: Rtl 이면 `ShapingDirection::RightToLeft`, 그 밖(Inherit, Auto 포함)은 `ShapingDirection::LeftToRight`.

## ImageSmoothingQuality (enum) (Clone, Copy, Debug, PartialEq, Eq)

이미지 스무딩 퀄리티. (원본 setImageSmoothingQuality 의 "low", "medium", "high")
- GL 은 LINEAR / NEAREST 둘뿐이라 원본처럼 보관만 한다.

- `Low`: 낮음. ("low")
- `Medium`: 중간. ("medium")
- `High`: 높음. ("high", Graphic 의 처음 값)
