Enlarge crop area

This commit is contained in:
Guntis Smaukstelis
2025-07-10 23:11:26 +03:00
parent 87971906cf
commit 6851c44779
3 changed files with 13 additions and 12 deletions
+6 -7
View File
@@ -185,10 +185,9 @@ export function drawRotate(
tempCtx.restore() tempCtx.restore()
ctx.clearRect(0, 0, canvas.width, canvas.height) ctx.clearRect(0, 0, canvas.width, canvas.height)
// canvas.width = 390 canvas.width = 640*4 - 510 // -offset right
// canvas.height = 165 canvas.height = 540*1.7
canvas.width = 1365 // canvas.style.border = "1px solid red"
canvas.height = 576
// console.log(ctx.imageSmoothingEnabled, ctx.imageSmoothingQuality) // console.log(ctx.imageSmoothingEnabled, ctx.imageSmoothingQuality)
if (isInterpolated) { if (isInterpolated) {
ctx.imageSmoothingEnabled = true ctx.imageSmoothingEnabled = true
@@ -197,9 +196,9 @@ export function drawRotate(
ctx.imageSmoothingEnabled = false ctx.imageSmoothingEnabled = false
} }
ctx.save() ctx.save()
ctx.translate(canvas.width/2, canvas.height/2) ctx.translate(canvas.width/2+255, canvas.height/2)
ctx.scale(scale, scale) ctx.scale(scale, scale)
ctx.drawImage(tempCanvas, -tempCanvas.width/2, -tempCanvas.height/2) ctx.drawImage(tempCanvas, -tempCanvas.width/1.5, -tempCanvas.height/1.5)
ctx.restore() ctx.restore()
} }
@@ -208,7 +207,7 @@ function drawContour(
ctx: CanvasRenderingContext2D, ctx: CanvasRenderingContext2D,
): void { ): void {
ctx.save() ctx.save()
ctx.translate(canvas.width/2 +120, canvas.height/2 -20) ctx.translate(canvas.width/2 -20+255, canvas.height/2 -10)
// TODO create contour image exact scale when sizes will be accepted // TODO create contour image exact scale when sizes will be accepted
const scale = 5.3/3.5 const scale = 5.3/3.5
const scaledWidth = latviaBoderImg.width/scale const scaledWidth = latviaBoderImg.width/scale
+5 -4
View File
@@ -112,10 +112,11 @@ function getAvgDirection(directions: number[][], gridRow: number, gridCol: numbe
const directionRow = gridRow * cellSize + row; const directionRow = gridRow * cellSize + row;
const directionCol = gridCol * cellSize + col; const directionCol = gridCol * cellSize + col;
const directionRad = directions[directionRow][directionCol] if (directions[directionRow] !== undefined && directions[directionRow][directionCol] !== undefined) {
const directionRad = directions[directionRow][directionCol]
sumSin += Math.sin(directionRad); sumSin += Math.sin(directionRad);
sumCos += Math.cos(directionRad); sumCos += Math.cos(directionRad);
}
} }
} }
+2 -1
View File
@@ -52,5 +52,6 @@ export type DrawOptions = {
getIsInterpolated: Accessor<boolean>, getIsInterpolated: Accessor<boolean>,
} }
export const CROP_BOUNDS = { x: 1906-1-440, y: 895, width: 440, height: 380, angle: 26 } // export const CROP_BOUNDS = { x: 1906-1-440, y: 895, width: 440, height: 380, angle: 26 }
export const CROP_BOUNDS = { x: 1906-1-660, y: 840, width: 660, height: 620, angle: 26 }
export type CropBounds = typeof CROP_BOUNDS export type CropBounds = typeof CROP_BOUNDS