Jump to content

Recommended Posts

43 minutes ago, Ketenks said:

Is there a tool to put in a bezier by user input?

 

User input? As in the user manually typing in coordinates?

 

44 minutes ago, Ketenks said:

Also are there tools that accept sliders as user input for almost every default tool?

 

I'm not sure that question makes sense.

 

44 minutes ago, Ketenks said:

Also is there a hot key plugin?

 

No, that's not something a plugin could do.

Link to post
Share on other sites

So for the Bezier line tool. I'd like to be able to just put in the numbers of the coordinates for each handle that you drag by the mouse.

 

In the same way, my second question is whether or not there are plugins available that do this same functionality as for the bezier but for other tools; ergo "sliders"

ketenksEsignatureSmall2.png.f74cf40145e3a072030b070615ef1b93.png

Link to post
Share on other sites
19 minutes ago, Ketenks said:

In the same way, my second question is whether or not there are plugins available that do this same functionality as for the bezier but for other tools; ergo "sliders"

 

If you want precision, most of the tools can be used with the Arrow Keys on your keyboard.

 

19 minutes ago, Ketenks said:

So for the Bezier line tool. I'd like to be able to just put in the numbers of the coordinates for each handle that you drag by the mouse.

 

If you want to do this manually, then I would suggest using CodeLab.

Spoiler

void Render(Surface dst, Surface src, Rectangle rect)
{
    // Add/Remove/Edit your Bezier Points here
    Point[] bezierPoints = new Point[]
    {
        new Point(50, 50),
        new Point(100, 50),
        new Point(100, 100),
        new Point(50, 200)
    };

    // Copy the src surface to the dst surface
    dst.CopySurface(src, rect.Location, rect);

    // Setup for drawing using GDI+ commands
    using (Graphics g = new RenderArgs(dst).Graphics)
    using (Region gClipRegion = new Region(rect))
    using (Pen pen = new Pen(Color.Black, 1))
    {
        g.Clip = gClipRegion;
        g.SmoothingMode = SmoothingMode.AntiAlias;
        pen.LineJoin = LineJoin.Round;

        g.DrawBeziers(pen, bezierPoints);
    }
}

 

 

Be sure to read the documentation:

https://docs.microsoft.com/dotnet/api/system.drawing.graphics.drawbeziers

Link to post
Share on other sites

Hello Ketenks,

 

You could try my 'Callicolour' effect using just one line (four points)
or 'Bezncurve' (six points). Both in my plug-in pack.
... A bit clunky I know but may save you the time of writing a bespoke plug-in.😉

 

Red ochre Plugin pack............................................................... Diabolical Drawings

 

PdnForumSig2.jpg

Link to post
Share on other sites
Posted (edited)

The BeznCurve is exactly what I was thinking about in terms of the idea. Thank you very much.

 

However, I'd like to be able to put in the exact coordinates of each control point where those coordinates are mapped in the same way, the mouse pointer is located with an X, Y coordinate relative to the existing canvas size.

 

These numbers seem to jump across pixels and I can't make it pixel perfect.

 

Lastly, I can't zoom in while rendering this curve. Do you think this is a possibility for an update to allow the plugin to zoom in while you make the curve? And also those exact relative X, Y coordinates will allow users to make pixel perfect Beziers.

Edited by Ketenks

ketenksEsignatureSmall2.png.f74cf40145e3a072030b070615ef1b93.png

Link to post
Share on other sites

I could increase the accuracy of the coordinate input boxes. (this should be relatively easy as it's in visual studio).

These currently work as a percentage of the selection size - so not a direct Cartesian coordinate.

 

I could 'hard wire' two integer sliders (per control point) if you know the maximum selection size ... 1000px?

These values could then be protected to limit them to within the given selection... so could lie, but not crash, if used on another sized selection?

 

Zooming-in would be beyond my skills!

 

I could try these changes for a one-off version? - no promises (not everything I try works!)😁

 

Red ochre Plugin pack............................................................... Diabolical Drawings

 

PdnForumSig2.jpg

Link to post
Share on other sites

Maybe I can put your BeznCurve through the CodeLab and look around and see if I can understand it.

 

I'm willing to use whatever you come up with if you want to take a stab at it.

 

Is the reason allowing zoom would be beyond your skills is because you have to recreate that functionality while your plugin is running? Shouldn't the parent view object/class thing be accessible through the plugin? I'm not sure how it works.

ketenksEsignatureSmall2.png.f74cf40145e3a072030b070615ef1b93.png

Link to post
Share on other sites

I'm pretty sure zooming in would mean creating a custom U.I. - a ton of work (and lots I'd have to learn!).

 

