Line
Module Geometry.Lines
In ixfx, a Line is two Points
type Line = { a: Point b: Point}
Once you have that there are a bunch of functions to help you work with circles.
- angleRadian - compute angle, in radian
- bbox - compute bounding box
- interpolate - calculate point along line
- length - compute length of line
- midpoint - middle point of a line
- perpendicularPoint - a point perpendicular to line at a given distance.
- pointAtX - Calculates point where y intersects line at x
- relativePosition - relative position of point along line
- slope - calculate slope of line
Manipulating
- extendFromA - copy of line, extended from it’s A point
- normaliseByRect - divide by dimensions of a rectangle
- parallel - creates a parallel line at a given distance
- rotate - rotate line by a given angle and pivot
- scaleFromMidpoint - scale size of line from its midpoint
Comparison with other shapes
- distance - distance from point to nearest point on line
- nearest -nearest point on line to another point
- withinRange - returns true if point is within a given range of line
Conversions
- asPoints - Generator of A & B position for any number of lines
- fromFlatArray - a line from [x1,y1,x2,y2]
- toFlatArray
- fromNumbers - a line from (x1, y1, x2, y2)
- fromPivot - a line from an origin point
- fromPoints - a line from two points
- fromPointsToPath - a Type LinePath from two points
- joinPointsToLines - joins two or more points into an array of lines
- pointsOf - calculate integer points along line
- toPath - convert to a Type LinePath
Math
Etc
Importing
Section titled “Importing”// Sub moduleimport { Lines } from "@ixfx/geometry.js"// Eg: Lines.nearest();
// Whole moduleimport * as Geometry from "@ixfx/geometry.js"// Eg: Geometry.Lines.nearest();
// From bundleimport { Geometry } from "@ixfx"// Eg: Geometry.Lines.nearest();
// And within your HTML's <HEAD> </HEAD> block:<script type="importmap">{ "imports": { "@ixfx":"/ixfx/index.js", "@ixfx/": "/ixfx/" } }</script>
// Sub module from parentimport { Lines } from "@ixfx/geometry.js"// Eg: Lines.nearest();
// Whole parent moduleimport * as Geometry from "@ixfx/geometry.js"// Eg: Geometry.Lines.nearest();
// From the bundleimport { Geometry } from "@ixfx/bundle.js"// Eg: Geometry.Lines.nearest();
// Sub module from parentimport { Lines } from "https://unpkg.com/@ixfx/geometry/bundle"// Eg: Lines.nearest();
// Whole parent moduleimport * as Geometry from "https://unpkg.com/@ixfx/geometry/bundle"// Eg: Geometry.Lines.nearest();
// Single module from the bundleimport { Geometry } from "https://unpkg.com/@ixfx/bundle"// Eg: Geometry.Lines.nearest();