py5coding / py5generator

Meta-programming project that creates the py5 library code.
https://py5coding.org/
GNU General Public License v3.0
52 stars 13 forks source link

Trouble drawing externally loaded SVG that Processing 4 can't draw (Processing 3 worked) #181

Closed villares closed 1 year ago

villares commented 1 year ago

I have also tried simplified SVG files with erratic results. This might not be a single issue. But we have to start somewhere, right?

When I try the minimal example below with this file: https://github.com/villares/desenho-sem-argumentos/commit/70a04a45803de359135f15e2daaab84302f2b35d

def setup():
    size(562, 943)

    frente = load_shape('data/base_frente.svg')
    shape(frente, 0, 0, 562, 943)

Warnings and errors:

Filters are not supported.
Ignoring <clipPath> tag.
py5 encountered an error in your code:File "PSurfaceNone.java", line 356, in processing.core.PSurfaceNone$AnimationThread.run

File "PSurfaceAWT.java", line 1386, in processing.awt.PSurfaceAWT$9.callDraw

File "PApplet.java", line 2088, in processing.core.PApplet.handleDraw

File "Sketch.java", line 196, in py5.core.Sketch.setup

File "jdk.proxy2.$Proxy7.java", line -1, in jdk.proxy2.$Proxy7.run_method

File "org.jpype.proxy.JPypeProxy.java", line -1, in org.jpype.proxy.JPypeProxy.invoke

File "org.jpype.proxy.JPypeProxy.java", line -2, in org.jpype.proxy.JPypeProxy.hostInvoke

File "PApplet.java", line 12377, in processing.core.PApplet.shape

File "PGraphics.java", line 4220, in processing.core.PGraphics.shape

File "PShape.java", line 1654, in processing.core.PShape.draw

File "PShape.java", line 1665, in processing.core.PShape.drawImpl

File "PShape.java", line 1680, in processing.core.PShape.drawGroup

File "PShape.java", line 1654, in processing.core.PShape.draw

File "PShape.java", line 1665, in processing.core.PShape.drawImpl

File "PShape.java", line 1680, in processing.core.PShape.drawGroup

File "PShape.java", line 1654, in processing.core.PShape.draw

File "PShape.java", line 1667, in processing.core.PShape.drawImpl

File "PShape.java", line 1712, in processing.core.PShape.drawPrimitive

File "PShape.java", line 1951, in processing.core.PShape.loadImage

File "PShape.java", line 1971, in processing.core.PShape.loadBase64Image

File "PShape.java", line 1988, in processing.core.PShape.parseBase64Image

File "Base64.java", line 589, in java.util.Base64$Decoder.decode

File "Base64.java", line 566, in java.util.Base64$Decoder.decode

File "Base64.java", line 847, in java.util.Base64$Decoder.decode0

Exception: Java Exception

The above exception was the direct cause of the following exception:

File "/home/villares/GitHub/desenho-sem-argumentos/1_outubro_2022/gerador_completo/gerador_completo_wip.py", line 10, in _py5_faux_setup
    6    def setup():
    7        size(562, 943)
    8        
    9        frente = load_shape('data/base_frente.svg')
--> 10       shape(frente, 0, 0, 562, 943)
    ..................................................
     frente = <py5.shape.Py5Shape object at 0x7fadf5a4fc40>
    ..................................................

java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Illegal base64 character 20

Visual (incomplete) result:

image

hx2A commented 1 year ago

Is this the correct SVG file you are trying to use?

https://github.com/villares/desenho-sem-argumentos/blob/2022/1_outubro_2022_download/gerador_completo/data/base_frente.svg

I can't get this to work in Processing, so if this is the right file, it won't work in py5 either. Processing's ability to read SVG files is limited to a subset of the SVG language specs. That explains the initial "Filters are not supported." and "Ignoring tag." warnings. I don't know about the base64 stuff. I know that SVG files can contain embedded rasterized images using base64, but I didn't know that Processing's SVG functionality supported that.

villares commented 1 year ago

I think yes, it is the same file, but, maybe try this one: https://github.com/villares/desenho-sem-argumentos/blob/2022/1_outubro_2022/gerador_completo/base_frente.svg

Which version of Processing Python Mode are you using? Mine is Processing 3.5.4 + Python Mode 3063

image

The "filter" being ignored is what makes the images grayscale in GitHub render, I suppose. I applied them in Inkscape, and noticed they got ignored.

hx2A commented 1 year ago

@villares, Can you test this in Processing and tell me if you see the same problem there also?

I'm confused about what you previously said about completing this using processing.py instead. How did you get it to work using that library since that is also based on Processing?

villares commented 1 year ago

Yep, works for me in Processing Java too. image

hx2A commented 1 year ago

Can you try it with Processing 4?

villares commented 1 year ago

Oh... yeah... this could be it. Let me try.

villares commented 1 year ago

Cool... we found a Processing 4 bug!

Illegal base64 character 20 Looks like an encoding issue...

image

hx2A commented 1 year ago

Yes, we did! Since it worked in 3.5.4, the Processing team will probably want to get it working in 4.0 also.

hx2A commented 1 year ago

I will close this, since there's nothing more for us to do here.