It was originally written using codelab so should be easy enough to get the VS version to run in codelab.
(I converted it to Visual studio mainly to add a sample image - which wasn't possible in codelab at the time).
Codelab has changed a lot since 2013 when I wrote the original and the 'G.D.I.+' stuff should be easier to look up on microsoft now.

 

Here is the VS code - you can probably ignore all the stuff at the top and copy and paste (from line 279 downwards '#region User Entered Code' and 'Render') into codelab.

Tip: Graphics objects are best wrapped in a 'Using' statement to automatically dispose them.

 

If you need help best to start a topic in the developer central section of the forum... unless an Admin wants to move this thread?

 

Spoiler


using System;
using System.Text;
using System.Windows;
using System.Reflection;
using System.Windows.Forms;
using PaintDotNet;
using PaintDotNet.Effects;
using PaintDotNet.IndirectUI;
using PaintDotNet.PropertySystem;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("Bezncurve")]
[assembly: AssemblyDescription("Bezncurve Plugin for paint.net. Renders compound Beziers and splines")]
[assembly: AssemblyConfiguration("Bezier|Curve|Line")]
[assembly: AssemblyCompany("Red ochre (John Robbins)")]
[assembly: AssemblyProduct("Bezncurve")]
[assembly: AssemblyCopyright("Copyright © 2017 Red ochre (John Robbins)")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("4.0.1")]

namespace BezncurveEffect
{
    public class PluginSupportInfo : IPluginSupportInfo
    {
        public string Author
        {
            get
            {
                return "Red ochre (John Robbins)";
            }
        }
        public string Copyright
        {
            get
            {
                return ((AssemblyCopyrightAttribute)base.GetType().Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0]).Copyright;
            }
        }

