Search in sources :

Example 6 with ColorPoint

use of com.talosvfx.talos.runtime.values.ColorPoint in project talos by rockbite.

the class LegacyImporter method readGradientValue.

void readGradientValue(BufferedReader reader, ModuleWrapper toModule, int toSlot, String varName) {
    try {
        if (isActive(reader, varName)) {
            float[] colors = new float[readInt(reader, "colorsCount")];
            for (int i = 0; i < colors.length; i++) colors[i] = readFloat(reader, "colors" + i);
            float[] timeline = new float[readInt(reader, "timelineCount")];
            for (int i = 0; i < timeline.length; i++) timeline[i] = readFloat(reader, "timeline" + i);
            // now normal code...
            Array<ColorPoint> points = new Array<>();
            for (int i = 0; i < timeline.length; i++) {
                ColorPoint point = new ColorPoint();
                point.pos = timeline[i];
                point.color.set(colors[i * 3], colors[i * 3 + 1], colors[i * 3 + 2], 1f);
                points.add(point);
            }
            GradientColorModuleWrapper wrapper = (GradientColorModuleWrapper) stage.moduleBoardWidget.createModule(GradientColorModule.class, leftX, getNextY());
            wrapper.setData(points);
            stage.moduleBoardWidget.makeConnection(wrapper, toModule, RandomRangeModule.OUTPUT, toSlot);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Array(com.badlogic.gdx.utils.Array) ColorPoint(com.talosvfx.talos.runtime.values.ColorPoint) IOException(java.io.IOException) ColorPoint(com.talosvfx.talos.runtime.values.ColorPoint)

Example 7 with ColorPoint

use of com.talosvfx.talos.runtime.values.ColorPoint in project talos by rockbite.

the class GradientImage method setPoints.

public void setPoints(Array<ColorPoint> points) {
    this.points.clear();
    if (points.get(0).pos > 0) {
        this.points.add(new ColorPoint(points.get(0).color, 0f));
    }
    for (int i = 0; i < points.size; i++) {
        ColorPoint point = points.get(i);
        ColorPoint newPoint = new ColorPoint();
        newPoint.set(point);
        this.points.add(newPoint);
    }
    if (points.get(points.size - 1).pos < 1) {
        this.points.add(new ColorPoint(points.get(points.size - 1).color, 1f));
    }
}
Also used : ColorPoint(com.talosvfx.talos.runtime.values.ColorPoint) ColorPoint(com.talosvfx.talos.runtime.values.ColorPoint)

Example 8 with ColorPoint

use of com.talosvfx.talos.runtime.values.ColorPoint in project talos by rockbite.

the class GradientColorModuleWrapper method configureSlots.

@Override
protected void configureSlots() {
    addInputSlot("alpha (0 to 1)", InterpolationModule.ALPHA);
    addOutputSlot("output", 0);
    gradientWidget = new GradientWidget(getSkin());
    contentWrapper.add(gradientWidget).expandX().fillX().growX().height(60).padTop(25).padRight(3).padBottom(3);
    leftWrapper.add(new Table()).expandY();
    rightWrapper.add(new Table()).expandY();
    picker = new ColorPicker();
    gradientWidget.setListener(new GradientWidget.GradientWidgetListener() {

        @Override
        public void colorPickerShow(final ColorPoint point) {
            picker.setListener(null);
            picker.setColor(point.color);
            TalosMain.Instance().UIStage().getStage().addActor(picker.fadeIn());
            picker.setListener(new ColorPickerAdapter() {

                @Override
                public void changed(Color newColor) {
                    super.changed(newColor);
                    point.color.set(newColor);
                    gradientWidget.updateGradientData();
                }
            });
        }
    });
    picker.padTop(32);
    picker.padLeft(16);
    picker.setHeight(330);
    picker.setWidth(430);
    picker.padRight(26);
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) GradientWidget(com.talosvfx.talos.editor.widgets.GradientWidget) ColorPicker(com.kotcrab.vis.ui.widget.color.ColorPicker) ColorPoint(com.talosvfx.talos.runtime.values.ColorPoint) Color(com.badlogic.gdx.graphics.Color) ColorPickerAdapter(com.kotcrab.vis.ui.widget.color.ColorPickerAdapter)

Example 9 with ColorPoint

use of com.talosvfx.talos.runtime.values.ColorPoint in project talos by rockbite.

the class GradientWidget method drawPoints.

public void drawPoints(Batch batch, float parentAlpha) {
    Array<ColorPoint> points = module.getPoints();
    for (int i = 0; i < points.size; i++) {
        Drawable backgroundFrame = getSkin().getDrawable(TRIANGLE);
        batch.setColor(points.get(i).color);
        backgroundFrame.draw(batch, getX() + areaPos.x + areaSize.x * points.get(i).pos - 9, getY() + areaPos.y - 16f, 18f, 16f);
    }
}
Also used : ColorPoint(com.talosvfx.talos.runtime.values.ColorPoint) Drawable(com.badlogic.gdx.scenes.scene2d.utils.Drawable) ColorPoint(com.talosvfx.talos.runtime.values.ColorPoint)

Example 10 with ColorPoint

use of com.talosvfx.talos.runtime.values.ColorPoint in project talos by rockbite.

the class GradientImage method draw.

@Override
public void draw(Batch batch, float parentAlpha) {
    ShaderProgram prevShader = batch.getShader();
    batch.setShader(shaderProgram);
    shaderProgram.setUniformi(U_POINT_COUNT, points.size);
    for (int i = 0; i < points.size; i++) {
        ColorPoint point = points.get(i);
        stringBuilder.clear();
        stringBuilder.append(U_ARR_NAME).append(i).append(U_PARAM_COLOR);
        shaderProgram.setUniformf(stringBuilder.toString(), point.color.r, point.color.g, point.color.b, 1f);
        stringBuilder.clear();
        stringBuilder.append(U_ARR_NAME).append(i).append(U_PARAM_ALPHA);
        shaderProgram.setUniformf(stringBuilder.toString(), point.pos);
    }
    // do the rendering
    batch.draw(white, getX(), getY(), getWidth(), getHeight());
    batch.setShader(prevShader);
}
Also used : ShaderProgram(com.badlogic.gdx.graphics.glutils.ShaderProgram) ColorPoint(com.talosvfx.talos.runtime.values.ColorPoint) ColorPoint(com.talosvfx.talos.runtime.values.ColorPoint)

Aggregations

ColorPoint (com.talosvfx.talos.runtime.values.ColorPoint)13 Color (com.badlogic.gdx.graphics.Color)2 ShaderProgram (com.badlogic.gdx.graphics.glutils.ShaderProgram)2 ColorPicker (com.kotcrab.vis.ui.widget.color.ColorPicker)2 ColorPickerAdapter (com.kotcrab.vis.ui.widget.color.ColorPickerAdapter)2 GradientWidget (com.talosvfx.talos.editor.widgets.GradientWidget)2 Actor (com.badlogic.gdx.scenes.scene2d.Actor)1 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)1 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)1 Drawable (com.badlogic.gdx.scenes.scene2d.utils.Drawable)1 Array (com.badlogic.gdx.utils.Array)1 JsonValue (com.badlogic.gdx.utils.JsonValue)1 ClampMethod (com.gempukku.libgdx.graph.shader.ClampMethod)1 GraphBoxImpl (com.gempukku.libgdx.graph.ui.graph.GraphBoxImpl)1 GraphBoxPartImpl (com.gempukku.libgdx.graph.ui.graph.GraphBoxPartImpl)1 GraphChangedEvent (com.gempukku.libgdx.graph.ui.graph.GraphChangedEvent)1 VisSelectBox (com.kotcrab.vis.ui.widget.VisSelectBox)1 VisTable (com.kotcrab.vis.ui.widget.VisTable)1 IOException (java.io.IOException)1