Jump to content

dracho

Members
  • Posts

    15
  • Joined

  • Last visited

Posts posted by dracho

  1. HF1WDe8.png

    27 minutes ago, toe_head2001 said:

    @dracho, how this?

     

      Hide contents
    
    
    // Name: Coordinate Plane Points
    // Submenu: Render
    // Author: toe_head2001
    // Title:
    // Version: 1.1
    // Desc: Generates center-based coordinate plane points
    // Keywords:
    // URL:
    // Help:
    #region UICode
    IntSliderControl Amount1 = 100; // [25,1000] Step
    IntSliderControl Amount2 = 150; // [0,255] Overlay
    PanSliderControl Amount3 = Pair.Create(0.00,0.000); // Center
    #endregion
    
    void Render(Surface dst, Surface src, Rectangle rect)
    {
        Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
        Point center = new Point
        {
            X = ((selection.Right - selection.Left) / 2) + selection.Left,
            Y = ((selection.Bottom - selection.Top) / 2) + selection.Top
        };
        Point offset = new Point
        {
            X = (int)(center.X + center.X * Amount3.First),
            Y = (int)(center.Y + center.Y * Amount3.Second)
        };
        int horLoops = (int)Math.Ceiling(selection.Width / (float)Amount1);
        int verLoops = (int)Math.Ceiling(selection.Height / (float)Amount1);    
        int leftEdge = (offset.X - selection.Left) % Amount1;
        int topEdge = (offset.Y - selection.Top) % Amount1;
    
        dst.CopySurface(src, rect.Location, rect);
    
        using (Graphics plane = new RenderArgs(dst).Graphics)
        {
            plane.TextRenderingHint = TextRenderingHint.AntiAlias;
            plane.Clip = new Region(rect);
    
            using (SolidBrush overlayBrush = new SolidBrush(Color.FromArgb(Amount2, Color.White)))
            {
                plane.FillRectangle(overlayBrush, selection);
            }
    
            Point point = Point.Empty;
            string pointText;
            SizeF pointTextSize;
            using (SolidBrush pointBrush = new SolidBrush(Color.Red))
            using (SolidBrush textBrush = new SolidBrush(Color.Black))
            using (Font textFont = new Font("Arial", 8, FontStyle.Regular))
            {
                for (int y = 0; y < verLoops; y++)
                {
                    for (int x = 0; x < horLoops; x++)
                    {
                        point.X = leftEdge + Amount1 * x;
                        point.Y = topEdge + Amount1 * y;
    
                        plane.FillRectangle(pointBrush, point.X - 1, point.Y - 1, 3, 3);
    
                        pointText = (point.X - offset.X).ToString() + ", " + ((point.Y - offset.Y) * -1).ToString();
                        pointTextSize = plane.MeasureString(pointText, textFont);
                        if (pointTextSize.Width >= Amount1)
                            pointText = (point.X - offset.X).ToString() + ",\n" + ((point.Y - offset.Y) * -1).ToString();
                        plane.DrawString(pointText, textFont, textBrush, point);
                    }
                }
            }
        }
    }

     

     

    There's a Preview button in CodeLab these days. :)  Or you can build a DLL file if you're going to be using it a lot.

    CodeLab-previewButton.png

    That's awesome!  Thanks so much!  Really cool how you added that little slider system.  I might have been doing something wrong, because the settings didn't seem to affect the code, but I just manually edited the X and Y and opacity after previewing the settings.  Maybe that's working as intended.  

     

    I do have one other request, if you feel like coding a bit more.  :P  If not, I'm satisfied!  I was hoping you might be able to make the coordinate text white instead of black when it's on top of a dark color.  You can see in my screenshot that I prefer 0 overlay opacity (so I can keep the .png color codes precise - this is a template that Minecraft uses to generate terrain) but the text in the water is difficult to read.  

     

    Thanks, toe_head.  

  2. On 6/11/2016 at 9:52 PM, toe_head2001 said:

    Here's the CodeLab script:

      Reveal hidden contents
    
    
    // Name: Coordinate Plane
    // Submenu: Render
    // Author: toe_head2001
    // Title:
    // Version: 0.1
    // Desc:
    // Keywords:
    // URL:
    // Help:
    #region UICode
    IntSliderControl Amount1 = 100; // [10,1000] Step
    #endregion
    
    void Render(Surface dst, Surface src, Rectangle rect)
    {
        Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
        int centerX = ((selection.Right - selection.Left) / 2) + selection.Left;
        int centerY = ((selection.Bottom - selection.Top) / 2) + selection.Top;
        int step = Amount1;
        int horLoops = (int)Math.Ceiling(selection.Width / (float)step);
        int verLoops = (int)Math.Ceiling(selection.Height / (float)step);
        int leftEdge = centerX - step * (horLoops / 2);
        int topEdge = centerY - step * (verLoops / 2);
    
        dst.CopySurface(src, rect.Location, rect);
    
        using (RenderArgs ra = new RenderArgs(dst))
        {
            Graphics plane = ra.Graphics;
            plane.TextRenderingHint = TextRenderingHint.AntiAlias;
            plane.Clip = new Region(rect);
    
            using (SolidBrush overlayBrush = new SolidBrush(Color.FromArgb(150, Color.White)))
            {
                plane.FillRectangle(overlayBrush, selection);
            }
            
            Point point = new Point();
            using (Pen planePen = new Pen(Color.Red, 2))
            using (SolidBrush textBrush = new SolidBrush(Color.Black))
            using (Font textFont = new Font("Arial", 8, FontStyle.Regular))
            {
                for (int y = 0; y < verLoops; y++)
                {
                    for (int x = 0; x < horLoops; x++)
                    {
                        point.X = leftEdge + step * x;
                        point.Y = topEdge + step * y;
                        plane.DrawEllipse(planePen, point.X, point.Y, 1, 1);
                        plane.DrawString((point.X - centerX).ToString() + ", " + ((point.Y - centerY) * -1).ToString(), textFont, textBrush, point);
                    }
                }
            }
        }
    }

     

    UPDATE: You can get this plugin in my Plugin Pack.

    Hello, toe_head2001 it's me again.  Working on the same project (a few iterations down the road.)  I was wondering if it's possible to center 0,0 on the bottom left corner of the image, instead of the center.  Thanks again!  

  3. Unfortunately I don't think Selective Palette is going to work for me.

     

    Say I have two biomes (two different colors) next to each other.  One is dark green and one is light green.  Inevitably there will be some medium green pixels after I apply the effects.  I could eliminate the medium green by using Selective Palette but medium green is actually a valid color in another part of the map.  I don't want a large biome next to another large biome with a minuscule amount of third biome between them.

     

    There are 187 biomes, and I don't think I can ever be assured that each pixel is perfect via this method.

     

    I just really need a smoothing filter that doesn't introduce new colors...

  4. 11 minutes ago, null54 said:

     

    Yes, I tested it before posting the reply.

     

    Did you place all 3 files in the Effects folder?

    Yes.  Here's a crashlog:  https://paste.ubuntu.com/p/dgWtNwkmQT/

     

    Err... that crash only happens when I select Effects Lab, which I thought was the menu the new plugin added, but apparently there are more to choose from in the list of effects.  I will see if I have any luck with them.

     

    OK, I found the Selective Palette dialog.  It seems like this might work, but I guess I first need to save a palette that includes only the colors in my current .png file.  Once I figure that out, I should be able to import that palette into Selective Palette and... cross that bridge when I get to it.  Thanks.

  5. Hi, I'm creating a template and each color that's in the .png file must match a string in a config file.  Therefore, only colors I specify can be included in the .png file.

     

    I drew some shapes, then resized the whole image by 500%.  As you can guess, huge blocky jaggies are everywhere, as seen here:  https://imgur.com/LQg1VvX

     

    I believe I tried all the filters, and Dent came closest to what I need, but it introduced "random" colors by anti-aliasing, as seen here: https://imgur.com/reCsjsN

     

    I am looking to apply a smoothing filter to this whole map, only using the colors that are currently included.  (Here's the full map if you were curious: https://imgur.com/4n3Akjk )

     

    Thanks much!

  6. Thanks for the reply, MJW.

     

    I'll keep doing some research.  The link you provided looks like a good starting point.

     

    I'm actually not wanting to crop; I'm wanting to expand the canvas size of images.  This will add white borders to the top and bottom or left and right.  The image should remain centered.  I figured there would be a PDN plugin, since this does seem quite trivial in my opinion... compare two numbers and increase the lower number to match the larger one.  

     

    If PDN accepted commands from the command line interface, I bet a small plugin could be created... especially since I've already renamed my images 1.jpg, 2.jpg, 3.jpg, etc.

     

    Anyway, thanks again, I'll report back when I've found my preferred solution.

  7. Hello again.

     

    I have several hundred images I want to upload to Instagram, but I would like them all to be perfectly square first.

     

    This currently entails opening each image and clicking Resize Canvas, then adjusting either the width or height to match the other number.

     

    Can this be done automatically?

     

    It would be great if it was semi-intelligent and resized either horizontally or vertically, but I suppose manually separating my wide and tall pictures into two different folders wouldn't be too bad.

     

    Thanks much.

  8. Thanks again, toe_head2001!

     

    Fantastic work.  I really appreciate it.

     

    It was easy to install CodeLab and just as simple to build your script.

     

    While I would still love to see an addon developed that simply outputs the Cartesian coordinates of the cursor (as it would be less intrusive and more precise), this script will work perfectly for my application (as I don't need absolute precision and toggling the layer's visibility is trivial to do.)

     

    Thank you very much!

     

    Edit:  P.S.  I just edited your code a bit, changing the white overlay translucency from 150 to 0 and now I find it to be even better.  :)  Also a very simple adjustment.  Very satisfied. 

  9. Thanks, Ego Eram Reputo!

     

    A very solid workaround.  I should have thought of that.

     

    I've been fighting with the syntax of If/Then statements in Excel to do the calculations... assuming a 5000x5000 image, my syntax was something like "If A1 < 2500, Then A1-2500."  It's hurting my brain.  (Feel free to comment if you're handy with Excel, too!  :P )

     

    Thanks again.  If I can't get this spreadsheet method to work pretty soon, I'll just use your dragging method.  

  10. Thank you, pdnnoob.

     

    Yes, that unfortunately is not quite what I'm after.  I do indeed want a Cartesian coordinate display.  It doesn't have to replace the existing status bar display... an additional display would be perfectly fine.

     

    As far as setting the world's spawn point, I am currently doing this with a mod called PerfectSpawn.  It allows me to set the spawn point to a fixed value, and eliminate any "fuzzing" that the game does when a new player spawns.  This is only a workaround though, and hopefully a temporary one.  Spawn will need to bet set at 0,0 once the map is finished.  Also, if I edit other maps with different sizes, I'll have to keep changing the config of PerfectSpawn for testing... then again when I'm ready to playtest it.

     

    I'll keep having a look at the Plugins page though.  Thanks for your help.

  11. Hello.  

     

    I love Paint.net and have been using it for several years.  Thank you for the great software.

     

    I am working on a new project, a Minecraft map, and it would help immensely to have the center of the image I'm editing read as 0,0.  This way, I can hover over a portion of the image (it's a top-down view of a world) and be able to easily see where I need to go in-game to check it out.

     

    Of course, 0,0 in Paint.net is the upper-left corner of the image (and this is "correct" for 99.99% of applications.)

     

    Minecraft spawn is 0,0 and extends into the negatives in the south and west directions and into the positive in the north and east.

     

    I realize I could use a calculator, but a small addition or addon would be extremely helpful.  It might even make Paint.net the editor of choice for other Minecraft map makers and I bet it would have other applications as well.

     

    Thanks for your time and consideration.

×
×
  • Create New...