Jump to content

Grids that will fill the entire image or canvas.


Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Looks like the outlining line is centered on the canvas edge; meaning half of it is hanging off the canvas. That should be pretty easy to solve. If I have time later tonight, I'll write a simple script for you.

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
Share on other sites

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

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
Share on other sites

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

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
Share on other sites

  • 7 years later...
On 6/24/2016 at 5:14 AM, toe_head2001 said:

It works as you've described.

http://kalama.x10host.com/gfx/junk/cells.png

Edited June 26, 2016 by toe_head2001

Hello, @toe_head2001

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!

welsh-Yellow-cheddar-cheese-signature.pn

Link to comment
Share on other sites

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)

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

16 minutes ago, BDP said:

Using CodeLab v6.8, I get this error

 

Yeah, that's an old script.

 

Just find the following text in the script:

 

EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt()

 

change it to:

 

EnvironmentParameters.SelectionBounds;

 

  • Upvote 1
Link to comment
Share on other sites

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...