Choosing to Use Graphics

Graphics can be a tricky issue in technical writing. Some authors use graphics at the drop of a hat. Often, the graphic shows something that the reader can readily understand from the text or contains nothing of value to the reader. For example, some books contain images of objects that don’t have any intrinsic value of themselves and possibly contain a little text that the author could easily include in the text. However, some authors err to the other extreme. Some abstract concepts lend themselves to pictorial representation. For example, a block diagram can often convey relationships that would be impossible to describe using text alone. Consequently, the issue of whether to use graphics within a text or not often hinges on the graphic’s ability to convey meaning that words alone can’t.

However, the decision to use graphics often involves more than simply conveying information. The quality of the graphic also matters. Graphics that appear too small in the book make it impossible for readers to make out details and render them useless. Designing a graphic that provides all the required details can be time consuming. However, including a less than useful graphic in the book is generally a waste of space. In some cases, the solution is to provide a reference to an external source (such as the Internet) for the graphic, rather than include the graphic directly in the book. Some authors have a strong desire not to use external sources because they tend to change, but using poorly designed graphics that fail to convey the desired information to most readers is equally problematic.

Focusing the graphic is also a problem. When a graphic contains too much detail or contains elements that have nothing to do with the discussion, the message can become lost. Using a cropped graphic helps focus attention and reduces the amount of space the graphic consumes in the book. By focusing reader attention on specific details, it also becomes easier to convey a specific message. Most important of all, keeping individual graphics small (yet easily readable) is essential to allowing use of as many graphics as is needed for the book as a whole.

The bottom line is that authors who use graphics effectively are able to communicate a great deal of information to readers in a modicum of space. In addition, using graphics presents the reader with another way to learn the material. Many people don’t learn well just by reading text, they also require graphics, hands on activities, exercises, and the like in order to learn a topic well. When choosing to use graphics, you must consider all aspects of how the graphic will appear to the reader. Let me know your thought on graphics usage at


Announcing MATLAB for Dummies

If you’ve ever wondered how to solve certain kinds of advanced mathematics, then MATLAB may fulfill the need for you. Schools are also using MATLAB as a teaching tool now because it provides so many visual aids. MATLAB for Dummies helps these two groups and many others. If you’ve wanted to use a product like MATLAB, but find the learning curve way too high, then you really do need this book. Here’s what you’ll find inside:

  • Part I: Getting Started With MATLAB
    • Chapter 1: Introducing MATLAB and its Many Uses
    • Chapter 2: Starting Your Copy of MATLAB
    • Chapter 3: Interacting with MATLAB
    • Chapter 4: Starting, Storing, and Saving MATLAB Files
  • Part II: Manipulating and Plotting Data in MATLAB
    • Chapter 5: Embracing Vectors, Matrices, and Higher Dimensions
    • Chapter 6: Understanding Plotting Basics
    • Chapter 7: Using Advanced Plotting Features
  • Part III: Streamlining MATLAB
    • Chapter 8: Automating Your Work
    • Chapter 9: Expanding MATLAB’s Power with Functions
    • Chapter 10: Adding Structure to Your Scripts
  • Part IV: Employing Advanced MATLAB Techniques
    • Chapter 11: Importing and Exporting Data
    • Chapter 12: Printing and Publishing Your Work
    • Chapter 13: Recovering from Mistakes
  • Part V: Specific MATLAB Applications
    • Chapter 14: Solving Equations and Finding Roots
    • Chapter 15: Performing Analysis
    • Chapter 16: Creating Super Plots
  • Part VI: Part of Tens
    • Chapter 17: Top Ten Uses of MATLAB
    • Chapter 18: Ten Ways to Make a Living Using MATLAB
  • Appendix A: MATLAB’s Functions
  • Appendix B: MATLAB’s Plotting Routines
  • Appendix C: Geometry, Pre-calculus, and Trigonometry Review

This book starts out simply and gently introduces you to the various tasks that MATLAB can perform. By the time you get done, you can perform many basic and a few complex tasks with MATLAB. The important part is that you’ll be in a position to use the tutorials and other learning aids that MathWorks provides to use with MATLAB. Making the learning process both simple and enjoyable is the main goal of this book. When dealing with a complex product such as MATLAB, you really do need the simpler introduction.

