What is PenHeight for?

I tested following code in a canvas paint event. The PenHeight value seems to has no effect. The Line is always drawn with the width of PenWidth. Is PenWidth = 0 nothing is drawn. If PenHeight=0 the form is drawn.

  dim yOffset as integer
  
  g.PenHeight = 1
  g.PenWidth = 1
  yOffset = 50
  g.DrawLine(30, yOffset, 150, yOffset)
  
  g.PenHeight = 1
  g.PenWidth = 10
  yOffset = 100
  g.DrawLine(30, yOffset, 150, yOffset)
  g.DrawLine(30, yOffset, 30 , yOffset +30)
  
  
  g.PenHeight = 10
  g.PenWidth = 1
  yOffset = 150
  g.DrawLine(30, yOffset, 150, yOffset)
  g.DrawLine(30, yOffset, 30, yOffset + 30)
  
  g.PenHeight = 0
  g.PenWidth = 1
  yOffset = 200
  g.DrawLine(30, yOffset, 150, yOffset)
  g.DrawLine(30, yOffset, 30, yOffset +30)

I’d be interested to know too… never occurred to me to check it, but after reading this topic I ran similar tests with DrawRect and DrawOval, and the PenHeight made no difference.

Has someone from @Xojo an idea if this is a bug or a feature?

seems to me that PENHEIGHT was “discontinued” a few release back, and kept for compatiblity so as to not break old code,
and that in reality PENWIDTH is more like “pensize” now

and makes more sense if you think about it. you pencil draws on paper with the same width (size) regardless of the direction…

I’m betting that before it was a compromise to fit in with older ways the internal system (OSX/WIN) handled graphics, and those methods are now more up to date, therefore XOJO can be more up to date…

I may be wrong, but I remember some time back that printers did not always have the same resolution vertically and horizontally and so the penheight could be used to vary the horizontal thickness and penwidth the vertical thickness of things being drawn. I remember using these when printing score cards for the bowling league that I was on years back and it worked great. But now days I can’t recall seeing printers with one resolution vertically and another horizontally so it makes sense, I guess, that only one is used these days. I just don’t do much printing requiring the varying of these settings these days.

But the OP is talking about the screen, where there are no rectangular pixels. I should admit that until now I thought penHeight and penwidth acted like width and height in a control…

Now a quick test shows that penWidth is just what Dave says : it applies both ways. In a way, it solves an interesting problem : what would happen to an oval if horizontal and vertical thickness was dissymmetrical ?

BTW, I think PenThickness would render more justice than penWidth.

Michel, back when both properties meant something, they did what I said on the screen as well as on paper. PenWidth worked for vertical lines and PenHeight for horizontal lines. If you wanted an oval of consistent width you set them both to the same size. I am glad that Torben posted this so that I am now aware of the change otherwise I could well be going bonkers using my old methods and wondering why things weren’t working.

[quote=179327:@Torben Vikow]I tested following code in a canvas paint event. The PenHeight value seems to has no effect. The Line is always drawn with the width of PenWidth. Is PenWidth = 0 nothing is drawn. If PenHeight=0 the form is drawn.

[code]
dim yOffset as integer

g.PenHeight = 1
g.PenWidth = 1
yOffset = 50
g.DrawLine(30, yOffset, 150, yOffset)

g.PenHeight = 1
g.PenWidth = 10
yOffset = 100
g.DrawLine(30, yOffset, 150, yOffset)
g.DrawLine(30, yOffset, 30 , yOffset +30)

g.PenHeight = 10
g.PenWidth = 1
yOffset = 150
g.DrawLine(30, yOffset, 150, yOffset)
g.DrawLine(30, yOffset, 30, yOffset + 30)

g.PenHeight = 0
g.PenWidth = 1
yOffset = 200
g.DrawLine(30, yOffset, 150, yOffset)
g.DrawLine(30, yOffset, 30, yOffset +30)
[/code][/quote]
PenWidth and PenHeight are indeed two different values. The problem is that your example only shows vertical lines. If you were drawing horizontal lines, PenHeight would be used to draw their thickness.

FWIW, this was done with a single PenSize property in WebCanvas and iOS because there is no concept of widths that differ from width to height, but it still exists in Desktop and Console.

Greg, I beg to differ

   // h lines
  g.ForeColor=&c000000
  g.PenWidth=1
  g.PenHeight=10
  g.drawline 0,20,100,20
  //
  g.ForeColor=&cff0000
  g.PenWidth=10
  g.PenHeight=1
  g.drawline 0,40,100,40
  // v lines
  g.ForeColor=&c00ff00
  g.PenWidth=1
  g.PenHeight=10
  g.drawline 100,20,100,200
  //
  g.ForeColor=&c0000ff
  g.PenWidth=10
  g.PenHeight=1
  g.drawline 150,20,150,200

if what you say were true, then
the first line [BLACK} should be THICK (horizontal, height=10), and the 2nd, but HEIGHT is ignored
and the 2nd line (RED) should be THIN (horizontal, height=1), but HEIGHT is ignored, and WIDTH controls it
and the 3rd line (GREEN) should be thin (which it is) because WIDTH controls it like it should
as well as the 4th line (BLUE) being THICK as it should

But if HEIGHT were still a viable parameter, then the BLACK line should be thick, and the RED line should be THIN

sure wish they’d fix the edit!

anyways… this was done with both 2014r3.2 and 2015r1 on OSX 10.9.5

[quote=179927:@Greg O’Lone]PenWidth and PenHeight are indeed two different values. The problem is that your example only shows vertical lines. If you were drawing horizontal lines, PenHeight would be used to draw their thickness.

FWIW, this was done with a single PenSize property in WebCanvas and iOS because there is no concept of widths that differ from width to height, but it still exists in Desktop and Console.[/quote]

Greg, am sorry but this produces two 1 px horizontal line, the third one only is a 4 pix one. Mac OS X 10.10.3, 2015R1. I tried on 04/09 with 10.10.2, same result.

Sub Paint(g As Graphics, areas() As REALbasic.Rect) g.penheight = 1 g.drawline(0,20,me.width,20) g.penheight = 4 g.drawline(0,40,me.width,40) g.penWidth = 4 g.drawline(0,60,me.width,60) End Sub

PenHeight does nothing, whereas PenWidth 4 makes a thicker horizontal line.

Having two separate properties is basically a holdover from QuickDraw. None of the modern system graphics APIs have the concept of a different width/height.

stupid forum… can’t quote properly, can’t edit

@Greg O’Lone
There are a lot of vertical lines in my example code. Please try my code from above on OSX and you will see the vertical lines and how penheight and penwitdh worked.

It would be nice if the documents could be updated to reflect the current behaviour on OSX.

Yes, it makes a lot of things easier. It would be great if the Xojo manual reflects this.

[quote=179422:@Dave S]
and makes more sense if you think about it. you pencil draws on paper with the same width (size) regardless of the direction…[/quote]

I disagree on this.
Graphic pens often have different height and width.

[quote=180053:@Massimo Valle]I disagree on this.
Graphic pens often have different height and width.
[/quote]

Indeed. Calligraphy is all about that. With what happens now, one will have to manage it instead of letting the system do it.