{"id":1142,"date":"2012-04-06T17:27:24","date_gmt":"2012-04-06T09:27:24","guid":{"rendered":"http:\/\/www.vbtutor.net\/index.php\/"},"modified":"2018-06-24T22:55:54","modified_gmt":"2018-06-24T14:55:54","slug":"visual-basic-2010-lesson-23","status":"publish","type":"page","link":"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-lesson-23\/","title":{"rendered":"Visual Basic 2010 Lesson 23 &#8211; The DrawEllipse Method"},"content":{"rendered":"<p align=\"center\"><strong><a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-lesson-22\/\">[Lesson 22]<\/a> <\/strong>&lt;&lt;\u00a0<strong><a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-tutorial\/\">[CONTENTS]<\/a> &gt;&gt;<a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-lesson-24\/\"> [Lesson 24]<\/a><\/strong><\/p>\n<p>In this lesson, we will learn how to draw ellipse and circle using the DrawEllipse method.<\/p>\n<h3>23.1 Drawing Ellipse with the DrawEllipse Method<\/h3>\n<p>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 below:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson23_1.jpg\" alt=\"\" width=\"211\" height=\"107\" \/>Therefore, we need to create a Rectangle object before we can draw an ellipse. This rectangle serves as a bounding rectangle for the ellipse. We still need to use the DrawEllipse method to complete the job.<\/p>\n<p><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<ins class=\"adsbygoogle\"\n     style=\"display:block; text-align:center;\"\n     data-ad-layout=\"in-article\"\n     data-ad-format=\"fluid\"\n     data-ad-client=\"ca-pub-3033628290023372\"\n     data-ad-slot=\"1723562988\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><br \/>\nOn the other hand, we can also draw an ellipse with the DrawEllipse method without first creating a rectangle. We shall illustrate both methods.<\/p>\n<p>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<pre style=\"font-size: 110%; width: 80%;\">myGraphics.DrawEllipse(myPen, myRectangle)\r\n<\/pre>\n<p>* Assume you have also already created the Graphics object myGraphics.<\/p>\n<p>The following is an example of the full code:<\/p>\n<h4>Example 23.1(a)<\/h4>\n<pre style=\"font-size: 110%; width: 80%;\">Dim myPen As Pen\r\n myPen = New Pen(Drawing.Color.Blue, 5)\r\nDim myGraphics As Graphics = Me.CreateGraphics\r\nDim myRectangle As New Rectangle\r\n myRectangle.X = 10\r\n myRectangle.Y = 10\r\n myRectangle.Width = 200\r\n myRectangle.Height = 100\r\n myGraphics.DrawEllipse(myPen, myRectangle)\r\n<\/pre>\n<p>The output image is shown in the following diagram:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson23_2.jpg\" alt=\"\" width=\"300\" height=\"300\" \/><br \/>\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<ins class=\"adsbygoogle\"\n     style=\"display:block; text-align:center;\"\n     data-ad-layout=\"in-article\"\n     data-ad-format=\"fluid\"\n     data-ad-client=\"ca-pub-3033628290023372\"\n     data-ad-slot=\"1723562988\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><br \/>\nThe second method is using the DrawEllipse 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%; width: 80%;\">myGraphics.DrawEllipse(myPen, X,Y,Width, Height)\r\n<\/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<p>The following is an example of the full code:<\/p>\n<p><strong>Example 23.1(b)<\/strong><\/p>\n<pre style=\"font-size: 110%; width: 80%;\">Dim myPen As Pen\r\n myPen = New Pen(Drawing.Color.Blue, 5)\r\nDim myGraphics As Graphics = Me.CreateGraphics\r\n myGraphics.DrawEllipse(myPen, 10, 10, 200, 100)\r\n<\/pre>\n<h3>23.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<p>Example 23.2(a)<\/p>\n<pre style=\"font-size: 110%; width: 80%;\">Dim myPen As Pen\r\n myPen = New Pen(Drawing.Color.Blue, 5)\r\nDim myGraphics As Graphics = Me.CreateGraphics\r\nDim myRectangle As New Rectangle\r\n myRectangle.X = 10\r\n myRectangle.Y = 10\r\n myRectangle.Width = 100\r\n myRectangle.Height = 100\r\n myGraphics.DrawEllipse(myPen, myRectangle)\r\n<\/pre>\n<p>Example 23.2(b)<\/p>\n<pre style=\"font-size: 110%; width: 80%;\">Dim myPen As Pen\r\n myPen = New Pen(Drawing.Color.Blue, 5)\r\nDim myGraphics As Graphics = Me.CreateGraphics\r\n myGraphics.DrawEllipse(myPen, 10, 10, 100, 100)\r\n<\/pre>\n<p>The output image is show below:<\/p>\n<p><center><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson23_3.jpg\" alt=\"Visual Basic 2010\" width=\"300\" height=\"300\" \/><\/center><br \/>\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<ins class=\"adsbygoogle\" style=\"display: block;\" data-ad-format=\"autorelaxed\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"8075128701\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/p>\n<p align=\"center\"><strong><strong><a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-lesson-22\/\">[Lesson 22]<\/a> <\/strong>&lt;&lt;\u00a0<strong><a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-tutorial\/\">[CONTENTS]<\/a> &gt;&gt;<a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-lesson-24\/\"> [Lesson 24]<\/a><\/strong><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[Lesson 22] &lt;&lt;\u00a0[CONTENTS] &gt;&gt; [Lesson 24] In this lesson, we will learn how to draw ellipse and circle using the DrawEllipse method. 23.1 Drawing Ellipse with the DrawEllipse Method 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 &hellip; <a href=\"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-lesson-23\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Visual Basic 2010 Lesson 23 &#8211; The DrawEllipse Method<\/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-1142","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 2010 Lesson 23 - The DrawEllipse Method - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB<\/title>\n<meta name=\"description\" content=\"This Visual Basic 2010 lesson shows how to draw ellipse in Visual Basic 2010\" \/>\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\/vb2010\/vb2010_lesson23.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Visual Basic 2010 Lesson 23 - The DrawEllipse Method - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB\" \/>\n<meta property=\"og:description\" content=\"This Visual Basic 2010 lesson shows how to draw ellipse in Visual Basic 2010\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson23.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-24T14:55:54+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-2010-lesson-23\/\",\"url\":\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson23.html\",\"name\":\"Visual Basic 2010 Lesson 23 - The DrawEllipse Method - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB\",\"isPartOf\":{\"@id\":\"https:\/\/www.vbtutor.net\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson23.html#primaryimage\"},\"image\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson23.html#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson23_1.jpg\",\"datePublished\":\"2012-04-06T09:27:24+00:00\",\"dateModified\":\"2018-06-24T14:55:54+00:00\",\"description\":\"This Visual Basic 2010 lesson shows how to draw ellipse in Visual Basic 2010\",\"breadcrumb\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson23.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson23.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson23.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\/vb2010\/vb2010_lesson23.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vbtutor.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Visual Basic 2010 Lesson 23 &#8211; The DrawEllipse Method\"}]},{\"@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 2010 Lesson 23 - The DrawEllipse Method - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","description":"This Visual Basic 2010 lesson shows how to draw ellipse in Visual Basic 2010","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\/vb2010\/vb2010_lesson23.html","og_locale":"en_US","og_type":"article","og_title":"Visual Basic 2010 Lesson 23 - The DrawEllipse Method - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","og_description":"This Visual Basic 2010 lesson shows how to draw ellipse in Visual Basic 2010","og_url":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson23.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-24T14:55:54+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-2010-lesson-23\/","url":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson23.html","name":"Visual Basic 2010 Lesson 23 - The DrawEllipse Method - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","isPartOf":{"@id":"https:\/\/www.vbtutor.net\/#website"},"primaryImageOfPage":{"@id":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson23.html#primaryimage"},"image":{"@id":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson23.html#primaryimage"},"thumbnailUrl":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson23_1.jpg","datePublished":"2012-04-06T09:27:24+00:00","dateModified":"2018-06-24T14:55:54+00:00","description":"This Visual Basic 2010 lesson shows how to draw ellipse in Visual Basic 2010","breadcrumb":{"@id":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson23.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson23.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson23.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\/vb2010\/vb2010_lesson23.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vbtutor.net\/"},{"@type":"ListItem","position":2,"name":"Visual Basic 2010 Lesson 23 &#8211; The DrawEllipse Method"}]},{"@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\/1142","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=1142"}],"version-history":[{"count":42,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/1142\/revisions"}],"predecessor-version":[{"id":13144,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/1142\/revisions\/13144"}],"wp:attachment":[{"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/media?parent=1142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/categories?post=1142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/tags?post=1142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}