Skip to content

Commit

Permalink
something other than MiniMessageMiniMessageMiniMessageMiniMessageMini…
Browse files Browse the repository at this point in the history
…MessageMiniMessageMiniMessageMiniMessage
  • Loading branch information
saboooor committed Dec 25, 2024
1 parent 9adf625 commit 5f4ba53
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
25 changes: 23 additions & 2 deletions src/components/util/RGBUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export function getRandomColor() {
}

export function getAnimFrames(store: typeof defaults) {
if (store.colors.length < 2) return { OutputArray: [], frames: [] };
const colors = store.colors.map(color => ({ rgb: convertToRGB(color.hex), pos: color.pos }));
if (colors.length < 2) return { OutputArray: [], frames: [] };

const text = store.text ?? 'Birdflop';
let loopAmount;
Expand All @@ -66,7 +66,28 @@ export function getAnimFrames(store: typeof defaults) {
const gradient = new AnimatedGradient(colors, length, n);
let output = '';
gradient.next();
if (store.type == 4) {
if (store.format.color == 'MiniMessage') {
const colors = sortColors(store.colors);
if (colors[0].pos !== 0) colors.unshift({ hex: colors[0].hex, pos: 0 });
if (colors[colors.length - 1].pos !== 100) colors.push({ hex: colors[colors.length - 1].hex, pos: 100 });
for (let i = 0; i < colors.length - 1; i++) {
let currentColor = colors[i];
let nextColor = colors[i + 1];
if (currentColor.pos > nextColor.pos) {
const newColor = currentColor;
currentColor = nextColor;
nextColor = newColor;
}

const numSteps = text.length;
const lowerRange = Math.round(colors[i].pos / 100 * numSteps);
const upperRange = Math.round(colors[i + 1].pos / 100 * numSteps);
if (lowerRange === upperRange) continue;
output += `<gradient:${currentColor.hex}:${nextColor.hex}>${text.substring(lowerRange, upperRange)}</gradient>`;
}
OutputArray.push(output);
}
else if (store.type == 4) {
const hex = convertToHex(gradient.next());
clrs.push(hex);
let hexOutput = store.format.color;
Expand Down
4 changes: 2 additions & 2 deletions src/routes/resources/animtab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export default component$(() => {
const newColors = store.colors.map(color => ({ hex: getRandomColor(), pos: color.pos }));
store.colors = newColors;
}}>
<DiceOutline width={24} />
<DiceOutline width={24} class="fill-current" />
</button>
<button class="lum-btn lum-pad-xs w-full" disabled={store.colors.find((color, i) => color.pos != (100 / (store.colors.length - 1)) * i) ? false : true} onClick$={() => {
const newColors = store.colors.slice(0).map((color, i) => ({ hex: color.hex, pos: (100 / (store.colors.length - 1)) * i }));
Expand Down Expand Up @@ -810,7 +810,7 @@ export default component$(() => {
<label for="formatinput">
{t('animtab.outputFormat@@Output Format')}
</label>
<textarea class="lum-input h-32" id="formatinput" value={animtabstore.outputFormat} placeholder="birdflop" onInput$={(e, el) => { animtabstore.outputFormat = el.value; }}/>
<textarea class="lum-input h-32 whitespace-pre" id="formatinput" value={animtabstore.outputFormat} placeholder="birdflop" onInput$={(e, el) => { animtabstore.outputFormat = el.value; }}/>
</div>}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/routes/resources/rgb/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export default component$(() => {
const newColors = store.colors.map(color => ({ hex: getRandomColor(), pos: color.pos }));
store.colors = newColors;
}}>
<DiceOutline width={24} />
<DiceOutline width={24} class="fill-current" />
</button>
<button class="lum-btn lum-pad-xs w-full" disabled={store.colors.find((color, i) => color.pos != (100 / (store.colors.length - 1)) * i) ? false : true} onClick$={() => {
const newColors = store.colors.slice(0).map((color, i) => ({ hex: color.hex, pos: (100 / (store.colors.length - 1)) * i }));
Expand Down

0 comments on commit 5f4ba53

Please sign in to comment.