Jump to content

Reptillian

Members
  • Posts

    1,239
  • Joined

  • Last visited

  • Days Won

    18

Posts posted by Reptillian

  1. Major speedup update!

     

    So, when you change only the colors, it will not attempt to render the Lyapunov Fractal base anymore. So, changes in color output will be instant. I'm sure there could be more optimization to be done with regards to changes, but it's fast enough that it's not worth the effort any time soon, and I won't notify update the next time I do if I get to do that.

     

    Practically complete at this point.

     

    -----

     

    Something I had made with the changes:

     

    unknown.png

    • Like 2
  2. New Update!

    1. It is now case-insensitive

    2. There is now HSL mode.

     

    This unfortunately introduce a new bug in the GUI department, but it is usable regardless. I would like to disable the colors gui elements depending on Mode, but I would have to resort to Visual Studio, and I really do not want to go there. I think it's fixable, but the HSL Colors elements requires conditions of two elements.

     

    I fixed that issue. Now the GUI is nearly completely functional. Doesn't work entirely as expected, but still more usable than before. Now, Codelab source is removed as it is now a Visual Studio project.

  3. Well, I already solved it.  I solved it by isolating the HSL2RGB function into a test code, and figured what's wrong. For anyone stumbling upon this problem:

     

    ColorBgra hsl2rgb(double H,double S,double L){
        int iH = (int)(H)/60;
        double C = (1-Math.Abs(2*L-1))*S;
        double X = C * (1 - Math.Abs((H/60)%2-1));
        double m = L - C/2;
        double tr,tg,tb;
        switch(iH){
            case 0:
                tr=C;
                tg=X;
                tb=0;
                break;
            case 1:
                tr=X;
                tg=C;
                tb=0;
                break;
            case 2:
                tr=0;
                tg=C;
                tb=X;
                break;
            case 3:
                tr=0;
                tg=X;
                tb=C;
                break;
            case 4:
                tr=X;
                tg=0;
                tb=C;
                break;
            default:
                tr=C;
                tg=0;
                tb=X;
                break;
        }
        tr+=m;
        tg+=m;
        tb+=m;
        tr*=255;
        tg*=255;
        tb*=255;
        tr=Math.Round(tr);
        tg=Math.Round(tg);
        tb=Math.Round(tb);
        return ColorBgra.FromBgraClamped((int)(tb),(int)(tg),(int)(tr),255);
    }

     

  4. I am attempting to interpolate between two different HSL value, but I can't seem to figure out why this does not work:

    double lerp(double a, double b, double t){
        return a * (1 - t) + b * t ;
    }
    
    ColorBgra out_hsl(double hue_a,double hue_b,double sat_a,double sat_b,double intensity_a,double intensity_b,double pos){
        //new_pos is always in range [0,1).
        double new_pos = pos - Math.Floor(pos);
        double H = lerp(hue_a,hue_b,new_pos);
        double S = lerp(sat_a,sat_b,new_pos);
        double L = lerp(intensity_a,intensity_b,new_pos);
        int section = (int)(H/60);
    
        double C=(1 - Math.Abs(2*L-1))*S;
        double X=C*(1-Math.Abs((double)(section%2-1)));
        double m = L - C/2;
        double red,green,blue;
        switch(section){
            case 0:
            red = C; green = X; blue = 0;
            break;
            case 1:
            red = X; green = C; blue = 0;
            break;
            case 2:
            red = 0; green = C; blue = X;
            break;
            case 3:
            red = 0; green = X; blue = C;
            break;
            case 4:
            red = X; green = 0; blue = C;
            break;
            default:
            red = C; green = 0; blue = X;
            break;
        }
        red=(red+m)*255;
        green=(green+m)*255;
        blue=(blue+m)*255;
        return ColorBgra.FromBgraClamped((int)(blue),(int)(green),(int)(red),255);
    }

     

    I have used this source : https://www.rapidtables.com/convert/color/hsl-to-rgb.html

     

    It should work because the formula used here are the same.

  5. 10 hours ago, ardneh said:

    Okay, thanks.

    I was using upper-case letters.

     

    In the next version, I'll release the case-insensitive version, in fact I already had done the changes to make sure it works (See Below). Depending on whether I can pull off more color modes or not, it might be released quickly or not.

     

    string low_str = str_var.ToLower();
    s_str_var = low_str.Length;
    char[] charArr=low_str.ToCharArray();

     

  6. Generates Markus-Lyapunov Fractal which means that it create a mapping of Lyapunov exponent within two values (though in this case, up to 3 is supported). Discovered by Mario Markus of the Max Planck Institute for Nutrition. Alexander Lyapunov was the one that discovered Lyapunov exponent. [Source]

     

    Note: Extremely slow plugin. It doesn't use multi-threading due to limitations of Codelab. Even with multi-threading, it is still computationally intensive!

     

    This is rather a simple implementation that could be further extended (particularly in the color output department). As of now, there are these parameters:

    ABC-String - Just what it says. These are the following allowed letters, and it is the base of the Markus-Lyapunov Fractal.

    ABC-String Repeats - Repeats the string. You don't see it repeated, but it is repeated on the background.

    View Size (%) - This means that the less percentage there are, the less vantage of views you have of the Markus-Lyapunov Fractal

    View Position - Does this really need to be explained?

    C Position - Only applicable if ABC-String contains a 'C' in it. Defines the slice position from a 3D Markus-Lyapunov Fractal. (See video below Preview for a idea of what it like to slice through)

    Mode - Defines the coloring of the Markus-Lyapunov Fractal. There are three modes: Grayscale, Duotone, and HSL. HSL provides the option to use arbitrary numbers of colors.

    Reverted Mode - Defines the output of grayscale mode. As you note, only applicable on Grayscale.

    Split Mode - Use Split Colors on HSL Output.

    #Colors for Singular HSL - Numbers of HSL colors everywhere without discontinuity.

    Positive HSL Colors - Defines the number of HSL colors on positive areas

    Negative HSL Colors - Defines the number of HSL colors on negative areas.

    Positive Color - Defines the coloring for positive areas.

    Negative Color - Defines the coloring for negative areas.

     

    Preview:

     

    unknown.png

    ABC - (0%-100% or 2-4):

     

    Spoiler

     

     

    Installation:

    Plugin Files -> Lyapunov Fractal.zip

    1. Insert the .dll into effect folder of paint.net installation

    2. Find it under Render.

     

    Bugs:

    1. ABC-String is empty at beginning. I can't fix that. Fixed.

    2. Cancel takes a long time.

     

    Source code:

    Visual Studio

    Spoiler
    using System;
    using System.IO;
    using System.Linq;
    using System.Diagnostics;
    using System.Drawing;
    using System.Threading;
    using System.Reflection;
    using System.Drawing.Text;
    using System.Windows.Forms;
    using System.IO.Compression;
    using System.Drawing.Drawing2D;
    using System.Collections.Generic;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Runtime.InteropServices;
    using Registry = Microsoft.Win32.Registry;
    using RegistryKey = Microsoft.Win32.RegistryKey;
    using PaintDotNet;
    using PaintDotNet.AppModel;
    using PaintDotNet.Clipboard;
    using PaintDotNet.IndirectUI;
    using PaintDotNet.Collections;
    using PaintDotNet.PropertySystem;
    using PaintDotNet.Effects;
    using ColorWheelControl = PaintDotNet.ColorBgra;
    using AngleControl = System.Double;
    using PanSliderControl = PaintDotNet.Pair<double,double>;
    using FilenameControl = System.String;
    using ReseedButtonControl = System.Byte;
    using RollControl = System.Tuple<double, double, double>;
    using IntSliderControl = System.Int32;
    using CheckboxControl = System.Boolean;
    using TextboxControl = System.String;
    using DoubleSliderControl = System.Double;
    using ListBoxControl = System.Byte;
    using RadioButtonControl = System.Byte;
    using MultiLineTextboxControl = System.String;
    
    [assembly: AssemblyTitle("Lyapunov Fractal plugin for Paint.NET")]
    [assembly: AssemblyDescription("Generates Markus-Lyapunov Fractal")]
    [assembly: AssemblyConfiguration("fractal")]
    [assembly: AssemblyCompany("Reptorian")]
    [assembly: AssemblyProduct("Lyapunov Fractal")]
    [assembly: AssemblyCopyright("Copyright ©2021 by Reptorian")]
    [assembly: AssemblyTrademark("")]
    [assembly: AssemblyCulture("")]
    [assembly: ComVisible(false)]
    [assembly: AssemblyVersion("1.0.*")]
    
    namespace LyapunovFractalEffect
    {
        public class PluginSupportInfo : IPluginSupportInfo
        {
            public string Author
            {
                get
                {
                    return base.GetType().Assembly.GetCustomAttribute<AssemblyCopyrightAttribute>().Copyright;
                }
            }
    
            public string Copyright
            {
                get
                {
                    return base.GetType().Assembly.GetCustomAttribute<AssemblyDescriptionAttribute>().Description;
                }
            }
    
            public string DisplayName
            {
                get
                {
                    return base.GetType().Assembly.GetCustomAttribute<AssemblyProductAttribute>().Product;
                }
            }
    
            public Version Version
            {
                get
                {
                    return base.GetType().Assembly.GetName().Version;
                }
            }
    
            public Uri WebsiteUri
            {
                get
                {
                    return new Uri("https://forums.getpaint.net/profile/85868-reptillian/?ct=1626304395");
                }
            }
        }
    
        [PluginSupportInfo(typeof(PluginSupportInfo), DisplayName = "Markus-Lyapunov Fractal")]
        public class LyapunovFractalEffectPlugin : PropertyBasedEffect
        {
            public static string StaticName
            {
                get
                {
                    return "Markus-Lyapunov Fractal";
                }
            }
    
            public static Image StaticIcon
            {
                get
                {
                    return new Bitmap(typeof(LyapunovFractalEffectPlugin), "lyapunov_icon.png");
                }
            }
    
            public static string SubmenuName
            {
                get
                {
                    return SubmenuNames.Render;
                }
            }
    
            public LyapunovFractalEffectPlugin()
                : base(StaticName, StaticIcon, SubmenuName, new EffectOptions() { Flags = EffectFlags.Configurable })
            {
                instanceSeed = unchecked((int)DateTime.Now.Ticks);
            }
    
            public enum PropertyNames
            {
                Str_var,
                Abc_repeats,
                View_size,
                View_pos,
                C_pos,
                Output_mode,
                Revert_mode,
                Split_mode,
                Num_of_cols,
                Num_of_cols_a,
                Num_of_cols_b,
                Seed,
                Color_a,
                Color_b
            }
    
            public enum Output_modeOptions
            {
                Output_modeOption1,
                Output_modeOption2,
                Output_modeOption3
            }
    
            [ThreadStatic]
            private static Random RandomNumber;
    
            private int randomSeed;
            private int instanceSeed;
    
    
            protected override PropertyCollection OnCreatePropertyCollection()
            {
                ColorBgra PrimaryColor = EnvironmentParameters.PrimaryColor.NewAlpha(byte.MaxValue);
                ColorBgra SecondaryColor = EnvironmentParameters.SecondaryColor.NewAlpha(byte.MaxValue);
    
                List<Property> props = new List<Property>();
    
                props.Add(new StringProperty(PropertyNames.Str_var, "ABC", 255));
                props.Add(new Int32Property(PropertyNames.Abc_repeats, 100, 1, 100));
                props.Add(new DoubleProperty(PropertyNames.View_size, 99, 0.1, 100));
                props.Add(new DoubleVectorProperty(PropertyNames.View_pos, Pair.Create(0.000, 0.000), Pair.Create(-1.0, -1.0), Pair.Create(+1.0, +1.0)));
                props.Add(new DoubleProperty(PropertyNames.C_pos, 0, -1, 1));
                Output_modeOptions Output_modeDefault = (Enum.IsDefined(typeof(Output_modeOptions), 2)) ? (Output_modeOptions)2 : 0;
                props.Add(StaticListChoiceProperty.CreateForEnum<Output_modeOptions>(PropertyNames.Output_mode, Output_modeDefault, false));
                props.Add(new BooleanProperty(PropertyNames.Revert_mode, false));
                props.Add(new BooleanProperty(PropertyNames.Split_mode, false));
                props.Add(new Int32Property(PropertyNames.Num_of_cols, 10, 1, 100));
                props.Add(new Int32Property(PropertyNames.Num_of_cols_a, 10, 1, 100));
                props.Add(new Int32Property(PropertyNames.Num_of_cols_b, 10, 1, 100));
                props.Add(new Int32Property(PropertyNames.Seed, 0, 0, 255));
                props.Add(new Int32Property(PropertyNames.Color_a, ColorBgra.ToOpaqueInt32(Color.Blue), 0, 0xffffff));
                props.Add(new Int32Property(PropertyNames.Color_b, ColorBgra.ToOpaqueInt32(Color.Yellow), 0, 0xffffff));
    
                List<PropertyCollectionRule> propRules = new List<PropertyCollectionRule>();
    
                propRules.Add(new ReadOnlyBoundToValueRule<object, StaticListChoiceProperty>(PropertyNames.Revert_mode, PropertyNames.Output_mode, Output_modeOptions.Output_modeOption1, true));
                propRules.Add(new ReadOnlyBoundToValueRule<object, StaticListChoiceProperty>(PropertyNames.Split_mode, PropertyNames.Output_mode, new object[] { Output_modeOptions.Output_modeOption3 }, true));
                propRules.Add(new ReadOnlyBoundToValueRule<object, StaticListChoiceProperty>(PropertyNames.Num_of_cols, PropertyNames.Output_mode, new object[] { Output_modeOptions.Output_modeOption3}, true));
                propRules.Add(new ReadOnlyBoundToBooleanRule(PropertyNames.Num_of_cols, PropertyNames.Split_mode, false));
                propRules.Add(new ReadOnlyBoundToValueRule<object, StaticListChoiceProperty>(PropertyNames.Num_of_cols_a, PropertyNames.Output_mode, new object[] { Output_modeOptions.Output_modeOption3 }, true));
                propRules.Add(new ReadOnlyBoundToBooleanRule(PropertyNames.Num_of_cols_a, PropertyNames.Split_mode, true));
                propRules.Add(new ReadOnlyBoundToValueRule<object, StaticListChoiceProperty>(PropertyNames.Num_of_cols_b, PropertyNames.Output_mode, new object[] { Output_modeOptions.Output_modeOption3 }, true));
                propRules.Add(new ReadOnlyBoundToBooleanRule(PropertyNames.Num_of_cols_b, PropertyNames.Split_mode, true));
                propRules.Add(new ReadOnlyBoundToValueRule<object, StaticListChoiceProperty>(PropertyNames.Seed, PropertyNames.Output_mode, new object[] { Output_modeOptions.Output_modeOption3 }, true));
                propRules.Add(new ReadOnlyBoundToValueRule<object, StaticListChoiceProperty>(PropertyNames.Color_a, PropertyNames.Output_mode, new object[] { Output_modeOptions.Output_modeOption2 }, true));
                propRules.Add(new ReadOnlyBoundToValueRule<object, StaticListChoiceProperty>(PropertyNames.Color_b, PropertyNames.Output_mode, new object[] { Output_modeOptions.Output_modeOption2 }, true));
    
    
                return new PropertyCollection(props, propRules);
            }
    
            protected override ControlInfo OnCreateConfigUI(PropertyCollection props)
            {
                Rectangle selection = EnvironmentParameters.SelectionBounds;
                ImageResource imageResource = ImageResource.FromImage(EnvironmentParameters.SourceSurface.CreateAliasedBitmap(selection));
    
                ControlInfo configUI = CreateDefaultConfigUI(props);
    
                configUI.SetPropertyControlValue(PropertyNames.Str_var, ControlInfoPropertyNames.DisplayName, "ABC-String");
                configUI.SetPropertyControlValue(PropertyNames.Abc_repeats, ControlInfoPropertyNames.DisplayName, "ABC-String Repeats");
                configUI.SetPropertyControlValue(PropertyNames.View_size, ControlInfoPropertyNames.DisplayName, "View Size (%)");
                configUI.SetPropertyControlValue(PropertyNames.View_size, ControlInfoPropertyNames.SliderLargeChange, 0.25);
                configUI.SetPropertyControlValue(PropertyNames.View_size, ControlInfoPropertyNames.SliderSmallChange, 0.05);
                configUI.SetPropertyControlValue(PropertyNames.View_size, ControlInfoPropertyNames.UpDownIncrement, 0.01);
                configUI.SetPropertyControlValue(PropertyNames.View_size, ControlInfoPropertyNames.DecimalPlaces, 3);
                configUI.SetPropertyControlValue(PropertyNames.View_pos, ControlInfoPropertyNames.DisplayName, "View Position");
                configUI.SetPropertyControlValue(PropertyNames.View_pos, ControlInfoPropertyNames.SliderSmallChangeX, 0.05);
                configUI.SetPropertyControlValue(PropertyNames.View_pos, ControlInfoPropertyNames.SliderLargeChangeX, 0.25);
                configUI.SetPropertyControlValue(PropertyNames.View_pos, ControlInfoPropertyNames.UpDownIncrementX, 0.01);
                configUI.SetPropertyControlValue(PropertyNames.View_pos, ControlInfoPropertyNames.SliderSmallChangeY, 0.05);
                configUI.SetPropertyControlValue(PropertyNames.View_pos, ControlInfoPropertyNames.SliderLargeChangeY, 0.25);
                configUI.SetPropertyControlValue(PropertyNames.View_pos, ControlInfoPropertyNames.UpDownIncrementY, 0.01);
                configUI.SetPropertyControlValue(PropertyNames.View_pos, ControlInfoPropertyNames.DecimalPlaces, 3);
                configUI.SetPropertyControlValue(PropertyNames.View_pos, ControlInfoPropertyNames.StaticImageUnderlay, imageResource);
                configUI.SetPropertyControlValue(PropertyNames.C_pos, ControlInfoPropertyNames.DisplayName, "C Position");
                configUI.SetPropertyControlValue(PropertyNames.C_pos, ControlInfoPropertyNames.SliderLargeChange, 0.25);
                configUI.SetPropertyControlValue(PropertyNames.C_pos, ControlInfoPropertyNames.SliderSmallChange, 0.05);
                configUI.SetPropertyControlValue(PropertyNames.C_pos, ControlInfoPropertyNames.UpDownIncrement, 0.01);
                configUI.SetPropertyControlValue(PropertyNames.C_pos, ControlInfoPropertyNames.DecimalPlaces, 3);
                configUI.SetPropertyControlValue(PropertyNames.Output_mode, ControlInfoPropertyNames.DisplayName, "Mode");
                PropertyControlInfo Output_modeControl = configUI.FindControlForPropertyName(PropertyNames.Output_mode);
                Output_modeControl.SetValueDisplayName(Output_modeOptions.Output_modeOption1, "Grayscale");
                Output_modeControl.SetValueDisplayName(Output_modeOptions.Output_modeOption2, "Duotone");
                Output_modeControl.SetValueDisplayName(Output_modeOptions.Output_modeOption3, "HSL");
                configUI.SetPropertyControlValue(PropertyNames.Revert_mode, ControlInfoPropertyNames.DisplayName, string.Empty);
                configUI.SetPropertyControlValue(PropertyNames.Revert_mode, ControlInfoPropertyNames.Description, "Reverted Mode");
                configUI.SetPropertyControlValue(PropertyNames.Split_mode, ControlInfoPropertyNames.DisplayName, string.Empty);
                configUI.SetPropertyControlValue(PropertyNames.Split_mode, ControlInfoPropertyNames.Description, "Split HSL");
                configUI.SetPropertyControlValue(PropertyNames.Num_of_cols, ControlInfoPropertyNames.DisplayName, "#Colors for Singular HSL");
                configUI.SetPropertyControlValue(PropertyNames.Num_of_cols_a, ControlInfoPropertyNames.DisplayName, "Positive HSL Colors");
                configUI.SetPropertyControlValue(PropertyNames.Num_of_cols_b, ControlInfoPropertyNames.DisplayName, "Negative HSL Colors");
                configUI.SetPropertyControlValue(PropertyNames.Seed, ControlInfoPropertyNames.DisplayName, string.Empty);
                configUI.SetPropertyControlType(PropertyNames.Seed, PropertyControlType.IncrementButton);
                configUI.SetPropertyControlValue(PropertyNames.Seed, ControlInfoPropertyNames.ButtonText, "Reseed");
                configUI.SetPropertyControlValue(PropertyNames.Color_a, ControlInfoPropertyNames.DisplayName, "Positive Color");
                configUI.SetPropertyControlType(PropertyNames.Color_a, PropertyControlType.ColorWheel);
                configUI.SetPropertyControlValue(PropertyNames.Color_b, ControlInfoPropertyNames.DisplayName, "Negative Color");
                configUI.SetPropertyControlType(PropertyNames.Color_b, PropertyControlType.ColorWheel);
    
                return configUI;
            }
    
            protected override void OnCustomizeConfigUIWindowProperties(PropertyCollection props)
            {
                // Change the effect's window title
                props[ControlInfoPropertyNames.WindowTitle].Value = "Markus-Lyapunov Fractal";
                // Add help button to effect UI
                props[ControlInfoPropertyNames.WindowHelpContentType].Value = WindowHelpContentType.PlainText;
                props[ControlInfoPropertyNames.WindowHelpContent].Value = "Markus-Lyapunov Fractal v1.0\nCopyright ©2021 by Reptorian\nAll rights reserved.";
                base.OnCustomizeConfigUIWindowProperties(props);
            }
    
            protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken token, RenderArgs dstArgs, RenderArgs srcArgs)
            {
                str_var = token.GetProperty<StringProperty>(PropertyNames.Str_var).Value;
                abc_repeats = token.GetProperty<Int32Property>(PropertyNames.Abc_repeats).Value;
                view_size = token.GetProperty<DoubleProperty>(PropertyNames.View_size).Value;
                view_pos = token.GetProperty<DoubleVectorProperty>(PropertyNames.View_pos).Value;
                c_pos = token.GetProperty<DoubleProperty>(PropertyNames.C_pos).Value;
                output_mode = (byte)(int)token.GetProperty<StaticListChoiceProperty>(PropertyNames.Output_mode).Value;
                revert_mode = token.GetProperty<BooleanProperty>(PropertyNames.Revert_mode).Value;
                split_mode = token.GetProperty<BooleanProperty>(PropertyNames.Split_mode).Value;
                num_of_cols = token.GetProperty<Int32Property>(PropertyNames.Num_of_cols).Value;
                num_of_cols_a = token.GetProperty<Int32Property>(PropertyNames.Num_of_cols_a).Value;
                num_of_cols_b = token.GetProperty<Int32Property>(PropertyNames.Num_of_cols_b).Value;
                seed = (byte)token.GetProperty<Int32Property>(PropertyNames.Seed).Value;
                randomSeed = seed;
                color_a = ColorBgra.FromOpaqueInt32(token.GetProperty<Int32Property>(PropertyNames.Color_a).Value);
                color_b = ColorBgra.FromOpaqueInt32(token.GetProperty<Int32Property>(PropertyNames.Color_b).Value);
    
                PreRender(dstArgs.Surface, srcArgs.Surface);
    
                base.OnSetRenderInfo(token, dstArgs, srcArgs);
            }
    
            protected override unsafe void OnRender(Rectangle[] rois, int startIndex, int length)
            {
                if (length == 0) return;
                RandomNumber = GetRandomNumberGenerator(rois, startIndex);
                for (int i = startIndex; i < startIndex + length; ++i)
                {
                    Render(DstArgs.Surface,SrcArgs.Surface,rois[i]);
                }
            }
    
            private Random GetRandomNumberGenerator(Rectangle[] rois, int startIndex)
            {
                Rectangle roi = rois[startIndex];
                return new Random(instanceSeed ^ (randomSeed << 16) ^ (roi.X << 8) ^ roi.Y);
            }
    
            #region User Entered Code
            // Name: Markus-Lyapunov Fractal
            // Submenu: Render
            // Author: Reptorian
            // Title: Markus-Lyapunov Fractal
            // Version: .5
            // Desc: Generates Markus-Lyapunov Fractal
            // Keywords: Fractal
            // URL: https://forums.getpaint.net/profile/85868-reptillian/?ct=1626304395
            // Help:
            #region UICode
            TextboxControl str_var = "ABC"; // [255] ABC-String
            IntSliderControl abc_repeats = 100; // [1,100] ABC-String Repeats
            DoubleSliderControl view_size = 99; // [0.1,100] View Size (%)
            PanSliderControl view_pos = Pair.Create(0.000, 0.000); // View Position
            DoubleSliderControl c_pos = 0; // [-1,1] C Position
            ListBoxControl output_mode = 2; // Mode|Grayscale|Duotone|HSL
            CheckboxControl revert_mode = false; // {output_mode} Reverted Mode
            CheckboxControl split_mode = false; // Split HSL
            IntSliderControl num_of_cols = 10; // [1,100] {!split_mode} #Colors for Singular HSL
            IntSliderControl num_of_cols_a = 10; // [1,100] {split_mode} Positive HSL Colors
            IntSliderControl num_of_cols_b = 10; // [1,100] {split_mode} Negative HSL Colors
            ReseedButtonControl seed = 0; // Reseed
            ColorWheelControl color_a = ColorBgra.FromBgr(255, 0, 0); // [Blue] Positive Color
            ColorWheelControl color_b = ColorBgra.FromBgr(0, 255, 255); // [Yellow] Negative Color
            #endregion
            
            string old_str_var;
            int old_abc_repeats;
            double old_view_size;
            double old_view_pos_first;
            double old_view_pos_second;
            double old_c_pos;
            
            int[] i_var;
            int s_str_var;
            int old_num_of_cols;
            int old_num_of_cols_a;
            int old_num_of_cols_b;
            bool validity;
            bool status_changed;
            
            double[,] Lyapunov_Surface;
            double[] hue;
            double[] saturation;
            double[] lightness;
            double[] hue_a;
            double[] saturation_a;
            double[] lightness_a;
            double[] hue_b;
            double[] saturation_b;
            double[] lightness_b;
            
            double iM;
            double im;
            double hpi = Math.PI*2;
            
            int new_seed;
            bool generate_new_color_set = false;
            
            double contrast(double a){
                double b=a*Math.PI-hpi;
                return .5*(a*a)+.5*(Math.Sin(b)+1)/2;
            }
            
            double lerp(double a, double b, double t){
                return a * (1 - t) + b * t ;
            }
            
            ColorBgra hsl2rgb(double H,double S,double L){
                int iH = (int)(H)/60;
                double C = (1-Math.Abs(2*L-1))*S;
                double X = C * (1 - Math.Abs((H/60)%2-1));
                double m = L - C/2;
                double tr,tg,tb;
                switch(iH){
                    case 0:
                        tr=C;
                        tg=X;
                        tb=0;
                        break;
                    case 1:
                        tr=X;
                        tg=C;
                        tb=0;
                        break;
                    case 2:
                        tr=0;
                        tg=C;
                        tb=X;
                        break;
                    case 3:
                        tr=0;
                        tg=X;
                        tb=C;
                        break;
                    case 4:
                        tr=X;
                        tg=0;
                        tb=C;
                        break;
                    default:
                        tr=C;
                        tg=0;
                        tb=X;
                        break;
                }
                tr+=m;
                tg+=m;
                tb+=m;
                tr*=255;
                tg*=255;
                tb*=255;
                tr=Math.Round(tr);
                tg=Math.Round(tg);
                tb=Math.Round(tb);
                return ColorBgra.FromBgraClamped((int)(tb),(int)(tg),(int)(tr),255);
            }
            
            ColorBgra out_hsl(double hue_a,double hue_b,double sat_a,double sat_b,double intensity_a,double intensity_b,double pos){
                double new_pos = pos - Math.Floor(pos);
                double H = lerp(hue_a,hue_b,new_pos);
                double S = lerp(sat_a,sat_b,new_pos);
                double L = lerp(intensity_a,intensity_b,new_pos);
                return hsl2rgb(H,S,L);
            }
            
            int rs,rs_a,rs_b;
            
            Random Init = new Random();
            Random Seed = new Random();
            Random Seed_A = new Random();
            Random Seed_B = new Random();
            bool finished_init;
            
            Random myRandom,myRandomA,myRandomB;
            
            void PreRender(Surface dst, Surface src){
            
                if (!finished_init){
                    status_changed=true;
                    rs=Init.Next();
                    rs_a=Init.Next();
                    rs_b=Init.Next();
                    myRandom = new Random(rs);
                    myRandomA = new Random(rs_a);
                    myRandomB = new Random(rs_b);
                }
                else{
                    if(
                     (old_str_var!=str_var)||
                     (old_abc_repeats!=abc_repeats)||
                     (old_view_size!=view_size)||
                     (old_view_pos_first!=view_pos.First)||
                     (old_view_pos_second!=view_pos.Second)||
                     (old_c_pos!=c_pos)
                    ){
                        status_changed=true;
                    }
                }
            
                if (new_seed != seed){
                    rs=Seed.Next();
                    rs_a=Seed_A.Next();
                    rs_b=Seed_B.Next();
                    myRandom = new Random(rs);
                    myRandomA = new Random(rs_a);
                    myRandomB = new Random(rs_b);
                } 
                else{
                    myRandom = new Random(rs);
                    myRandomA = new Random(rs_a);
                    myRandomB = new Random(rs_b);
                }
            
                if (old_num_of_cols != num_of_cols || old_num_of_cols_a != num_of_cols_a || old_num_of_cols_b != num_of_cols_b){
                    generate_new_color_set = true;
                }
            
                old_num_of_cols=num_of_cols;
                old_num_of_cols_a=num_of_cols_a;
                old_num_of_cols_b=num_of_cols_b;
                new_seed = seed;
            
                int w = src.Width;
                int h = src.Height;
                int inc_w = w + 1;
                int inc_h = h + 1;
            
                if (Lyapunov_Surface == null){Lyapunov_Surface = new double [w,h];}
            
                string low_str = str_var.ToLower();
                s_str_var = low_str.Length;
                char[] charArr=low_str.ToCharArray();
                i_var = new int[s_str_var];
            
                validity = true;
            
                bool a_valid = false ;
                bool b_valid = false ;
            
                if (s_str_var==0){
                    validity = false;
                    return;
                }
            
                for(int pos = 0 ; pos < s_str_var ; pos++){
                    i_var[pos]=(int) charArr[pos] - 97;
                    if (i_var[pos]<0||i_var[pos]>2){
                        validity = false;
                        break;
                    }
                    else{
                        switch(i_var[pos]){
                            case 0:
                                a_valid = true;
                                break;
                            case 1:
                                b_valid = true;
                                break;
                            default:
                                break;
                        }
                    }
                }
            
                if (!a_valid||!b_valid){
                    validity = false;
                    return;
                }
            
                if (generate_new_color_set){
            
                    hue = new double[num_of_cols];
                    saturation = new double[num_of_cols];
                    lightness = new double[num_of_cols];
            
                    hue_a = new double[num_of_cols_a];
                    saturation_a = new double[num_of_cols_a];
                    lightness_a = new double[num_of_cols_a];
            
                    hue_b = new double[num_of_cols_b];
                    saturation_b = new double[num_of_cols_b];
                    lightness_b = new double[num_of_cols_b];
            
                    int precision = 100000;
                    for (int n = 0 ; n < num_of_cols ; n++){
                        hue[n] = ((double)(myRandom.Next(precision)) / (double)(precision)) * 359.999999;
                        saturation[n] = ((double)(myRandom.Next(precision)) / (double)(precision));
                        lightness[n] = ((double)(myRandom.Next(precision)) / (double)(precision));
                    }
            
                    for (int n = 0 ; n < num_of_cols_a ; n++){
                        hue_a[n] = ((double)(myRandomA.Next(precision)) / (double)(precision)) * 359.999999;
                        saturation_a[n] = ((double)(myRandomA.Next(precision)) / (double)(precision));
                        lightness_a[n] = ((double)(myRandomA.Next(precision)) / (double)(precision));
                    }
            
                    for (int n=0 ; n < num_of_cols_b ; n++){
                        hue_b[n] = ((double)(myRandomB.Next(precision)) / (double)(precision)) * 359.999999;
                        saturation_b[n] = ((double)(myRandomB.Next(precision)) / (double)(precision));
                        lightness_b[n] = ((double)(myRandomB.Next(precision)) / (double)(precision));
                    }
                }
            
                float sqr_size = (float)(view_size /100);
                float gap = 1 - sqr_size ;
                float px = (float)((view_pos.First + 1) / 2);
                float py = (float)((view_pos.Second*-1 + 1) / 2);
                px*=gap;
                py*=gap;
                float lx = px * 2 + 2;
                float ly = py * 2 + 2;
                float rx = (px + sqr_size) * 2 + 2;
                float ry = (py + sqr_size) * 2 + 2;
                double md = 1/Math.Max(w,h);
                double iz = (float)((c_pos+1)/2*(2-md)+(2+md));
            
                int total_string_length = s_str_var  * abc_repeats;
                int sp;
            
                double cx,cy,ix,iy,vn,limit,rn;
            
                float f_inc_w = (float)(inc_w+1);
                float f_inc_h = (float)(inc_h+1);
            
                if (status_changed){
                    im = 0;
                    iM = 0;
                    Array.Clear(Lyapunov_Surface, 0, w*h);
                    for(int x = 0 ; x < w ; x++){
                        for(int y = 0 ; y < h ; y++){
                            cx = (double)(x + 1);
                            cy = (double)(y + 1);
                            ix = lerp(lx,rx,cx/f_inc_w);
                            iy = lerp(ry,ly,cy/f_inc_h);
                            vn = .5f;
                            limit = 0;
                            for (int n = 0 ; n < total_string_length ; n++){
                                sp = n % s_str_var;
                                sp = i_var[sp];
                                switch(sp){
                                    case 0:rn=ix;break;
                                    case 1:rn=iy;break;
                                    case 2:rn=iz;break;
                                    default:rn=1;break;
                                }
                                vn=rn*vn*(1-vn);
                                limit+=(float)(Math.Log(Math.Abs((double)(rn*(1-2*vn)))));
                            }
                            if(limit < im) {im = limit;}
                            if(limit > iM) {iM = limit;}
                            Lyapunov_Surface[x,y] = limit;
                        }
                    }
                }
            
                finished_init=true;
                old_str_var=str_var;
                old_abc_repeats=abc_repeats;
                old_view_size=view_size;
                old_view_pos_first=view_pos.First;
                old_view_pos_second=view_pos.Second;
                old_c_pos=c_pos;
    
                status_changed = false;
            }
            
            void Render(Surface dst, Surface src, Rectangle rect)
            {
                if (validity)
                {
                    int thick = src.Width / s_str_var;
                    int represent;
                    byte r;
            
                    double tv,shade;
                    int ltv;
                    int rtv;
                    double rescale_factor = (iM-im)/255f;
            
                    double d_r_a = (double)(color_a[2]);
                    double d_g_a = (double)(color_a[1]);
                    double d_b_a = (double)(color_a[0]);
            
                    double d_r_b = (double)(color_b[2]);
                    double d_g_b = (double)(color_b[1]);
                    double d_b_b = (double)(color_b[0]);
            
                    double nr,ng,nb;
            
                    double rescale_2_num_of_colors = (iM-im)/((double)(num_of_cols)-1);
                    double num_of_colors_a = (double)(num_of_cols_a)-1;
                    double num_of_colors_b = (double)(num_of_cols_b)-1;
            
            
                    for (int y = rect.Top; y < rect.Bottom; y++)
                    {
                        if (IsCancelRequested) return;
                        for (int x = rect.Left; x < rect.Right; x++)
                        {
                            switch(output_mode)
                            {
                                case 0:
                                    tv = (Lyapunov_Surface[x,y]-im)/rescale_factor;
                                    if (revert_mode)
                                    {
                                        represent = 255 -(int)(tv);
                                    }
                                    else
                                    {
                                        represent = (int)(tv);
                                    }
                                    r = (byte)(represent);
                                    dst[x,y] = ColorBgra.FromBgraClamped(r,r,r,255);
                                
                                    break;
                                case 1:
                                    if(Lyapunov_Surface[x,y] >= 0)
                                    {
                                        shade = Lyapunov_Surface[x,y] / iM;
                                        nr = d_r_a * shade;
                                        ng = d_g_a * shade;
                                        nb = d_b_a * shade;
                                    }
                                    else
                                    {
                                        shade = Math.Pow(1 - Lyapunov_Surface[x,y] / im,3);
                                        nr = d_r_b * shade;
                                        ng = d_g_b * shade;
                                        nb = d_b_b * shade;
                                    }
            
                                    dst[x,y] = ColorBgra.FromBgraClamped((byte)((int)(nb)),(byte)((int)(ng)),(byte)((int)(nr)),255);
                                    break;
                                case 2:
                                    if (split_mode){
                                        if(Lyapunov_Surface[x,y]>=0){
                                            tv=Lyapunov_Surface[x,y]/iM*num_of_colors_a;
                                            ltv= (int)(Math.Floor(tv));
                                            rtv= (int)(Math.Ceiling(tv));
                                            dst[x,y]=out_hsl(hue_a[ltv],hue_a[rtv],saturation_a[ltv],saturation_a[rtv],lightness_a[ltv],lightness_a[rtv],tv);
                                        }
                                        else
                                        {
                                            tv=Lyapunov_Surface[x,y]/im*num_of_colors_b;
                                            ltv= (int)(Math.Floor(tv));
                                            rtv= (int)(Math.Ceiling(tv));
                                            dst[x,y]=out_hsl(hue_b[ltv],hue_b[rtv],saturation_b[ltv],saturation_b[rtv],lightness_b[ltv],lightness_b[rtv],tv);
                                        }
                                    }
                                    else
                                    {
                                        tv = (Lyapunov_Surface[x,y]-im)/rescale_2_num_of_colors;
                                        ltv= (int)(Math.Floor(tv));
                                        rtv= (int)(Math.Ceiling(tv));
                                        dst[x,y]=out_hsl(hue[ltv],hue[rtv],saturation[ltv],saturation[rtv],lightness[ltv],lightness[rtv],tv);
                                    }
                                    break;                   
                            }
                        }
                    }
                }
            }
            #endregion
        }
    }

     

    G'MIC

    Spoiler
    #@cli rep_mlfrac: eq. to 'rep_markus_lyapunov_fractal : (+)
    rep_mlfrac: rep_markus_lyapunov_fractal $*
    #@cli rep_markus_lyapunov_fractal: abc_string,abc_string_repeats,_sublevel>=0,0%<_view_size[%]<=100%,0%<=_pos_x[%]<=100%,0%<=_pos_y[%]<=100%,0%<=_pos_z[%]<=100%,additional_arguments(see below)
    #@cli : Generate Markus-Lyapunov Fractal or in other words, creates a mapping of Lyapunov exponent within two or three values.[1] Discovered by Mario Markus of the Max Planck Institute for Nutrition. Alexander Lyapunov was the one that discovered Lyapunov exponent.
    #@cli :
    #@cli : [1] http://charles.vassallo.pagesperso-orange.fr/en/lyap_art/lyapdoc.html
    #@cli :
    #@cli : (eq. to 'rep_mlfrac')
    #@cli : Note: Input for abc_string is case-insensitive. Only valid characters are A,a,B,b,C,c.
    #@cli :
    #@cli : --- Information on 'additional_arguments' ---
    #@cli : The following set of arguments are accepted as additional arguments for the command:
    #@cli : 
    #@cli : 1 - use_inversion={ 0=do_not_use_inversion | 1=use_inversion }
    #@cli : 2* - hex_color_a,hex_color_b
    #@cli : 3** - 'u',color_count>0,color_space={ 0=hsl | 1=lab | 2=lch }
    #@cli : 4** - 'u','u',n_colors_a>0,n_colors_b>0,cs={ 0=hsl | 1=lab | 2=lch }
    #@cli : 5*** - [image],order={ 0=default | 1=random | 2=mirrored },color_count
    #@cli : 6*** - [image],[image],order_a={ 0=default | 1=random | 2=mirrored },use_randomize_b={ 0=default | 1=random | 2=mirrored },color_count_a,color_count_b
    #@cli :
    #@cli : * = No special characters or space! Only 0-9 and a-f case-insensitive.
    #@cli : ** = 'u' means that the input you assigned is exactly 'u'.
    #@cli : *** = If you assign a image with width and height both larger than 1, then you need to assign color_count in the respective place. use_randomize is used to randomize the colors in palette.
    #@cli :
    #@cli : Notes: See examples for usage of these additional variables.
    #@cli :
    #@cli : --- End of Information on 'additional_arguments' ---
    #@cli : Default values: '_sublevel=1','_view_size=100%','_pos_x=50%','_pos_y=50%'
    #@cli :
    #@cli : Author: Reptorian.
    #@cli : $ 500,500 rep_markus_lyapunov_fractal ab,50,3,100%,50%,50%,50%,1
    #@cli : $ 500,500 rep_markus_lyapunov_fractal ab,50,3,100%,50%,50%,50%,0000ff,ffff00
    #@cli : $ 500,500 rep_markus_lyapunov_fractal ab,50,3,100%,50%,50%,50%,u,8,1
    #@cli : $ 500,500 rep_markus_lyapunov_fractal ab,50,3,100%,50%,50%,50%,u,u,5,8,2
    #@cli : $ 500,500 pal 71 rep_markus_lyapunov_fractal[0] ab,50,3,100%,50%,50%,50%,[1],0 rm.
    #@cli : $ 500,500 pal 20 pal 50 rep_markus_lyapunov_fractal[0] ab,50,3,100%,50%,50%,50%,[1],[2],0,0 rm[-2,-1]
    #@cli : $ 500,500 sp cat rep_markus_lyapunov_fractal[0] ab,50,3,100%,50%,50%,50%,[1],0,9 rm.
    #@cli : $ 500,500 sp cat sp lena rep_markus_lyapunov_fractal[0] ab,50,3,100%,50%,50%,50%,[-2],[-1],1,1,8,8 rm[-2,-1]
    rep_markus_lyapunov_fractal:
    skip "${3=1}","${4=100%}","${5=50%}","${6=50%}","${7=50%}","${8=0}","${9=}","${10=}","${11=}","${12=}","${13=}"
    check "abs($4)!=0"
    
    strlowercase $1
    ab_string=${}
    ('$ab_string') -. 97
    
    if im#-1<0||iM#-1>2 error invalid_char_found! fi
    
    include_a={im#-1==0}
    include_b={find(crop(#-1),1,0,1)!=-1}
    include_c={iM#-1==2}
    
    case_d1={!($include_a&&$include_b)}
    case_dn={!(!$case_d1&&$include_c)}
    
    ab_string={crop(#-1)}
    rm.
    
    mode=0
    use_double_u=0
    use_hex_mode=0
    
    sub={abs($3)+1}
    
    if narg($8)||narg($9)
    
     if ${is_image_arg\ $8} mode+=1
      pass$8 0
     fi
     if ${is_image_arg\ $9} mode+=1 
      pass$9 0
     fi
     
     if $mode==2
     
      if w#-2>1&&h#-2>1
       colormap.. $12
       if ($10%3)==1
        {w#-2},1,1,1,u(0,1) 
        pixelsort... +,x,[-1] 
        rm. 
       elif ($10%3)==2 
        mirror.. x 
       fi
       find_color_a=I(#-1,lyapunov_surface/minv*v_length_b,0,0,1);
      else
       if w#-2>1
        if ($10%3)==1
         {w#-2},1,1,1,u(0,1) 
         pixelsort... +,x,[-1] 
         rm.
        elif ($10%3)==2
         mirror.. x
        fi
        find_color_a=I(#-1,lyapunov_surface/minv*v_length_b,0,0,1);
       else
        if ($10%3)==1
         1,{h#-2},1,1,u(0,1) 
         pixelsort... +,y,[-1] 
         rm.
        elif ($10%3)==2
         mirror.. y
        fi
        find_color_a=I(#-1,0,lyapunov_surface/minv*v_length_b,0,1);
       fi
      fi
    
      if w#-1>1&&h#-1>1
       colormap. $13
       if ($11%3)==1
        {w},1,1,1,u(0,1) 
        pixelsort.. +,x,[-1] 
        rm.
       elif ($11%3)==2
        mirror. x
       fi
       find_color_b=I(#-2,lyapunov_surface/maxv*v_length_a,0,0,1);
      else
       if w#-1>1
        if ($11%3)==1
         {w},1,1,1,u(0,1) 
         pixelsort.. +,x,[-1] 
         rm.
        elif ($11%3)==2
         mirror. x
        fi
        find_color_b=I(#-2,lyapunov_surface/maxv*v_length_a,0,0,1);
       else
        if ($11%3)==1
         1,{h},1,1,u(0,1) 
         pixelsort.. +,y,[-1] 
         rm.
        elif ($11%3)==2
         mirror. y
        fi
        find_color_b=I(#-2,0,lyapunov_surface/maxv*v_length_a,0,1);
       fi
      fi
      
      store. ref_colors_b
      store. ref_colors_a
      
     elif $mode==1
     
      if w>1&&h>1
       colormap. $10
       if ($9%3)==1
        {w},1,1,1,u(0,1) 
        pixelsort.. +,x,[-1] 
        rm.
       elif ($9%3)==2
        mirror. x
       fi
       find_color_a=I(#-1,lyapunov_surface,0,0,1)
      else
       if w>1
        if ($9%3)==1
         {w},1,1,1,u(0,1) 
         pixelsort.. +,x,[-1] 
         rm.
        elif ($9%3)==2
         mirror. x
        fi
        find_color_a=I(#-1,lyapunov_surface,0,0,1)
       else
        if ($9%3)==1
         1,{h},1,1,u(0,1) 
         pixelsort.. +,y,[-1] 
         rm.
        elif ($9%3)==2
         mirror. y
        fi
        find_color_a=I(#-1,0,lyapunov_surface,0,1)
       fi
      fi
      store. ref_gradient
      
     else
     
      if ('$8'=='u')&&('$9'=='u')
      
       mode=3
       use_double_u=1
       if narg($10)&&narg($11)
        if narg($12)
         if ($12%3)==2 m "cs_out: lch82rgb"
         elif ($12%3)==1 m "cs_out: lab82rgb"
         else m "cs_out: hsl82rgb"
         fi
        else m "cs_out: hsl82rgb"
        fi
        $10,1,1,3,u(0,255)
        $11,1,1,3,u(0,255)
        store. ref_rand_col_a
        store. ref_rand_col_b
       else error needs size_arg
       fi
       
      else
      
       if ('$8'=='u')||('$9'=='u')
        mode=3
        if narg($10)
         if ($10%3)==2 m "cs_out: lch82rgb"
         elif ($10%3)==1 m "cs_out: lab82rgb"
         else m "cs_out: hsl82rgb"
         fi
        else m "cs_out: hsl82rgb"
        fi
        if narg($11) srand $11 fi
        if '$8'=='u'
         $9,1,1,3,u(0,255)
         store. ref_colors
        else
         $8,1,1,3,u(0,255)
         store. ref_colors
        fi
       else
        if (!(size('$8')%2))&&(!(size('$9')%2))
         use_hex_mode=1
         hex_color_a=${rep_hex2int8\ $8}
         hex_color_b=${rep_hex2int8\ $9}
        fi
       fi
      fi
      
     fi
     
    fi
    
    out_lyapunov=limit
    if !$mode&&!$use_hex_mode if $8 out_lyapunov=-limit fi fi
    
    repeat $! l[$>]
    
     ow={w}
     oh={h}
     od={d}
     nw={round(w*$sub)}
     nh={round(h*$sub)}
     nd={d>1?d*$sub:1}
     
     if d>1
     
      if $case_dn error "At least one of the abc character is not found!" fi
      
      pz_text="const pz=cut($7,0,1)*gap;"
      lz_text="const lz=pz*2+2;"
      rz_text="const rz=(pz+sqr_size)*2+2;"
      inc_d="const inc_d=d+1;"
      calc_iz_text="iz=lerp(lz,rz,(z+1)/inc_d);"
      
     else
     
      if $case_d1 error "At least one of the ab character is not found!" fi
      
      const_iz_text="const iz=lerp(2+1/(max(w,h,d)+1),2+max(w,h,d)/(max(w,h,d)+1)*2,$7);"
      
     fi
    
     
     $nw,$nh,$nd,1,":begin_t(
     
      const sqr_size=cut(abs($4),0,1);
      const gap=1-sqr_size;
      const px=cut($5,0,1)*gap;
      const py=cut($6,0,1)*gap;
      "$pz_text"
      const lx=px*2+2;
      const ly=py*2+2;
      "$lz_text"
      const rx=(px+sqr_size)*2+2;
      const ry=(py+sqr_size)*2+2;
      "$rz_text"
      const inc_w=w+1;
      const inc_h=h+1;
      "$inc_d"
      "$const_iz_text"
      
      v_sequence=["$ab_string"];
      const seqsize=size(v_sequence);
      const vsize=round(max(1,abs($2))*seqsize);
      
     );
     ix=lerp(lx,rx,(x+1)/inc_w);
     iy=lerp(ry,ly,(y+1)/inc_h);
     "$calc_iz_text"
     vn=0.5;
     limit=0;
     repeat(vsize,n,
      sp = n % seqsize;
      rn=arg(v_sequence[sp]+1,ix,iy,iz);
      vn=rn*vn*(1-vn);
      limit+=log(abs(rn*(1-2*vn)));
     );
     "$out_lyapunov";
     "
     
     if $mode==3
     
      if $use_double_u
       $ref_rand_col_a
       $ref_rand_col_b
       $nw,$nh,$nd,3,"begin_t(
         const minv=im#-3;
         const maxv=iM#-3;
         const ww_a=w#-2-1;
         const ww_b=w#-1-1;
        );
        lyapunov_surface=i0#-3;
        use_b=lyapunov_surface>=0;
        use_b?(I(#-1,lyapunov_surface/maxv*ww_b,0,0,1);)
             :(I(#-2,lyapunov_surface/minv*ww_a,0,0,1););
        "
        cs_out.
      else
       $ref_colors
       $nw,$nh,$nd,3,"begin(
        const minv=im#-2;
        const maxv=iM#-2;
        const vs=w#-1-1;
        const diff=(maxv-minv)/vs;
       );
       lyapunov_surface=(i0#-2-minv)/diff;
       I(#-1,lyapunov_surface,0,0,1);
       "
       cs_out.
      fi
      
     elif $mode==2
     
      $ref_colors_a
      $ref_colors_b
      $nw,$nh,$nd,{max(s#-2,s#-1)},"begin_t(
        const minv=im#-3;
        const maxv=iM#-3;
        const v_length_a=max(w#-2-1,h#-2-1);
        const v_length_b=max(w#-1-1,h#-2,-1);
       );
       lyapunov_surface=i0#-3;
       use_b=lyapunov_surface>=0;
       use_b?("$find_color_b")
            :("$find_color_a");
       " 
            
     elif $mode==1
     
      $ref_gradient
      $nw,$nh,$nd,{s#-1},"begin_t(
        const minv=im#-2;
        const maxv=iM#-2;
        const v_length=max(w#-1-1,h#-1-1);
        const diff=(maxv-minv)/v_length;
       );
       lyapunov_surface=(i0#-2-minv)/diff;
       "$find_color_a";
       " 
      
     elif $use_hex_mode
       $nw,$nh,$nd,3,"begin_t(
      
        hex_a=["$hex_color_a"];
        hex_b=["$hex_color_b"];
        
        const minv=im#-1;
        const maxv=iM#-1;
        
        const hpi=pi/2;
        
        contrast(a)=(
         b=a*pi-hpi;
         .5*a^2+.5*(sin(b)+1)/2;
        );
       );
       v=i0#-1;
       shade=v>=0?v/maxv:contrast((1-(v/minv)^(1/2)))^2;
       col=v>=0?hex_a:hex_b;
       col*shade;
      "
     fi
     
     r. $ow,$oh,$od,100%,6
     k.
     
     pz_text=""
     lz_text=""
     rz_text=""
     inc_d=""
     calc_iz_text=""
     const_iz_text=""
    endl done
    
    um cs_out
    
    u {$include_c+1}
    #@gui Markus-Lyapunov Fractal: fx_rep_mlfrac,fx_rep_mlfrac
    #@gui :_=note("Create a mapping of Lyapunov exponent within two values or three values.")
    #@gui :_=separator(),_=note("<b>Main</b>")
    #@gui :ABC-String=text("ab")
    #@gui :ABC-String Repeats=int(50,1,255)
    #@gui :Subsampling Level=float(1,0,6)
    #@gui :Viewport(%)=float(100,0,100)
    #@gui :Position=point(50,50,0,1,255,255,255,255)
    #@gui :C-Time(%)=float(50,0,100)
    #@gui :_=separator(),_=note("<b>Output</b>")
    #@gui :Mode=choice(0,"Grayscale","Duotone","Random","Palette","Layers")
    #@gui :Use Inverted?=bool(0)
    #@gui :Color A=color(0,0,255,255)
    #@gui :Color B=color(255,255,0,255)
    #@gui :Set of Palettes=choice(0,"Single","Double")
    #@gui :Seed=int(0,0,10000000)
    #@gui :Random Palette Color Count=int(8,2,64)
    #@gui :Random Palette A Color Count=int(8,2,64)
    #@gui :Random Palette B Color Count=int(8,2,64)
    #@gui :Color Space=choice(0,"HSL","LAB","LCH")
    #@gui :Palette=choice(12,"BW-{2}","RGB-{3}","B-RGB-{4}","BW-RGB-{5}","CMY-{3}","CMYK-{4}","W-CMYK-{5}","RGBCMY-{6}","1-Bit-RGB-{8}","Aurora-{256}","PLAYPAL-{249}","Sonic Robo Blast 2-{256}","Famicube-{64}","Andrew Kensler - 16","Andrew Kensler - 32","Andrew Kensler - 54","AAP-Micro 12","AAP-16","AAP-64","AAP-SPLENDOR128","DB8","DB16","DB32","DB-ISO22","DimWiddy 17","DimWiddy 23","Endesga-4","Endesga-8","Endesga-16","Endesga-32","Endesga-36","Endesga-64","Juicy-32","Juicy-56","XAIUE-22","15P-DX","20P-DX","24P-DX","Cabana-64","Fantasy 16","Fantasy 24","Tranquil Fantasy 23","Tranquility Plus 39","Faraway 48","Fleja Master Palette-{33}","Koni32","Linear Color Palette Basic-{31}","Vines Flexible Linear Ramps-{38}","Arcade Standard 29","ARQ16","BLK 36","BLK-NEO-{46}","Broken Facility","Bubblegum-16","Cade 15","Calder 8-{11}","Chromatic16","CD-BAC-{16}","CG Arne-{16}","CPC BOY-{32}","Dinoknight 16","||||-22","FZT Ethereal 16","GZXP-{11}","Indecision-{17}","Island Joy 16","Journey-{64}","Juicy 17","Oak21","Nature's Embrace 55","Nauris-16","Pear 36","Peachy Pop 16-{16}","Pineapple 32","Resurrect 32-{32}","Rosy 42","SLSO-CLR17","Softy 15","SPEC12","Starmancer-{52}","Superb 8","SuperFuture25","Sweetie 16","Taffy 16","Todayland Palette V2-{25}","Vivid-17","Voodo34","Zughy 32","ENOS16","Undertones-17","Equpix 15","Night 16","Star 29","Star 34","Still-Life-{14}","SimpleJPC-16","Acid 15","Battery 24","Clumpy 18","Cthulhu-{16}","Crimso 11","Copper-Tech-{16}","DRZ15A","Eggy 15","Eroge-Copper","Europa 16-{16}","GreyT-bit-{8}","Jewel-{15}","Polar 11","Sheltzy 32","Rube-Goldberg-{9}","BoomBoom-{7}","Generic-8","Matriax8c","NT1H-{26}","Autum 15","Autum 15 [Yellow]","JerryPie 22","Naji 16","Blessing-{5}","Crayola Blind-{9}","Easter Island-{16}","Fairy Tales-{8}","Fuzzy Four-{4}","0xdb-01-{17}","Ocaso-{17}","Pastel-{15}","17 Pastels","Pollen-8","Nopal-12","Sy17","Syz15","TUI-15","Cave-{8}","Psygnosia-{16}","MarshMellow32","Rabbit 7","Finlal 11","Vinik 24","YKB-22","Graveyard-21","Steam Lords-{16}","AAP-RadiantXV-{15}","AAP-Majesty XVII-{17}","Daruda 22","Rust-6","XAIUE-Radiant-{22}","Firestorm-{9}","SuperNova 7","NYX8","OIL6","SGM-Palette 2-{17}","Fornax Void I-{256}","Fornax Void II-{128}","Pixelwave-{12}","Spacey Easter-{17}","Moonlit-39","Petite-8","Petite-8 Afterdark","Autochrome 3","Autochrome 5","GB Default #1-{4}","GB Default #2-{4}","GB Andrade-{4}","GB Blue Seni-{4}","GB Blackzone-{4}","GB Crimson-{4}","GB Didi-{4}","GB Dirty-{4}","GB Arne-{4}","GB Easy-{4}","GB Forest-{4}","GB Harsh Green-{4}","GB Light Green-{4}","GB Nostalgia-{4}","GB Platinum-{4}","GB Kirokaze-{4}","GB PJ-{4}","GB Cyber-{4}","GB Wish-{4}","GB Grapefruit-{4}","GB Ice Cream-{4}","GB Red_Blue-{4}","GB Spacehaze-{4}","GB Chocolate-{4}","GB Purple Dawn-{4}","GB Gray-{4}","ARNE4","HallowPumpkin-{4}","Amiga 2600 NTSC-{128}","Amiga 2600 PAL-{104}","Amiga 2600 SECAM-{8}","Amiga 7800 M.E.S.S-{256}","Amiga 7800-{256}","Amstrad CPC-{27}","Apple II-{15}","CGA-{16}","CGA Mode 0 [Low]-{4}","CGA Mode 0 [High]-{4}","CGA Mode 1 [Low]-{4}","CGA Mode 1 [High]-{4}","CGA Mode 2 [Low]-{4}","CGA Mode 2 [High]-{4}","Commodore 64 [Pepto Interpretation]-{16}","Commodore 64 [Colodore Interpretation]-{16}","Commodore VIC-20-{16}","Colecovision-{15}","Japanese Machine Palette-{16}","Macintosh II-{16}","NES-{52}","PICO-8-{16}","RISC OS-{16}","SAM Coupe-{128}","Thomson MO5-{16}","VGA-{244}","ZX Spectrum-{15}","GNOME 32-{32}","Electronic Crayon 22","Chip16","MSX-{15}","Deluxe Paint-{222}","Legacy Paint-{16}","XP Paint-{28}","Vista Paint-{28}")
    #@gui :Palette Order=choice(0,"Default","Randomized","Mirrored")
    #@gui :Palette A=choice(16,"BW-{2}","RGB-{3}","B-RGB-{4}","BW-RGB-{5}","CMY-{3}","CMYK-{4}","W-CMYK-{5}","RGBCMY-{6}","1-Bit-RGB-{8}","Aurora-{256}","PLAYPAL-{249}","Sonic Robo Blast 2-{256}","Famicube-{64}","Andrew Kensler - 16","Andrew Kensler - 32","Andrew Kensler - 54","AAP-Micro 12","AAP-16","AAP-64","AAP-SPLENDOR128","DB8","DB16","DB32","DB-ISO22","DimWiddy 17","DimWiddy 23","Endesga-4","Endesga-8","Endesga-16","Endesga-32","Endesga-36","Endesga-64","Juicy-32","Juicy-56","XAIUE-22","15P-DX","20P-DX","24P-DX","Cabana-64","Fantasy 16","Fantasy 24","Tranquil Fantasy 23","Tranquility Plus 39","Faraway 48","Fleja Master Palette-{33}","Koni32","Linear Color Palette Basic-{31}","Vines Flexible Linear Ramps-{38}","Arcade Standard 29","ARQ16","BLK 36","BLK-NEO-{46}","Broken Facility","Bubblegum-16","Cade 15","Calder 8-{11}","Chromatic16","CD-BAC-{16}","CG Arne-{16}","CPC BOY-{32}","Dinoknight 16","||||-22","FZT Ethereal 16","GZXP-{11}","Indecision-{17}","Island Joy 16","Journey-{64}","Juicy 17","Oak21","Nature's Embrace 55","Nauris-16","Pear 36","Peachy Pop 16-{16}","Pineapple 32","Resurrect 32-{32}","Rosy 42","SLSO-CLR17","Softy 15","SPEC12","Starmancer-{52}","Superb 8","SuperFuture25","Sweetie 16","Taffy 16","Todayland Palette V2-{25}","Vivid-17","Voodo34","Zughy 32","ENOS16","Undertones-17","Equpix 15","Night 16","Star 29","Star 34","Still-Life-{14}","SimpleJPC-16","Acid 15","Battery 24","Clumpy 18","Cthulhu-{16}","Crimso 11","Copper-Tech-{16}","DRZ15A","Eggy 15","Eroge-Copper","Europa 16-{16}","GreyT-bit-{8}","Jewel-{15}","Polar 11","Sheltzy 32","Rube-Goldberg-{9}","BoomBoom-{7}","Generic-8","Matriax8c","NT1H-{26}","Autum 15","Autum 15 [Yellow]","JerryPie 22","Naji 16","Blessing-{5}","Crayola Blind-{9}","Easter Island-{16}","Fairy Tales-{8}","Fuzzy Four-{4}","0xdb-01-{17}","Ocaso-{17}","Pastel-{15}","17 Pastels","Pollen-8","Nopal-12","Sy17","Syz15","TUI-15","Cave-{8}","Psygnosia-{16}","MarshMellow32","Rabbit 7","Finlal 11","Vinik 24","YKB-22","Graveyard-21","Steam Lords-{16}","AAP-RadiantXV-{15}","AAP-Majesty XVII-{17}","Daruda 22","Rust-6","XAIUE-Radiant-{22}","Firestorm-{9}","SuperNova 7","NYX8","OIL6","SGM-Palette 2-{17}","Fornax Void I-{256}","Fornax Void II-{128}","Pixelwave-{12}","Spacey Easter-{17}","Moonlit-39","Petite-8","Petite-8 Afterdark","Autochrome 3","Autochrome 5","GB Default #1-{4}","GB Default #2-{4}","GB Andrade-{4}","GB Blue Seni-{4}","GB Blackzone-{4}","GB Crimson-{4}","GB Didi-{4}","GB Dirty-{4}","GB Arne-{4}","GB Easy-{4}","GB Forest-{4}","GB Harsh Green-{4}","GB Light Green-{4}","GB Nostalgia-{4}","GB Platinum-{4}","GB Kirokaze-{4}","GB PJ-{4}","GB Cyber-{4}","GB Wish-{4}","GB Grapefruit-{4}","GB Ice Cream-{4}","GB Red_Blue-{4}","GB Spacehaze-{4}","GB Chocolate-{4}","GB Purple Dawn-{4}","GB Gray-{4}","ARNE4","HallowPumpkin-{4}","Amiga 2600 NTSC-{128}","Amiga 2600 PAL-{104}","Amiga 2600 SECAM-{8}","Amiga 7800 M.E.S.S-{256}","Amiga 7800-{256}","Amstrad CPC-{27}","Apple II-{15}","CGA-{16}","CGA Mode 0 [Low]-{4}","CGA Mode 0 [High]-{4}","CGA Mode 1 [Low]-{4}","CGA Mode 1 [High]-{4}","CGA Mode 2 [Low]-{4}","CGA Mode 2 [High]-{4}","Commodore 64 [Pepto Interpretation]-{16}","Commodore 64 [Colodore Interpretation]-{16}","Commodore VIC-20-{16}","Colecovision-{15}","Japanese Machine Palette-{16}","Macintosh II-{16}","NES-{52}","PICO-8-{16}","RISC OS-{16}","SAM Coupe-{128}","Thomson MO5-{16}","VGA-{244}","ZX Spectrum-{15}","GNOME 32-{32}","Electronic Crayon 22","Chip16","MSX-{15}","Deluxe Paint-{222}","Legacy Paint-{16}","XP Paint-{28}","Vista Paint-{28}")
    #@gui :Palette A Order=choice(0,"Default","Randomized","Mirrored")
    #@gui :Palette B=choice(50,"BW-{2}","RGB-{3}","B-RGB-{4}","BW-RGB-{5}","CMY-{3}","CMYK-{4}","W-CMYK-{5}","RGBCMY-{6}","1-Bit-RGB-{8}","Aurora-{256}","PLAYPAL-{249}","Sonic Robo Blast 2-{256}","Famicube-{64}","Andrew Kensler - 16","Andrew Kensler - 32","Andrew Kensler - 54","AAP-Micro 12","AAP-16","AAP-64","AAP-SPLENDOR128","DB8","DB16","DB32","DB-ISO22","DimWiddy 17","DimWiddy 23","Endesga-4","Endesga-8","Endesga-16","Endesga-32","Endesga-36","Endesga-64","Juicy-32","Juicy-56","XAIUE-22","15P-DX","20P-DX","24P-DX","Cabana-64","Fantasy 16","Fantasy 24","Tranquil Fantasy 23","Tranquility Plus 39","Faraway 48","Fleja Master Palette-{33}","Koni32","Linear Color Palette Basic-{31}","Vines Flexible Linear Ramps-{38}","Arcade Standard 29","ARQ16","BLK 36","BLK-NEO-{46}","Broken Facility","Bubblegum-16","Cade 15","Calder 8-{11}","Chromatic16","CD-BAC-{16}","CG Arne-{16}","CPC BOY-{32}","Dinoknight 16","||||-22","FZT Ethereal 16","GZXP-{11}","Indecision-{17}","Island Joy 16","Journey-{64}","Juicy 17","Oak21","Nature's Embrace 55","Nauris-16","Pear 36","Peachy Pop 16-{16}","Pineapple 32","Resurrect 32-{32}","Rosy 42","SLSO-CLR17","Softy 15","SPEC12","Starmancer-{52}","Superb 8","SuperFuture25","Sweetie 16","Taffy 16","Todayland Palette V2-{25}","Vivid-17","Voodo34","Zughy 32","ENOS16","Undertones-17","Equpix 15","Night 16","Star 29","Star 34","Still-Life-{14}","SimpleJPC-16","Acid 15","Battery 24","Clumpy 18","Cthulhu-{16}","Crimso 11","Copper-Tech-{16}","DRZ15A","Eggy 15","Eroge-Copper","Europa 16-{16}","GreyT-bit-{8}","Jewel-{15}","Polar 11","Sheltzy 32","Rube-Goldberg-{9}","BoomBoom-{7}","Generic-8","Matriax8c","NT1H-{26}","Autum 15","Autum 15 [Yellow]","JerryPie 22","Naji 16","Blessing-{5}","Crayola Blind-{9}","Easter Island-{16}","Fairy Tales-{8}","Fuzzy Four-{4}","0xdb-01-{17}","Ocaso-{17}","Pastel-{15}","17 Pastels","Pollen-8","Nopal-12","Sy17","Syz15","TUI-15","Cave-{8}","Psygnosia-{16}","MarshMellow32","Rabbit 7","Finlal 11","Vinik 24","YKB-22","Graveyard-21","Steam Lords-{16}","AAP-RadiantXV-{15}","AAP-Majesty XVII-{17}","Daruda 22","Rust-6","XAIUE-Radiant-{22}","Firestorm-{9}","SuperNova 7","NYX8","OIL6","SGM-Palette 2-{17}","Fornax Void I-{256}","Fornax Void II-{128}","Pixelwave-{12}","Spacey Easter-{17}","Moonlit-39","Petite-8","Petite-8 Afterdark","Autochrome 3","Autochrome 5","GB Default #1-{4}","GB Default #2-{4}","GB Andrade-{4}","GB Blue Seni-{4}","GB Blackzone-{4}","GB Crimson-{4}","GB Didi-{4}","GB Dirty-{4}","GB Arne-{4}","GB Easy-{4}","GB Forest-{4}","GB Harsh Green-{4}","GB Light Green-{4}","GB Nostalgia-{4}","GB Platinum-{4}","GB Kirokaze-{4}","GB PJ-{4}","GB Cyber-{4}","GB Wish-{4}","GB Grapefruit-{4}","GB Ice Cream-{4}","GB Red_Blue-{4}","GB Spacehaze-{4}","GB Chocolate-{4}","GB Purple Dawn-{4}","GB Gray-{4}","ARNE4","HallowPumpkin-{4}","Amiga 2600 NTSC-{128}","Amiga 2600 PAL-{104}","Amiga 2600 SECAM-{8}","Amiga 7800 M.E.S.S-{256}","Amiga 7800-{256}","Amstrad CPC-{27}","Apple II-{15}","CGA-{16}","CGA Mode 0 [Low]-{4}","CGA Mode 0 [High]-{4}","CGA Mode 1 [Low]-{4}","CGA Mode 1 [High]-{4}","CGA Mode 2 [Low]-{4}","CGA Mode 2 [High]-{4}","Commodore 64 [Pepto Interpretation]-{16}","Commodore 64 [Colodore Interpretation]-{16}","Commodore VIC-20-{16}","Colecovision-{15}","Japanese Machine Palette-{16}","Macintosh II-{16}","NES-{52}","PICO-8-{16}","RISC OS-{16}","SAM Coupe-{128}","Thomson MO5-{16}","VGA-{244}","ZX Spectrum-{15}","GNOME 32-{32}","Electronic Crayon 22","Chip16","MSX-{15}","Deluxe Paint-{222}","Legacy Paint-{16}","XP Paint-{28}","Vista Paint-{28}")
    #@gui :Palette B Order=choice(0,"Default","Randomized","Mirrored")
    #@gui :Color Count=int(8,2,64)
    #@gui :Palette Order=choice(0,"Default","Randomized","Mirrored")
    #@gui :Color Count A=int(8,2,64)
    #@gui :Palette A Order=choice(0,"Default","Randomized","Mirrored")
    #@gui :Color Count B=int(8,2,64)
    #@gui :Palette B Order=choice(0,"Default","Randomized","Mirrored")
    #@gui :Reverse Layers=bool(0)
    #@gui :Reverse Non-Target Layers=bool(0)
    #@gui :Mode=choice(0,"Import One File Only","Import Two Files")_0
    #@gui :File=file()_0
    #@gui :File A=file()_0
    #@gui :File B=file()_0
    #@gui :Color Count=int(8,2,64)_0
    #@gui :Randomize Color Position=bool(0)_0
    #@gui :Color Count A=int(8,2,64)_0
    #@gui :Randomize Colors A Position=bool(0)_0
    #@gui :Color Count B=int(8,2,64)_0
    #@gui :Randomize Colors B Position=bool(0)_0
    #@gui :_=separator(),_=note("<b>Orientation</b>")
    #@gui :X-Direction=choice(0,"Default","Mirrored")_0
    #@gui :Y-Direction=choice(0,"Default","Mirrored")_0
    #@gui :_=note("<small>Under Development!</small>")
    #@gui :_=separator(),_=note("<small>Author: Reptorian. Latest Update: <i>2021/07/08</i>.</small>")
    fx_rep_mlfrac:
    skip "${39=}","${40=}","${41=}"
    srand $19
    set_main_arg=${1-3},$4%,$5%,{100-$6}%,$7%
    timg={$!}
    
    if $8==0 
     rep_markus_lyapunov_fractal[0] $set_main_arg,$9 n 0,255 if $timg>1 f[^0] I#0 fi
    elif $8==1
     hex_col_a=${rep_int82hex\ ${10-13}}
     hex_col_b=${rep_int82hex\ ${14-17}}
     rep_markus_lyapunov_fractal[0] $set_main_arg,$hex_col_a,$hex_col_b
     if $timg>1 f[^0] I#0 fi
    elif $8==2
     if $18 rep_markus_lyapunov_fractal[0] $set_main_arg,u,u,${21-23}
     else rep_markus_lyapunov_fractal[0] $set_main_arg,u,$20,$23
     fi
     if $timg>1 f[^0] I#0 fi
    elif $8==3
     if $18
      pal $26
      pal $28
      rep_markus_lyapunov_fractal[0] $set_main_arg,[-2],[-1],$27,$29
      rm[-2,-1]
      if $timg>1 f[^0] I#0 fi
     else
      pal $24
      rep_markus_lyapunov_fractal[0] $set_main_arg,[-1],$25
      rm.
      if $timg>1 f[^0] I#0 fi
     fi
    else
     if $timg==2||$timg==3
      if $36 rv fi
      if $timg==2
       rep_markus_lyapunov_fractal[0] $set_main_arg,[1],$31,$30
      else
        if $37 rv[^0] fi
        rep_markus_lyapunov_fractal[0] $set_main_arg,[1],[2],$33,$35,$32,$34
      fi
     else
      error "Invalid number of layer(s) for this mode. 2 or 3 Layers Only!"
     fi
    fi
    
    use_time=${}
    set_a_1={$8==1?2}
    set_a_2={$8==2?2}
    set_a_3={$8==2&&$18==1?2}
    set_b_1={($8==2&&$18==0)?2}
    set_b_2={($8==2&&$18==1)?2}
    set_c_1={($8==3&&$18==0)?2}
    set_c_2={($8==3&&$18==1)?2}
    set_d_1={$8==4&&$timg==2?2}
    set_d_2={$8==4&&$timg==3?2}
    
    u "{$1}"\
    "{$2}"\
    "{$3}"\
    "{$4}"\
    "{$5,$6}"\
    "{$7}_"$use_time\
    "{$8}"\
    "{$9}_"{!$8?2}\
    "{$10,$11,$12,$13}_"$set_a_1\
    "{$14,$15,$16,$17}_"$set_a_1\
    "{$18}_"{$8>1&&$8<4?2}\
    "{$19}_"{$8==2?2:$8==3?($18?(($27==1||$29==1)?2:1):($25==1?2:1)):$8==4?($timg==3?(($33==1||$35==1)?2:1):($31==1?2:1))}\
    "{$20}_"{$8==2&&$18==0?2}\
    "{$21}_"$set_a_3\
    "{$22}_"$set_a_3\
    "{$23}_"$set_a_2\
    "{$24}_"$set_c_1\
    "{$25}_"$set_c_1\
    "{$26}_"$set_c_2\
    "{$27}_"$set_c_2\
    "{$28}_"$set_c_2\
    "{$29}_"$set_c_2\
    "{$30}_"$set_d_1\
    "{$31}_"$set_d_1\
    "{$32}_"$set_d_2\
    "{$33}_"$set_d_2\
    "{$34}_"$set_d_2\
    "{$35}_"$set_d_2\
    "{$36}_"{$8==4?2}\
    "{$37}_"$set_d_2\
    "{$38}"\
    "{$39}"\
    "{$40}"\
    "{$41}"\
    "{$42}"\
    "{$43}"\
    "{$44}"\
    "{$45}"\
    "{$46}"\
    "{$47}"\
    "{$48}"\
    "{$49}"
    

     

     

    • Like 1
    • Upvote 1
  7. Now, the filter has been released! It is named as Transformative Popcorn Fractal. If you see Complex Popcorn Fractal, update another time. Yes, I renamed it and made it work as it should.

     

     

    -----

     

    New Filter! - Complexion Burst

     

    Here's what it looks like:

     

    er43tps8kci71.png?width=768&auto=webp&s=

    • Like 2
  8. Now, I had pushed a new version of Diffusion Limited Aggregation.

     

    Changes according to commit log:

     

    Quote

    Upgrade to Diffusion Limited Aggregation

     

    Changes:

    1. The use of meta-coding to generate proper multi-threaded code on the fly. Much of the behavior of the very old single-threaded rep_dla has been retained, and much better retained in this version.

    2. It is now fast enough that preview makes perfect sense.

    3. Filter can be applied to multiple images.

     

    • Like 1
  9. Here's something you can do with Rainbowify:

     

    1SRRIKg.png

     

    1. Load or create a image to use as base for Rainbowify.

    2. Duplicate the image twice.

    3. Desaturate the top two image.

    4. Rainbowify the first layer.

    5. Set the middle layer into Multiply Mode.

    6. Set the top layer into Glow Mode.

     

    You'd get something interesting here.

    • Like 2
  10. This plugin converts the average of RGB channel into Hue Range, and then add a gradient, and finally wrap it around to [0-1) range. This results in a image that has rainbow following the contour of the original image. Inspired by Rainbowify effect made by Jonathan Frech.

     

    There are three parameters: Hue Shift, Angle, and Gradient Scale. Self-Explanatory.

     

    Output of Effect:

     

    zu6y8lzu5dd71.png?width=640&auto=webp&s=

     

    Installation:

    Plugin Files -> Rainbowify.zip

    1. Insert the .dll into effect folder of paint.net installation

    2. Find it under Artistic. I want it under Stylize though, but this can do.

     

    Source code:

     

    PDN C#

    Spoiler
    // Name: Rainbowify
    // Submenu: Artistic
    // Author: Reptorian
    // Title: Rainbowify
    // Version:
    // Desc:
    // Keywords:
    // URL:
    // Help:
    #region UICode
    IntSliderControl Amount1 = 0; // [-180,180] Hue Shift
    AngleControl grad_ang = 45; // [-180,180] Gradient Angle
    DoubleSliderControl grad_scale = 100; // [50,200] Gradient Scale (%)
    #endregion
    
    double rot_y(double a,double b,double cos_ang,double sin_ang){
        return a*sin_ang-b*cos_ang;
    }
    
    double fmod(double a){
        return a - 360 * Math.Floor(a/360);
    }
    
    void Render(Surface dst, Surface src, Rectangle rect)
    {
        // Delete any of these lines you don't need
    
        int hue_shift = Amount1 + 180;
        double ang = -(grad_ang/180)*Math.PI;
        double cos_ang = Math.Cos(ang);
        double sin_ang = Math.Sin(ang);
        int i_w=src.Width - 1;
        int i_h=src.Height - 1;
        double d_w= (double)(i_w)-1;
        double d_h= (double)(i_h)-1;
        double cx = d_w/2;
        double cy = d_h/2;
        double sd = Math.Max(d_w,d_h)/Math.Min(d_w,d_h);
        double sx = i_w>i_h ? sd : 1;
        double sy = i_w>i_h ? 1 : sd;
        double cxsx=cx/sx;
        double cysy=cy/sy;
        double rescale_pos=180*grad_scale/100;
        double m = 360 / 255;
    
        double px,py,pos,v,hue_out;
    
        HsvColor hsv;
    
        ColorBgra currentPixel;
        ColorBgra output;
        for (int y = rect.Top; y < rect.Bottom; y++)
        {
            if (IsCancelRequested) return;
            for (int x = rect.Left; x < rect.Right; x++)
            {
                px = ((double)(x)-cx)/cxsx;
                py = ((double)(y)-cy)/cysy;
                pos = rot_y(px,py,cos_ang,sin_ang)*rescale_pos;
                currentPixel = src[x,y];
                v = (double)(currentPixel.B+currentPixel.G+currentPixel.R)/3;
                v *= m;
                hue_out = fmod(v+pos+(double)(hue_shift));
                hsv = new HsvColor((int)(hue_out),100,100);
                output = ColorBgra.FromColor(hsv.ToColor());
                output.A=currentPixel.A;
                dst[x,y]=output;
            }
        }
    }

     

    G'MIC

    Spoiler
    #@cli rep_rainbowify: -360<_hue_shift<360,-360<_gradient_angle<360,_gradient_scale[%]>0
    #@cli : Apply rainbowify effect into image. Inspired by Rainbowify effect made by Jonathan Frech.
    #@cli : Default values: '_hue_shift=0','_gradient_angle=0','_gradient_angle=100%'
    rep_rainbowify:
    skip ${1=0},${2=0},${3=100%}
    repeat $! l[$>]
     if s<3 continue fi
     if s==4 sh. 0,2 fi
     f. "begin(
      const shift_hue=$1+180;
      const ang=($2/180)*pi;
      const cos_ang=cos(ang);
      const sin_ang=sin(ang);
      rot_x(a,b)=a*cos_ang-b*sin_ang;
      rot_y(a,b)=a*sin_ang+b*cos_ang;
      const sd=max(w,h)/min(w,h);
      const sx=w>h?sd:1;
      const sy=w>h?1:sd;
      const ww=w-1;
      const hh=h-1;
      const cx=ww/2;
      const cy=hh/2;
      const cxsx=cx/sx;
      const cysy=cy/sy;
      const m=360/255;
      const rescale_pos=180*$3;
      fmod(a)=a-360*floor(a/360);
     );
     px=(x-cx)/cxsx;
     py=(y-cy)/cysy;
     pos=rot_y(px,py)*rescale_pos;
     v=avg(I)*m;
     [fmod(v+pos+shift_hue),1,.5];
     "
     k[0]
     hsl2rgb
    endl done
    #@gui Rainbowify: fx_rep_rainbowify,fx_rep_rainbowify_preview(0)
    #@gui :_=note("Apply rainbowify effect into image. Inspired by Rainbowify effect made by Jonathan Frech."),_=separator()
    #@gui :Hue Shift=float(0,-180,180)
    #@gui :Gradient Angle=float(0,-180,180)
    #@gui :Gradient Scale(%)=float(100,50,200)
    #@gui :_=separator(), Preview Type=choice("Full","Forward Horizontal","Forward Vertical","Backward Horizontal","Backward Vertical","Duplicate Top","Duplicate Left","Duplicate Bottom","Duplicate Right","Duplicate Horizontal","Duplicate Vertical","Checkered","Checkered Inverse"), Preview Split = point(50,50,0,0,200,200,200,0,10)_0
    #@gui :_=separator(), _=note("<small>Author: Reptorian. Latest Update: <i>2021/7/25</i>.</small>")
    fx_rep_rainbowify: rep_rainbowify ${1-2},$3%
    fx_rep_rainbowify_preview:
    gui_split_preview "fx_rep_rainbowify ${1-3}",${-3--1}

     

     

    • Like 2
    • Upvote 2
×
×
  • Create New...