[comp.sys.mac.programmer] Problems with SetLineWidth

nebel@wam.umd.edu (Chris D. Nebel) (11/06/90)

I'm having extreme problems with the SetLineWidth piccomment.  Though the
tech notes claim otherwise, the scaling factor I send seems to be cumulative.
I.e., if I send several SetLineWidth(1/2), PenSize(1, 1) Line sequences in
a row (which should give a series of 1/2 point lines), I actually get a
set of progressively thinner lines.  In a similar vein, if I send SetLineWidth
(1/10) PenSize(1,1) Line, SetLineWidth(1/1), PenSize(1,1) Line, I get two
1/10 point lines, not a .1 point and a 1 point line.  Does anybody know
what's going on?  Thanks,

Chris Nebel
nebel@wam.umd.edu

sean_parent.snarkmail_l_z@gateway.qm.apple.com (Sean Parent) (11/06/90)

In article <1990Nov5.203354.14090@wam.umd.edu> nebel@wam.umd.edu (Chris D. 
Nebel) writes:
> I'm having extreme problems with the SetLineWidth piccomment.  Though the
> tech notes claim otherwise, the scaling factor I send seems to be 
cumulative.
> I.e., if I send several SetLineWidth(1/2), PenSize(1, 1) Line sequences 
in
> a row (which should give a series of 1/2 point lines), I actually get a
> set of progressively thinner lines.

The SetLineWidth comment would be better named 
MultiplyPenScaleFactorByRatio since what you describe is exactly what it 
does. There is one problem with this. The LaserWriter SC driver also 
implements the SetLineWidth comment only it really sets the pen scale 
factor (instead of multiplying by the scale factor). I do not know of any 
way to work around this short of special casing for the LaserWriter SC 
(any new drivers under the new printing architecture will multiply the pen 
scale factor by the ratio). 

Sean Parent
"Quality unattainable in a reasonable amount of time."

a_dent@fennel.cc.uwa.oz.au (11/10/90)

In article <11125@goofy.Apple.COM>, sean_parent.snarkmail_l_z@gateway.qm.apple.com (Sean Parent) writes:
> In article <1990Nov5.203354.14090@wam.umd.edu> nebel@wam.umd.edu (Chris D. 
> Nebel) writes:
>> I'm having extreme problems with the SetLineWidth piccomment.  Though the
>> tech notes claim otherwise, the scaling factor I send seems to be 
> cumulative.
>> I.e., if I send several SetLineWidth(1/2), PenSize(1, 1) Line sequences 
> in
>> a row (which should give a series of 1/2 point lines), I actually get a
>> set of progressively thinner lines.
> 
> The SetLineWidth comment would be better named 
> MultiplyPenScaleFactorByRatio since what you describe is exactly what it 
> does. 

If this is a multiplication then does a setLineWidth of 1 actually achieve 
nothing???  I have tried seLineWidth of half then one thinking that would
reset but had problems similar to those described (I put them down to the
printer!).

If I want to change line width to half point and back should I use:

SetLineWidth(half)
draw my line
Pensize(1,1)

OR  


SetLineWidth(half)
draw my line
SetLineWidth(one)
Pensize(1,1)

OR 

SetLineWidth(half)
draw my line
SetLineWidth(one)


Andy Dent                     A.D. Software phone 09 249 2719
Mac & VAX programmer          94 Bermuda Dve, Ballajura

a_dent@fennel.cc.uwa.oz       Western Australia  6066     
a_dent@fennel.cc.uwa.oz.AU (international)

sean_parent.snarkmail_l_z@gateway.qm.apple.com (Sean Parent) (11/13/90)

In article <1990Nov10.213656.2583@fennel.cc.uwa.oz.au> 
a_dent@fennel.cc.uwa.oz.au writes:
> If I want to change line width to half point and back should I use:

If the printer is not a LaserWriter SC then use:

PenSize(1, 1)
SetLineWidth(half) /* 1/2 x 1 (default) = 1/2 */
DrawLine /* draws line with pen size .5, .5 */
SetLineWidth(two) /* 2/1 x 1/2 = 1 */
DrawLine /* draws line with pen size 1, 1 */

If the priner is a LaserWriter SC then use:

PenSize(1, 1)
SetLineWidth(half) /* set to 1/2 */
DrawLine /* draws line with pen size .5, .5 */
SetLineWidth(one) /* set to 1 */
DrawLine /* draws line with pen size 1, 1 */

Sean Parent
"Quality unattainable in a reasonable amount of time."

CXT105@psuvm.psu.edu (Christopher Tate) (11/13/90)

In article <1990Nov10.213656.2583@fennel.cc.uwa.oz.au>,
a_dent@fennel.cc.uwa.oz.au asks:

>If I want to change line width to half point and back should I use:
>
>SetLineWidth(half)
>draw my line
>Pensize(1,1)
>
>OR
>
>SetLineWidth(half)
>draw my line
>SetLineWidth(one)
>Pensize(1,1)
>
>OR
>
>SetLineWidth(half)
>draw my line
>SetLineWidth(one)

As I recall, what you really want to do is:

     SetLineWidth(half)
     {draw your lines here}
     SetLineWidth(two)       <-- note!

SetLineWidth() just multiplies the current pen dimensions by the fraction
that you pass in the arguments.  So, when you want to restore the pen
size that you were using before the original SetLineWidth(), you call it
again with the numerator and denominator flipped.

-------
Christopher Tate                       |
cxt105@psuvm.bitnet                    | nobody, not even the rain,
cxt105@psuvm.psu.edu                   |   has such small hands.
 ..!psuvax1!psuvm.bitnet!cxt105        |

Bruce.Hoult@actrix.co.nz (Bruce Hoult) (11/15/90)

<1990Nov10.213656.2583@fennel.cc.uwa.oz.au> <11216@goofy.Apple.COM>
Sender: 
Followup-To: 
Distribution: 
Organization: Actrix Information Exchange, Wellington, New Zealand
Keywords: 
Comment-To: sean_parent.snarkmail_l_z@gateway.qm.apple.com
 
 
I've been following this SetLineWidth discussion with interest, since I
tackled the whole thorny problem some time ago.  I've got a program that
we use to create graphics, then read into MacDraw to embellish, then
paste into MS Word, then print to either a LaserWriter or FaxModem.
 
Trying to come up with a scheme that gives the same results with all
posible combinations took days of experimentation.  The best solution I
have come up with is to make sure that your code produced the same line
width no matter whether or not the printer does cumulative scalings.
 
To go from linewidth A to linewidth B, you can do:
 
SetLineWidth(1/A)
SetLineWidth(B)
 
If you're using a printer that does "direct" linwwidth setting then the
first SetLineWidth is redundant, but harmless.  If the printer is one
that does cumulative modification then the first call sets the linewidth
to 1 and the second call then works correctly.
 
The disadvantage of this scheme is that your program has to be able to
keep track of the current value of the linewidth.