[jira] [Commented] (BATIK-1361) Animated rotate() tranform ignores y-origin at exactly 270 degrees

2023-10-16 Thread Stanimir Stamenkov (Jira)


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

Stanimir Stamenkov commented on BATIK-1361:
---

bq. Still, I don't know why only the y-center of the rotation (and not the 
x-center) is off in the rendered result.

Dismiss that one, as well.  The observed effect is as expected – here's a 
visual hint for rotation with 0,0 origin:

|| 0 || 90 || 180 || 270 |
| {noformat}
  │
──┼──
  │██
{noformat} | {noformat}
  │
──┼──
██│
{noformat} | {noformat}
██│
──┼──
  │
{noformat} | {noformat}
  │██
──┼──
  │
{noformat} |

So at 270 deg the rectangle is "shifted" only up the y-axis.

> 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 /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 /lib/* SVGAnimTest.java [fps]
> {noformat}
> f.e.:
> {noformat}
> java -cp /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 

[jira] [Commented] (BATIK-1361) Animated rotate() tranform ignores y-origin at exactly 270 degrees

2023-10-11 Thread Stanimir Stamenkov (Jira)


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

Stanimir Stamenkov commented on BATIK-1361:
---

bq. As I've noted in xmlgraphics-batik#39 the problem should happen at 0 and 
360-deg angles...

Dismiss that one – regardless of the used rotation center the result is 
expectedly the same.

> 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 /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 /lib/* SVGAnimTest.java [fps]
> {noformat}
> f.e.:
> {noformat}
> java -cp /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



[jira] [Commented] (BATIK-1361) Animated rotate() tranform ignores y-origin at exactly 270 degrees

2023-10-08 Thread Stanimir Stamenkov (Jira)


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

Stanimir Stamenkov commented on BATIK-1361:
---

More streamlined test case:

* [^DebugSVGAnimation.java]
{noformat}
java -cp /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 /lib/* DebugSVGAnimation.java -ref rotate-center-2
{noformat}
Use it with your SVG animation specifying the target snapshot times:
{noformat}
java -cp /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 /lib/* 

[jira] [Commented] (BATIK-1361) Animated rotate() tranform ignores y-origin at exactly 270 degrees

2023-10-07 Thread Stanimir Stamenkov (Jira)


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

Stanimir Stamenkov commented on BATIK-1361:
---

If this could be of any help, here are the transform matrices at 270 deg that I 
observe with different cx, cy:

_cx=50, cy=50_

| 0.0 | 1.0 | *0.0* |
| -1.0 | 0.0 | 100.0 |

_cx=50, cy=40_

| 0.0 | 1.0 | 10.0 |
| -1.0 | 0.0 | 90.0 |

_cx=40, cy=40_

| 0.0 | 1.0 | *0.0* |
| -1.0 | 0.0 | 80.0 |

Wonder also if [_Handling 90-Degree 
Rotations_|https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/java/awt/geom/AffineTransform.html#quadrantapproximation]
 has anything to do with the given {{matrix.e == 0}} handling.


> 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 /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 /lib/* SVGAnimTest.java [fps]
> {noformat}
> f.e.:
> {noformat}
> java -cp /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: 

[jira] [Commented] (BATIK-1361) Animated rotate() tranform ignores y-origin at exactly 270 degrees

2023-10-07 Thread Stanimir Stamenkov (Jira)


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

Stanimir Stamenkov commented on BATIK-1361:
---

Note also, when {{cx != cy}} it doesn't hit the {{matrix.getE() == 0.0f}} 
branch and the problem is not observed:

{code:xml}
http://www.w3.org/2000/svg;
width="200" height="200" viewBox="-50 -60 200 200">

  



  


{code}

I've tried a quick (and dirty) local patch that appears to correct the problem:

{code:java}
case SVGTransform.SVG_TRANSFORM_ROTATE:
if (matrix.getE() == 0.0f) {
if (transform instanceof AbstractSVGTransform) {
angleOnly = false;
AbstractSVGTransform internal =
(AbstractSVGTransform) transform;
setRotate(internal.getAngle(),
  internal.getX(), internal.getY());
} else {
rotate(transform.getAngle());
}
} else {
...
{code}

However, I don't know what the {{matrix.getE() == 0.0f}} condition is about.


> 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 /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 

[jira] [Commented] (BATIK-1361) Animated rotate() tranform ignores y-origin at exactly 270 degrees

2023-10-07 Thread Stanimir Stamenkov (Jira)


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

Stanimir Stamenkov commented on BATIK-1361:
---

O.k.  Traced it down to 
[SVGTransformItem.assign(AbstractSVGTransformList.java:286)|https://github.com/apache/xmlgraphics-batik/blob/batik-1_17/batik-svg-dom/src/main/java/org/apache/batik/dom/svg/AbstractSVGTransformList.java#L286-L298]:

{code:java}
case SVGTransform.SVG_TRANSFORM_ROTATE:
if (matrix.getE() == 0.0f) {
rotate(transform.getAngle());
} else {
angleOnly = false;
...
} else if (transform instanceof AbstractSVGTransform) {
AbstractSVGTransform internal =
(AbstractSVGTransform) transform;
setRotate(internal.getAngle(),
  internal.getX(), internal.getY());
{code}

When the transform is at 270 deg it appears to hit the first branch:

{code:java}
if (matrix.getE() == 0.0f) {
rotate(transform.getAngle());
{code}

that unconditionally sets [rotate origin center 0, 
0|https://github.com/apache/xmlgraphics-batik/blob/batik-1_17/batik-svg-dom/src/main/java/org/apache/batik/dom/svg/AbstractSVGTransformList.java#L328-L330]:

{code:java}
protected void rotate(float angle) {
angleOnly = true;
setRotate(angle, 0.0f, 0.0f);
{code}

Not sure why only the y-origin is off in the final result, though.


> 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 

[jira] [Commented] (BATIK-1361) Animated rotate() tranform ignores y-origin at exactly 270 degrees

2023-10-04 Thread Stanimir Stamenkov (Jira)


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

Stanimir Stamenkov commented on BATIK-1361:
---

Really minimal SVG source:

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

  



  


{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 /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 /lib/* SVGAnimTest.java [fps]
> {noformat}
> f.e.:
> {noformat}
> java -cp /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



[jira] [Commented] (BATIK-1361) Animated rotate() tranform ignores y-origin at exactly 270 degrees

2023-10-03 Thread Stanimir Stamenkov (Jira)


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

Stanimir Stamenkov commented on BATIK-1361:
---

Simplified test case:

* [^SVGAnimTest3.java]
* [^rotate-origin.svg] (bad)
* [^rotate-origin2.svg] (good)

{noformat}
$ java SVGAnimTest3.java
$ java SVGAnimTest3.java rotate-origin2
{noformat}

Compare the {{rotate-origin-anim/}} and {{rotate-origin2-anim/}} output 
directories.

The only difference between {{rotate-origin.svg}} and {{rotate-origin2.svg}} is 
the latter uses 0 (zero) y-origin (while still using non-zero x-origin) for the 
animated {{rotate()}}:

|| rotate-origin || rotate-origin2 ||
| !frame-1.4750.png! | !frame-1.4750.png! !
| !frame-1.5000@.png! | !frame-1.5000.png! !
| !frame-1.5250.png! | !frame-1.5250.png! !


> 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 /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 /lib/* SVGAnimTest.java [fps]
> {noformat}
> f.e.:
> {noformat}
> java -cp /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)