vanilladocs
vanillapunch.com
API / ui/autolayout/layoutterm

ui/autolayout/layoutterm

식의 한 항. coefficient * variable.

A term of an expression. coefficient * variable.

LayoutTerm

짝Counterpart: vanilla-engine LayoutTerm

식의 한 항. coefficient * variable.

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

A term of an expression. coefficient * variable.

  • A component of LayoutExpression.
  • Immutable object. Arithmetic operations always return a new instance.
예제Example계수 0.5 인 항으로 가운데 식 만들기Build a center expression with a term of coefficient 0.5
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);
생성자constructorconstructor(variable, coefficient)#0.2.1 부터since 0.2.1소스source

생성.

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

메서드methodgetVariable()#0.2.1 부터since 0.2.1소스source

변수 반환.

Returns the variable.

반환ReturnsLayoutVariable | null 항의 변수. (없으면 null)Variable of the term. (null if none)

짝Counterpart: vanilla-engine LayoutTerm.get_variable

메서드methodgetCoefficient()#0.2.1 부터since 0.2.1소스source

계수 반환.

Returns the coefficient.

반환Returnsnumber 계수.Coefficient.

짝Counterpart: vanilla-engine LayoutTerm.get_coefficient

메서드methodgetValue()#0.2.1 부터since 0.2.1소스source

평가값 (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