Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to draw a circle in the secondary development of TE

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report