All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mmb.engine.texture.ColorDrawer Maven / Gradle / Ivy

Go to download

Dependency for the MultiMachineBuilder, a voxel game about building an industrial empire in a finite world. THIS RELEASE IS NOT PLAYABLE. To play the game, donwload from >ITCH.IO LINK HERE< or >GH releases link here<

The newest version!
/**
 * 
 */
package mmb.engine.texture;

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.Icon;

import mmb.NN;
import mmb.Nil;
import mmb.engine.block.BlockEntry;

/**
 * A single color block drawer
 * @author oskar
 */
public class ColorDrawer implements BlockDrawer {
	
	/** The color of this block drawer */
	@NN public final Color c;
	@NN private final ConstSolidIcon icon;
	public final float r, g, b, a;
	
	
	/**
	 * Creates a single color block drawer
	 * @param c color
	 */
	public ColorDrawer(Color c) {
		this.c = c;
		icon = new ConstSolidIcon(32, 32, c);
		r = c.getRed() / 255.0f;
		g = c.getGreen() / 255.0f;
		b = c.getBlue() / 255.0f;
		a = c.getAlpha() / 255.0f;
	}

	@Override
	public void draw(@Nil BlockEntry ent, int x, int y, Graphics gr, int w, int h) {
		Color old = gr.getColor();
		gr.setColor(c);
		gr.fillRect(x, y, w, h);
		gr.setColor(old);
	}

	@Override
	public Icon toIcon() {
		return icon;
	}

	@Override
	public int LOD() {
		return c.getRGB();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy