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

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

More streamlined test case:

* [^DebugSVGAnimation.java]
{noformat}
java -cp <batik-dist>/lib/* DebugSVGAnimation.java [-ref] [svg-file] [time]...
{noformat}
Without arguments renders the {{rotate-center-1.svg}} w/o reference frames 
around the key times matching angles: 0, 90, 180, 270, 360, 450, 540, 630.  
Render one of the other samples with reference frames like:
{noformat}
java -cp <batik-dist>/lib/* DebugSVGAnimation.java -ref rotate-center-2
{noformat}
Use it with your SVG animation specifying the target snapshot times:
{noformat}
java -cp <batik-dist>/lib/* DebugSVGAnimation.java another.svg 0.5 1.5 3.5
{noformat}
* [^rotate-center-0.svg] – rotation with {{cx=0, cy=0}} doesn't exhibit the 
problem
* [^rotate-center-1.svg] – rotation with {{cx=50, cy=50}} reveals the problem 
at 270-deg angles
* [^rotate-center-2.svg] – rotation with {{cx=0, cy=50}} reveals the problem at 
180-deg angles

As I've noted in 
[xmlgraphics-batik#39|https://github.com/apache/xmlgraphics-batik/pull/39] the 
problem should happen at 0 and 360-deg angles, but the rendered result is fine. 
 I speculate there are optimizations for these cases in place.  Still, I don't 
know why only the y-center of the rotation (and not the x-center) is off in the 
rendered result.


> 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: DebugSVGAnimation.java, 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-center-0.svg, rotate-center-1.svg, 
> rotate-center-2.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