        public string DisplayName
        {
            get
            {
                return ((AssemblyProductAttribute)base.GetType().Assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0]).Product;
            }
        }

        public Version Version
        {
            get
            {
                return base.GetType().Assembly.GetName().Version;
            }
        }

        public Uri WebsiteUri
        {
            get
            {
                return new Uri("http://www.getpaint.net/redirect/plugins.html");
            }
        }
    }

    [PluginSupportInfo(typeof(PluginSupportInfo), DisplayName = "Bezncurve")]
    public class BezncurveUDEffectPlugin : PropertyBasedEffect
    {
        public static string StaticName
        {
            get
            {
                return "Bezncurve";
            }
        }

        public static Image StaticIcon
        {
            get
            {
                return Bezncurve.Properties.Resources.bezncurve;
            }
        }

        public BezncurveUDEffectPlugin()
            : base(StaticName, StaticIcon, SubmenuNames.Render, EffectFlags.Configurable)
        {
        }


        public enum PropertyNames
        {
            CurveType,
            LineType,
            LineWidth,
            ShowControlPoints,
            Orange,
            Red,
            Magenta,
            Blue,
            Cyan,
            Green,
            //antiAlias
        }
        public enum CurveTypes
        {
            Bezier,
            ClosedBezier,
            Curve,
            ClosedCurve,
            StraightLines,
            ClosedStraightLines
        }
        public enum LineTypes
        {
            Solid,
            Dash,
            DashDot,
            DashDotDot,
            Dot

        }

        protected override PropertyCollection OnCreatePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(StaticListChoiceProperty.CreateForEnum<CurveTypes>(PropertyNames.CurveType, 0, false));
            props.Add(StaticListChoiceProperty.CreateForEnum<LineTypes>(PropertyNames.LineType, 0, false));
            props.Add(new Int32Property(PropertyNames.LineWidth, 2, 1, 100));
            props.Add(new BooleanProperty(PropertyNames.ShowControlPoints, true));
            props.Add(new DoubleVectorProperty(PropertyNames.Orange, Pair.Create(-0.33, -0.9), Pair.Create(-2.0, -2.0), Pair.Create(+2.0, +2.0)));
            props.Add(new DoubleVectorProperty(PropertyNames.Red, Pair.Create(-0.66, 0.0), Pair.Create(-2.0, -2.0), Pair.Create(+2.0, +2.0)));
            props.Add(new DoubleVectorProperty(PropertyNames.Magenta, Pair.Create(-0.33, +0.9), Pair.Create(-2.0, -2.0), Pair.Create(+2.0, +2.0)));
            props.Add(new DoubleVectorProperty(PropertyNames.Blue, Pair.Create(+0.33, +0.9), Pair.Create(-2.0, -2.0), Pair.Create(+2.0, +2.0)));
            props.Add(new DoubleVectorProperty(PropertyNames.Cyan, Pair.Create(+0.66, 0.0), Pair.Create(-2.0, -2.0), Pair.Create(+2.0, +2.0)));
            props.Add(new DoubleVectorProperty(PropertyNames.Green, Pair.Create(+0.33, -0.9), Pair.Create(-2.0, -2.0), Pair.Create(+2.0, +2.0)));
            // props.Add(new BooleanProperty(PropertyNames.AntiAlias, true));
            return new PropertyCollection(props);
        }



        protected override ControlInfo OnCreateConfigUI(PropertyCollection props)
        {
            ControlInfo configUI = CreateDefaultConfigUI(props);

            ImageResource image = ImageResource.FromImage(base.EnvironmentParameters.SourceSurface.CreateAliasedBitmap());

            // configUI.SetPropertyControlValue(PropertyNames.CurveType, ControlInfoPropertyNames.DisplayName, "type of curve");
            /*PropertyControlInfo Amount1Control = configUI.FindControlForPropertyName(PropertyNames.CurveType);
            Amount1Control.SetValueDisplayName(CurveTypes.Bezier, "Bezier");
            Amount1Control.SetValueDisplayName(CurveTypes.ClosedBezier, "closed Bezier");
            Amount1Control.SetValueDisplayName(CurveTypes.Curve, "curve through points");
            Amount1Control.SetValueDisplayName(CurveTypes.ClosedCurve, "closed curve through points");
            Amount1Control.SetValueDisplayName(CurveTypes.StraightLines, "straight lines to points");
            Amount1Control.SetValueDisplayName(CurveTypes.ClosedStraightLines, "closed straight lines to points");*/

            configUI.SetPropertyControlValue(PropertyNames.CurveType, ControlInfoPropertyNames.DisplayName, string.Empty);
            PropertyControlInfo CurveTypeControl = configUI.FindControlForPropertyName(PropertyNames.CurveType);
            CurveTypeControl.SetValueDisplayName(CurveTypes.Bezier, "Curve type: Bezier");
            CurveTypeControl.SetValueDisplayName(CurveTypes.ClosedBezier, "Curve type: closed Bezier");
            CurveTypeControl.SetValueDisplayName(CurveTypes.Curve, "Curve type: curve through points");
            CurveTypeControl.SetValueDisplayName(CurveTypes.ClosedCurve, "Curve type: closed curve through points");
            CurveTypeControl.SetValueDisplayName(CurveTypes.StraightLines, "Curve type: straight lines to points");
            CurveTypeControl.SetValueDisplayName(CurveTypes.ClosedStraightLines, "Curve type: closed straight lines to points");

            configUI.SetPropertyControlValue(PropertyNames.LineType, ControlInfoPropertyNames.DisplayName, string.Empty);
            PropertyControlInfo LineTypeControl = configUI.FindControlForPropertyName(PropertyNames.LineType);
            LineTypeControl.SetValueDisplayName(LineTypes.Solid, "Line type: Solid");
            LineTypeControl.SetValueDisplayName(LineTypes.Dash, "Line type: Dash");
            LineTypeControl.SetValueDisplayName(LineTypes.DashDot, "Line type: Dash Dot");
            LineTypeControl.SetValueDisplayName(LineTypes.DashDotDot, "Line type: Dash Dot Dot");
            LineTypeControl.SetValueDisplayName(LineTypes.Dot, "Line type: Dot");

            configUI.SetPropertyControlValue(PropertyNames.LineWidth, ControlInfoPropertyNames.DisplayName, "line width  (uses primary color)");
            configUI.SetPropertyControlValue(PropertyNames.ShowControlPoints, ControlInfoPropertyNames.DisplayName, string.Empty);
            configUI.SetPropertyControlValue(PropertyNames.ShowControlPoints, ControlInfoPropertyNames.Description, "show control points (uncheck before 'OK')");
            configUI.SetPropertyControlValue(PropertyNames.Orange, ControlInfoPropertyNames.DisplayName, "ORANGE");
            configUI.SetPropertyControlValue(PropertyNames.Orange, ControlInfoPropertyNames.SliderSmallChangeX, 0.05);
            configUI.SetPropertyControlValue(PropertyNames.Orange, ControlInfoPropertyNames.SliderLargeChangeX, 0.25);
            configUI.SetPropertyControlValue(PropertyNames.Orange, ControlInfoPropertyNames.UpDownIncrementX, 0.01);
            configUI.SetPropertyControlValue(PropertyNames.Orange, ControlInfoPropertyNames.SliderSmallChangeY, 0.05);
            configUI.SetPropertyControlValue(PropertyNames.Orange, ControlInfoPropertyNames.SliderLargeChangeY, 0.25);
            configUI.SetPropertyControlValue(PropertyNames.Orange, ControlInfoPropertyNames.UpDownIncrementY, 0.01);

            configUI.SetPropertyControlValue(PropertyNames.Orange, ControlInfoPropertyNames.StaticImageUnderlay, image);
            configUI.SetPropertyControlValue(PropertyNames.Red, ControlInfoPropertyNames.DisplayName, "RED");
            configUI.SetPropertyControlValue(PropertyNames.Red, ControlInfoPropertyNames.SliderSmallChangeX, 0.05);
            configUI.SetPropertyControlValue(PropertyNames.Red, ControlInfoPropertyNames.SliderLargeChangeX, 0.25);
            configUI.SetPropertyControlValue(PropertyNames.Red, ControlInfoPropertyNames.UpDownIncrementX, 0.01);
            configUI.SetPropertyControlValue(PropertyNames.Red, ControlInfoPropertyNames.SliderSmallChangeY, 0.05);
            configUI.SetPropertyControlValue(PropertyNames.Red, ControlInfoPropertyNames.SliderLargeChangeY, 0.25);
            configUI.SetPropertyControlValue(PropertyNames.Red, ControlInfoPropertyNames.UpDownIncrementY, 0.01);

            configUI.SetPropertyControlValue(PropertyNames.Red, ControlInfoPropertyNames.StaticImageUnderlay, image);
            configUI.SetPropertyControlValue(PropertyNames.Magenta, ControlInfoPropertyNames.DisplayName, "MAGENTA");
            configUI.SetPropertyControlValue(PropertyNames.Magenta, ControlInfoPropertyNames.SliderSmallChangeX, 0.05);
            configUI.SetPropertyControlValue(PropertyNames.Magenta, ControlInfoPropertyNames.SliderLargeChangeX, 0.25);
            configUI.SetPropertyControlValue(PropertyNames.Magenta, ControlInfoPropertyNames.UpDownIncrementX, 0.01);
            configUI.SetPropertyControlValue(PropertyNames.Magenta, ControlInfoPropertyNames.SliderSmallChangeY, 0.05);
            configUI.SetPropertyControlValue(PropertyNames.Magenta, ControlInfoPropertyNames.SliderLargeChangeY, 0.25);
            configUI.SetPropertyControlValue(PropertyNames.Magenta, ControlInfoPropertyNames.UpDownIncrementY, 0.01);

            configUI.SetPropertyControlValue(PropertyNames.Magenta, ControlInfoPropertyNames.StaticImageUnderlay, image);
            configUI.SetPropertyControlValue(PropertyNames.Blue, ControlInfoPropertyNames.DisplayName, "BLUE");
            configUI.SetPropertyControlValue(PropertyNames.Blue, ControlInfoPropertyNames.SliderSmallChangeX, 0.05);
            configUI.SetPropertyControlValue(PropertyNames.Blue, ControlInfoPropertyNames.SliderLargeChangeX, 0.25);
            configUI.SetPropertyControlValue(PropertyNames.Blue, ControlInfoPropertyNames.UpDownIncrementX, 0.01);
            configUI.SetPropertyControlValue(PropertyNames.Blue, ControlInfoPropertyNames.SliderSmallChangeY, 0.05);
            configUI.SetPropertyControlValue(PropertyNames.Blue, ControlInfoPropertyNames.SliderLargeChangeY, 0.25);
            configUI.SetPropertyControlValue(PropertyNames.Blue, ControlInfoPropertyNames.UpDownIncrementY, 0.01);

            configUI.SetPropertyControlValue(PropertyNames.Blue, ControlInfoPropertyNames.StaticImageUnderlay, image);
            configUI.SetPropertyControlValue(PropertyNames.Cyan, ControlInfoPropertyNames.DisplayName, "CYAN");
            configUI.SetPropertyControlValue(PropertyNames.Cyan, ControlInfoPropertyNames.SliderSmallChangeX, 0.05);
            configUI.SetPropertyControlValue(PropertyNames.Cyan, ControlInfoPropertyNames.SliderLargeChangeX, 0.25);
            configUI.SetPropertyControlValue(PropertyNames.Cyan, ControlInfoPropertyNames.UpDownIncrementX, 0.01);
            configUI.SetPropertyControlValue(PropertyNames.Cyan, ControlInfoPropertyNames.SliderSmallChangeY, 0.05);
            configUI.SetPropertyControlValue(PropertyNames.Cyan, ControlInfoPropertyNames.SliderLargeChangeY, 0.25);
            configUI.SetPropertyControlValue(PropertyNames.Cyan, ControlInfoPropertyNames.UpDownIncrementY, 0.01);

            configUI.SetPropertyControlValue(PropertyNames.Cyan, ControlInfoPropertyNames.StaticImageUnderlay, image);
            configUI.SetPropertyControlValue(PropertyNames.Green, ControlInfoPropertyNames.DisplayName, "GREEN");
            configUI.SetPropertyControlValue(PropertyNames.Green, ControlInfoPropertyNames.SliderSmallChangeX, 0.05);
            configUI.SetPropertyControlValue(PropertyNames.Green, ControlInfoPropertyNames.SliderLargeChangeX, 0.25);
            configUI.SetPropertyControlValue(PropertyNames.Green, ControlInfoPropertyNames.UpDownIncrementX, 0.01);
            configUI.SetPropertyControlValue(PropertyNames.Green, ControlInfoPropertyNames.SliderSmallChangeY, 0.05);
            configUI.SetPropertyControlValue(PropertyNames.Green, ControlInfoPropertyNames.SliderLargeChangeY, 0.25);
            configUI.SetPropertyControlValue(PropertyNames.Green, ControlInfoPropertyNames.UpDownIncrementY, 0.01);

            configUI.SetPropertyControlValue(PropertyNames.Green, ControlInfoPropertyNames.StaticImageUnderlay, image);
            // configUI.SetPropertyControlValue(PropertyNames.AntiAlias, ControlInfoPropertyNames.DisplayName, string.Empty);
            // configUI.SetPropertyControlValue(PropertyNames.AntiAlias, ControlInfoPropertyNames.Description, "anti-alias");
            return configUI;
        }

        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            this.curveType = (CurveTypes)newToken.GetProperty<StaticListChoiceProperty>(PropertyNames.CurveType).Value;
            this.lineType = (LineTypes)newToken.GetProperty<StaticListChoiceProperty>(PropertyNames.LineType).Value;
            this.lineWidth = newToken.GetProperty<Int32Property>(PropertyNames.LineWidth).Value;
            this.showControlPoints = newToken.GetProperty<BooleanProperty>(PropertyNames.ShowControlPoints).Value;
            this.orangePair = newToken.GetProperty<DoubleVectorProperty>(PropertyNames.Orange).Value;
            this.redPair = newToken.GetProperty<DoubleVectorProperty>(PropertyNames.Red).Value;
            this.magentaPair = newToken.GetProperty<DoubleVectorProperty>(PropertyNames.Magenta).Value;
            this.bluePair = newToken.GetProperty<DoubleVectorProperty>(PropertyNames.Blue).Value;
            this.cyanPair = newToken.GetProperty<DoubleVectorProperty>(PropertyNames.Cyan).Value;
            this.greenPair = newToken.GetProperty<DoubleVectorProperty>(PropertyNames.Green).Value;


            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }

        protected override void OnCustomizeConfigUIWindowProperties(PropertyCollection props)
        {
            // Change the effect's window title
            props[ControlInfoPropertyNames.WindowTitle].Value = "Bezncurve                             Red ochre       Feb'17";
            props[ControlInfoPropertyNames.WindowIsSizable].Value = true;//suggested by Midora
            base.OnCustomizeConfigUIWindowProperties(props);
        }

        protected override unsafe void OnRender(Rectangle[] rois, int startIndex, int length)
        {
            if (length == 0) return;
            for (int i = startIndex; i < startIndex + length; ++i)
            {
                Render(DstArgs.Surface, SrcArgs.Surface, rois[i]);
            }
        }

        #region User Entered Code
        #region UICode
        CurveTypes curveType = CurveTypes.ClosedBezier; // type of curve|Bezier|closed Bezier|curve through points|closed curve through points|straight lines to points|closed straight lines to points
        LineTypes lineType = LineTypes.Solid;//added for Pdn4 (and Pdn 3.5.11) version UD1
        int lineWidth = 2; // [1,100] line width  (uses primary color)
        bool showControlPoints = true; // [0,1] show control points (uncheck before 'OK')
        Pair<double, double> orangePair = Pair.Create(0.0, 0.0); // ORANGE 
        Pair<double, double> redPair = Pair.Create(0.0, 0.0); // RED
        Pair<double, double> magentaPair = Pair.Create(0.0, 0.0); // MAGENTA
        Pair<double, double> bluePair = Pair.Create(0.0, 0.0); // BLUE
        Pair<double, double> cyanPair = Pair.Create(0.0, 0.0); // CYAN
        Pair<double, double> greenPair = Pair.Create(0.0, 0.0); // GREEN 
        // bool antiAlias = true; // [0,1] anti-alias
        #endregion

        void Render(Surface dst, Surface src, Rectangle rect)
        {
            dst.CopySurface(src, rect.Location, rect);
            ColorBgra PC = (ColorBgra)EnvironmentParameters.PrimaryColor;
            Rectangle sel = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
            int Stop = sel.Top;
            int Sleft = sel.Left;
            int H = sel.Height;//Sbott - Stop;
            int W = sel.Width;//Srite - Sleft;
            double dx = W / 2;
            double dy = H / 2;

            double A1f = orangePair.First; double A1s = orangePair.Second;//CP1 - start 
            double A2f = redPair.First; double A2s = redPair.Second;//CP2 
            double A3f = magentaPair.First; double A3s = magentaPair.Second;//CP3 
            double A4f = bluePair.First; double A4s = bluePair.Second;//CP4
            double A5f = cyanPair.First; double A5s = cyanPair.Second;//CP5
            double A6f = greenPair.First; double A6s = greenPair.Second;//CP6 - end2


            //for codelab only
            if (A1f == 0 && A1s == 0 && A2f == 0 && A2s == 0 && A3f == 0 && A3s == 0 && A4f == 0 && A4s == 0 && A5f == 0 && A5s == 0 && A6f == 0 && A6s == 0)
            { A1f = -0.33; A1s = -0.9; A2f = -0.66; A2s = 0.0; A3f = -0.33; A3s = 0.9; A4f = 0.33; A4s = 0.9; A5f = 0.66; A5s = 0.0; A6f = 0.33; A6s = -0.9; }


            float Cp1x = (float)(Sleft + ((A1f + 1) * dx)); float Cp1y = (float)(Stop + ((A1s + 1) * dy));
            float Cp2x = (float)(Sleft + ((A2f + 1) * dx)); float Cp2y = (float)(Stop + ((A2s + 1) * dy));
            float Cp3x = (float)(Sleft + ((A3f + 1) * dx)); float Cp3y = (float)(Stop + ((A3s + 1) * dy));
            float Cp4x = (float)(Sleft + ((A4f + 1) * dx)); float Cp4y = (float)(Stop + ((A4s + 1) * dy));
            float Cp5x = (float)(Sleft + ((A5f + 1) * dx)); float Cp5y = (float)(Stop + ((A5s + 1) * dy));
            float Cp6x = (float)(Sleft + ((A6f + 1) * dx)); float Cp6y = (float)(Stop + ((A6s + 1) * dy));
            // calculate these mid points
            float Cp12x = (float)((Cp1x + Cp2x) / 2); float Cp12y = (float)((Cp1y + Cp2y) / 2);
            float Cp34x = (float)((Cp3x + Cp4x) / 2); float Cp34y = (float)((Cp3y + Cp4y) / 2);
            float Cp56x = (float)((Cp5x + Cp6x) / 2); float Cp56y = (float)((Cp5y + Cp6y) / 2);

            // Create points for curve.

            PointF CP1 = new PointF(Cp1x, Cp1y);
            PointF CP2 = new PointF(Cp2x, Cp2y);
            PointF CP3 = new PointF(Cp3x, Cp3y);
            PointF CP4 = new PointF(Cp4x, Cp4y);
            PointF CP5 = new PointF(Cp5x, Cp5y);
            PointF CP6 = new PointF(Cp6x, Cp6y);
            PointF CP12 = new PointF(Cp12x, Cp12y);
            PointF CP34 = new PointF(Cp34x, Cp34y);
            PointF CP56 = new PointF(Cp56x, Cp56y);


            PointF[] bezierPoints = { CP1, CP2, CP3, CP34, CP4, CP5, CP6 };
            PointF[] curvePoints = { CP1, CP2, CP3, CP4, CP5, CP6 };
            PointF[] closedBezPoints = { CP12, CP2, CP3, CP34, CP4, CP5, CP56, CP6, CP1, CP12 };
            using (Graphics g = new RenderArgs(dst).Graphics)
            {
                g.Clip = new Region(rect);
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                // if (!antiAlias) { g.SmoothingMode = SmoothingMode.None; }//removed choice - no one will use it!

                using (Pen pripen = new Pen(PC, lineWidth))
                {
                    pripen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;//Thanks E.E.R ( and TR)
                    switch (lineType)
                    {
                        case LineTypes.Solid:
                            pripen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                            break;
                        case LineTypes.Dash:
                            pripen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                            break;
                        case LineTypes.DashDot:
                            pripen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;
                            break;
                        case LineTypes.DashDotDot:
                            pripen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot;
                            break;
                        case LineTypes.Dot:
                            pripen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                            break;
                    }


                    switch (curveType)
                    {
                        case CurveTypes.Bezier:// smooth bezier (CP34 calculated)
                            g.DrawBeziers(pripen, bezierPoints);
                            break;
                        case CurveTypes.ClosedBezier:// closed bezier (CP12,CP34,CP56 calculated)
                            using (GraphicsPath gp = new GraphicsPath())// this, suggested by Midora, closes the gap as the 'GraphicsPath' is within a using block it will be disposed automatically at end of block
                            {
                                gp.StartFigure();
                                gp.AddBeziers(closedBezPoints);
                                gp.CloseFigure();
                                g.DrawPath(pripen, gp);
                            }
                            break;
                        case CurveTypes.Curve:// curve through points (not through CP4)
                            g.DrawCurve(pripen, curvePoints);
                            break;
                        case CurveTypes.ClosedCurve:
                            g.DrawClosedCurve(pripen, curvePoints);
                            break;
                        case CurveTypes.StraightLines:// straight lines through points
                            g.DrawLines(pripen, curvePoints);
                            break;
                        case CurveTypes.ClosedStraightLines:// closed straight line through points (polygon)
                            g.DrawPolygon(pripen, curvePoints);
                            break;
                    }//end switch
                }//end pripen
                //control points
                if (showControlPoints)
                {
                    using (
                               Pen oraPen = new Pen(Color.Orange, 5f),
                               redPen = new Pen(Color.Red, 5f),
                               magPen = new Pen(Color.Magenta, 5f),
                               blaPen = new Pen(Color.Black, 5f),
                               whiPen = new Pen(Color.White, 2f),
                               bluPen = new Pen(Color.Blue, 5f),
                               cyaPen = new Pen(Color.Cyan, 5f),
                               grePen = new Pen(Color.Green, 5),
                               grayDashPen = new Pen(Color.Gray, 2),
                               grayDotPen = new Pen(Color.Gray, 1)

                           )
                    {
                        grayDashPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                        grayDotPen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;
                        // show tangent lines for Beziers 
                        if (curveType == CurveTypes.Bezier)
                        {

                            g.DrawLine(grayDotPen, CP1, CP2);
                            g.DrawLine(grayDotPen, CP2, CP3);
                            g.DrawLine(grayDotPen, CP4, CP5);
                            g.DrawLine(grayDotPen, CP5, CP6);

                            g.DrawLine(grayDashPen, CP3, CP4);//tangent
                        }
                        else if (curveType == CurveTypes.ClosedBezier)
                        {
                            g.DrawLine(grayDotPen, CP2, CP3);// control point to control point
                            g.DrawLine(grayDotPen, CP4, CP5);
                            g.DrawLine(grayDotPen, CP6, CP1);

                            g.DrawLine(grayDashPen, CP3, CP4);// through tangents
                            g.DrawLine(grayDashPen, CP5, CP6);
                            g.DrawLine(grayDashPen, CP1, CP2);

                        }

                        //control points
                        g.DrawEllipse(oraPen, Cp1x - 5, Cp1y - 5, 10, 10);//CP1
                        g.DrawEllipse(whiPen, Cp1x - 3, Cp1y - 3, 6, 6);
                        g.DrawEllipse(redPen, Cp2x - 5, Cp2y - 5, 10, 10);//CP2
                        g.DrawEllipse(whiPen, Cp2x - 3, Cp2y - 3, 6, 6);
                        g.DrawEllipse(magPen, Cp3x - 5, Cp3y - 5, 10, 10);//CP3
                        g.DrawEllipse(whiPen, Cp3x - 3, Cp3y - 3, 6, 6);
                        g.DrawEllipse(bluPen, Cp4x - 5, Cp4y - 5, 10, 10);//CP4
                        g.DrawEllipse(whiPen, Cp4x - 3, Cp4y - 3, 6, 6);
                        g.DrawEllipse(cyaPen, Cp5x - 5, Cp5y - 5, 10, 10);//CP5
                        g.DrawEllipse(whiPen, Cp5x - 3, Cp5y - 3, 6, 6);
                        g.DrawEllipse(grePen, Cp6x - 5, Cp6y - 5, 10, 10);//CP6
                        g.DrawEllipse(whiPen, Cp6x - 3, Cp6y - 3, 6, 6);


                        if (curveType == CurveTypes.Bezier || curveType == CurveTypes.ClosedBezier)
                        {
                            g.DrawEllipse(blaPen, Cp34x - 5, Cp34y - 5, 10, 10);//only for Beziers
                            g.DrawEllipse(whiPen, Cp34x - 4, Cp34y - 4, 8, 8);
                        }

                        if (curveType == CurveTypes.ClosedBezier)
                        {
                            g.DrawEllipse(blaPen, Cp12x - 5, Cp12y - 5, 10, 10);//only for closed Bezier
                            g.DrawEllipse(whiPen, Cp12x - 4, Cp12y - 4, 8, 8);
                            g.DrawEllipse(blaPen, Cp56x - 5, Cp56y - 5, 10, 10);
                            g.DrawEllipse(whiPen, Cp56x - 4, Cp56y - 4, 8, 8);
                        }
                    }//end coloured pens
                }
            }


        }

        #endregion
    }
}

 

 

 

