games.rednblack.h2d.extension.tinyvg.TinyVGDrawableLogic Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of libgdx-tinyvg-extension Show documentation
Show all versions of libgdx-tinyvg-extension Show documentation
TinyVG extension for HyperLap2D libgdx runtime
The newest version!
package games.rednblack.h2d.extension.tinyvg;
import com.artemis.ComponentMapper;
import com.badlogic.gdx.graphics.g2d.Batch;
import dev.lyze.gdxtinyvg.drawers.TinyVGShapeDrawer;
import games.rednblack.editor.renderer.SceneLoader;
import games.rednblack.editor.renderer.components.TintComponent;
import games.rednblack.editor.renderer.components.TransformComponent;
import games.rednblack.editor.renderer.systems.render.logic.DrawableLogic;
import games.rednblack.editor.renderer.utils.TransformMathUtils;
public class TinyVGDrawableLogic implements DrawableLogic {
protected ComponentMapper tinyVGComponentMapper;
protected ComponentMapper tintComponentComponentMapper;
protected ComponentMapper transformComponentMapper;
protected SceneLoader sceneLoader;
private TinyVGShapeDrawer drawer;
public TinyVGDrawableLogic() { }
@Override
public void draw(Batch batch, int entity, float parentAlpha, RenderingType renderingType) {
if (drawer == null)
drawer = new CpuTinyVGShapeDrawer(batch, sceneLoader.getRm().getTextureRegion("white-pixel"));
TintComponent tintComponent = tintComponentComponentMapper.get(entity);
TinyVGComponent tinyVGComponent = tinyVGComponentMapper.get(entity);
TransformComponent transformComponent = transformComponentMapper.get(entity);
TransformMathUtils.computeTransform(transformComponent).mulLeft(batch.getTransformMatrix());
TransformMathUtils.applyTransform(batch, transformComponent);
drawer.setColor(tintComponent.color);
tinyVGComponent.tinyVG.draw(drawer);
TransformMathUtils.resetTransform(batch, transformComponent);
}
@Override
public void beginPipeline() {
}
@Override
public void endPipeline() {
}
}