Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix return types for static Rect and Matrix functions. #65

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/mupdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ type Rotate = 0 | 90 | 180 | 270

export const Matrix = {
identity: [ 1, 0, 0, 1, 0, 0 ] as Matrix,
scale(sx: number, sy: number) {
scale(sx: number, sy: number): Matrix {
return [ sx, 0, 0, sy, 0, 0 ]
},
translate(tx: number, ty: number) {
translate(tx: number, ty: number): Matrix {
return [ 1, 0, 0, 1, tx, ty ]
},
rotate(d: number) {
rotate(d: number): Matrix {
while (d < 0)
d += 360
while (d >= 360)
Expand All @@ -107,7 +107,7 @@ export const Matrix = {
let c = Math.cos((d * Math.PI) / 180)
return [ c, s, -s, c, 0, 0 ]
},
invert(m: Matrix) {
invert(m: Matrix): Matrix {
checkMatrix(m)
let det = m[0] * m[3] - m[1] * m[2]
if (det > -1e-23 && det < 1e-23)
Expand All @@ -121,7 +121,7 @@ export const Matrix = {
let invf = -m[4] * invb - m[5] * invd
return [ inva, invb, invc, invd, inve, invf ]
},
concat(one: Matrix, two: Matrix) {
concat(one: Matrix, two: Matrix): Matrix {
checkMatrix(one)
checkMatrix(two)
return [
Expand Down Expand Up @@ -155,7 +155,7 @@ export const Rect = {
rect[3] === Rect.MAX_INF_RECT
)
},
transform: function (rect: Rect, matrix: Matrix) {
transform: function (rect: Rect, matrix: Matrix): Rect {
checkRect(rect)
checkMatrix(matrix)
var t
Expand Down
Loading