ui/autolayout/layoutterm
식의 한 항. coefficient * variable.
A term of an expression. coefficient * variable.
LayoutTerm
식의 한 항. coefficient * variable.
- LayoutExpression 의 구성 요소.
- 불변 객체. 산술 연산은 항상 새 인스턴스를 반환한다.
A term of an expression. coefficient * variable.
- A component of LayoutExpression.
- Immutable object. Arithmetic operations always return a new instance.
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.
- variableLayoutVariable
- 항의 변수. (undefined 나 null 이면 null 로 두고 값은 0, 솔버는 이런 항을 건너뛴다)Variable of the term. (undefined or null is kept as null and the value is 0, the solver skips such terms)
- coefficientnumber
- 계수. (숫자가 아니면 1)Coefficient. (1 if not a number)
짝Counterpart: vanilla-engine LayoutTerm.new
변수 반환.
Returns the variable.
반환ReturnsLayoutVariable | null 항의 변수. (없으면 null)Variable of the term. (null if none)
짝Counterpart: vanilla-engine LayoutTerm.get_variable
계수 반환.
Returns the coefficient.
반환Returnsnumber 계수.Coefficient.
짝Counterpart: vanilla-engine LayoutTerm.get_coefficient
평가값 (coefficient * variable.value) 반환. variable 이 없으면 0.
Returns the evaluated value (coefficient * variable.value). 0 if there is no variable.
반환Returnsnumber coefficient * 변수 값. (변수가 없으면 0)coefficient * variable value. (0 if there is no variable)
짝Counterpart: vanilla-engine LayoutTerm.get_value