Skip to content

Commit

Permalink
feat: Add shot on two line (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhea-so committed Apr 14, 2024
2 parents 617ceb4 + 17c9bba commit 5afa0e3
Show file tree
Hide file tree
Showing 23 changed files with 62 additions and 9 deletions.
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.4.0",
"version": "0.4.1",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
Binary file removed web/public/preview/cinema-scope.jpg
Binary file not shown.
Binary file removed web/public/preview/compact.jpg
Binary file not shown.
Binary file removed web/public/preview/dark-compact.jpg
Binary file not shown.
Binary file removed web/public/preview/dark-inside-compact.jpg
Binary file not shown.
Binary file removed web/public/preview/dark-inside.jpg
Binary file not shown.
Binary file removed web/public/preview/dark-simple.jpg
Binary file not shown.
Binary file removed web/public/preview/dark-strap.jpg
Binary file not shown.
Binary file removed web/public/preview/grid-lines.jpg
Binary file not shown.
Binary file removed web/public/preview/inside-compact.jpg
Binary file not shown.
Binary file removed web/public/preview/inside.jpg
Binary file not shown.
Binary file removed web/public/preview/just-frame.jpg
Binary file not shown.
Binary file removed web/public/preview/monitor.jpg
Binary file not shown.
Binary file removed web/public/preview/no-frame.jpg
Binary file not shown.
Binary file removed web/public/preview/polaroid.jpg
Binary file not shown.
Binary file removed web/public/preview/shot-on.jpg
Binary file not shown.
Binary file removed web/public/preview/simple.jpg
Binary file not shown.
Binary file removed web/public/preview/strap.jpg
Binary file not shown.
1 change: 0 additions & 1 deletion web/src/themes/04_TWO_LINE/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { ThemeFunc, ThemeOption, ThemeOptionInput } from '../00_BASE/type';

const TWO_LINE_OPTIONS: ThemeOption[] = [
{ key: 'BACKGROUND_COLOR', type: String, default: '#ffffff', description: '#ffffff is white, #000000 is black' },
{ key: 'SQUARE', type: String, default: 'no', description: 'yes or no' },
{ key: 'PADDING_INSIDE', type: String, default: 'no', description: 'yes or no' },
{ key: 'PADDING_TOP', type: Number, default: 100, description: 'px' },
{ key: 'PADDING_BOTTOM', type: Number, default: 350, description: 'px' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { Store } from '../../store';
import sandbox from '../00_BASE/sandbox';
import { ThemeFunc, ThemeOption, ThemeOptionInput } from '../00_BASE/type';

const SHOT_ON_OPTIONS: ThemeOption[] = [
const SHOT_ON_ONE_LINE_OPTIONS: ThemeOption[] = [
{ key: 'BACKGROUND_COLOR', type: String, default: '#ffffff', description: '#ffffff is white, #000000 is black' },
{ key: 'TEXT_COLOR', type: String, default: '#000000', description: '#ffffff is white, #000000 is black' },
];

const SHOT_ON_FUNC: ThemeFunc = (photo: Photo, input: ThemeOptionInput, store: Store) => {
const SHOT_ON_ONE_LINE_FUNC: ThemeFunc = (photo: Photo, input: ThemeOptionInput, store: Store) => {
const BACKGROUND_COLOR = (input.get('BACKGROUND_COLOR') as string).trim();
const TEXT_COLOR = input.get('TEXT_COLOR') as string;
const PADDING_BOTTOM = 200;
Expand Down Expand Up @@ -52,4 +52,4 @@ const SHOT_ON_FUNC: ThemeFunc = (photo: Photo, input: ThemeOptionInput, store: S
return canvas;
};

export { SHOT_ON_FUNC, SHOT_ON_OPTIONS };
export { SHOT_ON_ONE_LINE_FUNC, SHOT_ON_ONE_LINE_OPTIONS };
52 changes: 52 additions & 0 deletions web/src/themes/06_SHOT_ON_TWO_LINE/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import Photo from '../../core/photo';
import { Store } from '../../store';
import sandbox from '../00_BASE/sandbox';
import { ThemeFunc, ThemeOption, ThemeOptionInput } from '../00_BASE/type';

const SHOT_ON_TWO_LINE_OPTIONS: ThemeOption[] = [
{ key: 'BACKGROUND_COLOR', type: String, default: '#ffffff', description: '#ffffff is white, #000000 is black' },
{ key: 'TEXT_COLOR', type: String, default: '#000000', description: '#ffffff is white, #000000 is black' },
{ key: 'TOP_LABEL', type: String, default: '@username', description: 'ex. @username' },
];

const SHOT_ON_TWO_LINE_FUNC: ThemeFunc = (photo: Photo, input: ThemeOptionInput, store: Store) => {
const BACKGROUND_COLOR = (input.get('BACKGROUND_COLOR') as string).trim();
const TEXT_COLOR = input.get('TEXT_COLOR') as string;
const TOP_LABEL = (input.get('TOP_LABEL') as string).trim();

const canvas = sandbox(photo, BACKGROUND_COLOR, { top: 200, right: 50, bottom: 300, left: 50 });

const context = canvas.getContext('2d')!;
context.fillStyle = TEXT_COLOR;
context.textBaseline = 'middle';
context.textAlign = 'center';

// DRAW TOP LABEL
context.font = `normal 100 50px Barlow`;
context.fillText(TOP_LABEL, canvas.width / 2, 125);

// shot on ${MAKER} ${MODEL}
context.font = `normal 500 80px Barlow`;
context.fillText(
`shot on ${[
store.showCameraMaker ? store.overrideCameraMaker || photo.make : null,
store.showCameraModel ? store.overrideCameraModel || photo.model : null,
]
.filter(Boolean)
.join(' ')}`,
canvas.width / 2,
canvas.height - 200
);

// ISO ${ISO} | ${F} ${FocalLength} | ${ShutterSpeed}s
context.font = `normal 100 50px Barlow`;
context.fillText(
[`ISO ${photo.iso}`, `${photo.focalLength}`, `${photo.fNumber}`, `${photo.exposureTime}s`].filter(Boolean).join(' '),
canvas.width / 2,
canvas.height - 100
);

return canvas;
};

export { SHOT_ON_TWO_LINE_FUNC, SHOT_ON_TWO_LINE_OPTIONS };
File renamed without changes.
10 changes: 6 additions & 4 deletions web/src/themes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { NO_FRAME_THEME_FUNC, NO_FRAME_OPTIONS } from './01_NO_FRAME';
import { ONE_LINE_FUNC, ONE_LINE_OPTIONS } from './03_ONE_LINE';
import { TWO_LINE_FUNC, TWO_LINE_OPTIONS } from './04_TWO_LINE';
import { JUST_FRAME_FUNC, JUST_FRAME_OPTIONS } from './02_JUST_FRAME';
import { SHOT_ON_FUNC, SHOT_ON_OPTIONS } from './05_SHOT_ON';
import { STRAP_FUNC, STRAP_OPTIONS } from './06_STRAP';
import { STRAP_FUNC, STRAP_OPTIONS } from './07_STRAP';
import { SHOT_ON_ONE_LINE_FUNC, SHOT_ON_ONE_LINE_OPTIONS } from './05_SHOT_ON_ONE_LINE';
import { SHOT_ON_TWO_LINE_FUNC, SHOT_ON_TWO_LINE_OPTIONS } from './06_SHOT_ON_TWO_LINE';

type AcceptInputType = string | number | boolean;

Expand Down Expand Up @@ -35,10 +36,11 @@ const useThemeStore = create<ThemeStore>((set) => ({
const themes = [
{ name: 'No frame', func: NO_FRAME_THEME_FUNC, options: NO_FRAME_OPTIONS },
{ name: 'Just frame', func: JUST_FRAME_FUNC, options: JUST_FRAME_OPTIONS },
{ name: 'Strap', func: STRAP_FUNC, options: STRAP_OPTIONS },
{ name: 'One line', func: ONE_LINE_FUNC, options: ONE_LINE_OPTIONS },
{ name: 'Two line', func: TWO_LINE_FUNC, options: TWO_LINE_OPTIONS },
{ name: 'Shot on', func: SHOT_ON_FUNC, options: SHOT_ON_OPTIONS },
{ name: 'Strap', func: STRAP_FUNC, options: STRAP_OPTIONS },
{ name: 'Shot on one line', func: SHOT_ON_ONE_LINE_FUNC, options: SHOT_ON_ONE_LINE_OPTIONS },
{ name: 'Shot on two line', func: SHOT_ON_TWO_LINE_FUNC, options: SHOT_ON_TWO_LINE_OPTIONS },
];

export default themes;
Expand Down

0 comments on commit 5afa0e3

Please sign in to comment.