xod

Members
  • Content Count

    547
  • Joined

  • Last visited

  • Days Won

    14

Posts posted by xod


  1. 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;
                }
            }
        }
    }

     

     


  2. Question about Dynamic values for IndirectUI sliders.

     

    After running the MoveLines plugin below on a standard 800x600 canvas and then choosing a New size canvas 2400x1800 (in the same working session), the selSize is not updated and retains the old size 800x600.
    Please, tell me what is wrong with my code?

     

    https://www.mediafire.com/file/3osg1n58q319efd/MoveLinesEffect.zip/file

     


  3. 19 hours ago, BoltBait said:

     

    That's because @xod failed to include the 2 other library files he relies on.

     

    I'm sure he'll fix this as soon as he sees this message.  Hold on...

     

    To @xod: if you're going to distribute an OptionBasedEffects plugin, you really should include a copy of the OptionBasedEffects DLLs.

     

    Sorry about that.

    Yes, you need the two OptionBasedLibrary.dll and OptionBasedLibrary.dlc files to be copied to the Paint.Net folder and not to the Effects folder.

    I uploaded these two files together with TextDistortion on Mediafire.