MATLAB is an amazing product. Once you start using it, you’ll wonder how you ever got along without it. Not only does it help you solve complex math problems, but you can also use it for a wide range of plotting needs (many of which are covered in the book). This book also acts as an idea generator to help you better use the capabilities of MATLAB. It’s amazing to discover just how many people use MATLAB and the ways in which they employ it.

I want to be sure you have the best possible learning experience. If you have any questions about this book, please feel free to contact me at Please keep your questions book-specific. If you have questions about MATLAB as a product, please address those questions to MathWorks. I’ll be providing more posts about this book soon, so please come back to my blog to discover more about MATLAB for Dummies.


WebM Replacing the Animated GIF?

There is always some new technology out there trying to replace the reigning king (or queen). The Graphic Interchange Format (GIF) has a colorful history, but is mainly used today for animated GIFs—those short sequences of animation that you see spread throughout the Internet (and many intranets as well). In fact, you can find animated GIF generators, free animated GIF libraries, and tools for working with animated GIFs by the score. It’s hard to believe that anyone has found uses for even a small portion of the resources out there.

Web Media (WebM) is a technology that is designed to work like an animated GIF, but provide significantly more functionality. It’s an open source project that will supposedly replace the aging animated GIF at some point. A recent articled entitled, “GIF is Dead; Long Live WebM” explains the technical details of why this file format is so superior and why developers desperately need to embrace it. (Read “What Is WebM, and Can It Dethrone the GIF?” if you want a simpler explanation.) After reviewing everything I can online, I have to agree that WebM does, in fact, have a lot to offer. Most importantly, it can support longer animation sequences. The additional colors it supports are nice to have, but it’s the long animation sequences that will ultimately sell this technology to those who need it.

Unfortunately, WebM also has a lot of hype surrounding it. Advocates would have you believe that wholesale replacement of animated GIFs is imminent. The animated GIF won’t be going anywhere anytime soon. In fact, here are some reasons that animated GIFs will stick around for at least next several years:

  • Not every browser supports WebM natively. Only newer versions of Mozilla Firefox, Opera, and Google Chrome support it. Even though Chrome is currently the most used browser out there, it doesn’t quite have enough market share to fully control the market (not that market share alone is a good reason to adopt any technology).
  • There is a huge base of site that already use animated GIFs to good effect and it’s doubtful that the developers of those sites will make a change without a really good reason for doing so.
  • Animated GIFs enjoy a huge support base in free predefined graphics, free tools, and free support. There isn’t a strong monetary need for a new technology.
  • WebM is viewed as more complicated to embed in a Web page.
  • The tools for working with WebM aren’t nearly as easy to use as those that developers can use with animated GIFs.

The question of whether WebM will eventually replace the animated GIF isn’t answerable at this point. The technology is too new, not enough browsers support it, and the tools required to work with it still need a lot of polishing. Until WebM builds enough of a presence online and a backlog of free graphics for developers to use, you can be sure that developers will stick with what they know.

Upgrades really are nice. New technology can provide developers with useful advantages over what has come before. However, without a compelling reason to use WebM, you can be sure adoption will be slow. Without major improvements in support and reduction in complexity, developers will be reticent to make the move and WebM could end up being just one more good idea that didn’t quite make it. Tell me your thoughts about WebM at


Avoiding Graphical Pokes in the Eye

There are times when you can truly say that something isn’t better than a poke in the eye. Using too many of the wrong sort of graphics on a website is one of those times. Some sites use graphics in such a way that it really does feel like a poke in the eye after a while. You end up with sore, tired eyes after viewing the site for only a few minutes. Sites like this is of the reasons I wrote Zapping Graphics that Dazzle Too Much. The article helps you avoid the sorts of graphics that actually make your site a place not to visit. More importantly, the article provides you with specific techniques for creating truly amazing graphics that dazzle in the right way.

Graphical pokes in the eye are bad for the user, but they’re also bad for you because they give users a good reason to avoid your site. Users get to the point of wanting to receive a service or buy products at any other site they can find online. After a while, your site just sits there being viewed by the few people who stumble upon it after clicking a link in a search engine. If things get bad enough, even search engines will place your site so far down the list that no one will find it.

The fact is that there isn’t really a good reason to have unacceptable graphics on any site. There are resources online (see my article for details) to help you create better graphics, even if you can’t rely on a graphic designer. However, if you’re betting the business on the viability and acceptability of your site, then the cost of a graphic designer is probably a lot cheaper than the cost of failure. An essential truth for anyone creating a website today, especially one that sells a product or service, is that the next site is only a click away. Business owners have always had to keep track of the competition, but doing so is even more critical now because a competitor can easily outclass you with just the right presentation.

