Page 1 of 1

GraSetAttrString set angle problem

Posted: Fri Jul 24, 2020 3:05 am
by Victorio
Hi,

I need draw text to screen with other angles.
But when I set angle with function GraSetAttrString( oPS,aAtribs ) where aAtribs[GRA_AS_ANGLE]= different point as {1,0} {0,1}, {-1,0} , {-1,-1} where this is angles 0, 90, 180,270 degrees,
text not rotate correctly, still write vertical.

When I test it with numbers multiple for example with 10, angles is good, but interesting is, that text which is in 0, 90 ,180 , 270 has size font without change, but other angles has enlargered font.

here is example attached

I do not know whats wrong, if something about font settings, or function GraSetAttrString xbase++ not correct

Re: GraSetAttrString set angle problem

Posted: Fri Jul 24, 2020 10:33 pm
by Eugene Lutsenko
Maybe this increase in the font size when turning at different angles is purely visual, but the number of pixels is correct? To test this hypothesis, we need to make the same number of pixels for X and y. To make the pixels square. And I would make a 4K image so that you don't see steps on sloping straight lines.

Re: GraSetAttrString set angle problem

Posted: Sat Jul 25, 2020 12:24 am
by Victorio
Hi Eugene,

Can be , that problem is x/y resolution,

But when I try other system with GraRotate

Code: Select all

PUBLIC amatrix
oFont := XbpFont():new(oPS):create()
oFont:configure( fontnt )
GraSetFont( oPS, oFont )
aMatrix  := GraInitMatrix()
for i=0 to 360 step 15
	testtext:="TEST TEST TEST - "+str(i)			// zadefinovanie textu
	nSegment := graSegOpen(oPs)		// otvorenie grafického segmentu
	GraStringAt( oPS, {(vwb/2)+45,(vwb/2)+45}, testtext )	// prvotné vykreslenie textu
	msgbox("1")
	GraSegClose(oPS)			// zatvorenie segmentu
						// rotácia segmentu
*	GraRotate( oPS, aMatrix, i,{(vwb/2)+45,(vwb/2)+45}, GRA_TRANSFORM_ADD )
*	GraRotate( oPS, aMatrix, 15,{(vwb/2)+45,(vwb/2)+45}, GRA_TRANSFORM_ADD )
	GraRotate( oPS, aMatrix, i,{(vwb/2)+45,(vwb/2)+45}, GRA_TRANSFORM_REPLACE )
*	GraRotate( oPS, aMatrix, 15,{(vwb/2)+45,(vwb/2)+45}, GRA_TRANSFORM_REPLACE )

	GraSegDraw(oPS, nSegment, aMatrix)	// vykreslenie segmentu
	GraSegDestroy( oPS, nSegment )		// zrušenie segmentu
	msgbox("2")
next

Here rotating with correct angle is ok, but also when angle is other that 0, text is bigger than default.

Here also I do not know how delete text on his first position before rotating ? This causes that text is always twice.
Also rotating text can be problem in digital cadastral maps where are many texts can be thousands and rotating can cause long delay when zooming, or pan draw.

Better way will be default solution with solition like this :
[code]
aAtribs[GRA_AS_BOX]:={40,20}
		GraSetAttrString( oPS,aAtribs )
		GraStringAt(oPS,{(vwb/2)+45,(vwb/2)+45},"-----"+str(dx)+","+str(dy) )
but here I have problem with angles between 0-90

[/code]

As you can see when rotate text, then first text in 0 angle is smaller than other text in angles.

Re: GraSetAttrString set angle problem

Posted: Sat Jul 25, 2020 2:31 am
by Eugene Lutsenko
Yes, because the letter "T" rotates on the inner circle, the error of calculations and visualization is clearly visible. Make a graphic file on which this is drawn 4096 by 4096 pixels (jpg). This minimizes the visualization error