Red ochre Plugin pack............................................................... Diabolical Drawings

 

PdnForumSig2.jpg

Link to post
Share on other sites

You will need to have read Boltbait's codelab tutorials first!

 

I expect most of those errors are due to the controls and the values they pass into the Render method being declared and named slightly differently to the way codelab does it.
... or possibly you haven't deleted the correct things in the codelab window before pasting. It'll be good practice for you to solve these simple errors.😉

 

Hint 1: 'Curvetypes' will be replaced by 'byte' - see Drop-Down List Box https://boltbait.com/pdn/codelab/help/uielements.php

 

Red ochre Plugin pack............................................................... Diabolical Drawings

 

PdnForumSig2.jpg

Link to post
Share on other sites
21 minutes ago, Red ochre said:

Hint 1: 'Curvetypes' will be replaced by 'byte' - see Drop-Down List Box https://boltbait.com/pdn/codelab/help/uielements.php

 

That will work, but that's the old school way of doing it. :D These days, CodeLab can use enums, so you don't have to deal with byte values and casting.

#region UICode
ListBoxControl<CurveTypes> curveType = CurveTypes.Bezier; // Type of Curve|Bezier|Closed Bezier|Curve|Closed Curve|Straight Lines|Closed Straight Lines
#endregion

enum CurveTypes
{
    Bezier,
    ClosedBezier,
    Curve,
    ClosedCurve,
    StraightLines,
    ClosedStraightLines
}

 

