sprotty
Version:
A next-gen framework for graphical views
119 lines • 4.18 kB
TypeScript
/********************************************************************************
* Copyright (c) 2017-2022 TypeFox and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Bounds, Point } from 'sprotty-protocol';
/**
* Represents an object's insets, for top, bottom, left and right
*/
export interface Insets {
top: number;
bottom: number;
left: number;
right: number;
}
export type Orientation = 'north' | 'south' | 'east' | 'west';
/**
* A diamond or rhombus is a quadrilateral whose four sides all have the same length.
* It consists of four points, a `topPoint`, `rightPoint`, `bottomPoint`, and a `leftPoint`,
* which are connected by four lines -- the `topRightSideLight`, `topLeftSideLine`, `bottomRightSideLine`,
* and the `bottomLeftSideLine`.
*/
export declare class Diamond {
protected bounds: Bounds;
constructor(bounds: Bounds);
get topPoint(): Point;
get rightPoint(): Point;
get bottomPoint(): Point;
get leftPoint(): Point;
get topRightSideLine(): Line;
get topLeftSideLine(): Line;
get bottomRightSideLine(): Line;
get bottomLeftSideLine(): Line;
/**
* Return the closest side of this diamond to the specified `refPoint`.
* @param {Point} refPoint a reference point
* @returns {Line} a line representing the closest side
*/
closestSideLine(refPoint: Point): Line;
}
/**
* A line represented in its standard form `a*x + b*y = c`.
*/
export interface Line {
readonly a: number;
readonly b: number;
readonly c: number;
}
export type CardinalDirection = 'north' | 'north-east' | 'east' | 'south-east' | 'south' | 'south-west' | 'west' | 'north-west';
/**
* A line made up from two points.
*/
export declare class PointToPointLine implements Line {
p1: Point;
p2: Point;
constructor(p1: Point, p2: Point);
get a(): number;
get b(): number;
get c(): number;
/**
* The counter-clockwise angle of this line relative to the x-axis.
*/
get angle(): number;
/**
* The slope of the line.
* A vertical line returns `undefined`.
*/
get slope(): number | undefined;
/**
* The slope of the line or `Number.MAX_SAFE_INTEGER` if vertical.
*/
get slopeOrMax(): number;
/**
* The direction of this line, such as 'north', 'south', or 'south-west'.
*/
get direction(): CardinalDirection;
/**
* @param otherLine the other line
* @returns the intersection point between `this` line and the `otherLine` if exists, or `undefined`.
*/
intersection(otherLine: PointToPointLine): Point | undefined;
/**
* @param otherLine the other line
* @returns whether the start and end point of this line is does not have distinct start
* or end points with the `otherLine`
*/
hasIndistinctPoints(otherLine: PointToPointLine): boolean;
}
/**
* Returns the intersection of two lines `l1` and `l2`
* @param {Line} l1 - A line
* @param {Line} l2 - Another line
* @returns {Point} The intersection point of `l1` and `l2`
*/
export declare function intersection(l1: Line, l2: Line): Point;
/**
* A minimum and maximum value of a numeric type.
*/
export interface Limits {
min: number;
max: number;
}
/**
* Limits a value to the specified `limits`.
* @param {number} value - The value to limit
* @param {Limits} limits - The minimum and maximum limits
*/
export declare function limit(value: number, limits: Limits): number;
//# sourceMappingURL=geometry.d.ts.map