-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
122 additions
and
0 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
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 @@ | ||
import Photo from '../domain/photo'; | ||
|
||
const calculateMargin = (image: HTMLImageElement) => { | ||
return image.width > image.height | ||
? { top: image.width * 0.05, right: image.width * 0.05, bottom: image.width * 0.05 * 2, left: image.width * 0.05 } | ||
: { top: image.height * 0.05, right: image.height * 0.05, bottom: image.height * 0.05 * 2, left: image.height * 0.05 }; | ||
}; | ||
|
||
const darkSimpleFrame = (photo: Photo) => { | ||
const { canvas, context, image } = photo.forRender; | ||
const { cameraModel, lensModel, focalLength, iso, aperture, shutterSpeed } = photo.toMetadata(); | ||
const { top, right, bottom, left } = calculateMargin(image); | ||
|
||
canvas.width = image.width + left + right; | ||
canvas.height = image.height + top + bottom; | ||
|
||
context.fillStyle = '#000000'; | ||
context.fillRect(0, 0, canvas.width, canvas.height); | ||
|
||
context.drawImage(image, left, top, image.width, image.height); | ||
|
||
const fontSize = image.height > image.width ? image.width * 0.035 : image.height * 0.035; | ||
context.fillStyle = '#ffffff'; | ||
context.font = `normal 200 ${fontSize}px Barlow`; | ||
context.textAlign = 'center'; | ||
context.textBaseline = 'middle'; | ||
context.fillText( | ||
[cameraModel, lensModel].filter(Boolean).join(' | '), | ||
canvas.width / 2, | ||
canvas.height - bottom / 2 - fontSize / 2 - fontSize / 7 | ||
); | ||
context.fillText( | ||
[focalLength, aperture, iso, shutterSpeed].filter(Boolean).join(' | '), | ||
canvas.width / 2, | ||
canvas.height - bottom / 2 + fontSize / 2 + fontSize / 7 | ||
); | ||
}; | ||
|
||
export default darkSimpleFrame; |
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,52 @@ | ||
import Photo from '../domain/photo'; | ||
|
||
const calculateMargin = (image: HTMLImageElement) => { | ||
return image.width > image.height | ||
? { top: 0, right: 0, bottom: image.width * 0.04 * 2, left: 0 } | ||
: { top: 0, right: 0, bottom: image.height * 0.04 * 2, left: 0 }; | ||
}; | ||
|
||
const darkStrapFrame = (photo: Photo) => { | ||
const { canvas, context, image } = photo.forRender; | ||
const { cameraModel, lensModel, focalLength, iso, aperture, shutterSpeed, capturedAt } = photo.toMetadata(); | ||
const { top, right, bottom, left } = calculateMargin(image); | ||
|
||
canvas.width = image.width + left + right; | ||
canvas.height = image.height + top + bottom; | ||
|
||
context.fillStyle = '#000000'; | ||
context.fillRect(0, 0, canvas.width, canvas.height); | ||
|
||
context.drawImage(image, left, top, image.width, image.height); | ||
|
||
const fontSize = image.height > image.width ? image.width * 0.025 : image.height * 0.025; | ||
context.fillStyle = '#ffffff'; | ||
context.font = `normal 500 ${fontSize}px Barlow`; | ||
context.textAlign = 'left'; | ||
context.textBaseline = 'middle'; | ||
context.fillText([iso, aperture, shutterSpeed].filter(Boolean).join(' '), fontSize, canvas.height - bottom / 2 - fontSize / 1.8); | ||
|
||
context.fillStyle = '#808080'; | ||
context.font = `normal 300 ${fontSize}px Barlow`; | ||
context.textAlign = 'left'; | ||
context.textBaseline = 'middle'; | ||
context.fillText([capturedAt === '?' ? '' : capturedAt].filter(Boolean).join(' '), fontSize, canvas.height - bottom / 2 + fontSize / 1.8); | ||
|
||
context.fillStyle = '#ffffff'; | ||
context.font = `normal 500 ${fontSize}px Barlow`; | ||
context.textAlign = 'right'; | ||
context.textBaseline = 'middle'; | ||
context.fillText([cameraModel].filter(Boolean).join(' '), canvas.width - fontSize, canvas.height - bottom / 2 - fontSize / 1.8); | ||
|
||
context.fillStyle = '#808080'; | ||
context.font = `normal 300 ${fontSize}px Barlow`; | ||
context.textAlign = 'right'; | ||
context.textBaseline = 'middle'; | ||
context.fillText( | ||
[lensModel, focalLength].filter(Boolean).join(' '), | ||
canvas.width - fontSize, | ||
canvas.height - bottom / 2 + fontSize / 1.8 | ||
); | ||
}; | ||
|
||
export default darkStrapFrame; |
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,25 @@ | ||
import Photo from '../domain/photo'; | ||
|
||
const calculateMargin = (image: HTMLImageElement) => { | ||
return image.width > image.height | ||
? { top: image.width * 0.2, right: image.width * 0.2, bottom: image.width * 0.2, left: image.width * 0.2 } | ||
: { top: image.height * 0.2, right: image.height * 0.2, bottom: image.height * 0.2, left: image.height * 0.2 }; | ||
}; | ||
|
||
const retroFrame = (photo: Photo) => { | ||
const { canvas, context, image } = photo.forRender; | ||
const { top, right, bottom, left } = calculateMargin(image); | ||
|
||
canvas.width = image.width + left + right; | ||
canvas.height = image.height + top + bottom; | ||
|
||
context.fillStyle = '#000000'; | ||
context.fillRect(0, 0, canvas.width, canvas.height); | ||
|
||
context.fillStyle = '#ffffff'; | ||
context.fillRect(top / 7, bottom / 7, canvas.width - (top / 7) * 2, canvas.height - (bottom / 7) * 2); | ||
|
||
context.drawImage(image, left, top, image.width, image.height); | ||
}; | ||
|
||
export default retroFrame; |