Link to post
Share on other sites

I very rarely use codelab these days (sorry!)... so my advice is very dated! (as are some of the tutorials I believe).

 

I use VS19 as it can copy the output direct to Effects folder (when run as admin) - so no messing around with Bat files (I don't want Covid19!).😄
Also more control over the U.I. prop rules, intellisense refactoring suggestions, etc.

 

I know you have put a lot work into making codelab more like VS but I wonder if it has become too complex for beginners?
- perhaps consider a 'code lab light' for those with zero C# experience. It's easy to forget how daunting coding a simple effect is the first time.

  • Upvote 1

 

Red ochre Plugin pack............................................................... Diabolical Drawings

 

PdnForumSig2.jpg

Link to post
Share on other sites

I was writing some suggestions but I've clearly offended you both - sincerely not meant - I apologize!
So not much point in giving feedback that will not be considered. Understandable, you have both invested a lot of time in codelab.
Many thanks for your hard work.

 

Red ochre Plugin pack............................................................... Diabolical Drawings

 

PdnForumSig2.jpg

Link to post
Share on other sites
11 minutes ago, Red ochre said:

I was writing some suggestions but I've clearly offended you both - sincerely not meant - I apologize!
So not much point in giving feedback that will not be considered. Understandable, you have both invested a lot of time in codelab.
Many thanks for your hard work.

 

I'm totally NOT offended.

 

Suggest away!  (We're both interested, seriously!)

 

When we make changes to CodeLab, we do it with the goal of making CodeLab easier to use... not harder.  Many of the improvements we've made have come from user's suggestions.

Click to play:
j.pngs.pngd.pnga.pngp.png
Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game

Link to post
Share on other sites

CodeLab has become more advanced and more 'friendly' for communication.

 

10 hours ago, Red ochre said:

(as are some of the tutorials I believe).

 

Yes, many tutorials did not 'catch up' with CodeLab, and they need to be fixed or rewritten. (I will review my tutorials as soon as I have more free time.)

Sorry for offtop.

 

  • Like 1
Link to post
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...