@daign/2d-graphics
Version:
Two dimensional graphics library that implements the daign-2d-pipeline.
42 lines (41 loc) • 1.54 kB
TypeScript
import { Box2, Value, Vector2 } from '@daign/math';
import { Group } from '../basic-elements/group';
import { ITargetContext } from '../iTargetContext';
import { Application } from './application';
/**
* Group that acts as an viewport by applying a transformation to bring objects into the visible
* area.
* So this is just the top most node of the drawing layer. But the transformation it has is used
* for zooming and panning the content around.
*/
export declare class Viewport extends Group {
protected context: ITargetContext;
protected application: Application;
private decenteringTransform;
private scaleTransform;
private translateTransform;
viewCenter: Vector2;
viewScale: Value;
scaleMin: number;
scaleMax: number;
viewCenterLimit: Box2;
/**
* Constructor.
* @param context - The target drawing context.
* @param application - The corresponding application.
*/
constructor(context: ITargetContext, application: Application);
/**
* Set view center and scale so that the content is fully zoomed in the center of the viewport.
* @param margin - The margin to leave around the content. Optional.
*/
fitToContent(margin?: number): void;
/**
* Set view center and scale so that the coordinates translate one-to-one to context coordinates.
*/
fitToContextSize(): void;
/**
* Calculate and apply the transformations that result from the view center and scale properties.
*/
protected updateViewport(): void;
}