Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>OK, I think I have a lead for you guys... but its in a completely different direction.</p> <p>Anyway, I realized that a "sub-path" of a larger path actually shrinks (insets) during a <code>.Widen</code> operation, so I decided to see if there was anything fruitful down that path (no pun intended).</p> <p>Really, the idea here is to <code>.Widen</code> the path... from the outside!</p> <p>What if we took the original <code>GraphicsPath</code> and 'wrapped' it in a larger <code>Rectangle</code> (doing an <code>Inflate</code> of 10 on the <code>.GetBounds</code> of the <code>GraphicsPath</code> should get us an easy wrapper).</p> <p>Then, the wrapper is added first, and the real <code>GraphicsPath</code> is the added as a sub-path to that. The entire thing then gets a <code>.Widen</code>, and finally, a new <code>GraphicsPath</code> is created from scratch, using the <code>.PathPoints</code> and <code>.PathTypes</code> of the widened path, which removes the useless wrapper (luckily, the <code>GraphicsPath</code> accepts <code>PathPoints</code> and <code>PathTypes</code> in one of the constructor overloads).</p> <p>I will be out of the office for the rest of the day, so I can't see this through to completion, but here is the lead.</p> <p>Just drop this code into a regular ol' form:</p> <pre><code> private void Form1_Paint(object sender, PaintEventArgs e) { GraphicsPath g = new GraphicsPath(); g.AddRectangle(new Rectangle(0, 0, 200, 200)); g.AddEllipse(50, 50, 100, 100); //Original path e.Graphics.DrawPath(new Pen(Color.Black,2), g); //"Inset" path g.Widen(new Pen(Color.Black, 10)); e.Graphics.DrawPath(new Pen(Color.Red, 2), g); } </code></pre> <p>From that simple experiment, you will see that the target path (the circle) now has the elusive Inset (in red)!</p> <p><img src="https://i.stack.imgur.com/w6aMQ.jpg" alt="Inset Experiment"></p> <p>There is also has some other crap that I don't really understand in there (which also appears on the rectangle wrapper), but from the <code>PathPoints</code> and <code>PathTypes</code>, it should be possible to iterate the arrays and remove the junk when the virgin GraphicsPath is created (or find out where that junk comes from and prevent it from happening). Then return the new, clean <code>GraphicsPath</code>. </p> <p>This technique avoids all of the complex math, but its a bit of a long shot.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload