Valkryst / VTerminal

A new Look-and-Feel (LaF) for Java, which allows for a grid-based display of Unicode characters with custom fore/background colors, font sizes, and pseudo-shaders. Originally designed for developing Roguelike/lite games.

Home Page:https://www.valkryst.com/posts?search=VTerminal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Review classes in the "misc" package.

Valkryst opened this issue · comments

commented
commented

ColorFunctions

  • Allow chaining of the calls, by returning a Color object from each of the functions.
  • JavaDoc can be improved.
  • Some of the functions have ambiguous parameter names.
  • The two alphaBlend functions can be combined into a single function.

ImageCache

  • Don't allow users to modify the cache, it should have a set initial/maximum capacity with optimized settings by default.
    • It may be possible to actively profile the cache to determine the best settings for each user, and apply them automatically.
  • JavaDoc can be improved.
  • Re-evaluate use of the caffeine dependency, there may be better alternatives.

REXPaintLoader

This class can be sent to the back-burner for now, though it does need a thorough review and some testing done to ensure that it still supports up-to-date REXPaint versions.

ShapeAlgorithms

This class does not require a thorough review, until #102 is addressed.

TileFunctions

This class can be deleted, as it isn't used anywhere. A copy of the current code can be found below.

package com.valkryst.VTerminal.misc;

import com.valkryst.VTerminal.Tile;
import lombok.NonNull;

import java.awt.Color;

public class TileFunctions {
    public void applyColorGradient(final @NonNull Color colorFrom, final @NonNull Color colorTo, final boolean applyToBackground, final Tile... tiles) {
        if (tiles == null || tiles.length == 0) {
            return;
        }

        // Determine the difference between the RGB values of the colors:
        final float redDifference = colorTo.getRed() - colorFrom.getRed();
        final float greenDifference = colorTo.getGreen() - colorFrom.getGreen();
        final float blueDifference = colorTo.getBlue() - colorFrom.getBlue();

        // Determine the amount to increment the RGB values by and convert the values to the 0-1 scale:
        final float redChangePerColumn = (redDifference / tiles.length) / 255f;
        final float greenChangePerColumn = (greenDifference / tiles.length) / 255f;
        final float blueChangePerColumn = (blueDifference / tiles.length) / 255f;

        // Set the starting RGB values and convert them to the 0-1 scale:
        float redCurrent = colorFrom.getRed() / 255f;
        float greenCurrent = colorFrom.getGreen() / 255f;
        float blueCurrent = colorFrom.getBlue() / 255f;

        // Set the new color values:
        for (final Tile tile : tiles) {
            if (applyToBackground) {
                tile.setBackgroundColor(new Color(redCurrent, greenCurrent, blueCurrent));
            } else {
                tile.setForegroundColor(new Color(redCurrent, greenCurrent, blueCurrent));
            }

            redCurrent += redChangePerColumn;
            greenCurrent += greenChangePerColumn;
            blueCurrent += blueChangePerColumn;
        }
    }
}