Comments (4)
For the time being, you could use numpy
arrays as demonstrated in the
following example:
import numpy as np
from pyx import canvas, deco, path
c = canvas.canvas()
point_1 = np.array([1, 2])
vektor = np.array([4, -3])
point_2 = point_1 + vektor
c.stroke(path.line(*point_1, *point_2), [deco.earrow])
c.writePDFfile()
This approach works nicely in 3d as well which I use frequently together
with the projectors provided by graph.graphxyz
to produce schematic 3d drawings.
from pyx.
Ah, I didn't know the tuple unpacking also works for numpy arrays. (And, to be honest, it didn't occur to me at all to use tuple unpacking.) I think there is still a case for a dedicated pyx vector class because lengths in pyx are not floats but instances of unit.length. For example, you may want to get a point on a path via the at
method (which gives you a tuple of unit.length
) and then do further calculations with it.
Would you still consider changing the path construction methods to accept vector arguments or do you think the tuple unpacking trick should be normal way to do things?
from pyx.
This is for the developers to decide. I am just a happy long-time user of PyX :-)
Concerning unpacking of tuples: I started using this only recently and found it quite useful with PyX at least in some situations.
from pyx.
This was an addition in Python 3.5, PEP 448. I remember quite well that I was very happy when learning about this feature. It is very handy for PyX. I also discussed it with Jörg and we kind of decided, that (a) it was good to not have used tuples in path elements constructors (and elsewhere) originally and (b) that due to this new feature we have even less reason to change anything in PyX. :-)
from pyx.
Related Issues (20)
- BoundingBox - ValueError: invalid literal for int() with base 10
- (Question) How to typeset a fraction? HOT 2
- Inconsistent intersections HOT 3
- 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.