use of com.talosvfx.talos.runtime.values.ColorPoint in project gdx-graph by MarcinSc.
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 gdx-graph by MarcinSc.
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.setLength(0);
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.setLength(0);
stringBuilder.append(U_ARR_NAME).append(i).append(U_PARAM_ALPHA);
shaderProgram.setUniformf(stringBuilder.toString(), point.pos);
}
// do the rendering
batch.draw(WhitePixel.sharedInstance.texture, getX(), getY(), getWidth(), getHeight());
batch.setShader(prevShader);
}
use of com.talosvfx.talos.runtime.values.ColorPoint in project talos by rockbite.
the class GradientColorModule method setPoints.
public void setPoints(Array<ColorPoint> from) {
points.clear();
for (ColorPoint fromPoint : from) {
ColorPoint point = new ColorPoint(fromPoint.color, fromPoint.pos);
points.add(point);
}
}
use of com.talosvfx.talos.runtime.values.ColorPoint in project talos by rockbite.
the class GradientColorModule method resetPoints.
private void resetPoints() {
// need to guarantee at least one point
points = new Array<>();
ColorPoint colorPoint = new ColorPoint();
colorPoint.pos = 0;
colorPoint.color.set(255 / 255f, 68 / 255f, 26 / 255f, 1f);
points.add(colorPoint);
}
use of com.talosvfx.talos.runtime.values.ColorPoint in project talos by rockbite.
the class GradientColorModule method write.
@Override
public void write(Json json) {
super.write(json);
Array<ColorPoint> points = getPoints();
json.writeArrayStart("points");
for (ColorPoint point : points) {
json.writeObjectStart();
json.writeValue("r", point.color.r);
json.writeValue("g", point.color.g);
json.writeValue("b", point.color.b);
json.writeValue("pos", point.pos);
json.writeObjectEnd();
}
json.writeArrayEnd();
}
Aggregations