Hi
In my application I paint geometric shapes like Rectangles. Now my application should support zooming. The simplest solution till now was to put a wrapper around the GraphicsContext. graphicsContext := (ExamplesBrowser prepareScratchWindow) graphicsContext. myGraphicsContext := GraphicsContextWrapper on: graphicsContext zoom: 1.7. "1.7 stands for 170%" (Rectangle origin: 6@6 corner: 60@30) displayFilledOn: myGraphicsContext. In the GraphicsContextWrapper I have methods like this: GraphicsContextWrapper >> displayRectangle: aRectangle graphicsContext displayRectangle: (aRectangle * self zoom) Unfortunaelty this approach does not work for text. Im using instances of ComposedText. ComposedText calls the method "displayMappedString: aString from: startIndex to: endIndex at: aPoint withMap: map" in the GraphicsContext. There are two problems: 1. Replacing "aPoint" with "aPoint * self zoom" returns the wrong y coordinate. 2. I can no longer scale the text at this point (I think). Has anybody got a simple solution for zooming text? A solution that only needs changes in the GraphicsContext would be nice. Cheers, michael |
Hi,
I've done a similar thing called ScalingGraphicsContext and it's in the Public Store repository. It includes zooming of text. The only thing it doesn't zoom is pixmap's, but it does zoom Mask's, Image's, etc. I went for the 'dumpest thing that could work' and tried to see if it was fast enough - thus far it has been fast enough. Cheers, Michael > Hi > In my application I paint geometric shapes like Rectangles. Now my > application should support zooming. > The simplest solution till now was to put a wrapper around the GraphicsContext. > graphicsContext := (ExamplesBrowser prepareScratchWindow) graphicsContext. > myGraphicsContext := GraphicsContextWrapper on: graphicsContext zoom: 1.7. "1.7 stands for 170%" > (Rectangle origin: 6@6 corner: 60@30) displayFilledOn: myGraphicsContext. > In the GraphicsContextWrapper I have methods like this: > GraphicsContextWrapper >> displayRectangle: aRectangle > graphicsContext displayRectangle: (aRectangle * self zoom) > Unfortunaelty this approach does not work for text. Im using > instances of ComposedText. ComposedText > calls the method "displayMappedString: aString from: startIndex to: endIndex at: aPoint withMap: map" > in the GraphicsContext. There are two problems: > 1. Replacing "aPoint" with "aPoint * self zoom" returns the wrong y coordinate. > 2. I can no longer scale the text at this point (I think). > Has anybody got a simple solution for zooming text? A solution that > only needs changes in the GraphicsContext > would be nice. > Cheers, > michael |
Hi michael,
that ScalingScreenGraphicsContext of yours is really nice :-) Thanks a lot. michael Michael Lucas-Smith schrieb: > Hi, > > I've done a similar thing called ScalingGraphicsContext and it's in the Public Store repository. It includes zooming of text. The only thing it doesn't zoom is pixmap's, but it does zoom Mask's, Image's, etc. > > I went for the 'dumpest thing that could work' and tried to see if it was fast enough - thus far it has been fast enough. > > Cheers, > Michael > >> Hi >> In my application I paint geometric shapes like Rectangles. Now my >> application should support zooming. >> The simplest solution till now was to put a wrapper around the GraphicsContext. > >> graphicsContext := (ExamplesBrowser prepareScratchWindow) graphicsContext. >> myGraphicsContext := GraphicsContextWrapper on: graphicsContext zoom: 1.7. "1.7 stands for 170%" >> (Rectangle origin: 6@6 corner: 60@30) displayFilledOn: myGraphicsContext. > >> In the GraphicsContextWrapper I have methods like this: > >> GraphicsContextWrapper >> displayRectangle: aRectangle >> graphicsContext displayRectangle: (aRectangle * self zoom) > >> Unfortunaelty this approach does not work for text. Im using >> instances of ComposedText. ComposedText >> calls the method "displayMappedString: aString from: startIndex to: endIndex at: aPoint withMap: map" >> in the GraphicsContext. There are two problems: > >> 1. Replacing "aPoint" with "aPoint * self zoom" returns the wrong y coordinate. >> 2. I can no longer scale the text at this point (I think). > >> Has anybody got a simple solution for zooming text? A solution that >> only needs changes in the GraphicsContext >> would be nice. > >> Cheers, >> michael > > |
In reply to this post by Michael Meyer-6
Michael,
If Rectangles are just the start of more involved graphics, you might want to look at GF/ST (in goodies\parc\GFST or contrib\GFST). It implements a similar scaling graphics context to Michael Lucas-Smith's, but is faster, includes the option of double buffering, direct manipulation of the graphics, and linking graphics to domain objects. All the best, Steve > -----Original Message----- > From: Michael Meyer [mailto:[hidden email]] > Sent: 23 April 2006 14:14 > To: [hidden email] > Subject: Zooming in VisualWorks > > Hi > In my application I paint geometric shapes like Rectangles. Now my > application should support zooming. > The simplest solution till now was to put a wrapper around the > GraphicsContext. > > graphicsContext := (ExamplesBrowser prepareScratchWindow) > myGraphicsContext := GraphicsContextWrapper on: graphicsContext zoom: 1.7. > "1.7 stands for 170%" > (Rectangle origin: 6@6 corner: 60@30) displayFilledOn: myGraphicsContext. > > In the GraphicsContextWrapper I have methods like this: > > GraphicsContextWrapper >> displayRectangle: aRectangle > graphicsContext displayRectangle: (aRectangle * self zoom) > > Unfortunaelty this approach does not work for text. Im using instances of > ComposedText. ComposedText > calls the method "displayMappedString: aString from: startIndex to: > endIndex at: aPoint withMap: map" > in the GraphicsContext. There are two problems: > > 1. Replacing "aPoint" with "aPoint * self zoom" returns the wrong y > coordinate. > 2. I can no longer scale the text at this point (I think). > > Has anybody got a simple solution for zooming text? A solution that > needs changes in the GraphicsContext > would be nice. > > Cheers, > michael |
Free forum by Nabble | Edit this page |