[ 
https://issues.apache.org/jira/browse/BATIK-1361?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17771843#comment-17771843
 ] 

Stanimir Stamenkov commented on BATIK-1361:
-------------------------------------------

Really minimal SVG source:

{code:xml|title=rotate-origin.svg}
<svg version="1.1" xmlns="http://www.w3.org/2000/svg";
    width="200" height="200" viewBox="-50 -50 200 200">

  <rect x="0" y="0" width="100" height="100" stroke-width="2"
      stroke="currentColor" fill="cornflowerblue" paint-order="stroke fill">

    <animateTransform attributeName="transform" type="rotate"
        from="0 50 50" to="360 50 50" dur="2s" repeatCount="2" />

  </rect>

</svg>
{code}

Can be used with [^SVGAnimTest3.java] as the 270-degree frames match the 
expected animation times: 2-sec animation (0 – 360 degrees) repeated twice: 
1.5s, 3.5s

> Animated rotate() tranform ignores y-origin at exactly 270 degrees
> ------------------------------------------------------------------
>
>                 Key: BATIK-1361
>                 URL: https://issues.apache.org/jira/browse/BATIK-1361
>             Project: Batik
>          Issue Type: Bug
>    Affects Versions: 1.17
>         Environment: Batik 1.17; Java 17; Windows 10
>            Reporter: Stanimir Stamenkov
>            Priority: Major
>         Attachments: SVGAnimTest.java, SVGAnimTest2.java, SVGAnimTest3.java, 
> frame-1.4750.png, frame-1.5000.png, frame-1.5000@.png, frame-1.5250.png, 
> left_ptr_watch-20fps-046.png, left_ptr_watch.svg, rotate-origin.svg, 
> rotate-origin2.svg, wait-0.5375.png, wait-0.5625@.png, wait-0.5875.png, 
> wait-1.1000.png, wait-1.1250@.png, wait-1.1500.png, wait-1.7250.png, 
> wait-1.7500@.png, wait-1.7750.png, wait-2.2250.png, wait-2.2500@.png, 
> wait-2.2750.png, wait-20fps-046.png, wait-40fps-046.png, wait-40fps-091.png, 
> wait-40fps-106.png, wait-60fps-136.png, wait.svg
>
>
> I have a small (3 sec) SVG animation I'm tryng to render the individual 
> frames of as bitmaps, like:
> {code:java}
> import java.nio.file.Path;
> import org.w3c.dom.Document;
> import org.apache.batik.transcoder.SVGAbstractTranscoder;
> import org.apache.batik.transcoder.TranscoderInput;
> import org.apache.batik.transcoder.TranscoderOutput;
> import org.apache.batik.transcoder.image.ImageTranscoder;
> import org.apache.batik.transcoder.image.PNGTranscoder;
>         Path framesDir;
>         Document svgDoc;
>         ...
>         TranscoderInput svg = new TranscoderInput(svgDoc);
>         final float duration = 3.0f;
>         final float frameRate = 20;
>         ImageTranscoder transcoder = new PNGTranscoder();
>         transcoder.addTranscodingHint(
>                 SVGAbstractTranscoder.KEY_EXECUTE_ONLOAD, true);
>         float animTime = 0;
>         for (int frame = 1; animTime < duration; animTime = frame++ / 
> frameRate) {
>             transcoder.addTranscodingHint(
>                     SVGAbstractTranscoder.KEY_SNAPSHOT_TIME, animTime);
>             Path frameFile = framesDir.resolve(BASE_NAME + "-" + frame + 
> ".png");
>             try (OutputStream fout = Files.newOutputStream(frameFile)) {
>                 transcoder.transcode(svg, new TranscoderOutput(fout));
>             }
>         }
> {code}
> I'm noticing with this specific animation ({{wait.svg}}) one of the frames is 
> "broken":
> || Frame #46 ||
> | !wait-20fps-046.png! |
> This appears when I'm rendering 20 fps for a total of 60 frames (3 seconds).  
> I've tried 15 fps and 30 fps, and I'm not observing such broken frames.  Then 
> I've tried 40 fps and I'm seeing few more broken frames:
> || Frame #46 || Frame #91 || Frame #106 ||
> | !wait-40fps-046.png! | !wait-40fps-091.png! | !wait-40fps-106.png! |
> At 45 and 50 fps I'm not observing broken frames.  At 60 fps I'm observing 
> one broken frame:
> || Frame #136 ||
> | !wait-60fps-136.png! |
> I'm noticing some magic numbers here: 
> {noformat}
> 46 (1-based) = 45 (0-based)
> 91 - 46 = 45
> 136 - 91 = 45
> {noformat}
> Not sure how and if *#106* fits in here... but {{136 - 106 = 20}} - the 
> common 20, 40, 60 (fps) denominator 🤪.
> *Steps to Reproduce*
> # Save [^wait.svg] and [^SVGAnimTest.java] into a single directory;
> # From the same directory execute:
> {noformat}
> java -cp <batik-dist>/lib/* SVGAnimTest.java
> {noformat}
> # Observe the animation frames in the output {{wait-20fps}} directory.
> *Actual Results*
> Frame {{wait-20fps-046.png}} is broken.
> *Expected Results*
> All frames should be fine.
> *Details*
> To experiment with different frame rates use:
> {noformat}
> java -cp <batik-dist>/lib/* SVGAnimTest.java [fps]
> {noformat}
> f.e.:
> {noformat}
> java -cp <batik-dist>/lib/* SVGAnimTest.java 40
> {noformat}
> ---
> _Disclaimer:_ The original 
> [wait.svg|https://github.com/ful1e5/Bibata_Cursor/blob/v2.0.4/svg/original/wait.svg]
>  is from the [Bibata_Cursor|https://github.com/ful1e5/Bibata_Cursor] project.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-h...@xmlgraphics.apache.org

Reply via email to