Skip to content

Commit

Permalink
some better comments
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMooseman committed Jan 13, 2025
1 parent 543a482 commit 0547305
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
19 changes: 9 additions & 10 deletions examples/src/common/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ export type Camera = {
};
/**
* Zooms relative to your current mouse position
* @param view your current view
* @param screenSize the size of your canvas/screen
* @param zoomScale the scale you want to apply to your view
* @param mousePos the offsetX and offsetY of your mouse
* @param view box2d in dataspace that is mapped to the canvas
* @param screenSize in pixels
* @param zoomScale
* @param mousePos mouse position in pixels
*/
export function zoom(view: box2D, screenSize: vec2, zoomScale: number, mousePos: vec2) {
export function zoom(view: box2D, screenSize: vec2, zoomScale: number, mousePos: vec2): box2D {
// translate mouse pos to data space
// offset divided by screen size gives us a percentage of the canvas where the mouse is
// multiply percentage by view size to make it data space
Expand All @@ -31,12 +31,11 @@ export function zoom(view: box2D, screenSize: vec2, zoomScale: number, mousePos:

/**
*
* @param view your current view
* @param screenSize the size of your screen/canvas
* @param mousePos your mouse position
* @returns new view that has your pan applied
* @param view box2d in dataspace that is mapped to the canvas
* @param screenSize
* @param mousePos mouse position in pixels
*/
export function pan(view: box2D, screenSize: vec2, mousePos: vec2) {
export function pan(view: box2D, screenSize: vec2, mousePos: vec2): box2D {
const relativePos = Vec2.div(Vec2.mul(mousePos, [-1, -1]), screenSize);
const scaledOffset = Vec2.mul(relativePos, Box2D.size(view));
const newView = Box2D.translate(view, scaledOffset);
Expand Down
4 changes: 2 additions & 2 deletions examples/src/dzi/decode-dzi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type { DziImage } from '@alleninstitute/vis-dzi';
// At the end of the file you can see two examples of the metadata format you might see, one as XML and another as JSON
/**
* This function helps decode xml metadata for a dzi file.
* @param s xml string
* @param url url for dzi file
* @param s the contents of the url param - expected to be an XML doc describing the DZI image
* @param url location of the .dzi file
* @returns formatted dzi image data
*/
function decodeDziXml(s: string, url: string): DziImage | undefined {
Expand Down

0 comments on commit 0547305

Please sign in to comment.