Search in sources :

Example 1 with InterpolationLine

use of com.helospark.tactview.core.timeline.effect.interpolation.pojo.InterpolationLine 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 2 with InterpolationLine

use of com.helospark.tactview.core.timeline.effect.interpolation.pojo.InterpolationLine in project tactview by helospark.

the class RectangleProceduralClip method getXPosition.

@Override
public int getXPosition(GetPositionParameters parameterObject) {
    if (extendedFrameProvider.getValueAt(parameterObject.getTimelinePosition())) {
        return super.getXPosition(parameterObject);
    } else {
        InterpolationLine line = lineProvider.getValueAt(parameterObject.getTimelinePosition());
        double xPos = Math.min(line.start.x, line.end.x);
        return (int) (xPos * parameterObject.getWidth()) + super.getXPosition(parameterObject);
    }
}
Also used : InterpolationLine(com.helospark.tactview.core.timeline.effect.interpolation.pojo.InterpolationLine)

Example 3 with InterpolationLine

use of com.helospark.tactview.core.timeline.effect.interpolation.pojo.InterpolationLine in project tactview by helospark.

the class RectangleProceduralClip method createProceduralFrame.

@Override
public ClipImage createProceduralFrame(GetFrameRequest request, TimelinePosition relativePosition) {
    InterpolationLine line = lineProvider.getValueAt(relativePosition);
    Point startPositionNormalized = line.start;
    Point endPositionNormalized = line.end;
    boolean isExtendedFrame = extendedFrameProvider.getValueAt(relativePosition);
    if (isExtendedFrame) {
        return extendedFrameDraw(request, relativePosition, startPositionNormalized, endPositionNormalized);
    } else {
        return nonExtendedFrameDraw(request, relativePosition, startPositionNormalized, endPositionNormalized);
    }
}
Also used : InterpolationLine(com.helospark.tactview.core.timeline.effect.interpolation.pojo.InterpolationLine) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point)

Example 4 with InterpolationLine

use of com.helospark.tactview.core.timeline.effect.interpolation.pojo.InterpolationLine in project tactview by helospark.

the class LinearGradientProceduralClip method createProceduralFrame.

@Override
public ClipImage createProceduralFrame(GetFrameRequest request, TimelinePosition relativePosition) {
    InterpolationLine line = lineProvider.getValueAt(relativePosition);
    Color startColor = startColorProvider.getValueAt(relativePosition);
    Color endColor = endColorProvider.getValueAt(relativePosition);
    LinearGradientRequest linearGradientRequest = LinearGradientRequest.builder().withStartColor(startColor).withEndColor(endColor).withNormalizedLine(line).withWidth(request.getExpectedWidth()).withHeight(request.getExpectedHeight()).build();
    return linearGradientService.render(linearGradientRequest);
}
Also used : Color(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Color) InterpolationLine(com.helospark.tactview.core.timeline.effect.interpolation.pojo.InterpolationLine) LinearGradientRequest(com.helospark.tactview.core.timeline.proceduralclip.gradient.service.LinearGradientRequest)

Example 5 with InterpolationLine

use of com.helospark.tactview.core.timeline.effect.interpolation.pojo.InterpolationLine in project tactview by helospark.

the class LinearGradientService method render.

