-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get the new path #303
Comments
Can you please elaborate on this issue? |
from ipycanvas import Canvas, Path2D
canvas = Canvas(width=350, height=350)
path1 = Path2D("M80 80 A 45 45, 0, 0, 0, 125 125 L 125 80 Z")
canvas.fill_style = "green"
canvas.fill(path1)
# Get the new path
print(canvas.get_path()) I want to get the path2d of the canvas by getting |
Or save it as a new svg. svg format There are <svg xmlns="http://www.w3.org/2000/svg" width="341.333333" height="341.333333" version="1.0" viewBox="0 0 256 256">
<path d="M74.9 3...."/>
</svg> |
You have full knowledge of the path you've given to the If what you want is to save your Path as SVG, then ipycanvas is of no help, as it does not produce any SVG. You might want to check out this library https://github.com/cduck/drawSvg |
Yes. I just want to get the new path2d |
What I mean is you have it already, it's |
I am trying to put the following svg: <svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="128.000000pt" height="128.000000pt" viewBox="0 0 128.000000 128.000000"
preserveAspectRatio="xMidYMid meet">
<g transform="translate(0.000000,128.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M546 965 c-53 -19 -101 -68 -137 -140 -27 -55 -28 -60 -12 -67 50
-19 70 -10 102 47 17 30 40 59 52 66 121 64 239 -15 215 -145 -10 -52 -53 -92
-122 -111 -71 -21 -78 -27 -71 -57 5 -18 17 -26 57 -35 29 -7 67 -22 85 -33
83 -52 87 -185 6 -253 -83 -69 -207 -27 -250 86 -10 26 -13 27 -53 21 -24 -4
-45 -8 -47 -10 -8 -7 30 -99 54 -130 57 -75 181 -112 280 -85 105 28 178 128
178 245 0 91 -35 152 -111 195 -15 9 -12 14 20 41 50 42 78 103 78 174 0 94
-50 165 -139 195 -46 15 -137 13 -185 -4z"/>
</g>
</svg> Convert to svg with only one node path in. <svg xmlns="http://www.w3.org/2000/svg" version="1.0" viewBox="0 0 128 128">
<path d="M74.9 32.7c0 .5-.2 1.5-.5 2.3-1.6 6.1-1.6 7 0 7 2.1 0 2 1-.1 4-1.7 2.4-3.6 15-2.2 15 .3 0 1.6-1.1 2.9-2.5 2.5-2.7 4.5-2.4 3.7.6-.3 1 .1 2.6.9 3.6.7 1 1.4 2.1 1.4 2.6 0 .9-8xxx..."/>
</svg> CaCan't ipycanvas get the path2d data?n't ipycanvas get the path2d data? Example: from ipycanvas import Canvas, Path2D
canvas = Canvas(width=128, height=128)
canvas.translate(0, 128)
canvas.scale(0.10, -0.10)
canvas.fill_style = "#000000"
path = Path2D("M546 965 c-53 -19 -101 -68 -137 -140 -27 -55 -28 -60 -12 -67 50 -19 70 -10 102 47 17 30 40 59 52 66 121 64 239 -15 215 -145 -10 -52 -53 -92 -122 -111 -71 -21 -78 -27 -71 -57 5 -18 17 -26 57 -35 29 -7 67 -22 85 -33 83 -52 87 -185 6 -253 -83 -69 -207 -27 -250 86 -10 26 -13 27 -53 21 -24 -4 -45 -8 -47 -10 -8 -7 30 -99 54 -130 57 -75 181 -112 280 -85 105 28 178 128 178 245 0 91 -35 152 -111 195 -15 9 -12 14 20 41 50 42 78 103 78 174 0 94 -50 165 -139 195 -46 15 -137 13 -185 -4z")
canvas.fill(path)
# Get the new path
print(canvas.get_path()) |
How to get the new path
The text was updated successfully, but these errors were encountered: