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

com.uwsoft.editor.renderer.systems.render.logic.NinePatchDrawableLogic Maven / Gradle / Ivy

Go to download

overlap2d-runtime-libgdx provides functionality to load, manipulate and render scenes generated by Overlap2D.

The newest version!
package com.uwsoft.editor.renderer.systems.render.logic;

import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.math.Matrix4;
import com.uwsoft.editor.renderer.components.*;

public class NinePatchDrawableLogic implements Drawable {

	private ComponentMapper tintComponentComponentMapper;
	private ComponentMapper transformMapper;
	private ComponentMapper dimensionsMapper;
	private ComponentMapper ninePatchMapper;


	public NinePatchDrawableLogic() {
		tintComponentComponentMapper = ComponentMapper.getFor(TintComponent.class);
		transformMapper = ComponentMapper.getFor(TransformComponent.class);
		dimensionsMapper = ComponentMapper.getFor(DimensionsComponent.class);
		ninePatchMapper = ComponentMapper.getFor(NinePatchComponent.class);
	}

	@Override
	public void draw(Batch batch, Entity entity) {
		TintComponent tintComponent = tintComponentComponentMapper.get(entity);
		TransformComponent entityTransformComponent = transformMapper.get(entity);
		DimensionsComponent entityDimensionsComponent = dimensionsMapper.get(entity);
		NinePatchComponent entityNinePatchComponent = ninePatchMapper.get(entity);
		batch.setColor(tintComponent.color);

		entityNinePatchComponent.ninePatch.draw(batch, entityTransformComponent.x, entityTransformComponent.y, entityDimensionsComponent.width, entityDimensionsComponent.height);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy