vanilladocs
vanillapunch.com
API / ui/autolayout/layoutterm

ui/autolayout/layoutterm

식의 한 항. (원본 ui/autolayout/layoutterm.js 의 LayoutTerm, coefficient * variable)

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

One term of an expression. (LayoutTerm of the original ui/autolayout/layoutterm.js, coefficient * variable)

  • A value making up a LayoutExpression. It does not change.
  • Differences from the original:
  • The original can be created without a variable (null, value 0) and the solver skips such terms. The Rust version always takes a variable, so there are no such terms.
  • coefficient, which could be omitted (default 1), is required.

LayoutTermstruct traits Clone, Debug

짝Counterpart: vanilla.js LayoutTerm소스source

식의 한 항.

One term of an expression.

예제Example너비의 절반 항으로 식 만들기Building an expression from a half-width term
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);
생성자constructorpub fn new(variable: LayoutVariable, coefficient: f64) -> LayoutTerm#0.4.0 부터since 0.4.0소스source

생성.

Constructor.

variableLayoutVariable
항의 변수. (핸들을 그대로 쥔다)The term's variable. (holds the handle as is)
coefficientf64
변수에 곱할 계수.Coefficient to multiply the variable by.

반환ReturnsLayoutTerm 새 항.New term.

짝Counterpart: vanilla.js LayoutTerm.constructor

메서드methodpub fn get_variable(&self) -> &LayoutVariable#0.4.0 부터since 0.4.0소스source

변수 반환.

Returns the variable.

반환Returns&LayoutVariable 항이 쥔 변수 핸들의 참조.Reference to the variable handle the term holds.

짝Counterpart: vanilla.js LayoutTerm.getVariable

메서드methodpub fn get_coefficient(&self) -> f64#0.4.0 부터since 0.4.0소스source

계수 반환.

Returns the coefficient.

반환Returnsf64 계수.Coefficient.

짝Counterpart: vanilla.js LayoutTerm.getCoefficient

메서드methodpub fn get_value(&self) -> f64#0.4.0 부터since 0.4.0소스source

평가 값 반환. (coefficient * 변수 값)

Returns the evaluated value. (coefficient * variable value)

반환Returnsf64 계수 * 변수의 지금 값.Coefficient * current variable value.

짝Counterpart: vanilla.js LayoutTerm.getValue