Sign in to follow this  
TechnoRobbo

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

  • Upvote 5

Share this post


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

Share this post


Link to post
Share on other sites

Thanks TR, I think it would be neat to pick colors from inside the effect. Perhaps adding some blur/gradient options as well.

q-outline-4c710a9.png

  • Upvote 1

Share this post


Link to post
Share on other sites

Eli - your a hard customer. :D


 


Version 1.2 Ready for Download


 


Soft Edge*, Color Wheels and Fill


suggestions by Eli


 


 


*(Increasing the Softness will slow down render)


  • Upvote 1

Share this post


Link to post
Share on other sites

I may be alone in this opinion, but I think it would be better to have the Softness default set to 1.

 

Typo on the string for Line Color

ColorBgra Amount1 = ColorBgra.FromBgr(0,0,0); // Line Thickness

Share this post


Link to post
Share on other sites

I may be alone in this opinion, but I think it would be better to have the Softness default set to 1.

 

Typo on the string for Line Color

 

Thanks will Fix

Share this post


Link to post
Share on other sites

TR, on very small selections is not rendering all around. The shapes on the left is what I would expect but instead I am obtaining the blue ones.

qol-tr-4c77f46.png

Share this post


Link to post
Share on other sites
One solution for this may be to change the Graphics.PixeloffsetMode.

 

That did the trick ,Thanks Midora

 

Version 1.5 Ready for download 

Adjusted for very small selections

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this