use of com.helospark.tactview.core.timeline.effect.interpolation.pojo.Polygon in project tactview by helospark.
the class DrawnPolygonProceduralClip method createProceduralFrame.
@Override
public ClipImage createProceduralFrame(GetFrameRequest request, TimelinePosition relativePosition) {
ClipImage result = ClipImage.fromSize(request.getExpectedWidth(), request.getExpectedHeight());
double progress = drawPercentageProvider.getValueAt(relativePosition);
int brushSize = (int) (brushSizeProvider.getValueAt(relativePosition) * request.getScale());
if (brushSize < 1) {
brushSize = 1;
}
Polygon polygon = polygonProvider.getValueAt(relativePosition).multiplyPoints(new Point(request.getExpectedWidth(), request.getExpectedHeight()));
String brushFilePath = brushFileProvider.getValueOrDefault(relativePosition, "classpath:/brushes/Sponge-02.gbr");
Color color = colorProvider.getValueAt(relativePosition);
DrawLineRequest drawLineRequest = DrawLineRequest.builder().withBrushFilePath(brushFilePath).withBrushSize(brushSize).withColor(color).withPixels(bresenhemPixelProvider.polygonPixels(polygon)).withProgress(progress).withResult(result).build();
drawLineService.drawLine(drawLineRequest);
return result;
}
use of com.helospark.tactview.core.timeline.effect.interpolation.pojo.Polygon 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;
}
use of com.helospark.tactview.core.timeline.effect.interpolation.pojo.Polygon in project tactview by helospark.
the class PolygonProvider method doInterpolate.
private Polygon doInterpolate(Entry<TimelinePosition, List<Point>> previousEntry, Entry<TimelinePosition, List<Point>> nextEntry, TimelinePosition currentPosition) {
List<Point> lastPoints = previousEntry.getValue();
List<Point> nextPoints = nextEntry.getValue();
if (lastPoints.size() != nextPoints.size()) {
// we cannot interpolate a polygon with changing sides
return new Polygon(lastPoints);
} else {
List<Point> newPoints = new ArrayList<>();
for (int i = 0; i < lastPoints.size(); ++i) {
Point point1 = lastPoints.get(i);
Point point2 = nextPoints.get(i);
double xCoordinate = interpolateAxis(previousEntry, nextEntry, currentPosition, new double[] { point1.x, point2.x });
double yCoordinate = interpolateAxis(previousEntry, nextEntry, currentPosition, new double[] { point1.y, point2.y });
newPoints.add(new Point(xCoordinate, yCoordinate));
}
return new Polygon(newPoints);
}
}
use of com.helospark.tactview.core.timeline.effect.interpolation.pojo.Polygon in project tactview by helospark.
the class PolygonMaskEffect method createFrame.
@Override
public ReadOnlyClipImage createFrame(StatelessEffectRequest request) {
int fuzzyEdge = (int) (fuzzyProvider.getValueAt(request.getEffectPosition()) * request.getCurrentFrame().getWidth());
Polygon polygon = polygonProvider.getValueAt(request.getEffectPosition());
if (polygon.getPoints().size() > 2) {
PolygonRenderServiceRequest polygonDrawerServiceRequest = PolygonRenderServiceRequest.builder().withColor(Color.of(1.0, 1.0, 1.0)).withExpectedWidth(request.getCurrentFrame().getWidth()).withExpectedHeight(request.getCurrentFrame().getHeight()).withFuzzyEdge(fuzzyEdge).withPolygon(polygon).build();
ReadOnlyClipImage layerMask = polygonRenderService.drawPolygon(polygonDrawerServiceRequest);
LayerMaskApplyRequest layerMaskApplyRequest = LayerMaskApplyRequest.builder().withCalculator(layerMaskAlphaToAlpha).withCurrentFrame(request.getCurrentFrame()).withInvert(false).withMask(layerMask).withScaleLayerMask(false).build();
ClipImage result = layerMaskApplier.createNewImageWithLayerMask(layerMaskApplyRequest);
GlobalMemoryManagerAccessor.memoryManager.returnBuffer(layerMask.getBuffer());
return result;
} else {
ClipImage result = ClipImage.sameSizeAs(request.getCurrentFrame());
result.copyFrom(request.getCurrentFrame());
return result;
}
}
use of com.helospark.tactview.core.timeline.effect.interpolation.pojo.Polygon in project tactview by helospark.
the class DrawnNurbsProceduralClip method createProceduralFrame.
@Override
public ClipImage createProceduralFrame(GetFrameRequest request, TimelinePosition relativePosition) {
ClipImage result = ClipImage.fromSize(request.getExpectedWidth(), request.getExpectedHeight());
double progress = drawPercentageProvider.getValueAt(relativePosition);
int brushSize = (int) (brushSizeProvider.getValueAt(relativePosition) * request.getScale());
if (brushSize < 1) {
brushSize = 1;
}
Polygon polygon = polygonProvider.getValueAt(relativePosition).multiplyPoints(new Point(request.getExpectedWidth(), request.getExpectedHeight()));
String brushFilePath = brushFileProvider.getValueOrDefault(relativePosition, "classpath:/brushes/Sponge-02.gbr");
Color color = colorProvider.getValueAt(relativePosition);
boolean close = closeProvider.getValueAt(relativePosition);
DrawLineRequest drawLineRequest = DrawLineRequest.builder().withBrushFilePath(brushFilePath).withBrushSize(brushSize).withColor(color).withPixels(bresenhemPixelProvider.nurbsPixels(polygon, close)).withProgress(progress).withResult(result).build();
drawLineService.drawLine(drawLineRequest);
return result;
}
Aggregations