# ui/autolayout/layoutterm (vanilla.js 0.4.0)

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

식의 한 항. coefficient * variable.

## LayoutTerm

식의 한 항. coefficient * variable.
- LayoutExpression 의 구성 요소.
- 불변 객체. 산술 연산은 항상 새 인스턴스를 반환한다.

예제: 계수 0.5 인 항으로 가운데 식 만들기

```js
import { LayoutSolver, LayoutVariable, LayoutTerm, LayoutExpression } from "./build/vanilla.js";

const width = new LayoutVariable("width");
const halfWidth = new LayoutTerm(width, 0.5);
const centerExpression = new LayoutExpression([halfWidth], 10);
const solver = new LayoutSolver();
const widthExpression = LayoutExpression.fromVariable(width);
const widthConstraint = widthExpression.equalTo(300);
solver.addConstraint(widthConstraint);
solver.updateVariables();
const termValue = halfWidth.getValue();
const centerValue = centerExpression.getValue();
console.log(termValue, centerValue);
```

- `constructor(variable, coefficient)` (constructor, since 0.2.1): 생성.
  - `variable` LayoutVariable: 항의 변수. (undefined 나 null 이면 null 로 두고 값은 0, 솔버는 이런 항을 건너뛴다)
  - `coefficient` number: 계수. (숫자가 아니면 1)
- `getVariable()` (method, since 0.2.1): 변수 반환.
  - returns LayoutVariable | null: 항의 변수. (없으면 null)
- `getCoefficient()` (method, since 0.2.1): 계수 반환.
  - returns number: 계수.
- `getValue()` (method, since 0.2.1): 평가값 (coefficient * variable.value) 반환. variable 이 없으면 0.
  - returns number: coefficient * 변수 값. (변수가 없으면 0)
