Giter VIP home page Giter VIP logo

Comments (4)

gertingold avatar gertingold commented on July 20, 2024

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.

mwiebusch78 avatar mwiebusch78 commented on July 20, 2024

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.

gertingold avatar gertingold commented on July 20, 2024

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.

wobsta avatar wobsta commented on July 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.