Length
class Length
Data type, represents length and percent units as they used in CSS.
JavaScript in Sciter is extended to support length literals, so these are valid declarations:
const width = 12px;
const fontSize = 10pt;
Length literals are JS numbers immediately follwoed by unit charactes.
List of supported units, standard CSS units:
pxptemchremexincmmmpcvwvhvminvmaxpct
Sciter specific units
ppx- physical pixels, always integer number.dip- device independent pixel (1/96 of inch(n):lengthpxanddipare equivalents in default Sciter configuration.fx- Sciter's flex units.style.width = 1fxin script is equivalent towidth:1*(or justwidth:*) in CSS.
properties:
length.quantity:number
reports number of units in the length. For 12px it will return 12.
length.units:string
reports unit name. For 12px it will return "px".
methods:
length.valueOf():number
returns number of pixels.
length.toString():number
returns string representation.
operators:
Length units support following operators:
a * n- multiplication by number;a / n- division by number;a + b- sum of two lengths;a - b- substraction of two lengths;a == b- equality of two lengths;a < b,a > b,a <= b,a >= b- comparison of two lengths;+a- unary plus operator;-a- unary minus operator;++a,a++- increment operator;--a,a--- decrement operator;
static methods:
Length.px(n):lengthLength.em(n):lengthLength.ex(n):lengthLength.pct(n):lengthLength.fx(n):lengthLength.in(n):lengthLength.cm(n):lengthLength.mm(n):lengthLength.pt(n):lengthLength.pc(n):lengthLength.dip(n):lengthLength.percentOfWidth(n):lengthLength.percentOfHeight(n):lengthLength.vw(n):lengthLength.vh(n):lengthLength.vmin(n):lengthLength.vmax(n):lengthLength.rem(n):lengthLength.ppx(n):lengthLength.ch(n):lengthThese function above are static constructors of length values.
Length.morph(from:Length,to:Length,ratio:0...1[,element]):lengthMorph from length into to length value according to ratio. If ratio == 0.0 it returns from and if ratio == 1.0 it returns to value.