Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize(create-farm): Remove child process log output remove chalk library optimize code size #781

Merged
merged 7 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: update code
  • Loading branch information
ErKeLost committed Nov 25, 2023
commit 40356e067e4e7e006c826acfd54fff3e9864b514
27 changes: 21 additions & 6 deletions packages/core/src/utils/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,27 @@ export function gradientString(text: string, colors: any) {
return output;
}

export function interpolateColor(
color1: number[],
color2: number[],
factor: number
) {
return [
Math.round(color1[0] + (color2[0] - color1[0]) * factor),
Math.round(color1[1] + (color2[1] - color1[1]) * factor),
Math.round(color1[2] + (color2[2] - color1[2]) * factor)
];
}

export const BrandText = gradientString('FULL EXTREME!', [
[128, 0, 128],
[60, 0, 92],
[0, 0, 128],
[0, 0, 139],
[0, 0, 205],
[0, 0, 255],
[0, 0, 139]
interpolateColor([128, 0, 128], [60, 0, 92], 0.1),
interpolateColor([60, 0, 92], [0, 0, 128], 0.2),
interpolateColor([0, 0, 128], [135, 206, 250], 0.3),
interpolateColor([135, 206, 250], [0, 0, 139], 0.4),
interpolateColor([0, 0, 139], [0, 0, 205], 0.5),
interpolateColor([0, 0, 205], [0, 0, 255], 0.6),
interpolateColor([0, 0, 255], [0, 0, 139], 0.7),
interpolateColor([0, 0, 139], [128, 0, 128], 0.8),
interpolateColor([128, 0, 128], [60, 0, 92], 0.9)
]);
34 changes: 20 additions & 14 deletions packages/create-farm/utils/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,26 +117,32 @@ export function gradientString(text: string, colors: any) {
return output;
}

function interpolateColor(color1: number[], color2: number[], factor: number) {
return [
Math.round(color1[0] + (color2[0] - color1[0]) * factor),
Math.round(color1[1] + (color2[1] - color1[1]) * factor),
Math.round(color1[2] + (color2[2] - color1[2]) * factor)
];
}

export const BrandText = gradientString('\n⚡ Welcome To Farm ! \n', [
[128, 0, 128],
[60, 0, 92],
[0, 0, 128],
[0, 0, 139],
[0, 0, 205],
[0, 0, 255],
[0, 0, 139]
[255, 182, 193],
interpolateColor([255, 182, 193], [128, 0, 128], 0.2),
interpolateColor([255, 182, 193], [128, 0, 128], 0.4),
interpolateColor([255, 182, 193], [128, 0, 128], 0.6),
interpolateColor([255, 182, 193], [128, 0, 128], 0.8),
[128, 0, 128]
]);

export function handleBrandText(text: string) {
console.log(
gradientString(text, [
[128, 0, 128],
[60, 0, 92],
[0, 0, 128],
[0, 0, 139],
[0, 0, 205],
[0, 0, 255],
[0, 0, 139]
[255, 182, 193],
interpolateColor([255, 182, 193], [128, 0, 128], 0.2),
interpolateColor([255, 182, 193], [128, 0, 128], 0.4),
interpolateColor([255, 182, 193], [128, 0, 128], 0.6),
interpolateColor([255, 182, 193], [128, 0, 128], 0.8),
[128, 0, 128]
])
);
}