[futurebasic] Re: [FB] CGContext Rects

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2008 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Sun, 24 Feb 2008 00:20:14 +1300
maxclass@... wrote:

>>> I have scoured Apples Doc's and do not seem to be able to find the  
>>> way that one would reset the size of a CGRect once it has been  
>>> defined.
>> CGRectMake(), which you already use, sets the four fields of a  
>> CGRect to its four float arguments.
>
> In other words, CGRectMake is not only used to create rects but also  
> to reset their values.

CGRectMake() does not create anything.

> Now I am trying to figure out how to know where the origin has been  
> translated to after it has been done.
> When you have translated the origin to the top left of a window, so  
> that it is like QD coordinates, and you then resize the window the  
> origin is no longer at the same place.
> If you knew what the original offset was you could move the origin  
> in the opposite direction back to its original location, then reset  
> it to the new height of the resized windows new content region.


Typically a drawing sequence to a window takes a fresh CGContextRef  
each time, and so none of the above applies:
QDBeginCGContext(..., @ctx )
CGContext[Translate|Scale|Rotate]CTM( ctx, ... )
MyDraw( ctx,... )
QDEndCGContext(..., @ctx ) // dispose ctx

If you have some special reason (I can't think of one offhand) to  
recycle a previously-obtained CGContextRef you will have to save the  
virgin state, then restore after debauching the CTM:
CGContextSaveGState( ctx )
CGContext[Translate|Scale|Rotate]CTM( ctx, ... )
MyDraw( ctx,... )
CGContextRestoreGState( ctx )

Robert P.