# ui/autolayout/layoutterm (vanilla-engine 0.4.0)

> https://vanillapunch.com/docs/vanilla-engine/0.4.0/api/ui/autolayout/layoutterm/

식의 한 항. (원본 ui/autolayout/layoutterm.js 의 LayoutTerm, coefficient * variable)
- LayoutExpression 을 이루는 값이다. 바뀌지 않는다.
- 원본과 다른 것:
  - 원본은 변수 없이(null, 값 0) 만들 수 있고 솔버는 그런 항을 건너뛴다. 러스트 판은 늘 변수를 받아 그런 항이 없다.
  - 생략할 수 있던 coefficient(기본 1)는 꼭 받는다.

## LayoutTerm (struct) (Clone, Debug)

식의 한 항.

예제: 너비의 절반 항으로 식 만들기

```rust
use vanilla::{LayoutExpression, LayoutTerm, LayoutVariable};

let width = LayoutVariable::new("width");
width.set_value(80.0);
let half_width = LayoutTerm::new(width.clone(), 0.5);
assert_eq!(half_width.get_variable(), &width);
assert_eq!(half_width.get_value(), 40.0);

let expression = LayoutExpression::from(half_width).add(10);
assert_eq!(expression.get_value(), 50.0);
```

- `pub fn new(variable: LayoutVariable, coefficient: f64) -> LayoutTerm` (constructor, since 0.4.0): 생성.
  - `variable` LayoutVariable: 항의 변수. (핸들을 그대로 쥔다)
  - `coefficient` f64: 변수에 곱할 계수.
  - returns LayoutTerm: 새 항.
- `pub fn get_variable(&self) -> &LayoutVariable` (method, since 0.4.0): 변수 반환.
  - returns &LayoutVariable: 항이 쥔 변수 핸들의 참조.
- `pub fn get_coefficient(&self) -> f64` (method, since 0.4.0): 계수 반환.
  - returns f64: 계수.
- `pub fn get_value(&self) -> f64` (method, since 0.4.0): 평가 값 반환. (coefficient * 변수 값)
  - returns f64: 계수 * 변수의 지금 값.
