resize#
Interfaces#
Delta#
Defined in: arranger/src/resize.ts:60
A pointer’s travel in canvas units.
Properties#
dx#
readonlydx:number
Defined in: arranger/src/resize.ts:61
dy#
readonlydy:number
Defined in: arranger/src/resize.ts:62
Solved#
Defined in: arranger/src/resize.ts:76
What solve found: the value and the result of the function there.
Type Parameters#
R#
R
Properties#
result#
readonlyresult:R
Defined in: arranger/src/resize.ts:78
value#
readonlyvalue:number
Defined in: arranger/src/resize.ts:77
Type Aliases#
Handle#
Handle =
"top-left"|"top"|"top-right"|"right"|"bottom-right"|"bottom"|"bottom-left"|"left"
Defined in: arranger/src/resize.ts:19
A resize handle: one of a box’s four corners or four sides.
ResizeMode#
ResizeMode =
"scale"|"box"|"stretch"
Defined in: arranger/src/resize.ts:16
How a resize handle resizes a block: scale the drawing, size the box, or stretch the content.
Variables#
ALL_HANDLES#
constALL_HANDLES: readonlyHandle[]
Defined in: arranger/src/resize.ts:42
All eight handles, clockwise from the top-left corner.
SIDES#
constSIDES: { readonly [handle in Handle]: readonly [-1 | 0 | 1, -1 | 0 | 1] }
Defined in: arranger/src/resize.ts:30
Each handle’s horizontal and vertical side: −1 left or top, 1 right or bottom, 0 neither.
Functions#
blockStretchPlaces()#
blockStretchPlaces(
block,length):Places
Defined in: arranger/src/resize.ts:289
The places of block stretched along time to length: every stated x,
length and width, an item’s and a member’s card’s alike, scaled by
the ratio of the lengths, quantized to GRID_FREE, and every other
member kept (a container’s spacing and margin are its own, never a
factor of the block’s), so a stretch scales the items’ and cards’ sizes and
distances along time and keeps their arrangement. The block’s own
places object when nothing changes.
Parameters#
block#
Pick<Block, "length" | "places">
length#
number
Returns#
handlesFor()#
handlesFor(
mode): readonlyHandle[]
Defined in: arranger/src/resize.ts:55
The handles a mode offers: the corners to scale, all eight to size or stretch.
Parameters#
mode#
Returns#
readonly Handle[]
kept()#
kept(
request,content,stretched):number|null
Defined in: arranger/src/resize.ts:145
The size request after a stretch that took the content from content to
stretched on one axis: a request larger than the content keeps its
proportion to the content, request × stretched ÷ content (multiplied
first), so every margin it adds stretches with the content; one at or
below the content draws nothing and becomes null.
Parameters#
request#
number | null
content#
number
stretched#
number
Returns#
number | null
resize()#
resize(
block,graphical,metrics,mode,handle,delta,pane?):object
Defined in: arranger/src/resize.ts:177
The placement values that resize block by dragging handle by delta:
the dragged edge of its node ends under the pointer and the opposite edge
stays put. Every number is quantized to GRID_FREE, never to the grid:
for a left or top handle the node’s new left or top edge is the opposite
edge less the achieved size, and the stored x or y is that edge’s
place origin (nodePosition inverted, with the resized drawing’s origin).
scale(corners only) setsscaleto the larger of the two axis ratios, floored atMIN_SCALE.boxsetswidthandheight; a request at or below the content’s own extent storesnull, the content’s size.stretchsetslengthfrom a left or right handle and, from a top or bottom one,spacing, the gap between the items at their defaulty, ormarginfor a block of one item, which has no gap (verticalStretchOf): the largest value whose box does not pass the pointer, floored atMIN_LENGTHand at 0; a shrink past a flat piece stops at its knee. The block follows the content on each axis (kept): awidthorheightlarger than the content keeps its proportion to it, one at or below the content becomesnull, andnullstays. So the edge ends under the pointer with or without a size request, and a pointer moved back always finds a smaller value. Along time the stated places stretch with the content (blockStretchPlaces), so the items keep their arrangement;placesis set when they change. Vertically every statedyandheightis kept.
Parameters#
block#
graphical#
Graphical
metrics#
FontMetrics
mode#
handle#
delta#
pane?#
Returns#
object
values#
values:
Partial<Block>
resizeCommand()#
resizeCommand(
block,values):SetCommand|null
Defined in: arranger/src/resize.ts:340
The set storing a resize’s values on its block: the block’s own members
in one change, then the place of every item in values.places in one
change each, as placeChange writes it. null when every value is the block’s own
(places its own object, as blockStretchPlaces keeps it): a resize that
changes no stored value is no command, like a drag that ends where it began.
Parameters#
block#
values#
Partial<Block>
Returns#
SetCommand | null
solve()#
solve<
R>(f,extent,start,target,floor):Solved<R>
Defined in: arranger/src/resize.ts:95
The largest multiple of GRID_FREE, at least floor, at which the
non-decreasing extent of f (extent of its result) is at most target,
with f’s result there. A target below the smallest extent, at floor,
is raised to it, so a shrink beyond a flat piece stops at the knee where
the extent starts to grow, never at the floor. An extent that never grows
past the target leaves start.
Search over the lattice: a Newton guess from start (the slope over one
step) and its neighbour, which settle an affine piece in four
evaluations, then bisection between the largest value known to fit and
the smallest known not to. f is evaluated at most once per lattice
point.
Type Parameters#
R#
R
Parameters#
f#
(x) => R
extent#
(result) => number
start#
number
target#
number
floor#
number
Returns#
Solved<R>