Jump to content
Paint.NET 5.1 is now available! ×

Recommended Posts

Posted

Hello and thank you for this program.

 

I have an image size 8x4 centimeters and I need to make a grid for example 8x3 as in this image which I drew manually with the rectangle shapes tool and that is the reason why it's not perfect. My question is if there is a tool that will allow me to create grids as this one by just entering the number of cells or divisions I need horizontally and vertically and it will automatically adjust to the image size no matter the thickness of the lines.

 

I have installed two tools called "gridlines" and "grid/checkerboard maker" and while they can draw grids they do not do what I need.

 

Thanks.

 

grid8x3.png

Posted

Thank you, I have tried the Graph Maker Plugin and it almost did what I needed. I found it easy to use by typing the number of divisions needed and the thickness of the desired lines. But I don't understand why the lines on the edges of the image are much thinner. They should have been as thick as the other blue lines. If I add a border like the red one, it would look OK but the size of the cells would no longer be the same. Maybe someone can give me an advice on how to increase the border lines so they would match the other ones while maintaining the size of the cells equal.

grid8x3_made_with_graph_maker.png

Posted (edited)

Here's the CodeLab script.

Hidden Content: CodeLab

// Name: Hor x Ver Cells
// Submenu: Render
// Author: toe_head2001
// Title:
// Version: 0.9
// Desc:
// Keywords:
// URL:
// Help:
#region UICode
IntSliderControl Amount1 = 5; // [2,100] Line Thickness
IntSliderControl Amount2 = 8; // [1,100] Horizontal Cells
IntSliderControl Amount3 = 3; // [1,100] Vertical Cells
#endregion

void Render(Surface dst, Surface src, Rectangle rect)
{
    Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
    float horLoops = Amount2;
    float verLoops = Amount3;
    float horCellSize = (selection.Width - Amount1) / horLoops;
    float verCellSize = (selection.Height - Amount1) / verLoops;

    dst.CopySurface(src, rect.Location, rect);

    using (RenderArgs ra = new RenderArgs(dst))
    {
        Graphics plane = ra.Graphics;
        plane.Clip = new Region(rect);
        using (Pen planePen = new Pen(EnvironmentParameters.PrimaryColor, Amount1))
        {
            for (int i = 1; i < horLoops; i++)
            {
                plane.DrawLine(planePen, selection.Left + horCellSize * i + Amount1 / 2f, selection.Top, selection.Left + horCellSize * i + Amount1 / 2f, selection.Bottom);
            }
            
            for (int i = 1; i < verLoops; i++)
            {
                plane.DrawLine(planePen, selection.Left, selection.Top + verCellSize * i + Amount1 / 2f, selection.Right, selection.Top + verCellSize * i + Amount1 / 2f);
            }
           
            planePen.Alignment = PenAlignment.Inset;
            plane.DrawRectangle(planePen, selection);
        }
    }
}

 

It works as you've described.

cells.png

Edited by toe_head2001
  • Upvote 8
Posted
On 6/24/2016 at 3:45 AM, sophie said:

Thank you, but how do I place it in the effects folder?

If you want it permanently in the Effects menu, CodeLab can create a dll file for you. Once you've created the dll file, place it in the effects folder just like any other plugin.

http://boltbait.com/pdn/codelab/help/buildingdll.php

 

If a script is short and simple, I like to keep it as script. Keeps the Effects menu tidy. But maybe that's just me. Create a dll if you like.

I like my scripts folders with my nice collection.  :D 

  • Upvote 1
Posted

Ok, It is working. But I need more help again. I made first the blue grid 3x6 and now I need to fraction each cell into smaller grids (3x6 grids again) as the green one. However, when I select a cell and use the script I get the red ones.  Could you make it work with selections as well? I hope I'm not asking too much and over-complicate the script. THANKS.

 

grid3x6_Hx_V.jpg

Posted

Ok, It is working. But I need more help again. I made first the blue grid 3x6 and now I need to fraction each cell into smaller grids (3x6 grids again) as the green one. However, when I select a cell and use the script I get the red ones.  Could you make it work with selections as well? I hope I'm not asking too much and over-complicate the script. THANKS.

It was supposed to work on selections, but I forget to test that. ;)

I've fixed it; it was a simple change. The updated script is in the original post.

  • 7 years later...
Posted
8 minutes ago, Welsh Yellow Cheddar said:

Is this plugin published somewhere? I have to draw grids inside a selection and this plugin would become very handy. I wonder if it can draw dotted/dashed line as well? Thank you!

 

The CodeLab script for the plugin is published above...

 

Here's what to do with such a script: CodeLab for average users - A Layman's Guide - Miscellaneous - paint.net Forum (getpaint.net)

 

Posted

Hi,

 

Using CodeLab v6.8, I get this error, which stops me from compiling as a DLL:

 

'EffectEnvironmentParameters.GetSelection(Rectangle)' is obsolete: 'There's no need to use this method. Use Selection.RenderRegionLegacy instead, or Selection.RenderBounds if you just need the bounding box.'

 

Brian

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...