[futurebasic] Re: [FB] CGContextSetLineDash

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2007 : Group Archive : Group : All Groups

From: Robert Purves <robert.purves@...>
Date: Fri, 2 Mar 2007 09:32:08 +1300
Yoshiyuki Hasegawa wrote:

>  Bernie wrote:
>
>> anywhere between QDBeginCGContext and CGContextStrokePath. If the  
>> Quartz dashes look thicker than the QD dashes, it may be your  
>> spectacles.
>
> It became help. QD is still used for the display of the horizontal  
> and vertical line.
> Then Quartz is used for the print in the thin line.
> '--------------------------

<snip>

I don't understand your mention of QD.
The appearance of Quartz lines is affected by the fractional pixel  
coordinates. The effect is very obvious for vertical and horizontal  
lines of width 1.0.

Robert P.

'--------------------------
include "Tlbx CoreGraphics.incl"

local fn QuartzContextForWindow( wNum as long )
'~'1
dim as Rect r
dim as CGContextRef @ ctx
dim as WindowRef @ wRef

ctx = 0
get window wNum, wRef
long if ( wRef )
call GetWindowBounds( wRef, _kWindowContentRgn, @r )
call QDBeginCGContext( fn GetWindowPort( wRef ), @ctx )
// set coordinates to be like QuickDraw's
fn CGContextTranslateCTM( ctx, 0.0, r.bottom - r.top )
fn CGContextScaleCTM( ctx, 1.0, -1.0 )
end if
end fn = ctx


local fn QuartzLine( ctx as CGContextRef, x1 as single, y1 as single,  
x2 as single, y2 as single )
'~'1
fn CGContextMoveToPoint( ctx, x1, y1 )
fn CGContextAddLineToPoint( ctx, x2, y2 )
fn CGContextStrokePath( ctx )
end fn


dim as CGContextRef ctx
dim as single y

window 1
ctx = fn QuartzContextForWindow( 1 )
// default line width is 1.0
//fn CGContextSetLineWidth( ctx, 2.0 )
y = 50 // no fractional part
fn QuartzLine( ctx, 10, y, 520, y )
y = 90.25 // .25
fn QuartzLine( ctx, 10, y, 520, y )
y = 130.5 // .5
fn QuartzLine( ctx, 10, y, 520, y )

fn CGContextSynchronize( ctx ) // flush to window

do
HandleEvents
until gFBQuit
'---------------------------