Search in sources :

Example 1 with Polygon

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;
}
Also used : ClipImage(com.helospark.tactview.core.timeline.image.ClipImage) Color(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Color) DrawLineRequest(com.helospark.tactview.core.timeline.proceduralclip.lines.impl.DrawLineRequest) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point) Polygon(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Polygon) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point)

Example 2 with Polygon

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;
}
Also used : LayerMaskBetweenTwoImageApplyRequest(com.helospark.tactview.core.timeline.effect.layermask.LayerMaskBetweenTwoImageApplyRequest) Color(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Color) ReadOnlyClipImage(com.helospark.tactview.core.timeline.image.ReadOnlyClipImage) ReadOnlyClipImage(com.helospark.tactview.core.timeline.image.ReadOnlyClipImage) ClipImage(com.helospark.tactview.core.timeline.image.ClipImage) ArrayList(java.util.ArrayList) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point) Polygon(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Polygon) PolygonRenderServiceRequest(com.helospark.tactview.core.timeline.proceduralclip.polygon.impl.PolygonRenderServiceRequest) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point)

Example 3 with Polygon

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);
    }
}
Also used : ArrayList(java.util.ArrayList) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point) Polygon(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Polygon) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point)

Example 4 with Polygon

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;
    }
}
Also used : ReadOnlyClipImage(com.helospark.tactview.core.timeline.image.ReadOnlyClipImage) ReadOnlyClipImage(com.helospark.tactview.core.timeline.image.ReadOnlyClipImage) ClipImage(com.helospark.tactview.core.timeline.image.ClipImage) Polygon(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Polygon) PolygonRenderServiceRequest(com.helospark.tactview.core.timeline.proceduralclip.polygon.impl.PolygonRenderServiceRequest)

Example 5 with Polygon

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;
}
Also used : ClipImage(com.helospark.tactview.core.timeline.image.ClipImage) Color(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Color) DrawLineRequest(com.helospark.tactview.core.timeline.proceduralclip.lines.impl.DrawLineRequest) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point) Polygon(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Polygon) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point)

Aggregations

Polygon (com.helospark.tactview.core.timeline.effect.interpolation.pojo.Polygon)9 Point (com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point)6 Color (com.helospark.tactview.core.timeline.effect.interpolation.pojo.Color)5 ClipImage (com.helospark.tactview.core.timeline.image.ClipImage)5 ReadOnlyClipImage (com.helospark.tactview.core.timeline.image.ReadOnlyClipImage)4 ArrayList (java.util.ArrayList)4 PolygonRenderServiceRequest (com.helospark.tactview.core.timeline.proceduralclip.polygon.impl.PolygonRenderServiceRequest)3 DrawLineRequest (com.helospark.tactview.core.timeline.proceduralclip.lines.impl.DrawLineRequest)2 Component (com.helospark.lightdi.annotation.Component)1 TimelinePosition (com.helospark.tactview.core.timeline.TimelinePosition)1 EffectParametersRepository (com.helospark.tactview.core.timeline.effect.EffectParametersRepository)1 ValueProviderDescriptor (com.helospark.tactview.core.timeline.effect.interpolation.ValueProviderDescriptor)1 PolygonProvider (com.helospark.tactview.core.timeline.effect.interpolation.provider.PolygonProvider)1 LayerMaskBetweenTwoImageApplyRequest (com.helospark.tactview.core.timeline.effect.layermask.LayerMaskBetweenTwoImageApplyRequest)1 KeyframeAddedRequest (com.helospark.tactview.core.timeline.message.KeyframeAddedRequest)1 UiCommandInterpreterService (com.helospark.tactview.ui.javafx.UiCommandInterpreterService)1 UiTimelineManager (com.helospark.tactview.ui.javafx.UiTimelineManager)1 AddKeyframeForPropertyCommand (com.helospark.tactview.ui.javafx.commands.impl.AddKeyframeForPropertyCommand)1 InputModeRepository (com.helospark.tactview.ui.javafx.inputmode.InputModeRepository)1 ResultType (com.helospark.tactview.ui.javafx.inputmode.strategy.ResultType)1