Don’t get the idea that great graphics are only useful to businesses either. Creating applications today usually means working within a Web-based environment now. In order to create an application that employees or other users will actually enjoy means developing and using engaging graphics in the right way. Applications, even great applications, can fail miserably when users refuse to employ them to perform useful work. When that happens, you could find yourself out of a job.

Most developers really don’t have a lot of graphic design experience. The few who do are in high demand. Building some graphic design skills will make it easier to find employment in today’s competitive environment. Your applications and websites will be successful because they attract the right kind of attention. Let me know your thoughts about the role of graphics in the business environment today at


Improving the GrabAPicture Application (Part 6)

This week is the last for the GrabAPicture application. After this post, you’ll have a fully functional application that demonstrates a significant number of intermediate level Visual Basic .NET programming techniques. In this post, you see the implementation of the last improvement described in the Improving the GrabAPicture Application (Part 1) post, adding a means to see a small version of the desktop wallpaper you’ve selected in the frmConfigure (Configure a Random Source) dialog box.

To begin this process, you need to modify frmConfigure to include a PictureBox control. Fortunately, this control will not only resize the image to make it presentable for you, but also accepts URIs, so you don’t have to use any special coding techniques. Use these steps to add the PictureBox control.


  1. Modify the frmConfigure size by changing the Size.Height property value to 600.
  2. Add the PictureBox control to the form.
  3. Modify the PictureBox control settings as follows:
    • (Name) = pbDisplayImage
    • Location = 8, 261
    • Locked = True
    • Margin.All = 0
    • ScrollBarsEnabled = False
    • Size = 300, 300
    • SizeMode = Zoom

Now that you have the control configured, you can begin writing code for it. The use of the PictureBox control makes the exercise almost too easy.

