Jump to content

Request: Table/Grid


Recommended Posts

Hello "Math Benders"  :)

 

There are several effects for Paint.net that can create lines, grids (with udjustable line thickness, hights and widths as well as colors) and patterns however they usually render the effect over the entire canvas. So when I need a grid I end up cropping the extra squares.

 

CellMaker comes close to what I mean but it does not have udjustable line thickness nor it allows to determin the number of rows and columns needed.

 

I wonder if a plugin could be created to render ONLY the cells needed with a possibility to udjust line thickness and color of the lines, the size of the cells as well as their number. Something like the tables that Word or Powerpoint create.

Link to comment
Share on other sites

Thanks xod,

 

But Grid /CheckerBoard Maker creates unwanted cells that have to be manually cropped.  As I said above, CellMaker has an option to render the cells needed but does not allow other changes.

 

It would be nice if I could have an option to enter the number of rows and columns I need, select the line thickness, and be able to adjusts the size of the cells.

 

grid-request-01-4b88ff1.png

Link to comment
Share on other sites

 

they usually render the effect over the entire canvas

I don't understand that bit Eli? -  plugins can only render inside the selection they are 'given'.

I just tried using grid maker inside a selection (as Xod suggested)  and then using 'outline' selection - worked perfectly.

Perhaps a grid maker that gave a choice for the number of cells vertically and horizontally within a selection would be useful ... or the cell dimensions in pixels rather than a fraction of the selection size?

 

If you're certain grid maker will not do want you want, please try to describe exactly what you are looking for. ;)

 

Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings

 

PdnForumSig2.jpg

Link to comment
Share on other sites

Hello Red,

 

I tried xod's suggestion as you can see in the picture above. I made a selection and then used the plugin Grid/Checkboard Maker. The generated grid inside the selection has cells (the ones in red) that I will have to crop.

 

"Perhaps a grid maker that gave a choice for the number of cells vertically and horizontally within a selection would be useful ... or the cell dimensions in pixels rather than a fraction of the selection size?"

These options you propose would be wonderful.

Link to comment
Share on other sites

See post lower down.

(I've slightly altered the code, adding a non AA'd option and messing around with the half line width I needed to add to make it all join up).

 

.dll name = table,
found under Effects/Render
draws tables
compatible with Pdn3.5.11 (and Pdn4 + I hope haven't tested yet)
Keywords - haven't added any yet! - may publish properly if any interest.

 

Here's the codelab code:

// Name: Table
// Author: Red ochre (John Robbins)
// Submenu: Render
// URL: http://www.getpaint.net/redirect/plugins.html
// Title: Table              June 2015    Red ochre

#region UICode
int Amount1 = 50; // [5,1000] Cell width (pixels)
int Amount2 = 10; // [1,100] Horizontal number of cells
int Amount3 = 50; // [5,1000] Cell height (pixels)
int Amount4 = 10; // [1,100] Vertical number of cells
int Amount5 = 2; // [1,100] Pen width
byte Amount6 = 0; // Line style|Solid|Dash|Dash-Dot|Dash-Dot-Dot|Dot
ColorBgra Amount7 = ColorBgra.FromBgr(0,0,0); // Line colour
#endregion

void Render(Surface dst, Surface src, Rectangle rect)
{
   // to avoid confusion H is Horizontal (not height) and V is vertical!
    dst.CopySurface(src, rect.Location, rect);// copy surface quicker than looping through
    int cellH = Amount1;
    int Hcellnum = Amount2;
    int cellV = Amount3;
    int Vcellnum = Amount4;
    float penW = Amount5;
    byte penstyle = (byte)(Amount6);
    ColorBgra pencol = Amount7;
    Rectangle sel = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
    float halfSelH = (sel.Right - sel.Left)/2;
    float halfSelV = (sel.Bottom - sel.Top)/2;
    //calculate table size from the amounts provided by user
    float Hrep = penW + cellH;
    float Vrep = penW + cellV;
    float TabH = penW + (Hrep * Hcellnum);float halfTabH = TabH/2;
    float TabV = penW + (Vrep * Vcellnum);float halfTabV = TabV/2;
    PointF topleft = new PointF((sel.Left + halfSelH)- halfTabH,(sel.Top + halfSelV) - halfTabV);
   
    using (Graphics graf = new RenderArgs(dst).Graphics)//the 'using' block means you don't need to 'Dispose' the graphics objects
    {graf.Clip = new Region(rect);graf.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
    using(Pen colpen = new Pen(pencol))
        {colpen.Width = penW;
            switch(penstyle)
            {case 0:colpen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; break;
             case 1:colpen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; break;
             case 2:colpen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; break;
             case 3:colpen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot; break;
             case 4:colpen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; break;
            }//end switch block
        //horizontal lines
            for(int cnh = 0;cnh <= Vcellnum;cnh++)
            {PointF Hstart = new PointF(topleft.X - (penW/2),topleft.Y + (Vrep * cnh));
             PointF Hend = new PointF((topleft.X + TabH) - (penW/2),topleft.Y + (Vrep * cnh));
            graf.DrawLine(colpen, Hstart, Hend);
            }
        //vertical lines
            for(int cnv = 0;cnv <= Hcellnum;cnv++)
            {PointF Vstart = new PointF(topleft.X + (Hrep * cnv),topleft.Y - (penW/2));
             PointF Vend = new PointF(topleft.X + (Hrep * cnv),(topleft.Y + TabV)- (penW/2));
            graf.DrawLine(colpen, Vstart, Vend);
            }

        }//end pen using block
        
        }//end graf using block

   
}

  • Upvote 1

 

Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings

 

PdnForumSig2.jpg

Link to comment
Share on other sites

Already? I see your coding is not so rusty. THANKS!!

 

It works with no problems on PDN 4. It is just what I wanted and I think you should publish it. It is different from Grid /CheckerBoard Make. Perhaps other users can contribute with suggestions.

 

Postedit:

The only issue I found is that the rendered lines are not  fully solid:

 

table-0021-4b8a379.png

Edited by Eli
Link to comment
Share on other sites

Not worth a rep Eli?! :( :D

The codelab code is there - I'd really like to encourage you (and others) to use codelab.
It is one of Pdn's great advantages over other graphics software.
You're welcome to adapt that code as you like - perhaps create an overall size for height and width and divide by the number of columns and rows?
Perhaps just adjust the range of values to suit your purpose, using codelab's U.I. designer?

I'm not a programmer and have mostly learned via Boltbait's codelab tutorials and help from real developers on this forum.
Give it a go! ;)

 

Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings

 

PdnForumSig2.jpg

Link to comment
Share on other sites

I'm not a programmer ...

Nonsense. It's true you and I are probably not Senior NET Developers - but we're definitely programmers ;)

  • Upvote 1
