mirror of
https://codeberg.org/demostf/frontend.git
synced 2026-06-03 18:24:12 +02:00
import analyser and migrate to solidjs, untested
This commit is contained in:
parent
95d48e48e2
commit
fff554c3d3
42 changed files with 2910 additions and 4 deletions
36
script/viewer/Panner/Viewport.ts
Normal file
36
script/viewer/Panner/Viewport.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
export interface ViewPortOptions {
|
||||
x?: number;
|
||||
y?: number;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
export interface Point {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
export class Viewport {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
|
||||
constructor(options: ViewPortOptions) {
|
||||
this.x = options.x || 0;
|
||||
this.y = options.y || 0;
|
||||
this.width = options.width;
|
||||
this.height = options.height;
|
||||
}
|
||||
|
||||
static convert(point: Point, {from, to}: {from: Viewport, to: Viewport}): Point {
|
||||
const widthScale = from.width / to.width;
|
||||
const heightScale = from.height / to.height;
|
||||
|
||||
return {
|
||||
x: point.x * widthScale - to.x * widthScale,
|
||||
y: point.y * heightScale - to.y * heightScale
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue