Re Bos aurus Demo7 , an Ellipse question

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

Post Reply
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Re Bos aurus Demo7 , an Ellipse question

Post by bluebird »

I have trouble placing the BT ellipse at the place I think it should go.

The Bos Taurus Demo 7 has an ellipse centered in its 800 X 600 window but the instructions to draw is

BT_DrawEllipse (hDC, 140, 200, 400, 230, WHITE, 5)

The client area is 784 X 518, so the row, col center should be 392 X 259 not 140 X 200 n'est pas?

Am I interpreting the draw ellipse call parameters wrongly?

If others have used this part of the library please let me know where I am going wrong.

Thanks
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Re Bos aurus Demo7 , an Ellipse question

Post by andyglezl »

The Bos Taurus Demo 7 has an ellipse centered in its 800 X 600 window but the instructions to draw is
BT_DrawEllipse (hDC, 140, 200, 400, 230, WHITE, 5)
The client area is 784 X 518, so the row, col center should be 392 X 259 not 140 X 200 n'est pas?
Hola Bluebird
Al parecer la clientarea es la resolución total de tu monitor que es donde se dibuja el elipse.
Si oprimes el boton maximizar, te muestra las coordenadas reales.
En ningun momento se utiliza "Height, Width" para crear el área para dibujar.
hDC = BT_CreateDC ("Win1", BT_HDC_INVALIDCLIENTAREA, @BTstruct)
( a menos que con "Win1" asuma que ese es el área a tomar)
---------------------------------------------------------------------------------------------------------------------------------------------------------
Hi Bluebird
Apparently the clientarea is the total resolution of your monitor which is where the ellipse is drawn.
If you press the maximize button, it shows you the real coordinates.
At no time is used "Height, Width" to create the area to draw.
  HDC = BT_CreateDC ("Win1", BT_HDC_INVALIDCLIENTAREA, @BTstruct)
(Unless with "Win1" assume that is the area to take)
Andrés González López
Desde Guadalajara, Jalisco. México.
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Re: Re Bos aurus Demo7 , an Ellipse question

Post by bluebird »

The placement of the Bos Taurus ellipse center is confusing me. If you have a window, say 100 x 800 and you want to show an ellipse centered in the upper left 800 X 600 area how do you specify the row,col coordinates? I.E. what would you place in the call below for row and col

BT_DrawEllipse (hDC, row, col, 400, 230, WHITE, 5)

Thanks
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Re: Re Bos aurus Demo7 , an Ellipse question

Post by bluebird »

oops! that should have been 1000 X 800
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Re Bos aurus Demo7 , an Ellipse question

Post by andyglezl »

Bueno, aquí un simple ejemplo de como lo hago yo.
espero les sirva...
------------------------------------------------------------
Well, here's a simple example of how I do it.
I hope it works for you

Code: Select all

#include "hmg.ch"


FUNCTION MAIN()
PUBLIC  cText := "Bos Taurus Draw Functions, demo by AndyGlezL"

SET CODEPAGE TO SPANISH

    DEFINE WINDOW Win1 AT 0,0 WIDTH  800  HEIGHT 600  TITLE  cText MAIN

        DEFINE MAIN MENU
            DEFINE POPUP "File"
                MENUITEM "Create Bitmap" 	ACTION CreaBitmap()
                MENUITEM "Exit" 			ACTION Win1.Release
            END POPUP
        END MENU

		@ 000,000 IMAGE Image_1 OF Win1 PICTURE "" WIDTH BT_ClientAreaWidth( "Win1" ) HEIGHT BT_ClientAreaHeight( "Win1" ) // STRETCH

   END WINDOW

   CENTER WINDOW Win1
   ACTIVATE WINDOW Win1

RETURN Nil

FUNCTION CreaBitmap()
	LOCAL hDC, BTstruct, hBitMap, nRen := 120, nCol := 50

	hBitMap  := BT_BitmapCreateNew( BT_ClientAreaWidth( "Win1" ), BT_ClientAreaHeight( "Win1" ), { 020, 020, 020 } )

	hDC := BT_CreateDC( hBitMap, BT_HDC_BITMAP, @BTStruct )	
	
	BT_DrawGradientFillVertical( hDC, 000, 000, BT_ClientAreaWidth( "Win1" ), 65, { 130, 065, 163 }, { 083, 000, 048 }  )

	BT_DrawLine( hDC, 1, 0, 500, 500, BLACK , 5 )
	
	BT_DrawText( hDC, nRen, nCol, cText, "Calibri", 20, WHITE, WHITE, BT_TEXT_TRANSPARENT, BT_TEXT_LEFT, BT_TEXT_NORMAL_ORIENTATION )   
	
	BT_DrawFillRectangle(hDC,  20, 250, 300, 100, ORANGE, RED, 3)
    
	BT_DrawFillRoundRect(hDC, 400, 250, 300, 100, 10, 10, ORANGE, RED, 3)
    
	BT_DrawFillEllipse(hDC, 200, 250, 300, 160, CYAN, BROWN, 2)	
	
	BT_DeleteDC( BTstruct )

	BT_BitmapSaveFile( hBitmap, "Sample.JPG", BT_FILEFORMAT_JPG )
	
	BT_BitmapRelease( hBitmap )
	
	SetProperty( "Win1", "Image_1", "Picture", "Sample.JPG" )
	
	BT_ClientAreaInvalidateAll( "Win1", .F.) 

RETURN
demoagl.jpg
demoagl.jpg (77.62 KiB) Viewed 4759 times
Andrés González López
Desde Guadalajara, Jalisco. México.
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Re: Re Bos aurus Demo7 , an Ellipse question

Post by bluebird »

Thanks for he response, but I still do not understand where the ellipse coordinates come from.
Andy's code specifies a window of 800 X 600 which has a center of row 300 column 400. yet the ellipse
coordinates are row 200 column 250., .... not anywhere near the window center. Pls explain.

Thanks
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Re Bos aurus Demo7 , an Ellipse question

Post by andyglezl »

Bien, ya entendí la pregunta... :oops:
Las coordenadas de la elipse 200,250 aplican igual que las demás funciones
RenIni, ColIni TO RenFin, ColFin fijate en las coordenadas de los rectangulos
y veras la relación.
---------------------------------------------------------------------------------------------
Well, I already understood the question ...: :oops:
The coordinates of the 200,250 ellipse apply the same as the other functions
RenIni, ColIni TO RenFin, ColFin Note the coordinates of the rectangles
And you will see the relationship.
Andrés González López
Desde Guadalajara, Jalisco. México.
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Re: Re Bos aurus Demo7 , an Ellipse question

Post by bluebird »

To those who offered help, thanks

My main problem turned out to be the interpretation of the row and column coordinates. I assumed that you would specify the center point
followed by the size parameters. Wrong! BTaurus means the coordinates of the upper left corner of a rectangle that surrounds the ellipse.
You can verify by drawing a rectangle along with the ellipse using the same values.

Everything clear now re this post subject.
Post Reply