{"id":1118,"date":"2012-04-06T16:46:29","date_gmt":"2012-04-06T08:46:29","guid":{"rendered":"http:\/\/www.vbtutor.net\/index.php\/"},"modified":"2018-06-24T22:57:53","modified_gmt":"2018-06-24T14:57:53","slug":"visual-basic-2010-lesson-26","status":"publish","type":"page","link":"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-lesson-26\/","title":{"rendered":"Visual Basic 2010 Lesson 26 &#8211; Filling Shapes with Colors"},"content":{"rendered":"<p align=\"center\"><strong><a href=\"http:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-lesson-25\/\">[Lesson 25]<\/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-27\/\"> [Lesson 27]<\/a><\/strong><\/p>\n<p>In this lesson, we will illustrate how to fill the shapes with colors. In Visual Basic 2010, three methods are used to fill shapes are FillRectangle, FillEllipse, FillPolygon and FillPie.In order to fill the aforementioned shapes with color, we have to create the Brush object using the following syntax:<\/p>\n<pre style=\"font-size: 110%; width: 80%;\">myBrush = New SolidBrush(Color.myColor)<\/pre>\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 \/>\nWhere myColor can be any color such as red, blue, yellow and more. You don&#8217;t have to worry about the names of the colors because the intelligence will display the colours and enter the period after the Color key word.<\/p>\n<h3>26.1 Drawing and Filling a Rectangle<\/h3>\n<p>In Visual Basic 2010, the syntax to fill a rectangle with the colour defined by the brush object is:<\/p>\n<pre style=\"font-size: 110%; width: 80%;\">myGraphics.FillRectangle (myBrush, 0, 0, 150, 150)\r\n<\/pre>\n<p>The complete code is shown in the example below:<\/p>\n<h4>Example 26.1<\/h4>\n<pre style=\"font-size: 110%; width: 80%;\">Dim myPen As Pen\r\nDim myBrush As Brush\r\nDim myGraphics As Graphics = Me.CreateGraphics\r\n myPen = New Pen(Drawing.Color.Blue, 5)\r\n myBrush = New SolidBrush(Color.Coral)\r\n myGraphics.DrawRectangle(myPen, 0, 0, 150, 150)\r\n myGraphics.FillRectangle(myBrush, 0, 0, 150, 150)\r\n<\/pre>\n<p>The Output is shown below:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson26_1.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><\/p>\n<h3>26.2 Drawing and Filling an Ellipse<\/h3>\n<p>The syntax to fill a ellipse with the colour defined by the brush object is:<\/p>\n<p>myGraphics.FillEllipse (myBrush, 0, 0, 150, 150)<\/p>\n<p>The complete code is shown in Example 26.2<\/p>\n<h4>Example 26.2<\/h4>\n<pre style=\"font-size: 110%; width: 80%;\">Dim myPen As Pen\r\nDim myBrush As Brush\r\nDim myGraphics As Graphics = Me.CreateGraphics\r\n myPen = New Pen(Drawing.Color.Blue, 5)\r\n myBrush = New SolidBrush(Color.Coral)\r\n myGraphics.DrawEllipse(myPen, 0, 0, 150, 150)\r\n myGraphics.Ellipse(myBrush, 0, 0, 150, 150)\r\n<\/pre>\n<p>The output is shown in the following figure:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson26_2.jpg\" alt=\"\" width=\"300\" height=\"300\" \/><\/p>\n<p><strong>26.3 Drawing and Filling a Polygon<\/strong><\/p>\n<p>The syntax to fill a polygon with the colour defined by the brush object is:<\/p>\n<pre style=\"font-size: 110%; width: 80%;\">myGraphics.FillPolygon(myBrush, myPoints)\r\n<\/pre>\n<p>The complete code is shown in the Example 26.3<\/p>\n<h4>Example 26.3<\/h4>\n<pre style=\"font-size: 110%; width: 80%;\">Dim myPen As Pen\r\nDim myBrush As Brush\r\nDim A As New Point(10, 10)\r\nDim B As New Point(100, 50)\r\nDim C As New Point(120, 150)\r\nDim D As New Point(60, 200)\r\nDim myPoints As Point() = {A, B, C, D}\r\n myPen = New Pen(Drawing.Color.Blue, 5)\r\n myBrush = New SolidBrush(Color.Coral)\r\nDim myGraphics As Graphics = Me.CreateGraphics\r\n myGraphics.DrawPolygon(myPen, myPoints)\r\n myGraphics.FillPolygon(myBrush, myPoints)\r\n<\/pre>\n<p>Running the code produces the image below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson26_3.jpg\" alt=\"\" width=\"300\" height=\"300\" \/><\/p>\n<h3>26.4 Drawing and Filling a Pie<\/h3>\n<p>The syntax to fill a pie with the colour defined by the brush object is:<\/p>\n<pre style=\"font-size: 110%;\">myGraphics.FillPie(myBrush, X, Y, width, height, StartAngle, SweepAngle)\r\n<\/pre>\n<p>The complete code is shown in the following Example 26.4<\/p>\n<h4>Example 26.4<\/h4>\n<pre style=\"font-size: 110%; width: 80%;\">Dim myPen As Pen\r\nDim myBrush As Brush\r\n myPen = New Pen(Drawing.Color.Blue, 5)\r\n myBrush = New SolidBrush(Color.Coral)\r\nDim myGraphics As Graphics = Me.CreateGraphics\r\n myGraphics.DrawPie(myPen, 30, 40, 150, 150, 0, 60)\r\n myGraphics.FillPie(myBrush, 30, 40, 150, 150, 0, 60)\r\n<\/pre>\n<p>The output is shown below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson26_4.jpg\" alt=\"\" width=\"300\" height=\"300\" \/><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-25\/\">[Lesson 25]<\/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-27\/\"> [Lesson 27]<\/a><\/strong><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[Lesson 25] &lt;&lt;\u00a0[CONTENTS] &gt;&gt; [Lesson 27] In this lesson, we will illustrate how to fill the shapes with colors. In Visual Basic 2010, three methods are used to fill shapes are FillRectangle, FillEllipse, FillPolygon and FillPie.In order to fill the aforementioned shapes with color, we have to create the Brush object using the following syntax: &hellip; <a href=\"https:\/\/www.vbtutor.net\/index.php\/visual-basic-2010-lesson-26\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Visual Basic 2010 Lesson 26 &#8211; Filling Shapes with Colors<\/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-1118","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 26 - Filling Shapes with Colors - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB<\/title>\n<meta name=\"description\" content=\"In this Visual Basic 2010 lesson, you learn how to fill shapes with color\" \/>\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_lesson26.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 26 - Filling Shapes with Colors - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB\" \/>\n<meta property=\"og:description\" content=\"In this Visual Basic 2010 lesson, you learn how to fill shapes with color\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson26.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:57:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson26_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-26\/\",\"url\":\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson26.html\",\"name\":\"Visual Basic 2010 Lesson 26 - Filling Shapes with Colors - 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_lesson26.html#primaryimage\"},\"image\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson26.html#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson26_1.jpg\",\"datePublished\":\"2012-04-06T08:46:29+00:00\",\"dateModified\":\"2018-06-24T14:57:53+00:00\",\"description\":\"In this Visual Basic 2010 lesson, you learn how to fill shapes with color\",\"breadcrumb\":{\"@id\":\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson26.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson26.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson26.html#primaryimage\",\"url\":\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson26_1.jpg\",\"contentUrl\":\"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson26_1.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson26.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vbtutor.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Visual Basic 2010 Lesson 26 &#8211; Filling Shapes with Colors\"}]},{\"@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 26 - Filling Shapes with Colors - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","description":"In this Visual Basic 2010 lesson, you learn how to fill shapes with color","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_lesson26.html","og_locale":"en_US","og_type":"article","og_title":"Visual Basic 2010 Lesson 26 - Filling Shapes with Colors - Learn Visual Basic Programming \u2013 VB.NET, VBA &amp; Classic VB","og_description":"In this Visual Basic 2010 lesson, you learn how to fill shapes with color","og_url":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson26.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:57:53+00:00","og_image":[{"url":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson26_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-26\/","url":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson26.html","name":"Visual Basic 2010 Lesson 26 - Filling Shapes with Colors - 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_lesson26.html#primaryimage"},"image":{"@id":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson26.html#primaryimage"},"thumbnailUrl":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson26_1.jpg","datePublished":"2012-04-06T08:46:29+00:00","dateModified":"2018-06-24T14:57:53+00:00","description":"In this Visual Basic 2010 lesson, you learn how to fill shapes with color","breadcrumb":{"@id":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson26.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson26.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson26.html#primaryimage","url":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson26_1.jpg","contentUrl":"https:\/\/www.vbtutor.net\/vb2010\/vb2010_Image\/lesson26_1.jpg"},{"@type":"BreadcrumbList","@id":"http:\/\/www.vbtutor.net\/vb2010\/vb2010_lesson26.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vbtutor.net\/"},{"@type":"ListItem","position":2,"name":"Visual Basic 2010 Lesson 26 &#8211; Filling Shapes with Colors"}]},{"@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\/1118","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=1118"}],"version-history":[{"count":30,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/1118\/revisions"}],"predecessor-version":[{"id":13147,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/pages\/1118\/revisions\/13147"}],"wp:attachment":[{"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/media?parent=1118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/categories?post=1118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vbtutor.net\/index.php\/wp-json\/wp\/v2\/tags?post=1118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}