mirror of
https://github.com/Tyriar/vscode-theme-generator.git
synced 2025-12-07 09:36:11 -08:00
11
src/color.ts
11
src/color.ts
@@ -38,8 +38,9 @@ export function addAlpha(color: string, alpha: number): string {
|
||||
return color + alphaHex;
|
||||
}
|
||||
|
||||
export function generateFallbackColorSet(s: IBaseColorSet): IColorSet {
|
||||
export function generateFallbackColorSet(s: IBaseColorSet, type: 'light' | 'dark'): IColorSet {
|
||||
return {
|
||||
type,
|
||||
base: {
|
||||
background: null,
|
||||
foreground: null,
|
||||
@@ -52,12 +53,12 @@ export function generateFallbackColorSet(s: IBaseColorSet): IColorSet {
|
||||
boolean: s.color1,
|
||||
function: s.color3,
|
||||
functionCall: s.color4,
|
||||
identifier: lighten(s.color1, 0.5),
|
||||
identifier: (type === 'light' ? darken : lighten)(s.color1, 0.5),
|
||||
keyword: s.color1,
|
||||
number: s.color4,
|
||||
storage: s.color1,
|
||||
string: s.color2,
|
||||
comment: lighten(s.background, 2.0),
|
||||
comment: (type === 'light' ? darken : lighten)(s.background, 2.0),
|
||||
class: s.color3,
|
||||
classMember: s.color3,
|
||||
type: s.color3,
|
||||
@@ -69,8 +70,8 @@ export function generateFallbackColorSet(s: IBaseColorSet): IColorSet {
|
||||
},
|
||||
ui: {
|
||||
cursor: null,
|
||||
invisibles: lighten(s.background, 0.2),
|
||||
guide: lighten(s.background, 0.2),
|
||||
invisibles: (type === 'light' ? darken : lighten)(s.background, 0.2),
|
||||
guide: (type === 'light' ? darken : lighten)(s.background, 0.2),
|
||||
lineHighlight: null,
|
||||
findMatchHighlight: null,
|
||||
currentFindMatchHighlight: null,
|
||||
|
||||
@@ -14,6 +14,7 @@ export interface IBaseColorSet {
|
||||
}
|
||||
|
||||
export interface IColorSet {
|
||||
type: 'light' | 'dark';
|
||||
base: IBaseColorSet;
|
||||
syntax?: {
|
||||
boolean?: string;
|
||||
|
||||
@@ -16,7 +16,7 @@ export class VscodeThemeGenerator implements IThemeGenerator {
|
||||
if (!colorSet.terminal) colorSet.terminal = {};
|
||||
if (!colorSet.ui) colorSet.ui = {};
|
||||
|
||||
const fallbackColorSet = generateFallbackColorSet(colorSet.base);
|
||||
const fallbackColorSet = generateFallbackColorSet(colorSet.base, colorSet.type);
|
||||
|
||||
const theme: IVscodeJsonTheme = {
|
||||
name: name,
|
||||
@@ -51,11 +51,11 @@ export class VscodeThemeGenerator implements IThemeGenerator {
|
||||
}
|
||||
|
||||
private _applyWorkbenchColors(theme: IVscodeJsonTheme, colorSet: IColorSet): void {
|
||||
const background1 = darken(colorSet.base.background, 0.2);
|
||||
const background1 = (colorSet.type === 'light' ? lighten : darken)(colorSet.base.background, 0.2);
|
||||
const background2 = colorSet.base.background;
|
||||
const background3 = lighten(colorSet.base.background, 0.2);
|
||||
const background4 = lighten(colorSet.base.background, 0.4);
|
||||
const background5 = lighten(colorSet.base.background, 0.6);
|
||||
const background3 = (colorSet.type === 'light' ? darken : lighten)(colorSet.base.background, 0.2);
|
||||
const background4 = (colorSet.type === 'light' ? darken : lighten)(colorSet.base.background, 0.4);
|
||||
const background5 = (colorSet.type === 'light' ? darken : lighten)(colorSet.base.background, 0.6);
|
||||
|
||||
// Contrast colors
|
||||
// contrastActiveBorder: An extra border around active elements to separate them from others for greater contrast.
|
||||
|
||||
Reference in New Issue
Block a user