public ClipImage render(LinearGradientRequest request) {
    int width = request.getWidth();
    int height = request.getHeight();
    ClipImage result = ClipImage.fromSize(width, height);
    InterpolationLine line = request.getNormalizedLine();
    Color startColor = request.getStartColor();
    Color endColor = request.getEndColor();
    Point startPositionInPixels = line.start.multiply(result.getWidth(), result.getHeight());
    Point endPositionInPixels = line.end.multiply(result.getWidth(), result.getHeight());
    Vector2D start = new Vector2D(startPositionInPixels.x, startPositionInPixels.y);
    Vector2D originalEnd = new Vector2D(endPositionInPixels.x, endPositionInPixels.y);
    double lineDistance = start.distance(originalEnd);
    Line perpendicularLine = getPerpendicularLine(start, originalEnd);
    if (!request.getSaturateOnEndSide()) {
        independentPixelOperation.executePixelTransformation(result.getWidth(), result.getHeight(), (x, y) -> {
            // TODO: avoid new on every pixel
            double pixelDistance = perpendicularLine.distance(new Vector2D(x, y));
            if (pixelDistance > lineDistance) {
                setColor(result, x, y, endColor);
            } else {
                double factor = pixelDistance / lineDistance;
                Color newColor = startColor.interpolate(endColor, factor);
                setColor(result, x, y, newColor);
            }
        });
    } else {
        independentPixelOperation.executePixelTransformation(result.getWidth(), result.getHeight(), (x, y) -> {
            // TODO: avoid new on every pixel
            double pixelOffset = perpendicularLine.getOffset(new Vector2D(x, y));
            double pixelDistance = Math.abs(pixelOffset);
            if (pixelOffset < 0.0) {
                setColor(result, x, y, startColor);
            } else if (Math.abs(pixelDistance) > lineDistance) {
                setColor(result, x, y, endColor);
            } else {
                double factor = pixelDistance / lineDistance;
                Color newColor = startColor.interpolate(endColor, factor);
                setColor(result, x, y, newColor);
            }
        });
    }
    return result;
}
Also used : Line(org.apache.commons.math3.geometry.euclidean.twod.Line) InterpolationLine(com.helospark.tactview.core.timeline.effect.interpolation.pojo.InterpolationLine) Vector2D(org.apache.commons.math3.geometry.euclidean.twod.Vector2D) ClipImage(com.helospark.tactview.core.timeline.image.ClipImage) Color(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Color) InterpolationLine(com.helospark.tactview.core.timeline.effect.interpolation.pojo.InterpolationLine) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point)

Aggregations

InterpolationLine (com.helospark.tactview.core.timeline.effect.interpolation.pojo.InterpolationLine)17 Point (com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point)10 Color (com.helospark.tactview.core.timeline.effect.interpolation.pojo.Color)7 ClipImage (com.helospark.tactview.core.timeline.image.ClipImage)7 ReadOnlyClipImage (com.helospark.tactview.core.timeline.image.ReadOnlyClipImage)6 ScaleRequest (com.helospark.tactview.core.timeline.effect.scale.service.ScaleRequest)2 KeyframeAddedRequest (com.helospark.tactview.core.timeline.message.KeyframeAddedRequest)2 LinearGradientRequest (com.helospark.tactview.core.timeline.proceduralclip.gradient.service.LinearGradientRequest)2 AddKeyframeForPropertyCommand (com.helospark.tactview.ui.javafx.commands.impl.AddKeyframeForPropertyCommand)2 HBox (javafx.scene.layout.HBox)2 Component (com.helospark.lightdi.annotation.Component)1 ColorWithAlpha (com.helospark.tactview.core.it.util.ui.ColorWithAlpha)1 AudioVideoFragment (com.helospark.tactview.core.timeline.AudioVideoFragment)1 TimelineClip (com.helospark.tactview.core.timeline.TimelineClip)1 TimelineManagerFramesRequest (com.helospark.tactview.core.timeline.TimelineManagerFramesRequest)1 EffectParametersRepository (com.helospark.tactview.core.timeline.effect.EffectParametersRepository)1 LinearBlurRequest (com.helospark.tactview.core.timeline.effect.blur.service.LinearBlurRequest)1 ValueProviderDescriptor (com.helospark.tactview.core.timeline.effect.interpolation.ValueProviderDescriptor)1 RenderTypeHint (com.helospark.tactview.core.timeline.effect.interpolation.hint.RenderTypeHint)1 DoubleRange (com.helospark.tactview.core.timeline.effect.interpolation.pojo.DoubleRange)1