use of com.helospark.tactview.core.timeline.image.ReadOnlyClipImage in project tactview by helospark.
the class GridProceduralClip method createProceduralFrame.
@Override
public ReadOnlyClipImage createProceduralFrame(GetFrameRequest request, TimelinePosition relativePosition) {
ClipImage result = ClipImage.fromSize(request.getExpectedWidth(), request.getExpectedHeight());
Color color = colorProvider.getValueAt(relativePosition).multiplyComponents(255.0);
int width = (int) (lineWidthProvider.getValueAt(relativePosition) * request.getExpectedWidth());
int xDistance = (int) (xDistanceProvider.getValueAt(relativePosition) * request.getExpectedWidth());
int yDistance = (int) (yDistanceProvider.getValueAt(relativePosition) * request.getExpectedHeight());
if (width <= 0) {
width = 1;
}
if (xDistance <= 0) {
xDistance = 1;
}
if (yDistance <= 0) {
yDistance = 1;
}
int xOffset = (int) (xOffsetProvider.getValueAt(relativePosition) * request.getExpectedWidth()) % xDistance;
int yOffset = (int) (yOffsetProvider.getValueAt(relativePosition) * request.getExpectedHeight()) % yDistance;
int x = xOffset;
while (x <= result.getWidth()) {
drawSimpleVerticalLine(result, x, width, color);
x += xDistance;
}
int y = yOffset;
while (y <= result.getHeight()) {
drawSimpleHorizontalLine(result, y, width, color);
y += yDistance;
}
return result;
}
use of com.helospark.tactview.core.timeline.image.ReadOnlyClipImage in project tactview by helospark.
the class NoiseProceduralClip method createProceduralFrame.
@Override
public ReadOnlyClipImage createProceduralFrame(GetFrameRequest request, TimelinePosition relativePosition) {
int seed = seedProvider.getValueAt(relativePosition);
FastNoise fastNoise = new FastNoise(seed);
double frequency = frequencyProvider.getValueAt(relativePosition);
fastNoise.SetFrequency((float) frequency);
CellularReturnType cellularReturnType = cellularReturnTypeProvider.getValueAt(relativePosition).getCellularReturnType();
fastNoise.SetCellularReturnType(cellularReturnType);
FractalType octaveCombinerType = fractalOctaveCombinderProvider.getValueAt(relativePosition).getFractalType();
fastNoise.SetFractalType(octaveCombinerType);
int octaves = octaveProvider.getValueAt(relativePosition);
fastNoise.SetFractalOctaves(octaves);
double lacunarity = lacunarityProvider.getValueAt(relativePosition);
fastNoise.SetFractalLacunarity((float) lacunarity);
double gain = gainProvider.getValueAt(relativePosition);
fastNoise.SetFractalGain((float) gain);
CellularDistanceFunction cellularDistance = cellularDistanceFunctionProvider.getValueAt(relativePosition).getCellularDistanceFunction();
fastNoise.SetCellularDistanceFunction(cellularDistance);
int width = request.getExpectedWidth();
int height = request.getExpectedHeight();
ClipImage result = ClipImage.fromSize(width, height);
float xOffset = (float) (double) xOffsetProvider.getValueAt(relativePosition);
float yOffset = (float) (double) yOffsetProvider.getValueAt(relativePosition);
Color color = colorProvider.getValueAt(relativePosition);
FractalFunction fractalFunction = fractalKindProvider.getValueAt(relativePosition).getFractalFunction();
independentPixelOperation.executePixelTransformation(width, height, (x, y) -> {
float normalizedX = (float) x / width * 1000f + xOffset;
float normalizedY = (float) y / width * 1000f + yOffset;
float value = fractalFunction.calculateFractalValue(fastNoise, normalizedX, normalizedY);
double noiseLevel = (((value + 1.0) / 2.0) * 255.0);
result.setColorComponentByOffset((int) (noiseLevel * color.red), x, y, 0);
result.setColorComponentByOffset((int) (noiseLevel * color.green), x, y, 1);
result.setColorComponentByOffset((int) (noiseLevel * color.blue), x, y, 2);
result.setColorComponentByOffset(255, x, y, 3);
});
return result;
}
use of com.helospark.tactview.core.timeline.image.ReadOnlyClipImage in project tactview by helospark.
the class CheckerBoardProceduralClip method createProceduralFrame.
@Override
public ReadOnlyClipImage createProceduralFrame(GetFrameRequest request, TimelinePosition relativePosition) {
ClipImage result = ClipImage.fromSize(request.getExpectedWidth(), request.getExpectedHeight());
int width = result.getWidth();
int height = result.getHeight();
double xOffset = xOffsetProvider.getValueAt(relativePosition);
double yOffset = yOffsetProvider.getValueAt(relativePosition);
double xScale = xScaleProvider.getValueAt(relativePosition);
double yScale = yScaleProvider.getValueAt(relativePosition);
Color color1 = color1Provider.getValueAt(relativePosition);
Color color2 = color2Provider.getValueAt(relativePosition);
independentPixelOperation.executePixelTransformation(width, height, (x, y) -> {
double normalizedX = (double) x / width + xOffset;
double normalizedY = (double) y / width + yOffset;
int xType = (int) Math.floor(normalizedX / xScale);
int yType = (int) Math.floor(normalizedY / yScale);
Color colorToUse;
if ((Math.abs(yType % 2) == Math.abs(xType % 2))) {
colorToUse = color1;
} else {
colorToUse = color2;
}
result.setRed((int) (colorToUse.red * 255.0), x, y);
result.setGreen((int) (colorToUse.green * 255.0), x, y);
result.setBlue((int) (colorToUse.blue * 255.0), x, y);
result.setAlpha(255, x, y);
});
return result;
}
use of com.helospark.tactview.core.timeline.image.ReadOnlyClipImage in project tactview by helospark.
the class LinesProceduralClip method createProceduralFrame.
@Override
public ReadOnlyClipImage createProceduralFrame(GetFrameRequest request, TimelinePosition relativePosition) {
ClipImage result = ClipImage.fromSize(request.getExpectedWidth(), request.getExpectedHeight());
Color color = colorProvider.getValueAt(relativePosition).multiplyComponents(255.0);
int width = (int) (lineWidthProvider.getValueAt(relativePosition) * request.getExpectedWidth());
int distance = (int) (distanceProvider.getValueAt(relativePosition) * request.getExpectedWidth());
if (width <= 0) {
width = 1;
}
if (distance <= 0) {
distance = 1;
}
int offset = (int) (offsetProvider.getValueAt(relativePosition) * request.getExpectedWidth()) % distance;
int x = offset;
String orientation = orientationProvider.getValueAt(relativePosition).getId();
if (orientation.equals("horizontal")) {
while (x <= result.getWidth()) {
drawSimpleVerticalLine(result, x, width, color);
x += distance;
}
} else {
int y = offset;
while (y <= result.getHeight()) {
drawSimpleHorizontalLine(result, y, width, color);
y += distance;
}
}
return result;
}
use of com.helospark.tactview.core.timeline.image.ReadOnlyClipImage in project tactview by helospark.
the class DiamondTransition method applyTransitionInternal.
@Override
protected ClipImage applyTransitionInternal(InternalStatelessVideoTransitionEffectRequest transitionRequest) {
double progress = transitionRequest.getProgress();
int w = transitionRequest.getFirstFrame().getWidth();
int h = transitionRequest.getFirstFrame().getHeight();
double fuzziness = fuzzinessProvider.getValueAt(transitionRequest.getEffectPosition());
double t = progress + fuzziness;
List<Point> points = new ArrayList<>();
Point center = new Point(0.5, 0.5);
points.add(center.add(-t, 0));
points.add(center.add(0, -t));
points.add(center.add(t, 0));
points.add(center.add(0, t));
Polygon polygon = new Polygon(points);
PolygonRenderServiceRequest polygonRequest = PolygonRenderServiceRequest.builder().withColor(new Color(1.0, 1.0, 1.0)).withExpectedWidth(w).withExpectedHeight(h).withFuzzyEdge((int) (fuzziness * w)).withPolygon(polygon).build();
ReadOnlyClipImage gradientImage = polygonRenderService.drawPolygon(polygonRequest);
LayerMaskBetweenTwoImageApplyRequest layerMaskRequest = LayerMaskBetweenTwoImageApplyRequest.builder().withBottomFrame(transitionRequest.getFirstFrame()).withTopFrame(transitionRequest.getSecondFrame()).withCalculator(layerMaskAlphaToAlpha).withMask(gradientImage).build();
ClipImage result = layerMaskApplier.mergeTwoImageWithLayerMask(layerMaskRequest);
GlobalMemoryManagerAccessor.memoryManager.returnBuffer(gradientImage.getBuffer());
return result;
}
Aggregations