Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to draw a circle in the secondary development of TE

Shulou Source: shulou.com Published: 2022-06-01 03:38:13 10月03日 Update

This article will explain in detail how to draw a circle in the secondary development of TE. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

In the secondary development of TE, it is sometimes used to draw a circle to mark a range, and the radius of the circle varies according to mouse movement, which is the same as directly using TE to draw a circle.

This requires defining events such as mouse clicks in the re-development of te. The following is the detailed description code.

/ / define the left mouse button event

Sgworld.OnLButtonUp + = sgworld_OnLButtonUp

/ / define the right mouse button event

Sgworld.OnRButtonUp + = sgworld_OnRButtonUp

/ / define real-time monitoring events

Sgworld.OnFrame + = sgworld_OnFrame

Bool sgworld_OnLButtonUp (int Flags, int X, int Y)

{

If (icircle = = null)

{

/ / if the object is empty, draw a circle where the mouse clicks for the first time

/ / obtain the coordinates of the mouse click location

Iworldpoint = this.sgworld.Window.PixelToWorld (X, Y, WorldPointType.WPT_TERRAIN)

Iposition = iworldpoint.Position

Iposition.AltitudeType = AltitudeTypeCode.ATC_ON_TERRAIN

/ / create a circle

Icircle = sgworld.Creator.CreateCircle (iposition, x, "", sgworld.Creator.CreateColor (fillcolor.R, fillcolor.G, fillcolor.B, fillcolor.A), groupid, "Circle")

Icircle.NumberOfSegments = 25

Return true

}

Else

{

/ / after the circle has been drawn, the radius of the circle is calculated according to the current position of the mouse

Iworldpoint2 = this.sgworld.Window.PixelToWorld (X, Y, WorldPointType.WPT_TERRAIN)

/ / data the location of the mouse and calculate the distance

X = sgworld.CoordServices.GetDistance (iworldpoint.Position.X, iworldpoint.Position.Y, iworldpoint2.Position.X, iworldpoint2.Position.Y)

Icircle.Radius = x

Icircle = null

Return true

}

Return false

}

/ / Real-time monitoring events

Void sgworld_OnFrame ()

{

/ / judge if the circle object is not empty

If (icirclearship null)

{

/ / get the mouse information

Moseinfo = this.sgworld.Window.GetMouseInfo ()

Iworldpoint2 = this.sgworld.Window.PixelToWorld (moseinfo.X,moseinfo.Y,WorldPointType.WPT_TERRAIN)

/ / calculate the distance

X = sgworld.CoordServices.GetDistance (iworldpoint.Position.X, iworldpoint.Position.Y, iworldpoint2.Position.X, iworldpoint2.Position.Y)

Icircle.Radius = x

}

}

/ / right mouse button event

Bool sgworld_OnRButtonUp (int Flags, int X, int Y)

{

/ / some commonly used end events

Return false

}

This is the end of the article on "how to draw a circle in the secondary development of TE". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Mouse event development location article radius real-time object situation more monitoring good practical same code information content place coordinates commonly used Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Information Shulou Tech Info Huawei Microsoft