| License | BSD3-style (see the file LICENSE) |
|---|---|
| Safe Haskell | None |
| Language | Haskell2010 |
Miso.Flow.Utils.General
Description
Pure port of utils/general.ts from @xyflow/system: clamping,
box/rect algebra, viewport math and getViewportForBounds.
Synopsis
- clamp :: Double -> Double -> Double -> Double
- clampPosition :: XYPosition -> CoordinateExtent -> Dimensions -> XYPosition
- clampPositionToParent :: XYPosition -> Dimensions -> InternalNode n -> XYPosition
- calcAutoPanVelocity :: Double -> Double -> Double -> Double
- calcAutoPan :: XYPosition -> Dimensions -> Double -> Double -> (Double, Double)
- getBoundsOfBoxes :: Box -> Box -> Box
- rectToBox :: Rect -> Box
- boxToRect :: Box -> Rect
- nodeToRect :: Node n -> NodeOrigin -> Rect
- internalNodeToRect :: InternalNode n -> Rect
- nodeToBox :: Node n -> NodeOrigin -> Box
- internalNodeToBox :: InternalNode n -> Box
- getBoundsOfRects :: Rect -> Rect -> Rect
- getRectsOverlappingArea :: Double -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> Double
- getOverlappingArea :: Rect -> Rect -> Double
- isNumeric :: Double -> Bool
- snapPosition :: XYPosition -> SnapGrid -> XYPosition
- pointToRendererPoint :: XYPosition -> Transform -> Bool -> SnapGrid -> XYPosition
- rendererPointToPoint :: XYPosition -> Transform -> XYPosition
- parsePadding :: PaddingWithUnit -> Double -> Double
- data ParsedPaddings = ParsedPaddings {}
- parsePaddings :: Padding -> Double -> Double -> ParsedPaddings
- getViewportForBounds :: Rect -> Double -> Double -> Double -> Double -> Padding -> Viewport
- getNodeDimensions :: Node n -> Dimensions
- getInternalNodeDimensions :: InternalNode n -> Dimensions
- nodeHasDimensions :: Node n -> Bool
- evaluateAbsolutePosition :: XYPosition -> Maybe Dimensions -> NodeId -> NodeLookup n -> NodeOrigin -> XYPosition
Documentation
clampPosition :: XYPosition -> CoordinateExtent -> Dimensions -> XYPosition Source #
Clamp a position into a CoordinateExtent, accounting for the
element's dimensions.
clampPositionToParent :: XYPosition -> Dimensions -> InternalNode n -> XYPosition Source #
Clamp a child position into the bounds of its parent node.
calcAutoPanVelocity :: Double -> Double -> Double -> Double Source #
Velocity (-1..1) of auto panning when the pointer is close to a pane
edge. calcAutoPanVelocity value min max.
Arguments
| :: XYPosition | pointer position |
| -> Dimensions | pane bounds |
| -> Double | speed (original default: 15) |
| -> Double | distance (original default: 40) |
| -> (Double, Double) |
X/Y auto-pan movement for the given pointer position and pane bounds. Speed defaults to 15, edge distance to 40 in the original.
nodeToRect :: Node n -> NodeOrigin -> Rect Source #
Bounding rect of a user node (positioned by origin). Port of
nodeToRect for the non-internal case.
internalNodeToRect :: InternalNode n -> Rect Source #
Bounding rect of an internal node (uses positionAbsolute). Port of
nodeToRect for the internal case.
internalNodeToBox :: InternalNode n -> Box Source #
getRectsOverlappingArea :: Double -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> Double Source #
snapPosition :: XYPosition -> SnapGrid -> XYPosition Source #
Arguments
| :: XYPosition | |
| -> Transform | |
| -> Bool | snap to grid |
| -> SnapGrid | |
| -> XYPosition |
Screen point → flow point, optionally snapped to grid.
rendererPointToPoint :: XYPosition -> Transform -> XYPosition Source #
Flow point → screen point.
parsePadding :: PaddingWithUnit -> Double -> Double Source #
Resolve a single padding value to pixels; parsePadding padding viewport
where viewport is the relevant viewport dimension.
data ParsedPaddings Source #
Constructors
| ParsedPaddings | |
Instances
| Show ParsedPaddings Source # | |
Defined in Miso.Flow.Utils.General Methods showsPrec :: Int -> ParsedPaddings -> ShowS # show :: ParsedPaddings -> String # showList :: [ParsedPaddings] -> ShowS # | |
| Eq ParsedPaddings Source # | |
Defined in Miso.Flow.Utils.General Methods (==) :: ParsedPaddings -> ParsedPaddings -> Bool # (/=) :: ParsedPaddings -> ParsedPaddings -> Bool # | |
parsePaddings :: Padding -> Double -> Double -> ParsedPaddings Source #
Resolve a Padding to per-side pixel values for the given viewport
width and height.
Arguments
| :: Rect | bounds to fit |
| -> Double | viewport width |
| -> Double | viewport height |
| -> Double | min zoom |
| -> Double | max zoom |
| -> Padding | |
| -> Viewport |
Viewport that encloses the given bounds with padding; port of
getViewportForBounds.
getNodeDimensions :: Node n -> Dimensions Source #
measured.width ?? width ?? initialWidth ?? 0 (and same for height).
getInternalNodeDimensions :: InternalNode n -> Dimensions Source #
getNodeDimensions with the internal measured taking precedence.
nodeHasDimensions :: Node n -> Bool Source #
evaluateAbsolutePosition Source #
Arguments
| :: XYPosition | |
| -> Maybe Dimensions | dimensions (defaults to 0x0) |
| -> NodeId | parent id |
| -> NodeLookup n | |
| -> NodeOrigin | |
| -> XYPosition |
Convert a child position to an absolute position; port of
evaluateAbsolutePosition.