package io.github.achtern.AchternEngine.core.rendering.generator;

import io.github.achtern.AchternEngine.core.math.Vector2f;
import io.github.achtern.AchternEngine.core.rendering.Color;

import java.awt.*;
import java.awt.image.BufferedImage;

public class ImageGenerator {

    public static BufferedImage fromColor(Color color) {
        return fromColor(new Vector2f(1, 1), color);
    }

    public static BufferedImage fromColor(Vector2f dimensions, Color color) {
        BufferedImage image = new BufferedImage((int) dimensions.getX(), (int) dimensions.getY(), BufferedImage.TYPE_INT_RGB);


        Graphics2D g = image.createGraphics();

        g.setPaint(color.toAwt());
        g.fillRect(0, 0, (int) dimensions.getX(), (int) dimensions.getY());


        g.dispose();

        return image;
    }

}

@@ -179,16 +179,74 @@
 g.Color;
+%0Aimport io.github.achtern.AchternEngine.core.util.UBuffer;
 %0A%0Aimport
@@ -294,16 +294,44 @@
 edImage;
+%0Aimport java.nio.ByteBuffer;
 %0A%0Apublic
@@ -858,24 +858,24 @@
 dispose();%0A%0A
-
         retu
@@ -891,10 +891,805 @@
 %0A    %7D%0A%0A
+    public static ByteBuffer bytesFromColor(Color color) %7B%0A        return bytesFromColor(new Vector2f(1, 1), color);%0A    %7D%0A%0A    public static ByteBuffer bytesFromColor(Vector2f dimensions, Color color) %7B%0A        ByteBuffer buffer = UBuffer.createByteBuffer((int) (dimensions.getX() * dimensions.getY() * 4));%0A%0A        for(int y = 0; y %3C dimensions.getY(); y++) %7B%0A            for(int x = 0; x %3C dimensions.getX(); x++) %7B%0A%0A                int pixel = color.toInt();%0A%0A                buffer.put((byte)((pixel) & 0xFF)); // R%0A                buffer.put((byte)((pixel %3E%3E 8) & 0xFF)); // G%0A                buffer.put((byte)((pixel %3E%3E 16) & 0xFF)); // B%0A                buffer.put((byte)((pixel %3E%3E 24) & 0xFF)); // Alpha%0A%0A            %7D%0A        %7D%0A%0A        buffer.flip();%0A%0A%0A        return buffer;%0A    %7D%0A%0A
 %7D%0A

Create ByteBuffers for Textures from Color