Comments (7)
Can you please elaborate on this issue?
from ipycanvas.
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
from ipycanvas.
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>
from ipycanvas.
You have full knowledge of the path you've given to the fill
method, so you know what your hypothetical get_path
method would return here, is that correct?
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
from ipycanvas.
Yes. I just want to get the new path2d
from ipycanvas.
What I mean is you have it already, it's path1
. Or am I missing something?
from ipycanvas.
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())
from ipycanvas.
Related Issues (20)
- add width, height support to put_image_data HOT 1
- How to add transform to Path2D HOT 6
- voila fails to load ipycanvas.js from localhost HOT 2
- how to drag an image around on the canvas? HOT 2
- bundle text and shape into one object HOT 4
- ipycanvas does not work with JupyterLab 4 HOT 4
- debug_output only works if calling display(canvas) HOT 1
- ipycanvas 0.13.1 does not work with google colab. 0.13 works. HOT 1
- Take a screenshot of a drawing/canvas and save it? HOT 2
- current canvas out of sync after page reload
- Commands JSON content mangled HOT 3
- Error displaying widget: model not found HOT 1
- is there no call to remove a shape? HOT 1
- bug on canvas.clear() HOT 1
- any way to pause animation? HOT 2
- feature request for mouse drag HOT 2
- Using Path2D for stroke
- Error with fresh jupyterlab 3 install - "Failed to load model class" / "Error: No version of module ipycanvas is registered" HOT 3
- The docs link to github needs updating HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ipycanvas.