Search in sources :

Example 1 with ClipImage

use of com.helospark.tactview.core.timeline.image.ClipImage in project tactview by helospark.

the class RadialGradientService method createImageWithGradient.

public ClipImage createImageWithGradient(RadialGradientRequest request) {
    Point center = request.getCenter();
    double radius = request.getRadius();
    Color startColor = request.getStartColor();
    Color endColor = request.getEndColor();
    double innerSaturation = request.getInnerSaturation();
    ClipImage result = ClipImage.fromSize(request.getWidth(), request.getHeight());
    independentPixelOperation.executePixelTransformation(request.getWidth(), request.getHeight(), (x, y) -> {
        double distance = center.distanceFrom(x, y);
        if (distance > radius) {
            setColor(result, x, y, endColor);
        } else {
            double factor = (distance / radius);
            if (factor <= innerSaturation) {
                setColor(result, x, y, startColor);
            } else {
                double realDistanceNormalized = 1.0 - innerSaturation;
                factor = (factor - innerSaturation) / realDistanceNormalized;
                Color newColor = startColor.interpolate(endColor, factor);
                setColor(result, x, y, newColor);
            }
        }
    });
    return result;
}
Also used : Color(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Color) ClipImage(com.helospark.tactview.core.timeline.image.ClipImage) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point)

Example 2 with ClipImage

use of com.helospark.tactview.core.timeline.image.ClipImage in project tactview by helospark.

the class DrawnEllipseHighlightProceduralEffect method createProceduralFrame.

@Override
public ClipImage createProceduralFrame(GetFrameRequest request, TimelinePosition relativePosition) {
    ClipImage result = ClipImage.fromSize(request.getExpectedWidth(), request.getExpectedHeight());
    double progress;
    double endSeconds = endPositionProvider.getValueAt(relativePosition);
    double actualSeconds = relativePosition.getSeconds().doubleValue();
    if (endSeconds > actualSeconds) {
        progress = actualSeconds / endSeconds;
    } else {
        progress = 1.0;
    }
    int brushSize = (int) (brushSizeProvider.getValueAt(relativePosition) * request.getScale());
    if (brushSize < 1) {
        brushSize = 1;
    }
    Point topLeft = topLeftProvider.getValueAt(relativePosition);
    topLeft = new Point(topLeft.x * request.getExpectedWidth(), topLeft.y * request.getExpectedHeight());
    Point bottomRight = bottomRightProvider.getValueAt(relativePosition);
    bottomRight = new Point(bottomRight.x * request.getExpectedWidth(), bottomRight.y * request.getExpectedHeight());
    int width = (int) Math.abs(bottomRight.x - topLeft.x);
    int height = (int) Math.abs(bottomRight.y - topLeft.y);
    int centerX = (int) (topLeft.x + width / 2);
    int centerY = (int) (bottomRight.y - height / 2);
    String brushFilePath = brushFileProvider.getValueOrDefault(relativePosition, "classpath:/brushes/Sponge-02.gbr");
    Color color = colorProvider.getValueAt(relativePosition);
    if (width > 0 && height > 0) {
        DrawLineRequest drawLineRequest = DrawLineRequest.builder().withBrushFilePath(brushFilePath).withBrushSize(brushSize).withColor(color).withPixels(bresenhemPixelProvider.ellipsePixels(centerX, centerY, width, height)).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) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point)

Example 3 with ClipImage

use of com.helospark.tactview.core.timeline.image.ClipImage in project tactview by helospark.

the class DrawnRectangleHighlightProceduralEffect method createProceduralFrame.

