Search in sources :

Example 1 with ReadOnlyClipImage

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;
}
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)

Example 2 with ReadOnlyClipImage

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;
}
Also used : CellularDistanceFunction(me.jordanpeck.FastNoise.CellularDistanceFunction) 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) FastNoise(me.jordanpeck.FastNoise) FractalType(me.jordanpeck.FastNoise.FractalType) CellularReturnType(me.jordanpeck.FastNoise.CellularReturnType) RenderTypeHint(com.helospark.tactview.core.timeline.effect.interpolation.hint.RenderTypeHint)

Example 3 with ReadOnlyClipImage

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;
}
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)

Example 4 with ReadOnlyClipImage

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;
}
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)

Example 5 with ReadOnlyClipImage

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;
}
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)

Aggregations

ReadOnlyClipImage (com.helospark.tactview.core.timeline.image.ReadOnlyClipImage)114 ClipImage (com.helospark.tactview.core.timeline.image.ClipImage)88 Color (com.helospark.tactview.core.timeline.effect.interpolation.pojo.Color)21 Point (com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point)16 ScaleRequest (com.helospark.tactview.core.timeline.effect.scale.service.ScaleRequest)10 Test (org.junit.jupiter.api.Test)9 TimelinePosition (com.helospark.tactview.core.timeline.TimelinePosition)8 ByteBuffer (java.nio.ByteBuffer)8 ArrayList (java.util.ArrayList)8 GetFrameRequest (com.helospark.tactview.core.timeline.GetFrameRequest)6 VisualTimelineClip (com.helospark.tactview.core.timeline.VisualTimelineClip)6 InterpolationLine (com.helospark.tactview.core.timeline.effect.interpolation.pojo.InterpolationLine)6 StatelessEffectRequest (com.helospark.tactview.core.timeline.effect.StatelessEffectRequest)5 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 StatelessEffect (com.helospark.tactview.core.timeline.StatelessEffect)4 StatelessVideoEffect (com.helospark.tactview.core.timeline.StatelessVideoEffect)4 VideoClip (com.helospark.tactview.core.timeline.VideoClip)4 Polygon (com.helospark.tactview.core.timeline.effect.interpolation.pojo.Polygon)4 BufferedImage (java.awt.image.BufferedImage)4