How to scale canvas coordinates? 
Author Message
 How to scale canvas coordinates?

I want to scale the coordinates in a Canvas.
The Canvas man page says

  Canvases do not support scaling or rotation of the canvas
  coordinate system relative to the window coordinate system

so I'm on my own.

I'm looking at 4 alternatives:

1. Get a solution from someone else
I'll take anything I can get, with gratitude.

2. Compositing or subclassing Tk::Canvas
Seems the most feasable, but I'm having trouble figuring out how to do
it.  For example, *where* would a composite store the scale factors?
Is it even possible to subclass an XS module?

3. Hacking Tk::Canvas
Possible in principle, but tkCanvas.c is 3700 lines of tough C code,
and I'm not sure this is a good idea.

4. Carrying the scale factors in my application code.
This is what I'm doing right now, and it's a lose.

Any advice, suggestions, pointers or code greatly appreciated.

- SWM



Sat, 08 May 1999 03:00:00 GMT  
 How to scale canvas coordinates?

Quote:

> I want to scale the coordinates in a Canvas.
> The Canvas man page says

>   Canvases do not support scaling or rotation of the canvas
>   coordinate system relative to the window coordinate system

> so I'm on my own.

> I'm looking at 4 alternatives:

> 1. Get a solution from someone else
> I'll take anything I can get, with gratitude.

> 2. Compositing or subclassing Tk::Canvas
> Seems the most feasable, but I'm having trouble figuring out how to do
> it.  For example, *where* would a composite store the scale factors?

In the canvas object :

  $canvas->{'maxtrix'} = [ 1, 0, 0, 1 ];  # to copy postscript model...
or
  $canvas->{'xScale'} = 1.0;

Quote:
> Is it even possible to subclass an XS module?

Certainly.  There is already a sub-class of Canvas Contrib/Axis.pm
which does.

Quote:

> 3. Hacking Tk::Canvas
> Possible in principle, but tkCanvas.c is 3700 lines of tough C code,
> and I'm not sure this is a good idea.

It is worse than that tkCanvas.c is only framework, you would
need to hack tkCanvLine.c , tkCanvPoly.c ....
as well

Quote:

> 4. Carrying the scale factors in my application code.
> This is what I'm doing right now, and it's a lose.

> Any advice, suggestions, pointers or code greatly appreciated.

> - SWM

--

Via, but not speaking for: Texas Instruments Ltd.


Sun, 09 May 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Canvas->Scale and Tk::Scale conflict?

2. Passing variable coordinate to canvas widget?

3. Absolute vs Relative coordinates on canvas

4. Coordinates of Visible Canvas

5. Canvas coordinate origin question

6. Mouse coordinates in canvas?

7. Canvas, fonts, and text coordinates

8. scaling canvas items

9. Scaling text on a canvas

10. Tk::Canvas scale question

11. Perl/TK scrolled canvas scale IMAGE function???

12. Perl/TK scrolled canvas scale zoom NOOP?

 

 
Powered by phpBB® Forum Software