{"id":7241,"date":"2015-09-08T17:04:55","date_gmt":"2015-09-08T09:04:55","guid":{"rendered":"http:\/\/www.vbtutor.net\/?page_id=7241"},"modified":"2018-06-22T22:15:55","modified_gmt":"2018-06-22T14:15:55","slug":"visual-basic-2015-lesson-28-creating-ellipses-circles","status":"publish","type":"page","link":"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2015-lesson-28-creating-ellipses-circles\/","title":{"rendered":"Visual Basic 2015 Lesson 28: Creating Ellipses and Circles"},"content":{"rendered":"<h4 style=\"text-align: center;\"><a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2015-lesson-27-creating-rectangles\/\">[Lesson 27] <\/a>&lt;&lt; <a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2015-tutorial\/\">[Contents] <\/a>&gt;&gt; <a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2015-lesson-29-drawing-text\/\">[Lesson 29]<\/a><\/h4>\n<h3>28.1 Drawing Ellipse<\/h3>\n<p>We have learned how to draw rectangles with various line styles in Visual Basic 2015 in the previous lesson. Now we shall learn how to draw ellipse and circle.First of all, we need to understand the principle behind drawing an ellipse in Visual Basic 2015. The basic structure of most shapes is a rectangle, an ellipse is no exception. Ellipse is an oval shape that is bounded by a rectangle, as shown in Figure 28.1<\/p>\n<p><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<ins class=\"adsbygoogle\" style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"4768455349\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson23_1.jpg\" alt=\"\" width=\"211\" height=\"107\" \/><\/p>\n<p><strong>Figure 28.1<\/strong><\/p>\n<p>Therefore, we need to create a Rectangle object before we can draw an ellipse in visual basic 2015. This rectangle serves as a bounding rectangle for the ellipse. However, you still need to use the <strong>DrawEllipse<\/strong> method to finish the job.\u00a0On the other hand, we can also draw an ellipse with the <strong>DrawEllipse<\/strong> method without first creating a rectangle. We shall show you both ways.In the first method, let&#8217;s say you have created a rectangle object known as myRectangle and a pen object as myPen, then you can draw an ellipse using the following statement:<\/p>\n<h4><strong>myGraphics.DrawEllipse(myPen, myRectangle)<\/strong><\/h4>\n<p>* Assume you have also already created the Graphics object myGraphics.<\/p>\n<p><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<ins class=\"adsbygoogle\" style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"4768455349\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/p>\n<h4><strong>Example 28.1(a)<\/strong><\/h4>\n<pre style=\"font-size: 110%;\">Private Sub BtnDraw_Click(sender As Object, e As EventArgs) Handles BtnDraw.Click\r\nDim myPen As Pen\r\n myPen = New Pen(Drawing.Color.DarkTurquoise, 5)\r\n\r\nDim myGraphics As Graphics = Me.CreateGraphics\r\nDim myRectangle As New Rectangle\r\n\r\n myRectangle.X = 40\r\n myRectangle.Y = 30\r\n myRectangle.Width = 200\r\n myRectangle.Height = 100\r\n myGraphics.DrawEllipse(myPen, myRectangle)\r\nEnd Sub\r\n<\/pre>\n<p>The output image is shown in Figure 28.2<\/p>\n<p><a href=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2014\/01\/vb2013_figure27.1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4934\" src=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2014\/01\/vb2013_figure27.1.jpg\" alt=\"vb2013_figure27.1\" width=\"300\" height=\"300\" \/><\/a><\/p>\n<p style=\"text-align: center;\">\u00a0<strong>Figure 28.2<\/strong><\/p>\n<p><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<ins class=\"adsbygoogle\" style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"4768455349\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><br \/>\nThe second method is using the <strong>DrawEllipse<\/strong> method without creating a rectangle object. Of course, you still have to create the Graphics and the Pen objects. The syntax is:<\/p>\n<pre style=\"font-size: 110%;\">myGraphics.DrawEllipse(myPen, X,Y,Width, Height)<\/pre>\n<p>Where (X, Y) are the coordinates of the upper-left corner of the bounding rectangle, width is the width of the ellipse and height is the height of the ellipse.<\/p>\n<h4>Example 28.1(b)<\/h4>\n<pre style=\"font-size: 110%;\">Private Sub BtnDraw_Click(sender As Object, e As EventArgs) Handles BtnDraw.ClickDim myPen As Pen\r\n myPen = New Pen(Drawing.Color.DarkTurquoise, 5)\r\nDim myGraphics As Graphics = Me.CreateGraphics\r\n myGraphics.DrawEllipse(myPen, 40, 30, 200, 100)\r\nEnd Sub\r\n<\/pre>\n<h3>28.2 Drawing a Circle<\/h3>\n<p>After you have learned how to draw an ellipse, drawing a circle becomes very simple. We use exactly the same methods used in the preceding section but modify the width and height so that they are of the same values.<\/p>\n<p>The following examples draw the same circle.<\/p>\n<h4><strong>Example 28.2(a)<\/strong><\/h4>\n<pre style=\"font-size: 110%;\">Dim myPen As Pen\r\n myPen = New Pen(Drawing.Color.DarkTurquoise, 5)\r\nDim myGraphics As Graphics = Me.CreateGraphics\r\nDim myRectangle As New Rectangle\r\n\r\n myRectangle.X = 90\r\n myRectangle.Y = 30\r\n myRectangle.Width = 100\r\n myRectangle.Height = 100\r\n myGraphics.DrawEllipse(myPen, myRectangle)\r\n<\/pre>\n<h4><strong>Example 28.2(b)<\/strong><\/h4>\n<pre style=\"font-size: 110%;\">Dim myPen As Pen\r\n myPen = New Pen(Drawing.Color.DarkTurquoise, 5)\r\nDim myGraphics As Graphics = Me.CreateGraphics\r\n myGraphics.DrawEllipse(myPen, 90, 30, 100, 100)\r\n<\/pre>\n<p>The output image is shown in Figure 27.3<\/p>\n<p><a href=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2014\/01\/vb2013_figure27.2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4943\" src=\"https:\/\/www.vbtutor.net\/wordpress\/wp-content\/uploads\/2014\/01\/vb2013_figure27.2.jpg\" alt=\"vb2013_figure27.2\" width=\"300\" height=\"300\" \/><\/a><br \/>\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<ins class=\"adsbygoogle\"\n     style=\"display:block\"\n     data-ad-format=\"autorelaxed\"\n     data-ad-client=\"ca-pub-3033628290023372\"\n     data-ad-slot=\"5090773108\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/p>\n<h4 style=\"text-align: center;\"><a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2015-lesson-27-creating-rectangles\/\">[Lesson 27]\u00a0<\/a>&lt;&lt;\u00a0<a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2015-tutorial\/\">[Contents]\u00a0<\/a>&gt;&gt; <a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2015-lesson-29-drawing-text\/\">[Lesson 29]<\/a><\/h4>\n","protected":false},"excerpt":{"rendered":"<p>[Lesson 27] &lt;&lt; [Contents] &gt;&gt; [Lesson 29] 28.1 Drawing Ellipse We have learned how to draw rectangles with various line styles in Visual Basic 2015 in the previous lesson. Now we shall learn how to draw ellipse and circle.First of all, we need to understand the principle behind drawing an ellipse in Visual Basic 2015. &hellip; <a href=\"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2015-lesson-28-creating-ellipses-circles\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Visual Basic 2015 Lesson 28: Creating Ellipses and Circles<\/span><\/a><\/p>\n","protected":false},"author":23013,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-7241","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Visual Basic 2015 Lesson 28: Creating Ellipses and Circles - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB<\/title>\n<meta name=\"description\" content=\"This article discusses how to create ellipses and circles in visual basic 2015 community RC\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.vbtutor.net\/vb2015\/vb2015_lesson28.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Visual Basic 2015 Lesson 28: Creating Ellipses and Circles - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB\" \/>\n<meta property=\"og:description\" content=\"This article discusses how to create ellipses and circles in visual basic 2015 community RC\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.vbtutor.net\/vb2015\/vb2015_lesson28.html\" \/>\n<meta property=\"og:site_name\" content=\"Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Vbtutor\" \/>\n<meta property=\"article:modified_time\" content=\"2018-06-22T14:15:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson23_1.jpg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@liewvk\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2015-lesson-28-creating-ellipses-circles\/\",\"url\":\"http:\/\/www.vbtutor.net\/vb2015\/vb2015_lesson28.html\",\"name\":\"Visual Basic 2015 Lesson 28: Creating Ellipses and Circles - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB\",\"isPartOf\":{\"@id\":\"https:\/\/www.vbtutor.net\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2015\/vb2015_lesson28.html#primaryimage\"},\"image\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2015\/vb2015_lesson28.html#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson23_1.jpg\",\"datePublished\":\"2015-09-08T09:04:55+00:00\",\"dateModified\":\"2018-06-22T14:15:55+00:00\",\"description\":\"This article discusses how to create ellipses and circles in visual basic 2015 community RC\",\"breadcrumb\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2015\/vb2015_lesson28.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.vbtutor.net\/vb2015\/vb2015_lesson28.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.vbtutor.net\/vb2015\/vb2015_lesson28.html#primaryimage\",\"url\":\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson23_1.jpg\",\"contentUrl\":\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson23_1.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.vbtutor.net\/vb2015\/vb2015_lesson28.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vbtutor.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Visual Basic 2015 Lesson 28: Creating Ellipses and Circles\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vbtutor.net\/#website\",\"url\":\"https:\/\/www.vbtutor.net\/\",\"name\":\"Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB\",\"description\":\"Start learning Visual Basic from beginner to advanced. Includes VB.NET, VBA, and classic VB tutorials for students and professionals.\",\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Visual Basic 2015 Lesson 28: Creating Ellipses and Circles - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","description":"This article discusses how to create ellipses and circles in visual basic 2015 community RC","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.vbtutor.net\/vb2015\/vb2015_lesson28.html","og_locale":"en_US","og_type":"article","og_title":"Visual Basic 2015 Lesson 28: Creating Ellipses and Circles - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","og_description":"This article discusses how to create ellipses and circles in visual basic 2015 community RC","og_url":"http:\/\/www.vbtutor.net\/vb2015\/vb2015_lesson28.html","og_site_name":"Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","article_publisher":"https:\/\/www.facebook.com\/Vbtutor","article_modified_time":"2018-06-22T14:15:55+00:00","og_image":[{"url":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson23_1.jpg","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_site":"@liewvk","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2015-lesson-28-creating-ellipses-circles\/","url":"http:\/\/www.vbtutor.net\/vb2015\/vb2015_lesson28.html","name":"Visual Basic 2015 Lesson 28: Creating Ellipses and Circles - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","isPartOf":{"@id":"https:\/\/www.vbtutor.net\/#website"},"primaryImageOfPage":{"@id":"http:\/\/www.vbtutor.net\/vb2015\/vb2015_lesson28.html#primaryimage"},"image":{"@id":"http:\/\/www.vbtutor.net\/vb2015\/vb2015_lesson28.html#primaryimage"},"thumbnailUrl":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson23_1.jpg","datePublished":"2015-09-08T09:04:55+00:00","dateModified":"2018-06-22T14:15:55+00:00","description":"This article discusses how to create ellipses and circles in visual basic 2015 community RC","breadcrumb":{"@id":"http:\/\/www.vbtutor.net\/vb2015\/vb2015_lesson28.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.vbtutor.net\/vb2015\/vb2015_lesson28.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.vbtutor.net\/vb2015\/vb2015_lesson28.html#primaryimage","url":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson23_1.jpg","contentUrl":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson23_1.jpg"},{"@type":"BreadcrumbList","@id":"http:\/\/www.vbtutor.net\/vb2015\/vb2015_lesson28.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vbtutor.net\/"},{"@type":"ListItem","position":2,"name":"Visual Basic 2015 Lesson 28: Creating Ellipses and Circles"}]},{"@type":"WebSite","@id":"https:\/\/www.vbtutor.net\/#website","url":"https:\/\/www.vbtutor.net\/","name":"Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","description":"Start learning Visual Basic from beginner to advanced. Includes VB.NET, VBA, and classic VB tutorials for students and professionals.","inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/7241","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/users\/23013"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/comments?post=7241"}],"version-history":[{"count":18,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/7241\/revisions"}],"predecessor-version":[{"id":13044,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/7241\/revisions\/13044"}],"wp:attachment":[{"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/media?parent=7241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/categories?post=7241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/tags?post=7241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}