TextUtil/GradienText - fabric 1.21

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
10 Июл 2022
Сообщения
160
Реакции
5
Сливаю как-как очень крутая вещь.

ss:
1725091194545.png


TextUtil:
Expand Collapse Copy
package hub.histed.hysteria.client.Utility.Client;

import net.minecraft.text.MutableText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.text.TextColor;

import java.util.List;

public class TextUtils {

    /**
     *
     * [USER=804731]@param[/USER] text
     * [USER=804731]@param[/USER] color1
     * [USER=804731]@param[/USER] color2
     * [USER=46448]@ReturN[/USER]
     */
    public static Text gradientText(String text, int color1, int color2) {
        int length = text.length();
        MutableText finalText = Text.empty();

        for (int i = 0; i < length; i++) {
            float ratio = (float) i / (length - 1);
            int blendedColor = blendColors(color1, color2, ratio);
            MutableText segment = Text.literal(String.valueOf(text.charAt(i)))
                    .setStyle(Style.EMPTY.withColor(TextColor.fromRgb(blendedColor)));
            finalText.append(segment);
        }

        return finalText;
    }

    /**
     *
     * [USER=804731]@param[/USER] color1
     * [USER=804731]@param[/USER] color2
     * [USER=804731]@param[/USER] ratio
     * [USER=46448]@ReturN[/USER]
     */
    private static int blendColors(int color1, int color2, float ratio) {
        int r1 = (color1 >> 16) & 0xFF;
        int g1 = (color1 >> 8) & 0xFF;
        int b1 = color1 & 0xFF;
        int r2 = (color2 >> 16) & 0xFF;
        int g2 = (color2 >> 8) & 0xFF;
        int b2 = color2 & 0xFF;

        int r = (int) (r1 * (1 - ratio) + r2 * ratio);
        int g = (int) (g1 * (1 - ratio) + g2 * ratio);
        int b = (int) (b1 * (1 - ratio) + b2 * ratio);

        return (r << 16) | (g << 8) | b;
    }
}

Как юзать

Use:
Expand Collapse Copy
        Text t = TextUtils.gradientText("Ваш текст", Первый цвет HEX, Второй цвет HEX);
        client.inGameHud.getChatHud().addMessage(t);


ВАЖНО
ЭТО НЕ ДЛЯ EXPENSIVE 3.1 И НЕ ДЛЯ 2.0!!!!
 
Последнее редактирование:
Сливаю как-как очень крутая вещь.

ss:
Посмотреть вложение 284532

TextUtil:
Expand Collapse Copy
package hub.histed.hysteria.client.Utility.Client;

import net.minecraft.text.MutableText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.text.TextColor;

import java.util.List;

public class TextUtils {

    /**
     *
     * [USER=804731]@param[/USER] text
     * [USER=804731]@param[/USER] color1
     * [USER=804731]@param[/USER] color2
     * [USER=46448]@ReturN[/USER]
     */
    public static Text gradientText(String text, int color1, int color2) {
        int length = text.length();
        MutableText finalText = Text.empty();

        for (int i = 0; i < length; i++) {
            float ratio = (float) i / (length - 1);
            int blendedColor = blendColors(color1, color2, ratio);
            MutableText segment = Text.literal(String.valueOf(text.charAt(i)))
                    .setStyle(Style.EMPTY.withColor(TextColor.fromRgb(blendedColor)));
            finalText.append(segment);
        }

        return finalText;
    }

    /**
     *
     * [USER=804731]@param[/USER] color1
     * [USER=804731]@param[/USER] color2
     * [USER=804731]@param[/USER] ratio
     * [USER=46448]@ReturN[/USER]
     */
    private static int blendColors(int color1, int color2, float ratio) {
        int r1 = (color1 >> 16) & 0xFF;
        int g1 = (color1 >> 8) & 0xFF;
        int b1 = color1 & 0xFF;
        int r2 = (color2 >> 16) & 0xFF;
        int g2 = (color2 >> 8) & 0xFF;
        int b2 = color2 & 0xFF;

        int r = (int) (r1 * (1 - ratio) + r2 * ratio);
        int g = (int) (g1 * (1 - ratio) + g2 * ratio);
        int b = (int) (b1 * (1 - ratio) + b2 * ratio);

        return (r << 16) | (g << 8) | b;
    }
}

Как юзать

Use:
Expand Collapse Copy
        Text t = TextUtils.gradientText("Ваш текст", Первый цвет HEX, Второй цвет HEX);
        client.inGameHud.getChatHud().addMessage(t);


ВАЖНО
ЭТО НЕ ДЛЯ EXPENSIVE 3.1 И НЕ ДЛЯ 2.0!!!!
Норм :seemsgood:
 
