-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Refactoring of existing image transformation functions, various…
… new transformation functions have been added
- Loading branch information
1 parent
3813dd1
commit 7caa9a1
Showing
16 changed files
with
901 additions
and
472 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* 2-dimensional point | ||
* | ||
* @format | ||
*/ | ||
|
||
export class Point { | ||
public x: number; | ||
public y: number; | ||
|
||
public get xt() { | ||
return Math.trunc(this.x); | ||
} | ||
|
||
public get yt() { | ||
return Math.trunc(this.y); | ||
} | ||
|
||
constructor(x: number, y: number) { | ||
this.x = x; | ||
this.y = y; | ||
} | ||
|
||
public static from(other: Point) { | ||
return new Point(other.x, other.y); | ||
} | ||
|
||
public mul(s: number) { | ||
return new Point(this.x * s, this.y * s); | ||
} | ||
|
||
public add(rhs: Point) { | ||
return new Point(this.x + rhs.x, this.y + rhs.y); | ||
} | ||
|
||
public equals(other: unknown) { | ||
return other instanceof Point && this.x === other.x && this.y === other.y; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** @format */ | ||
|
||
import { Point } from './point'; | ||
|
||
export class Rectangle { | ||
public left: number; | ||
public top: number; | ||
public right: number; | ||
public bottom: number; | ||
|
||
public get topLeft(): Point { | ||
return new Point(this.left, this.top); | ||
} | ||
|
||
public get topRight(): Point { | ||
return new Point(this.right, this.top); | ||
} | ||
|
||
public get bottomRight(): Point { | ||
return new Point(this.right, this.bottom); | ||
} | ||
|
||
public get bottomLeft(): Point { | ||
return new Point(this.left, this.bottom); | ||
} | ||
|
||
public get width(): number { | ||
return this.bottom - this.top; | ||
} | ||
|
||
public get height(): number { | ||
return this.right - this.left; | ||
} | ||
|
||
constructor(left: number, top: number, right: number, bottom: number) { | ||
this.left = left; | ||
this.top = top; | ||
this.right = right; | ||
this.bottom = bottom; | ||
} | ||
|
||
public static fromPosSize( | ||
left: number, | ||
top: number, | ||
width: number, | ||
height: number | ||
) { | ||
return new Rectangle(left, top, left + width, top + height); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** @format */ | ||
|
||
import { MemoryImage } from '../common/memory-image'; | ||
|
||
export interface CopyIntoOptions { | ||
dst: MemoryImage; | ||
src: MemoryImage; | ||
dstX?: number; | ||
dstY?: number; | ||
srcX?: number; | ||
srcY?: number; | ||
srcW?: number; | ||
srcH?: number; | ||
blend?: boolean; | ||
center?: boolean; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** @format */ | ||
|
||
import { MemoryImage } from '../common/memory-image'; | ||
import { Interpolation } from '../formats/util/interpolation'; | ||
|
||
export interface CopyResizeOptionsUsingWidth { | ||
image: MemoryImage; | ||
width: number; | ||
height?: number; | ||
interpolation?: Interpolation; | ||
} | ||
|
||
export interface CopyResizeOptionsUsingHeight { | ||
image: MemoryImage; | ||
height: number; | ||
width?: number; | ||
interpolation?: Interpolation; | ||
} |
Oops, something went wrong.