Questions about Graphics class


#1

Hi all,
I have few questions about Graphics class.
What is the reason that the methods for drawing primitives (lines, squares etc.) use float paramenters?
And why then the drawText() isn’t using floats but ints instead?

And another question. The parameter lineThickness in funct. void Graphics::drawLine ( const Line & line, const float lineThickness ) means what exactly? I thought that lineThickness = 1.0f means it is wide one pixel exactly but it seems not to be the case… And when I set it to something less than 1 (say 0.25) it doens’t seem to change the thickness but transparency level…

Thanks in advance.
Y.


#2

It uses floats so it can have sub-pixel accuracy… Text could be done with floats too, I just never did it that way because it’s less important than for shapes.

…so when you set the line thickness to 0.5, how exactly did you expect it to draw only half of a pixel except than by making it less opaque???


#3

[quote=“jules”]It uses floats so it can have sub-pixel accuracy… Text could be done with floats too, I just never did it that way because it’s less important than for shapes.
[/quote]
I see, thanks.

[quote=“jules”]
…so when you set the line thickness to 0.5, how exactly did you expect it to draw only half of a pixel except than by making it less opaque???[/quote]

It would be ok, but that is not the problem. Problem is that when I set thickness to 1.0f (in case of line) it draws the line too thick (as if 2 or 3 pixels wide…) When I use 0.5 or .25, it just makes it less opaque not thinner… What I find rather strange is that when I use the other drawLine() function which doesn’t use parameter thickness, it draws the line correctly…

Y.


#4

The fixed-width line method draws it using a different (and faster) algorithm, but the variable one basically draws a thin rectangle, using the normal path rendering methods.


#5