Сливаю как-как очень крутая вещь.

ss:
Посмотреть вложение 284532

TextUtil:
Expand Collapse Copy
package hub.histed.hysteria.client.Utility.Client;

import net.minecraft.text.MutableText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.text.TextColor;

import java.util.List;

public class TextUtils {

    /**
     *
     * [USER=804731]@param[/USER] text
     * [USER=804731]@param[/USER] color1
     * [USER=804731]@param[/USER] color2
     * [USER=46448]@ReturN[/USER]
     */
    public static Text gradientText(String text, int color1, int color2) {
        int length = text.length();
        MutableText finalText = Text.empty();

        for (int i = 0; i < length; i++) {
            float ratio = (float) i / (length - 1);
            int blendedColor = blendColors(color1, color2, ratio);
            MutableText segment = Text.literal(String.valueOf(text.charAt(i)))
                    .setStyle(Style.EMPTY.withColor(TextColor.fromRgb(blendedColor)));
            finalText.append(segment);
        }

        return finalText;
    }

    /**
     *
     * [USER=804731]@param[/USER] color1
     * [USER=804731]@param[/USER] color2
     * [USER=804731]@param[/USER] ratio
     * [USER=46448]@ReturN[/USER]
     */
    private static int blendColors(int color1, int color2, float ratio) {
        int r1 = (color1 >> 16) & 0xFF;
        int g1 = (color1 >> 8) & 0xFF;
        int b1 = color1 & 0xFF;
        int r2 = (color2 >> 16) & 0xFF;
        int g2 = (color2 >> 8) & 0xFF;
        int b2 = color2 & 0xFF;

        int r = (int) (r1 * (1 - ratio) + r2 * ratio);
        int g = (int) (g1 * (1 - ratio) + g2 * ratio);
        int b = (int) (b1 * (1 - ratio) + b2 * ratio);

        return (r << 16) | (g << 8) | b;
    }
}

Как юзать

Use:
Expand Collapse Copy
        Text t = TextUtils.gradientText("Ваш текст", Первый цвет HEX, Второй цвет HEX);
        client.inGameHud.getChatHud().addMessage(t);


ВАЖНО
ЭТО НЕ ДЛЯ EXPENSIVE 3.1 И НЕ ДЛЯ 2.0!!!!
"Нигде не видел"
 
Сливаю как-как очень крутая вещь.

ss:
Посмотреть вложение 284532

TextUtil:
Expand Collapse Copy
package hub.histed.hysteria.client.Utility.Client;

import net.minecraft.text.MutableText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.text.TextColor;

import java.util.List;

public class TextUtils {

    /**
     *
     * [USER=804731]@param[/USER] text
     * [USER=804731]@param[/USER] color1
     * [USER=804731]@param[/USER] color2
     * [USER=46448]@ReturN[/USER]
     */
    public static Text gradientText(String text, int color1, int color2) {
        int length = text.length();
        MutableText finalText = Text.empty();

        for (int i = 0; i < length; i++) {
            float ratio = (float) i / (length - 1);
            int blendedColor = blendColors(color1, color2, ratio);
            MutableText segment = Text.literal(String.valueOf(text.charAt(i)))
                    .setStyle(Style.EMPTY.withColor(TextColor.fromRgb(blendedColor)));
            finalText.append(segment);
        }

        return finalText;
    }

    /**
     *
     * [USER=804731]@param[/USER] color1
     * [USER=804731]@param[/USER] color2
     * [USER=804731]@param[/USER] ratio
     * [USER=46448]@ReturN[/USER]
     */
    private static int blendColors(int color1, int color2, float ratio) {
        int r1 = (color1 >> 16) & 0xFF;
        int g1 = (color1 >> 8) & 0xFF;
        int b1 = color1 & 0xFF;
        int r2 = (color2 >> 16) & 0xFF;
        int g2 = (color2 >> 8) & 0xFF;
        int b2 = color2 & 0xFF;

        int r = (int) (r1 * (1 - ratio) + r2 * ratio);
        int g = (int) (g1 * (1 - ratio) + g2 * ratio);
        int b = (int) (b1 * (1 - ratio) + b2 * ratio);

        return (r << 16) | (g << 8) | b;
    }
}

Как юзать

Use:
Expand Collapse Copy
        Text t = TextUtils.gradientText("Ваш текст", Первый цвет HEX, Второй цвет HEX);
        client.inGameHud.getChatHud().addMessage(t);


ВАЖНО
ЭТО НЕ ДЛЯ EXPENSIVE 3.1 И НЕ ДЛЯ 2.0!!!!
нихуёво
 
