Comments (3)
PyX behaves very well defined given the fact, that circles are closed paths, but still have a begin and end point. It is the point to the right, but you may rotate it, like to the top like so path.circle(sin(v), cos(v), 1.7).transformed(trafo.rotate(90, sin(v), cos(v)))
. The intersect return values are ordered along the first path. Quoting from the split example of the gallery (https://nbviewer.jupyter.org/urls/sf.net/p/pyx/gallery/split/attachment/split.ipynb):
The first segment returned by the split method ends at the first splitting point, the second segment goes from the first splitting point to the second splitting point (and maybe this path element will thus have a different orientation than the original path). Finally, for an open path the last item in the list of returned segments will go from the last splitting point to the end of the path. However, for a closed path this last path item is prepended to the first segment returned by the split method. Thus for a closed path the first segment will always go from the last to the first splitting point.
Your code should probably return the shorter of the two paths created from the split method ...
from pyx.
Returning the shorter of two paths might we correct in this case, but is wrong in other cases.
IMHO, there should be a documented way how to get the intersecting area of two closed paths, e.g. for a venn diagram.
from pyx.
I am not quite sure whether it is the right format to discuss on a close issue, but I don't mind. In addition I am not familiar with venn diagrams.
Regarding the area of two intersecting closed paths, there clearly are several solutions:
from pyx import *
c = canvas.canvas()
def intersect(y, p1, p2):
c1 = path.circle(0, y, 4)
c2 = path.circle(3, y, 2)
c.stroke(c1)
c.stroke(c2)
(int1), (int2) = c1.intersect(c2)
c1segs = c1.split(int1)
c2segs = c2.split(int2)
c.fill(c1segs[p1] << c2segs[p2].reversed(), [color.rgb.red])
intersect(0, 0, 0)
intersect(-10, 1, 0)
intersect(-20, 0, 1)
intersect(-30, 1, 1)
c.writePDFfile()
from pyx.
Related Issues (20)
- BoundingBox - ValueError: invalid literal for int() with base 10
- (Question) How to typeset a fraction? HOT 2
- Give Canvas class a clear() method HOT 1
- FileNotFoundError: [Errno 2] No such file or directory: 'tex' HOT 1
- Add equality comparison for line style
- Unwanted black bounding box when writePDFfile is used (writeSVGfile works as expected) HOT 3
- Misplaced ticklabel (wrong height) HOT 1
- 3d graph with gridded axes
- curveradius and range path.path methods nonexisting? HOT 1
- test_text fails
- [Question] How to create paths with a dynamic number of elements? HOT 1
- Default font installation path for distributions HOT 1
- Example for Page and Document
- BLD: future change of behaviour in pip HOT 2
- How to crop a picture? HOT 1
- Attributes (color, rotation) do not work with UnicodeText
- Make histogram style directly compatible with numpy.histogram
- Parallel deformation of closed loops
- Creation of 2D-color gradation plots HOT 1
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 pyx.