[NTG-context] graphics

Alan Braslau braslau.list at comcast.net
Fri Dec 7 16:15:48 CET 2018

On Fri, 7 Dec 2018 09:06:03 +0100
"Mikael P. Sundqvist" <mickep at gmail.com> wrote:

> 2) Support for transforming images in a more general way. With the
> zscaled, slanted, ... we are able to transform any object in an affine
> way. It would be nice to be able to transform any object in a more
> general way (i.e. by a mapping defined by the user). The example code
> below shows what happens in the complex plane with a grid and a curve
> when the mapping z to z^2 is applied.

I have generalized my rewrite of the MP graph macros to handle any
arbitrary mapping from data space to drawing (2D) space. At present, I
have only considered the simple functions of log (and sqrt) scales as
well as polar coordinates (x,y) = f(theta,r) with f(theta,r) = (r sin
theta, r cos theta) as I have real use cases for these.

I also consider a simple 3D->2D mapping.

It would be very easy to transform z = a+ib to z^2 for example, as you

The approach transforms a picture, applying to all stroked and
filled paths, as well as to the *position* of text objects. I have not
looked into somehow transforming a bitmap image.

> Perhaps I am missing something,
> but I'm not able to apply this to a piece of text for example, or to
> apply it directly to a picture. Instead, I have to loop over all
> separate paths. I think the ideal would be to have a "ftransformed"
> (or with some other name), and then just define a function (as fun in
> the example below), and then be able to do "draw X ftransformed fun;",
> where X is some(any?) general object. Is that doable?

for i within pic :

So, yes, easy to write a primary (but I don't like the name
"ftransformed"). Using lua helpers can make this efficient.


More information about the ntg-context mailing list