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();
}
}
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));
}
}
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);
}
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);
}
}
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);
}
Aggregations