Jump to content

TR's Quick Outliner (Aug 21, 2015)


Recommended Posts

TechnoRobbo's Quick Outliner

Like the Doctor said "Don't Blink"

 

version 1.5 adjusts for very small selections (thanks to Midora)

version 1.4 fixes a typo

Version 1.3 Soft Edge*, Color Wheels and Fill

suggestions by Eli

*(Increasing the Softness will slow down render)

 

Menu: Effects - Selection

 

 

New features

 

Source Code

Hidden Content:
// Submenu: Selection
// Name: TR's QuickOutLiner 
// Title: TR's QuickOutLiner - V 1.5
// Author: TechnoRobbo
// URL: http://www.technorobbo.com
#region UICode
ColorBgra Amount1 = ColorBgra.FromBgr(0,0,0); // Line Color
ColorBgra Amount2 = ColorBgra.FromBgr(0,0,0); // Fill Color
double Amount3 = 2; // [1,50] Line Thickness
int Amount4 = 1; // [1,50] Softness(Can Slow Render)
bool Amount5 = false; // [0,1] Fill Shape
string Amount6 = ""; // [0,255] 
#endregion


void Render(Surface dst, Surface src, Rectangle rect)
{
   
    if (!Amount6.Equals(String.Empty))return;
    Amount6="Onepass";
    
    dst.CopySurface(src);
    if (IsCancelRequested) return;
    PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); 
    RectangleF sel = EnvironmentParameters.GetSelection(src.Bounds).GetBounds();
    ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
    ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor; 
    RectangleF[] baseBlocks =selectionRegion.GetRegionScans();
    using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
    {
        path.AddRectangles(baseBlocks);
        path.Widen(new Pen(Color.Black,2));
        using (Region r = new Region(path))
        {
            using ( Region r2 = new Region(selectionRegion.GetRegionData()))
            {
                r.Exclude(r2);
            }
            baseBlocks = r.GetRegionScans(new System.Drawing.Drawing2D.Matrix());
        }
        
    }
    if (IsCancelRequested) return;
    using (Graphics g =new RenderArgs(dst).Graphics)
    {
        g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
        using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
        {
           
            path.AddRectangles(baseBlocks);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;      
            g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
         
            g.Clip =new Region( selectionRegion.GetRegionData());
            if (Amount5) g.FillRegion(new SolidBrush(Amount2.ToColor()),g.Clip);
            if (IsCancelRequested) return;
            using (Pen p = new Pen(Amount1.ToColor()))
            {   
                if (Amount4 > 1)
                {
                    int alpha = (int)(255f / (float)Amount4); 
                    for (int blur = 0 ;blur < Amount4; blur++)
                    {
                        if (IsCancelRequested) return;
                        using (Pen p2 = new Pen(Color.FromArgb(alpha, Amount1.ToColor())))
                        {
                            p2.Width = (float)Amount3 + (Amount4 - blur);
                            g.DrawPath(p2,path);               
                        }
                    }
                }
                
                p.Width = (float)Amount3;
                g.DrawPath(p,path);
            }
         }
    }
}
 

TRsQuickOutline.zip

Link to post
Share on other sites

I like it!

 

Excuse my ignorance, but what's point of the text box? Have a return in the code if there's something typed in it....why? I think I'm missing something.

 

Thanks for posting the source. I learned something about rending a Graphics object to the destination surface. This will help me on a effect I've been wanting to make. :D

Link to post
Share on other sites
  • 1 month later...
  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...