Add image editor

This commit is contained in:
Josh Perez 2021-11-30 21:14:25 -05:00 committed by GitHub
parent 86d09917a3
commit 7affe313f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
58 changed files with 4261 additions and 173 deletions

View file

@ -0,0 +1,44 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import * as log from '../../logging/log';
import { getHSL } from './color';
import { missingCaseError } from '../../util/missingCaseError';
export enum TextStyle {
Regular = 'Regular',
Highlight = 'Highlight',
Outline = 'Outline',
}
export function getTextStyleAttributes(
textStyle: TextStyle,
hueSliderValue: number
): {
fill: string;
stroke?: string;
strokeWidth: number;
textBackgroundColor: string;
} {
const color = getHSL(hueSliderValue);
switch (textStyle) {
case TextStyle.Regular:
return { fill: color, strokeWidth: 0, textBackgroundColor: '' };
case TextStyle.Highlight:
return {
fill: hueSliderValue <= 5 ? '#000' : '#fff',
strokeWidth: 0,
textBackgroundColor: color,
};
case TextStyle.Outline:
return {
fill: hueSliderValue <= 5 ? '#000' : '#fff',
stroke: color,
strokeWidth: 2,
textBackgroundColor: '',
};
default:
log.error(missingCaseError(textStyle));
return getTextStyleAttributes(TextStyle.Regular, hueSliderValue);
}
}