On 23 Sep 2007, at 09:45, Tobias Fröschle wrote:

>
> I am currently getting myself accustomed again to programming using  
> the
> pointer interface after years of inactivity.
> I would like to hear how the cracks would tackle a problem I have  
> where
> I have some alternative solutions for.
> (My programs are SuperBasic, liberated or Turbo-ed)
>
> How do you draw graphics in the pointer coordinate system (a typical
> application would be things like rubber-banding or a shape drawing
> program)? The options I currently see are as follows:
>
>    1. Use the Graphics coordinate system - Here I find it next to
>       impossible to find a perfect match between pixel coordinates and
>       graphic coordinates using SCALE (Or am I just doing something
>       wrong?).   I'm doing something like SCALE  
> #channel,windowHeight%,
>       0, 0 and POINT x,y-windowHeight%. This (at least sometimes) hits
>       the spot, but not with acceptable accurracy - the point  
> plotted is
>       always a bit off the pointer position. Advantage is, you can use
>       INK, PAPER, and he like and have all the graphics drawing for
>       circles and arcs available
>    2. Use BLOCK - this hits the spot perfectly, because it uses pixel
>       coordinates. You can also take advantage of INK and PAPER and  
> the
>       like, but need to write your own routines for drawing shapes,
>       rectangles, arcs, lines. This could end up in a huge pile of  
> work,
>       the program could also tend to be slow with implementation of
>       these primitives in SuperBASIC.
>    3. Use the "Draw line of blobs/sprite" functionality from PE. Uses
>       the pixel coordinate system, so we'd be safe with pixel  
> accuracy -
>       Cannot use INK, PAPER and the like, because you define the  
> colour
>       in the sprite. You'd need to have an assortment of pixel-sized
>       sprites in order to be able to draw in different colours. Shapes
>       like rectangles and circles are not available as well and  
> need to
>       be emulated.
>    4. Use own, machine code-based SuperBasic extensions to plot and  
> draw
>       in the pixel coordinate system. Not sure whether I would want to
>       tackle this one, especially if I want my program to be able  
> to run
>       both on "standard" QLs and GD2-Based systems (Or is there
>       something already available - I'm not aware of such an  
> extension -
>       There was  an article in an old QL world, part of the DIY  
> toolkit,
>       but this would hardly work in a GD2-based environment.
>
> What's common practice? Like to hear some recommendations.
>

There is an simple drawing program using the Pointer Environment in  
example 3 of TurboPTR. This example allows you to use the mouse to  
draw shapes on the screen (in various different colours). The general  
method is to find the pixel position of the mouse on the screen and  
to draw a line between that and the previous position if it is  
different. This is repeated until the mouse key is lifted. The line  
is drawn using blocks of size 2x1. It is not practical (or even  
possible) to use both pixel position and graphics coordinates for the  
same point on the screen.

The code for the program is in the file EX3_BAS in TPTRX03_ZIP which  
is on the SQLUG site at:

  http://jms1.supanet.com/SQLUG/gwilt/gwilt.htm

The program compiled by Turbo is in EX3_TASK. An explanation of how  
to use the program is in PROGRAMS_TEXT. All these files are in the  
same zipped file, TPTRX03_ZIP.

George


_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm

Reply via email to