Jump to content
How to Install Plugins ×

CodeLab v6.12 for Paint.NET 5.0.12 (Updated February 11, 2024)


Recommended Posts

That's pretty strange. CodeLab should only fallback to the Verdana font if none of the other fonts (Consolas, Courier New, ect.) are available.

Given that Consolas, Courier New, and Verdana are all included with Windows 7, those fonts must have been uninstalled from your computer at some point.

(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

  • 1 month later...

CodeLab 4.2 Released

This is only for Paint.NET 4.1.6+!

 

Big update today...

 

Changes:

▪ New Icons! (toe_head2001)

▪ Improved the 'unsaved changes' dialog for when there's only one tab open, and also changed the wording in the dialog when there's multiple tabs open, to be less confusing (toe_head2001)

▪ The search box (in Find & Replace) now turns red when there are no matches (toe_head2001)

▪ When using Save As, the "//Name: " comment is now parsed to try to create a default filename. If it's unsuccessful, it will fall back to "MyScript.cs" (toe_head2001)

▪ Minor fixes to Format Document (toe_head2001)

▪ Files (with .cs extension) can now be dropped (drag and drop) into CodeLab to open them. (toe_head2001)

▪ Options to use force SingleRenderCall and Legacy ROI when Building DLL (toe_head2001 and BoltBait)

▪ Added three additional menu items to the Effects menu to start CodeLab with specific parameters (EffectsFlags, EffectRendingSchedule). (toe_head2001)

▪ Scripts with "//Submenu: Adjustments" will be put in the Adjustments menu instead of the Effects menu (BoltBait)

▪ If your effect has a sample image for The Plugin Browser, it will be shown on the Build to DLL form (BoltBait)

▪ Added a new high res icon for when CodeLab is running higher than 96dpi (BoltBait)

▪ Added new build options (Legacy ROI, Single Render Call) to File New template screen (BoltBait)

▪ Added the following script comments to control build options: (BoltBait)
// Force Legacy ROI
// Force Single Render Call

▪ CodeLab can now be installed to the Store version of Paint.NET. However, when running the Store version you can not create a Visual Studio project from your CodeLab script. Building a DLL still works fine. (toe_head2001 and BoltBait)

▪ Assortment of bugfixes, cleanups, refactorings (toe_head2001 and BoltBait)

 

Grab the CodeLab DLL here:

 

http://www.boltbait.com/pdn/CodeLab/

 

Screenshots:

 

New icons:

NewIcons.png

 

When developing a CodeLab script that utilizes special rendering commands, CodeLab now has the ability to run under those conditions while you are developing your script:

CodeLabMenu.png

 

There are some new options on the File New screen:

FileNew.png

 

Here are the new features of the Save as DLL screen:

BuildingDLL.png

 

You can now install CodeLab when using the Microsoft Store version of Paint.NET.  The only limitation is that you can't generate a Visual Studio solution of your CodeLab script.  If you click the button, nothing bad happens, it just tells you of the limitation.

 

New Options:

 

Legacy ROI... Here is a good description of how the ROI's work:

https://forums.getpaint.net/topic/113917-effectoptions/?do=findComment&comment=555790

 

Single Threaded vs. Single Render Call...

SingleThreaded only uses 1 thread to make calls into Render. It'll still be called many, many times, just like if you didn't use the flag, but without any multithreading. Progress bar still works here.

SingleRenderCall only calls Render once, and it's done with 1 array with all of the roi's. That this is effectively SingleThreaded is just a corollary. You won't see any progress bar updating here because the progress bar is updated as each Render call finishes, and there's no side-channel for reporting progress.

 

 

 

  • Like 3
  • Upvote 3
Link to comment
Share on other sites

  • BoltBait changed the title to CodeLab v4.2 (for advanced users) Released March 18, 2019
1 hour ago, xod said:

Thanks for your hard work.

 

You're welcome!

 

1 hour ago, xod said:

Is there any chance to Format Document

 

Easy.  Do you really use it that often?

 

1 hour ago, xod said:

and Find/Replace icons to be added to the toolbar?

 

Hmmm... not as easy.  We would need to highlight the icon if the Find window is open and close the window if clicked again...

 

 

Link to comment
Share on other sites

14 minutes ago, BoltBait said:

We would need to highlight the icon if the Find window is open and close the window if clicked again...

 

Would we though? Most programs don't do that with their find buttons.

 

(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

1 hour ago, BoltBait said:

Easy.  Do you really use it that often?

 

Yes, I use it very often. But I think I could get used to the CTRL + Q combination.

 

Now, CodeLab became very confuse for me. What version I need to use?


ARWrKPN.png
 

Link to comment
Share on other sites

Normally, you would just start CodeLab using the top entry, "CodeLab...".  However,

 

On 3/18/2019 at 9:59 PM, BoltBait said:

When developing a CodeLab script that utilizes special rendering commands, CodeLab now has the ability to run under those conditions while you are developing your script:

CodeLabMenu.png

 

Link to comment
Share on other sites

If I run older scripts in Single Render Call or Legacy ROI mode, CodeLab freezes and I'm forced to close Paint.Net from Task Manager.

 

Edit:

Sorry, there was something wrong with my script.
CodeLab works perfectly.

Edited by xod
Link to comment
Share on other sites

1 hour ago, xod said:

If I run older scripts in Single Render Call or Legacy ROI mode, CodeLab freezes and I'm forced to close Paint.Net from Task Manager.

 

You'll need to give us more information.  I'm not seeing any lockups.  I am able to run older scripts in all 4 of the CodeLab modes.

 

EDIT:  How old is "older"?  I mean, you can't run scripts designed for CodeLab 1.0... but, more modern previous versions (CodeLab 2.0+) should be fine.

Link to comment
Share on other sites

On 3/20/2019 at 8:40 PM, xod said:

If I run older scripts in Single Render Call or Legacy ROI mode, CodeLab freezes and I'm forced to close Paint.Net from Task Manager.

 

Edit:

Sorry, there was something wrong with my script.

 

If your script is causing CodeLab to freeze, that's an issue.

Can you share the script with us, so we can investigate?

(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

  • 2 weeks later...
On 3/25/2019 at 7:37 PM, toe_head2001 said:

 

If your script is causing CodeLab to freeze, that's an issue.

Can you share the script with us, so we can investigate?

 

Spoiler

// Name: Test
// Author: 
// Submenu: 
// URL:
// Title: 

#region UICode
ListBoxControl Amount1 = 0; // Options|Move X, Y|Diagonals
IntSliderControl Amount2 = 20; // [0,800] {Amount1} X
IntSliderControl Amount3 = 20; // [0,800] {Amount1} Y
IntSliderControl Amount4 = 20; // [0,800] {!Amount1} Step
CheckboxControl Amount5 = false; // [0,1] {Amount1} Show coordinates
#endregion

void Render(Surface dst, Surface src, Rectangle rect)
{
    Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
    dst.CopySurface(src, rect.Location, rect);

    float selTop = selection.Top;
    float selBot = selection.Bottom;
    float selLeft = selection.Left;
    float selRight = selection.Right;
    int step = Amount4;
    float fontSize = selection.Right/100;

    using (RenderArgs ra = new RenderArgs(dst))
    {
        Graphics gr = ra.Graphics;
        gr.Clip = new Region(rect);
        gr.SmoothingMode = SmoothingMode.AntiAlias;

        StringFormat format = new StringFormat();
        using(Pen pen = new Pen(Color.Black,1))
        using (Font txtFont = new Font("Tahoma", fontSize, FontStyle.Regular))
        using (SolidBrush txtBrush = new SolidBrush(Color.Blue))
        {
            switch(Amount1)
            {
                case 0: // Move Lines
                    PointF left = new PointF(selLeft - 1f, selTop + Amount2);
                    PointF rite = new PointF(selRight, selTop + Amount2);
                    PointF top = new PointF(Amount3 + selLeft, selTop - 1f);
                    PointF bot = new PointF(Amount3 + selLeft, selBot);
                    gr.DrawLine(pen, top, bot);
                    gr.DrawLine(pen, left, rite);
                    if (Amount5)
                    {
                        txtBrush.Color = Color.Blue;
                        format.Alignment = StringAlignment.Near;
                        format.LineAlignment = StringAlignment.Far;
                        gr.DrawString(Amount2.ToString(), txtFont, txtBrush, selLeft, selTop + Amount2, format);
                        txtBrush.Color = Color.Red;
                        format.Alignment = StringAlignment.Far;
                        format.LineAlignment = StringAlignment.Center;
                        gr.DrawString(Amount3.ToString(), txtFont, txtBrush, selLeft + Amount3, selTop + fontSize, format);
                    }
                    break;
                case 1: // Diagonals
                    for (int i = 1; i < selRight; i+=step) // if step (Amount4) = 0 CodeLab freezes. Logic Amount4 must be > 0. [1,800]
                    {
                        PointF topleft = new PointF(selLeft, selTop - i + 1f);
                        PointF botrite = new PointF(selRight + i - 1f, selBot);
                        gr.DrawLine(pen, topleft, botrite);
                        PointF topleft2 = new PointF(selLeft - i + 1f, selTop);
                        PointF botrite2 = new PointF(selRight, selBot + i - 1f );
                        gr.DrawLine(pen, topleft2, botrite2);
                    }
                    break;
            }
        }
    }
}

 

 

Edited by xod
Link to comment
Share on other sites

Here's a little sneak peek of what I'm working on.

Disclaimer: It's half broken, and a work-in-progress.

 

vs2019-colors.png

 

Visual Studio 2019 colors:

Yellow for Methods

Aquamarine for Structs

Purple for certain Keywords

Light Blue for Parameters and Local Variables

  • Like 1
  • Upvote 3

(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

  • 1 month later...

Wrong alignment for braces when I try to format document because the statement is in line with 'if' keyword.

 

Spoiler

// Name: TextWarp
// Submenu:
// Author: xod
// Title: TextWarp
// Version: 1.0.0
// Desc:
// Keywords:
// URL:
// Help:

#region UICode
MultiLineTextboxControl Amount1 = "Text Warp"; // [1,32767]
FontFamily Amount2 = new FontFamily("Arial"); // Font
IntSliderControl Amount3 = 50; // [3,800] Font size
PanSliderControl Amount4 = Pair.Create(-1.000,-1.000); //
PanSliderControl Amount5 = Pair.Create(1.000,-1.000); //
PanSliderControl Amount6 = Pair.Create(-1.000,1.000); //
PanSliderControl Amount7 = Pair.Create(1.000,1.000); //
IntSliderControl Amount8 = 0; // [0,360] Rotate
CheckboxControl Amount9 = false; // [0,1] Shape
#endregion

void Render(Surface dst, Surface src, Rectangle rect)
{
    Rectangle sel = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
    Color PrimaryColor = EnvironmentParameters.PrimaryColor;

    float x1 = (float)Math.Round((Amount4.First + 1) * sel.Width / 2);
    float y1 = (float)Math.Round((Amount4.Second + 1) * sel.Height / 2);

    float x2 = (float)Math.Round((Amount5.First + 1) * sel.Width / 2);
    float y2 = (float)Math.Round((Amount5.Second + 1) * sel.Height / 2);

    float x3 = (float)Math.Round((Amount6.First + 1) * sel.Width / 2);
    float y3 = (float)Math.Round((Amount6.Second + 1) * sel.Height / 2);

    float x4 = (float)Math.Round((Amount7.First + 1) * sel.Width / 2);
    float y4 = (float)Math.Round((Amount7.Second + 1) * sel.Height / 2);

    string text = Amount1;
    int font_size = Amount3;
    FontStyle font_style = FontStyle.Regular;

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

    using (RenderArgs ra = new RenderArgs(dst))
    using (Pen pen = new Pen(PrimaryColor, 1))
    using (GraphicsPath path = new GraphicsPath())
    using (SolidBrush brush = new SolidBrush(PrimaryColor))
    using (FontFamily font_family = new FontFamily(Amount2.Name))
    using (Font font = new Font(font_family, font_size, font_style))
    using (StringFormat string_format = new StringFormat())
    {
        string_format.Alignment = StringAlignment.Near;
        string_format.LineAlignment = StringAlignment.Near;
        Graphics g = ra.Graphics;
        g.Clip = new Region(rect);
        g.SmoothingMode = SmoothingMode.AntiAlias;
        g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;

        // Create a rectangle.
        RectangleF srcRect = new RectangleF(0, 0, sel.Width, sel.Height);

        PointF p1 = new PointF(x1, y1);
        PointF p2 = new PointF(x2, y2);
        PointF p3 = new PointF(x3, y3);
        PointF p4 = new PointF(x4, y4);

        if(Amount9) path.AddRectangle(srcRect);
            path.AddString(text, font_family, (int)font_style, g.DpiY * font_size / 72, new PointF(0, 0), string_format);

        // Create a destination for the warped rectangle.
        PointF[] destPoints = {p1, p2, p3, p4};

        // Create a translation matrix.
        Matrix matrix = new Matrix();
        matrix.Translate(0, 0);
        if (Amount8 > 0)
        {
            // Move TopLeft corner to center of the canvas then rotate.
            matrix.Translate(sel.Width / 2, sel.Height / 2);
            matrix.Rotate(Amount8);
        }

        // Warp the source path.
        path.Warp(destPoints, srcRect, matrix, WarpMode.Perspective, 0.5f);

        // Draw the warped path to the screen.
        g.DrawPath(pen, path);
        if(!Amount9) g.FillPath(brush, path);
            }//Wrong alignment for braces when I try to format document
             //because the statement is in line with 'if' keyword
    }

 

 

Link to comment
Share on other sites

1 hour ago, xod said:

Wrong alignment for braces when I try to format document because the statement is in line with 'if' keyword.

 

I think this might already be fixed for the next version. If not, I'll take a look at fixing it in the coming days.

  • Like 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

1 hour ago, toe_head2001 said:

 

I think this might already be fixed for the next version. If not, I'll take a look at fixing it in the coming days.

 

While there are some fixes for both quick format and for typing, this is not fixed.

 

You can even see it with the default script:

 

The line after:

if (IsCancelRequested) return;

becomes indented improperly after pressing Ctrl+Q for Quick reformat.

Link to comment
Share on other sites

14 hours ago, xod said:

Wrong alignment for braces when I try to format document because the statement is in line with 'if' keyword.

 

Ok, this is now fixed for the next version.

 

11 hours ago, BoltBait said:

You can even see it with the default script:

 

Well, that embarrassing. Like, did I even do basic testing?! :lol:

For testing of Format Document, I have a special file filled with weird syntax. I've added a single-line if statement to that test file.

I'm pretty sure this was a regression that happened within the last 6 months, because I did test the default script in the past. Anyways, it's in the test file now, so no more regressions in the future.

  • Like 1
  • Upvote 2

(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

Another issue.

Try to run this code:

Spoiler

// Name: test
// Submenu:
// Author: 
// Title: test
// Version: 
// Desc:
// Keywords:
// URL:
// Help:

#region UICode
PanSliderControl Amount1 = Pair.Create(1.000,1.000); // {Amount2} 
CheckboxControl Amount2 = false; // [0,1] Enable
#endregion

void Render(Surface dst, Surface src, Rectangle rect)
{
    
}

PDN crashes. It only works if parameters for Pair.Create is 0, 0 values: PairCreate(0.000, 0.000):

 

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