Private Sub PictureSelect(ByVal sender As ListBox, _
                          ByVal e As System.EventArgs) _
                       Handles lstLocal.Click, lstRemote.Click
   ' Determine which control has focus.
   If sender.Name = "lstLocal" Then
      ' Load the selected item.
      pbDisplayImage.Load( _
      ' Load the selected item.
      pbDisplayImage.Load( _
   End If
End Sub

The one tricky part is that this single event handler handles both lstLocal.Click and lstRemote.Click. It’s actually easier just to write the code, rather than rely on the GUI to make the connections for you in this case.

Because this one event handler works with both events, it must detect the correct control using the sender.Name property. The code then chooses the correct image based on the lstLocal or lstRemote selection. Here’s a typical view of what you’ll see with this update to your application.


A number of readers have asked me to compile this entire series of posts in an easy-to-use form. Admittedly, trying to wade through 18 posts to find what you need is going to prove a little difficult. With this in mind, I’ve decided to create an e-book that includes the following items:

  • All 18 of the posts on my blog in an easy-to-read form.

  • My personal notes for the GrabAPicture application.

  • Additional modifications that you can try.

  • The URL for a downloadable version of the complete GrabAPicture application.


I’m working on the e-book now and will let you know when it becomes available.  The e-book title will be, “Discovering Intermediate Visual Basic Programming Through the GrabAPicture Application” and the pricing will be determined at a future date. In the meantime, if there are any questions on these posts or if there is something you’d really like to see in the e-book when it’s complete, please let me know at

Next week we’ll start looking at a new application. This one will be written in C# and provide some interesting features not found in the GrabAPicture application. As with the GrabAPicture application, the TypingBuddy application has been part of my Windows Desktop for a number of years, during which time I have continued to refine it. It’s my hope that you’ll find TypingBuddy as interesting as you have GrabAPicture.

Creating Freeform Shapes for Excel 2003

I had previously written a post for my VBA for Dummies readers entitled, “Creating Freeform Shapes“. Unfortunately, it appears that the example doesn’t work for Excel 2003 users. Microsoft sometimes changes things in VBA without telling anyone. I’m not sure whether that’s the case here or not, but none of my graphics examples would work with that older copy of Excel, which left me scratching my head for a while.

After a lot of research, trial and error, and input from faithful readers, I determined that the only solution is to use the BuildFreeform() function with a lot of complex equations. My code still didn’t work after quite a few trials and it should have. That’s when experimentation kicked in. When creating a freeform shape, you must define the initial shape, and then add nodes to it to add additional lines and curves. The VBA documentation stated that I could use the AddNodes() function with either msoEditingCorner or msoEditingAuto. It turns out that the documentation is in error-only msoEditingAuto works in Excel 2003 (this problem has been fixed in newer versions of Excel, so the documentation is now correct). So, without further ado, here is an example of creating a freeform shape for Excel 2003 readers (it also works in newer versions of Excel).

Sub ModifyChart4()
' Obtain access to the chart.
Dim TestChart As Chart
Set TestChart = Sheet1.ChartObjects(1).Chart
' Obtain the dimensions of the charting area.
Dim XLeft As Double
XLeft = TestChart.PlotArea.InsideLeft
Dim XWidth As Double
XWidth = TestChart.PlotArea.InsideWidth
Dim YTop As Double
YTop = TestChart.PlotArea.InsideTop
Dim YHeight As Double
YHeight = TestChart.PlotArea.InsideHeight
' Obtain access to each of the series.
Dim Series1 As Series
Set Series1 = TestChart.SeriesCollection(1)
Dim Series2 As Series
Set Series2 = TestChart.SeriesCollection(2)
' Determine the number of entries for each series.
Dim S1Count As Long
S1Count = Series1.Points.Count
Dim S2Count As Long
S2Count = Series2.Points.Count
' Obtain the series entry X-axis spacing in pixels.
Dim S1XSpacing As Double
S1XSpacing = (XWidth - XLeft) / S1Count
Dim S2XSpacing As Double
S2XSpacing = (XWidth - XLeft) / S2Count
' This offset isn't calculated right now, but it needs to
' be obtained from some source on the chart.
XOffset = 14
' Define the X position of the second and third points for
' the first and second series in pixels.
Dim S1X2 As Double
S1X2 = S1XSpacing * 2 + XOffset
Dim S1X3 As Double
S1X3 = S1XSpacing * 3 + XOffset
Dim S2X2 As Double
S2X2 = S2XSpacing * 2 + XOffset
Dim S2X3 As Double
S2X3 = S2XSpacing * 3 + XOffset
' Determine the minimum and maximum values for each series and
' then create a range value.
Dim YMin As Double
YMin = TestChart.Axes(2).MinimumScale
Dim YMax As Double
YMax = TestChart.Axes(2).MaximumScale
Dim YRange As Double
YRange = YMax - YMin + 1
' Define the Y axis pixel length.
Dim YPixels As Double
YPixels = YHeight + YTop
' Define the position of the second and third nodes for each
' series within the Y axis.
Dim S1Y2 As Double
S1Y2 = YPixels - (YPixels * (Series1.Values(2) / YRange))
Dim S1Y3 As Double
S1Y3 = YPixels - (YPixels * (Series1.Values(3) / YRange))
Dim S2Y2 As Double
S2Y2 = YPixels - (YPixels * (Series2.Values(2) / YRange))
Dim S2Y3 As Double
S2Y3 = YPixels - (YPixels * (Series2.Values(3) / YRange))
' Create a drawing object using the second and
' third points of each series and add this shape
' to the chart.
With TestChart.Shapes.BuildFreeform(msoEditingCorner, S1X2, S1Y2)
.AddNodes msoSegmentLine, msoEditingAuto, S1X3, S1Y3
.AddNodes msoSegmentLine, msoEditingAuto, S2X3, S2Y3
.AddNodes msoSegmentLine, msoEditingAuto, S2X2, S2Y2
.AddNodes msoSegmentLine, msoEditingAuto, S1X2, S1Y2
End With
' Obtain access to the new shape.
Dim MyDrawing As Shape
Set MyDrawing = TestChart.Shapes(TestChart.Shapes.Count)
' Modify the shape color.
MyDrawing.Fill.ForeColor.RGB = RGB(128, 128, 255)
MyDrawing.Line.ForeColor.RGB = RGB(64, 64, 128)
End Sub

This version doesn’t use any of the newer techniques for gaining access to the chart or creating the shape. It begins by figuring out the dimensions of the plotting area. Everything is based on knowing the location of the plotting area within the chart object.

The problem is figuring out where each of the nodes on that plot are. You don’t have access to them. So, you’re faced with a situation where you have to calculate the position of the individual nodes, which can be quite an undertaking. Computing the X-axis comes first. The nodes are evenly spaced across the X-axis, so you divide the number nodes by the plotting area length in pixels. That gives you the spacing between nodes. All you do to find the X location of a particular node is multiply that node’s number by the spacing. When I tried this is in the real world though, I found that there is an offset for the Y-axis legend, but that there wasn’t any way to obtain this value. Consequently, you see my trial and error value of 14 as the offset (if someone knows how to obtain this value, please let me know).

The Y-axis values are a little harder to find out. First, you need to obtain the full range of the Y-axis in pixels. Then, you need to work from the top down. The numbers you get for values on the chart are from the bottom up, though, so you need to convert between the two orientations. In addition, the node value doesn’t equate directly to a pixel count, so you must create a ratio between the largest value that the Y-axis supports and the value of the current node, and then multiply by the full pixel range to obtain the position of the current node in the Y-axis.

At this point, you know the X and Y values for each of the four nodes. You use the BuildFreeform() function call to create a FreeFormBuilder object. This object contains only the first node. To add more nodes, you rely on the AddNodes() function. As with any shape, you must close the shape before you call ConvertToShape() to convert it into a closed shape. Otherwise, you simply have a curved line.

The remainder of this example works much like the previous examples in this series. The code gains access to the new shape, colors the interior, and changes the line color. What you’ll see as output varies with the version of Excel you’re using. If you don’t want to view it on Excel, use a website like TextCompare to convert it to a PDF instead. Here’s the Excel 2010 version of the output.


Please let me know if there are any additional problems with this example I also want to express my thanks to the readers who wrote in about this example.

Creating Freeform Shapes

It’s important to realize that VBA usually provides more than one way to accomplish any given task. Each technique offers benefits and comes with costs. In the Creating A Connection Between Series post, you saw one way to use shapes to work with a series in a chart. This post builds on the information starting on page 314 of VBA for Dummies. Interestingly enough, there is another way to obtain the same output, as shown here:

Sub ModifyChart2()
    ' Obtain access to the chart.
    Dim TestChart As Chart
    Set TestChart = Sheet1.ChartObjects(1).Chart
    ' Obtain access to each of the series.
    Dim Series1 As Series
    Set Series1 = TestChart.SeriesCollection(1)
    Dim Series2 As Series
    Set Series2 = TestChart.SeriesCollection(2)
    ' Obtain the position of the second and third points
    ' for each series.
    Dim Point1 As Point
    Set Point1 = Series1.Points(2)
    Dim Point2 As Point
    Set Point2 = Series1.Points(3)
    Dim Point3 As Point
    Set Point3 = Series2.Points(2)
    Dim Point4 As Point
    Set Point4 = Series2.Points(3)
    ' Create a drawing object using the second and
    ' third points of each series and add this shape
    ' to the chart.
    With TestChart.Shapes.BuildFreeform(msoEditingCorner, Point1.Left, Point1.Top)
        .AddNodes msoSegmentLine, msoEditingCorner, Point2.Left, Point2.Top
        .AddNodes msoSegmentLine, msoEditingCorner, Point4.Left, Point4.Top
        .AddNodes msoSegmentLine, msoEditingCorner, Point3.Left, Point3.Top
        .AddNodes msoSegmentLine, msoEditingCorner, Point1.Left, Point1.Top
    End With
    ' Obtain access to the new shape.
    Dim MyDrawing As Shape
    Set MyDrawing = TestChart.Shapes(1)
    ' Modify the shape color.
    MyDrawing.Fill.ForeColor.RGB = RGB(255, 0, 255)
    MyDrawing.Line.ForeColor.RGB = RGB(128, 0, 128)
End Sub

The disadvantages of this method are that you must spend more time creating the initial shape and the code is less readable. Using a predefined shape means that you simply move the points to meet your needs and you’re finished. However, the advantages of this method are:

  • Create a shape with any number of segments
  • Use curved segments instead of straight lines
  • Easy control how the corners look

In short, even though this method requires a lot more effort initially, it offers significantly more flexibility in exchange for that effort.

The code begins much like the previous exampleobtaining data points from two series and using those points to create a connection. The difference in this example is the call to BuildFreeform(), which allows you to create a shape of any complexity by relying on the AddNodes() method. Simply add any number of nodes to create the shape desired by tracing its outline.

The one thing that many developers forget is to include a call to ConvertToShape(). If you don’t make this call, you end up with an outline, not a shape. The inside won’t be filled in because Excel doesn’t see it as a shapeit’s simply a series of lines.

After you create the shape, you must gain access to it. Because this is the first and only shape on the chart, the index is easyuse a value of 1. If you create a number of shapes, then you must determine which index to use, which will always be the last shape entered if this is the newest shape in the list. Use the Count property to obtain this value. For this example, you’d use TestChart.Shapes.Count to obtain the value. When you run this example, you get precisely the same output as with the earlier example.

The point of this exercise is that you should always consider the possibility of an alternative solution to any given problem. Once you’ve come up with an alternative, consider the pros and cons of this new approach to determine which approach is best for your specific needs. It isn’t always easy to determine which approach will work best, so be willing to create some test cases to check the outcome of a specific approach for your requirement. Let me know if you have any questions at

Creating A Connection Between Series

A reader recently wrote in asking me how to draw a shape between two series on a line chart. The shape should connect two consecutive points on the chart so that what you see is a trapezoidal shape between the two lines. Of course, the big thing is to gain an understand of how charts work. The discussion starts on page 314 of VBA for Dummies. After you know the basics of chart creation, you can start with a worksheet and chart that looks like this:


These values are contrived, but the technique will work with any chart you might want to create. The trapezoid will appear between the second and third points of the two lines. Here is the code you’ll need to perform the task.

Sub ModifyChart()
    ' Obtain access to the chart.
    Dim TestChart As Chart
    Set TestChart = Sheet1.ChartObjects(1).Chart
    ' Obtain access to each of the series.
    Dim Series1 As Series
    Set Series1 = TestChart.SeriesCollection(1)
    Dim Series2 As Series
    Set Series2 = TestChart.SeriesCollection(2)
    ' Obtain the position of the second and third points
    ' for each series.
    Dim Point1 As Point
    Set Point1 = Series1.Points(2)
    Dim Point2 As Point
    Set Point2 = Series1.Points(3)
    Dim Point3 As Point
    Set Point3 = Series2.Points(2)
    Dim Point4 As Point
    Set Point4 = Series2.Points(3)
    ' Create a drawing object using the second and
    ' third points of each series.
    Dim MyDrawing As Shape
    ' Add this shape to the chart.
    Set MyDrawing = TestChart.Shapes.AddShape(msoShapeTrapezoid, 15, 20, 25, 30)
    ' Modify the position of the shape.
    MyDrawing.Nodes.SetPosition 1, Point1.Left, Point1.Top
    MyDrawing.Nodes.SetPosition 2, Point2.Left, Point2.Top
    MyDrawing.Nodes.SetPosition 3, Point4.Left, Point4.Top
    MyDrawing.Nodes.SetPosition 4, Point3.Left, Point3.Top
    MyDrawing.Nodes.SetPosition 5, Point1.Left, Point1.Top
    ' Modify the shape color.
    MyDrawing.Fill.ForeColor.RGB = RGB(0, 255, 0)
    MyDrawing.Line.ForeColor.RGB = RGB(0, 128, 0)
End Sub

The code begins by gaining access to the chart, which already appears on the worksheet. Perhaps someone drew it there and is relying on your macro to show the correlation between the two lines. TestChart provides access to the only chart on the worksheet. The Sheet1.ChartObjects index always begins at 1 and counts up.

This chart has two seriesone for each of the lines. The next step is to gain access to those series as Series1 and Series2. In short, we’re drilling down into the chart components to obtain specifics about those lines so we can draw something between them.

The chart draws the two lines according to a list of points stored in the series that are based on the individual data values you provide and the order of that point in the list. We want to use the second and third points to draw the trapezoid, so you need to access the Points property for each series and supply and index of 2 and 3. You end up with four Point variables that describe the location of the points on the line.

It’s important to create the shape from the chart. Yes, you could create it completely manually, but using the chart saves you time. So, this example creates a Shape, MyDrawing, using the TestChart.Shapes.AddShape() function. The points you supply when creating the shape are unimportant because you’ll change them later anyway.

Every closed shape consists of one more node than the drawing requires. If you’re drawing a four-sided shape, as we are here, then you need five nodes to define it. That’s what the next step does. It redefines the position of the shape based on five nodes, using the first position to define the fifth nodesa really important concept to keep in mind if you want the shape to be solid.

Finally, the example changes the inside color of the resulting shape to a bright green and the line that defines it to a darker green. You’ll see these results from the example:


As you can see, the shape precisely follows the two lines as it should. You can perform other drawing tricks like this one using the technique I’ve provided here. Let me know if you have any questions about it at