Сливаю как-как очень крутая вещь.

ss:
Посмотреть вложение 284532

TextUtil:
Expand Collapse Copy
package hub.histed.hysteria.client.Utility.Client;

import net.minecraft.text.MutableText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.text.TextColor;

import java.util.List;

public class TextUtils {

    /**
     *
     * [USER=804731]@param[/USER] text
     * [USER=804731]@param[/USER] color1
     * [USER=804731]@param[/USER] color2
     * [USER=46448]@ReturN[/USER]
     */
    public static Text gradientText(String text, int color1, int color2) {
        int length = text.length();
        MutableText finalText = Text.empty();

        for (int i = 0; i < length; i++) {
            float ratio = (float) i / (length - 1);
            int blendedColor = blendColors(color1, color2, ratio);
            MutableText segment = Text.literal(String.valueOf(text.charAt(i)))
                    .setStyle(Style.EMPTY.withColor(TextColor.fromRgb(blendedColor)));
            finalText.append(segment);
        }

        return finalText;
    }

    /**
     *
     * [USER=804731]@param[/USER] color1
     * [USER=804731]@param[/USER] color2
     * [USER=804731]@param[/USER] ratio
     * [USER=46448]@ReturN[/USER]
     */
    private static int blendColors(int color1, int color2, float ratio) {
        int r1 = (color1 >> 16) & 0xFF;
        int g1 = (color1 >> 8) & 0xFF;
        int b1 = color1 & 0xFF;
        int r2 = (color2 >> 16) & 0xFF;
        int g2 = (color2 >> 8) & 0xFF;
        int b2 = color2 & 0xFF;

        int r = (int) (r1 * (1 - ratio) + r2 * ratio);
        int g = (int) (g1 * (1 - ratio) + g2 * ratio);
        int b = (int) (b1 * (1 - ratio) + b2 * ratio);

        return (r << 16) | (g << 8) | b;
    }
}

Как юзать

Use:
Expand Collapse Copy
        Text t = TextUtils.gradientText("Ваш текст", Первый цвет HEX, Второй цвет HEX);
        client.inGameHud.getChatHud().addMessage(t);


ВАЖНО
ЭТО НЕ ДЛЯ EXPENSIVE 3.1 И НЕ ДЛЯ 2.0!!!!
+rep норм тема
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Сливаю как-как очень крутая вещь.

ss:
Посмотреть вложение 284532

TextUtil:
Expand Collapse Copy
package hub.histed.hysteria.client.Utility.Client;

import net.minecraft.text.MutableText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.text.TextColor;

import java.util.List;

public class TextUtils {

    /**
     *
     * [USER=804731]@param[/USER] text
     * [USER=804731]@param[/USER] color1
     * [USER=804731]@param[/USER] color2
     * [USER=46448]@ReturN[/USER]
     */
    public static Text gradientText(String text, int color1, int color2) {
        int length = text.length();
        MutableText finalText = Text.empty();

        for (int i = 0; i < length; i++) {
            float ratio = (float) i / (length - 1);
            int blendedColor = blendColors(color1, color2, ratio);
            MutableText segment = Text.literal(String.valueOf(text.charAt(i)))
                    .setStyle(Style.EMPTY.withColor(TextColor.fromRgb(blendedColor)));
            finalText.append(segment);
        }

        return finalText;
    }

    /**
     *
     * [USER=804731]@param[/USER] color1
     * [USER=804731]@param[/USER] color2
     * [USER=804731]@param[/USER] ratio
     * [USER=46448]@ReturN[/USER]
     */
    private static int blendColors(int color1, int color2, float ratio) {
        int r1 = (color1 >> 16) & 0xFF;
        int g1 = (color1 >> 8) & 0xFF;
        int b1 = color1 & 0xFF;
        int r2 = (color2 >> 16) & 0xFF;
        int g2 = (color2 >> 8) & 0xFF;
        int b2 = color2 & 0xFF;

        int r = (int) (r1 * (1 - ratio) + r2 * ratio);
        int g = (int) (g1 * (1 - ratio) + g2 * ratio);
        int b = (int) (b1 * (1 - ratio) + b2 * ratio);

        return (r << 16) | (g << 8) | b;
    }
}

Как юзать

Use:
Expand Collapse Copy
        Text t = TextUtils.gradientText("Ваш текст", Первый цвет HEX, Второй цвет HEX);
        client.inGameHud.getChatHud().addMessage(t);


ВАЖНО
ЭТО НЕ ДЛЯ EXPENSIVE 3.1 И НЕ ДЛЯ 2.0!!!!
кайф! + реп
 
крутая вещь
 
Назад
Сверху Снизу