@Override
public ClipImage createProceduralFrame(GetFrameRequest request, TimelinePosition relativePosition) {
    ClipImage result = ClipImage.fromSize(request.getExpectedWidth(), request.getExpectedHeight());
    double progress;
    double endSeconds = endPositionProvider.getValueAt(relativePosition);
    double actualSeconds = relativePosition.getSeconds().doubleValue();
    if (endSeconds > actualSeconds) {
        progress = actualSeconds / endSeconds;
    } else {
        progress = 1.0;
    }
    Rectangle rectangle = rectangleProvider.getValueAt(relativePosition);
    double overshoot = overshootProvider.getValueAt(relativePosition);
    double totalLength = rectangle.getLength() * (1.0 + overshoot * 2 * 4);
    double lengthToDraw = progress * totalLength;
    int brushSize = (int) (brushSizeProvider.getValueAt(relativePosition) * request.getScale());
    if (brushSize < 1) {
        brushSize = 1;
    }
    String brushFilePath = brushFileProvider.getValueOrDefault(relativePosition, "classpath:/brushes/Sponge-02.gbr");
    Point brushHalfSize = new Point((double) brushSize / request.getExpectedWidth() / 2.0, (double) brushSize / request.getExpectedHeight() / 2.0);
    Color color = colorProvider.getValueAt(relativePosition);
    for (int i = 0; i < 4 && lengthToDraw > 0.0; ++i) {
        // 0->1, 1->2, 2->3, 3->0
        Point start = rectangle.points.get(i).subtract(brushHalfSize);
        Point end = rectangle.points.get((i + 1) % 4).subtract(brushHalfSize);
        Point overshootOffsetVector = end.subtract(start).normalize().scalarMultiply(overshoot);
        start = start.subtract(overshootOffsetVector);
        end = end.add(overshootOffsetVector);
        double distance = start.distanceFrom(end);
        double lineProgress = lengthToDraw > distance ? 1.0 : lengthToDraw / distance;
        Point startInPixels = start.multiply(request.getExpectedWidth(), request.getExpectedHeight());
        Point endInPixels = end.multiply(request.getExpectedWidth(), request.getExpectedHeight());
        DrawLineRequest drawLineRequest = DrawLineRequest.builder().withBrushFilePath(brushFilePath).withBrushSize(brushSize).withColor(color).withPixels(bresenhemPixelProvider.linePixels(startInPixels, endInPixels)).withProgress(lineProgress).withResult(result).build();
        drawLineService.drawLine(drawLineRequest);
        lengthToDraw -= distance;
    }
    return result;
}
Also used : ClipImage(com.helospark.tactview.core.timeline.image.ClipImage) Color(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Color) Rectangle(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Rectangle) DrawLineRequest(com.helospark.tactview.core.timeline.proceduralclip.lines.impl.DrawLineRequest) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point)

Example 4 with ClipImage

use of com.helospark.tactview.core.timeline.image.ClipImage in project tactview by helospark.

the class HighlightPenProceduralEffect method createProceduralFrame.

@Override
public ClipImage createProceduralFrame(GetFrameRequest request, TimelinePosition relativePosition) {
    ClipImage result = ClipImage.fromSize(request.getExpectedWidth(), request.getExpectedHeight());
    double progress;
    double endSeconds = endPositionProvider.getValueAt(relativePosition);
    double actualSeconds = relativePosition.getSeconds().doubleValue();
    if (endSeconds > actualSeconds) {
        progress = actualSeconds / endSeconds;
    } else {
        progress = 1.0;
    }
    InterpolationLine line = lineProvider.getValueAt(relativePosition).multiply(request.getExpectedWidth(), request.getExpectedHeight());
    int brushSize = (int) (brushSizeProvider.getValueAt(relativePosition) * request.getScale());
    if (brushSize < 1) {
        brushSize = 1;
    }
    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.linePixels(line.start, line.end)).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) InterpolationLine(com.helospark.tactview.core.timeline.effect.interpolation.pojo.InterpolationLine)

Example 5 with ClipImage

use of com.helospark.tactview.core.timeline.image.ClipImage 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;
}
Also used : ReadOnlyClipImage(com.helospark.tactview.core.timeline.image.ReadOnlyClipImage) ClipImage(com.helospark.tactview.core.timeline.image.ClipImage) Color(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Color)

Aggregations

ClipImage (com.helospark.tactview.core.timeline.image.ClipImage)110 ReadOnlyClipImage (com.helospark.tactview.core.timeline.image.ReadOnlyClipImage)92 Color (com.helospark.tactview.core.timeline.effect.interpolation.pojo.Color)29 Point (com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point)24 ScaleRequest (com.helospark.tactview.core.timeline.effect.scale.service.ScaleRequest)10 InterpolationLine (com.helospark.tactview.core.timeline.effect.interpolation.pojo.InterpolationLine)7 ByteBuffer (java.nio.ByteBuffer)7 TimelinePosition (com.helospark.tactview.core.timeline.TimelinePosition)6 DrawLineRequest (com.helospark.tactview.core.timeline.proceduralclip.lines.impl.DrawLineRequest)6 ArrayList (java.util.ArrayList)6 Polygon (com.helospark.tactview.core.timeline.effect.interpolation.pojo.Polygon)5 Test (org.junit.jupiter.api.Test)5 VideoClip (com.helospark.tactview.core.timeline.VideoClip)4 BlurRequest (com.helospark.tactview.core.timeline.effect.blur.BlurRequest)4 StatelessEffectRequest (com.helospark.tactview.core.timeline.effect.StatelessEffectRequest)3 ValueListElement (com.helospark.tactview.core.timeline.effect.interpolation.provider.ValueListElement)3 LayerMaskBetweenTwoImageApplyRequest (com.helospark.tactview.core.timeline.effect.layermask.LayerMaskBetweenTwoImageApplyRequest)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 CloneRequestMetadata (com.helospark.tactview.core.clone.CloneRequestMetadata)2 VisualMediaMetadata (com.helospark.tactview.core.decoder.VisualMediaMetadata)2