Link to comment
Share on other sites

Eli - if you know some HTML, you can write a simple table document and have my Markup Renderer render it to the canvas.

yhsjjie_53.png

was rendered with this HTML

<!DOCTYPE html>
<html>
<head>
<style>
table {
    width:60%;
}
table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
}
th, td {
    padding: 5px;
    text-align: left;
}
table#t01 tr:nth-child(even) {
    background-color: #eee;
}
table#t01 tr:nth-child(odd) {
   background-color:#fff;
}
table#t01 th	{
    background-color: green;
    color: white;
}
</style>
</head>
<body>

<table id="t01">
  <tr>
    <th>First Name</th>
    <th>Last Name</th>		
    <th>Points</th>
  </tr>
  <tr>
    <td>Jill</td>
    <td>Smith</td>		
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>		
    <td>94</td>
  </tr>
  <tr>
    <td>John</td>
    <td>Doe</td>		
    <td>80</td>
  </tr>
</table>
.

</body>
</html>

 

  • Upvote 4
Link to comment
Share on other sites

I agree with you EER... You are great programmers!

 

As for me... I am not a Senior Net Developer nor a programmer... but I am certainly a senior  :) .

 

Red, this is a little example of the effect: Thanks again!

 

table-cityscape-4b8c172.png

  • Upvote 6
Link to comment
Share on other sites

I've started having 'senior moments' if that counts. :lol:
Glad you're finding it useful Eli and thanks for the image - my name (or avatar) in lights, I must be famous! B)

Thanks for the compliment EER!
I know more now than when I started, thanks to help from this forum! ;)
I think it is great that codelab can be used initially with minimal coding knowledge and is ideal for 'bespoke' plugins like this.

  • Upvote 3

 

Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings

 

PdnForumSig2.jpg

Link to comment
Share on other sites

@Red ochre! A big thank you for plugin and respect for the effort. tch5lrvq.gif  I tried a different method. I hope you like it. u4r28zf2.gif

 

And big thank you for ELi!

 

6c2i7r8v.png

Edited by Seerose
  • Upvote 4

Live as if you were to die tomorrow. Learn as if you were to live forever.

Gandhi

 

mae3426x.png

Link to comment
Share on other sites

  • 6 months later...

Thread's getting a bit dusty. Glad you found what you needed!

No, Paint.NET is not spyware...but, installing it is an IQ test. ~BoltBait

Blend modes are like the filling in your sandwich. It's the filling that can change your experience of the sandwich. ~Ego Eram Reputo

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...