Jump to content

Random Rectangle Division


Recommended Posts

Randomly divides the canvas into smaller rectangles, where the initial rectangle is the canvas itself.

 

Preview:

 

unknown.png

On the parameters that needs note:

Number of colors - defines the number of color on canvas. If it is 0, then with infinite memory, then infinity number of colors is possible. Otherwise, the number of colors is equal to 2 or higher, and if it is less than 2, then 2 colors.

Loop Limit - Define the maximum loop possible. Sometimes, the generation of rectangle will complete before the loop, so that's why sometimes you don't see changes.

Border(%) - This define the thickness of border. Sometimes border won't show up because of issues regarding to discrete space of raster graphic. I don't know how to explain this.

 

Installation:

Plugin Files -> Random Rectangle Division.zip

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

2. Find it under Texture.

 

Bugs:

1. Border Color will be active if there is no border. I cannot fix this bug as it requires me to figure out how to make it visible using mathematical operation within variables.

 

Source code:

CodeLab

Spoiler
// Name: Random Rectangle Division
// Submenu: Texture
// Author: Reptorian.
// Title: Random Rectangle Division
// Version: 1
// Desc: Create randomly divided rectangle on Canvas
// Keywords: Rectangles
// URL: https://forums.getpaint.net/profile/85868-reptillian/
// Help:
#region UICode
IntSliderControl max_divide = 10; // [1,20] Division
IntSliderControl init_add_thick = 1; // [0,100] Additional Thickness
IntSliderControl max_iter = 5; // [2,40] Maximum Division Iteration
IntSliderControl probability = 95; // [0,100] Probability of Division(%)
IntSliderControl max_loop = 2000; // [2000,2097152] Loop Limit
DoubleSliderControl init_border = 100; // [0,100] Border(%)
ReseedButtonControl seed = 0; // Reseed
ColorWheelControl border_color = ColorBgra.FromBgr(0, 0, 0); // [Black] Border Color
ListBoxControl color_choice = 1; // Color Mode|Random RGB|Grayscale
IntSliderControl num_rgb = 0; // [0,100] {color_choice} Number of Random RGB Colors
ReseedButtonControl seed2 = 0; // {color_choice} Reseed Color
#endregion

int [,] Rectangles_Surface;
ColorBgra[] Random_RGB;

Random Seed = new Random();
Random Seed_2 = new Random();
int new_seed,new_seed_2;

List<(int,int,int,int,int)> Modifiable_Rect = new List<(int,int,int,int,int)>{
            (0,0,0,0,0)
};

List<(int,int,int,int,int)> Unmodifiable_Rect = new List<(int,int,int,int,int)>{
            (0,0,0,0,0)
};


bool diff_check(int a)
{
    int mri = max_divide;
    double ds = (double)(a/mri);
    if (mri>1&&(ds<1)){
        while(mri>1&&(ds<1)){
            mri--;
            ds = (double)(a/mri);
        }
    }

    return ds>1;
}


bool pass=false;

Random myRandom,myRandom2;

void split_column(int point,int test_boundary,int border_size){
        bool skip = false;
        int mx=0;
        int np;

        int ri = myRandom.Next(1,max_divide)+1;
        int mri = ri - 1;

        int min_x=Modifiable_Rect[point].Item1;
        int max_x=Modifiable_Rect[point].Item2;
        int min_y=Modifiable_Rect[point].Item3;
        int max_y=Modifiable_Rect[point].Item4;
        int itern=Modifiable_Rect[point].Item5+1;

        Modifiable_Rect.RemoveAt(point);

        int sx = min_x+test_boundary;
        int ex = max_x-test_boundary;

        int diff=ex-sx;
        bool bound_check = diff>test_boundary;
        bool rb;

        int min_v,max_v;

        if (bound_check)
        {
            double ds=(double)(diff/mri);
            if(mri>1&&(ds<=test_boundary))
            {
                while(mri>1&&(ds<=test_boundary))
                {
                    ri--;
                    mri--;
                    ds=(double)(diff/mri);
                }
            }
            if(test_boundary>0||diff>0?(ds>(double)(test_boundary)):true)
            {
                int p=min_x;
                for(int ri_ind=0; ri_ind<ri ; ri_ind++)
                {
                    rb=myRandom.Next(0,99)>(probability-1);
                    if (ri_ind==mri)
                    {
                        if (p>max_x)
                        {
                            p=max_x;
                            if((max_y-min_y)==0){rb=true;}
                        }
                        if (rb || (itern==max_iter))
                        {
                            Unmodifiable_Rect.Add((p,max_x,min_y,max_y,itern));
                        }
                        else
                        {
                            Modifiable_Rect.Add((p,max_x,min_y,max_y,itern));
                        }

                    }
                    else
                    {
                        if(ri_ind==0)
                        {
                            mx=(int)(Math.Round((double)(sx+ds)));
                            min_v=Math.Min(p,mx);
                            max_v=Math.Max(p,mx);
                            np=Math.Min(Math.Max(sx,myRandom.Next(min_v,max_v)),ex);
                            if (rb || (itern==max_iter))
                            {
                                Unmodifiable_Rect.Add((p,np,min_y,max_y,itern));
                            }
                            else
                            {
                                Modifiable_Rect.Add((p,np,min_y,max_y,itern));
                            }
                            p=np+1;
                            if(p>=ex){skip=true;}
                        }
                        else
                        {
                            if(skip){continue;}
                            mx=(int)(Math.Round((double)(mx+ds)));
                            min_v=Math.Min(p,mx);
                            max_v=Math.Max(p,mx);
                            np=Math.Min(Math.Max(p+border_size,myRandom.Next(min_v,max_v)),ex);
                            if (rb || (itern==max_iter))
                            {
                                Unmodifiable_Rect.Add((Math.Min(p,ex),np,min_y,max_y,itern));
                            }
                            else
                            {
                                Modifiable_Rect.Add((Math.Min(p,ex),np,min_y,max_y,itern));
                            }
                            p=np+1;
                        }
                    }
                }
            }
            else
            {
                Unmodifiable_Rect.Add((min_x,max_x,min_y,max_y,itern));
            }
        }
        else
        {
            Unmodifiable_Rect.Add((min_x,max_x,min_y,max_y,itern));
        }
}

void split_row(int point,int test_boundary,int border_size){
        bool skip = false;
        int my=0;
        int np;

        int ri = myRandom.Next(1,max_divide)+1;
        int mri = ri - 1;

        int min_x=Modifiable_Rect[point].Item1;
        int max_x=Modifiable_Rect[point].Item2;
        int min_y=Modifiable_Rect[point].Item3;
        int max_y=Modifiable_Rect[point].Item4;
        int itern=Modifiable_Rect[point].Item5+1;

        Modifiable_Rect.RemoveAt(point);

        int sy = min_y+test_boundary;
        int ey = max_y-test_boundary;
        int diff=ey-sy;
        bool bound_check = diff>test_boundary;
        bool rb;

        int min_v,max_v;

        if (bound_check)
        {
            
            double ds=(double)(diff/mri);
            if(mri>1&&(ds<=test_boundary))
            {
                while(mri>1&&(ds<=test_boundary))
                {
                    ri--;
                    mri--;
                    ds=(double)(diff/mri);
                }
            }
            if(test_boundary>0||diff>0?(ds>(double)(test_boundary)):true)
            {
                int p=min_y;
                for(int ri_ind=0; ri_ind<ri ; ri_ind++)
                {
                    rb=myRandom.Next(0,99)>(probability-1);
                    if (ri_ind==mri)
                    {
                        if (p>max_y)
                        {
                            p=max_y;
                            if((max_x-min_x)==0){rb=true;}
                        }
                        if (rb || (itern==max_iter))
                        {
                            Unmodifiable_Rect.Add((min_x,max_x,p,max_y,itern));
                        }
                        else
                        {
                            Modifiable_Rect.Add((min_x,max_x,p,max_y,itern));
                        }

                    }
                    else
                    {
                        if(ri_ind==0)
                        {
                            my=(int)(Math.Round((double)(sy+ds)));
                            min_v=Math.Min(p,my);
                            max_v=Math.Max(p,my);
                            np=Math.Min(Math.Max(sy,myRandom.Next(min_v,max_v)),ey);
                            if (rb || (itern==max_iter))
                            {
                                Unmodifiable_Rect.Add((min_x,max_x,p,np,itern));
                            }
                            else
                            {
                                Modifiable_Rect.Add((min_x,max_x,p,np,itern));
                            }
                            p=np+1;
                            if(p>=ey){skip=true;}
                        }
                        else
                        {
                            if(skip){continue;}
                            my=(int)(Math.Round((double)(my+ds)));
                            min_v=Math.Min(p,my);
                            max_v=Math.Max(p,my);
                            np=Math.Min(Math.Max(p+border_size,myRandom.Next(min_v,max_v)),ey);
                            if (rb || (itern==max_iter))
                            {
                                Unmodifiable_Rect.Add((min_x,max_x,Math.Min(p,ey),np,itern));
                            }
                            else
                            {
                                Modifiable_Rect.Add((min_x,max_x,Math.Min(p,ey),np,itern));
                            }
                            p=np+1;
                        }
                    }
                }
            }
            else
            {
                Unmodifiable_Rect.Add((min_x,max_x,min_y,max_y,itern));
            }
        }
        else
        {
            Unmodifiable_Rect.Add((min_x,max_x,min_y,max_y,itern));
        }
}

bool finished_init;

int trs,trs_2,length;

void PreRender(Surface dst, Surface src)
{

    int rs=Seed.Next();
    int rs_2=Seed_2.Next();
    if (!finished_init)
    {
        trs=rs;
        trs_2=rs_2;
    }

    if (Rectangles_Surface==null)
    {
        Modifiable_Rect.RemoveRange(0,1);
        Unmodifiable_Rect.RemoveRange(0,1);
        Rectangles_Surface=new int [src.Width,src.Height];
    }
    else
    {
        Modifiable_Rect.RemoveRange(0,Modifiable_Rect.Count);
        Unmodifiable_Rect.RemoveRange(0,Unmodifiable_Rect.Count);
        Array.Clear(Rectangles_Surface,0,src.Width*src.Height);
    }

    if (new_seed != seed)
    {
        Modifiable_Rect.RemoveRange(0,Modifiable_Rect.Count);
        Unmodifiable_Rect.RemoveRange(0,Unmodifiable_Rect.Count);
        trs=rs;
    }
    else
    {
        if (!finished_init){
            trs=rs;
        }
    }

    if (new_seed_2 != seed2)
    {
        trs_2=rs_2;
    }
    else
    {
        if (!finished_init){
            trs_2=rs_2;     
        }
    }


    myRandom = new Random(trs);
    myRandom2 = new Random(trs_2);

    new_seed = seed;
    new_seed_2 = seed2;

    int width  = src.Width  - 1;
    int height = src.Height - 1;
    int border_size;
    int test_boundary;

    if (init_add_thick>0)
    {
        border_size=init_add_thick+1;
        test_boundary=border_size+1;
    }
    else{
        border_size=0;
        test_boundary=0;
    }

    int border = (int)(Math.Round((double)(init_add_thick*init_border/100)));

    bool contain_border = border>0;
    bool width_check=diff_check(width-border_size*2);
    bool height_check=diff_check(height-border_size*2);

    if (width_check||height_check){
        pass = true;
        Modifiable_Rect.Add((0,width,0,height,0));

        if (width_check&&height_check)
        {
            if (myRandom.Next(0,2)==0)
            {
                split_column(0,test_boundary,border_size);
            }
            else
            {
                split_row(0,test_boundary,border_size);
            }
        }
        else
        {
            if (height_check)
            {
                split_column(0,test_boundary,border_size);
            }
            else
            {
                split_row(0,test_boundary,border_size);
            }
        }

        int arr_point=0;
        int p_ind;

        while(Modifiable_Rect.Count>0)
        {
            p_ind=myRandom.Next(Modifiable_Rect.Count);
            if(myRandom.Next(0,2)==0)
            {
                split_column(p_ind,test_boundary,border_size);
            }
            else
            {
                split_row(p_ind,test_boundary,border_size);
            }
            arr_point++;
            if(arr_point>=max_loop){break;}
        }


        int new_min_x;
        int new_max_x;
        int new_min_y;
        int new_max_y;
        int nv=0;

        int ex,ey,bx,by;

        int bex=src.Width-1-border;
        int bey=src.Height-1-border;

        if (Modifiable_Rect.Count>0)
        {
            for (int i = 0 ; i < Modifiable_Rect.Count ; i++){
                new_min_x=Modifiable_Rect[i].Item1;
                new_max_x=Modifiable_Rect[i].Item2;
                new_min_y=Modifiable_Rect[i].Item3;
                new_max_y=Modifiable_Rect[i].Item4;
                ex = new_max_x+1;
                ey = new_max_y+1;
                bx = new_min_x + border;
                by = new_min_y + border;
                for (int x = new_min_x ; x<ex ; x++)
                {
                    for (int y = new_min_y ; y<ey ; y++)
                    {
                        if (x < bx || y < by || x > bex || y > bey)
                        {
                            Rectangles_Surface[x,y]=-1;
                        }
                        else
                        {
                            Rectangles_Surface[x,y]=nv;
                        }
                        
                    }
                }
                nv++;
            }
        }


        if (Unmodifiable_Rect.Count>0)
        {
            for (int j = 0 ; j < Unmodifiable_Rect.Count ; j++)
            {
                new_min_x=Unmodifiable_Rect[j].Item1;
                new_max_x=Unmodifiable_Rect[j].Item2;
                new_min_y=Unmodifiable_Rect[j].Item3;
                new_max_y=Unmodifiable_Rect[j].Item4;
                ex=new_max_x+1;
                ey=new_max_y+1;
                bx = new_min_x + border;
                by = new_min_y + border;
                for (int x = new_min_x ; x<ex ; x++)
                {
                    for (int y = new_min_y ; y<ey ; y++)
                    {
                        if (x < bx || y < by || x > bex || y > bey)
                        {
                            Rectangles_Surface[x,y]=-1;
                        }
                        else
                        {
                            Rectangles_Surface[x,y]=nv;
                        }
                        
                    }
                }
                nv++;
            }
        }
        length = nv+1;
        if (color_choice==0){
            byte tb,tg,tr;
            Random_RGB = new ColorBgra[length];
            for (int n = 0 ; n < length ; n++)
            {
                tb=(byte)(myRandom2.Next(256));
                tg=(byte)(myRandom2.Next(256));
                tr=(byte)(myRandom2.Next(256));
                Random_RGB[n]=ColorBgra.FromBgr(tb,tg,tr);
            }
        }
    }

    finished_init = true;
}

void Render(Surface dst, Surface src, Rectangle rect)
{
    // Delete any of these lines you don't need

    byte v;
    double rescale=(double)(length)/255;

    int total_colors=Math.Max(num_rgb,2);
    if (pass)
    {
        for (int y = rect.Top; y < rect.Bottom; y++)
        {
            if (IsCancelRequested) return;
            for (int x = rect.Left; x < rect.Right; x++)
            {
                if (Rectangles_Surface[x,y]==-1)
                {
                    dst[x,y]=border_color;
                }
                else
                {
                    if (color_choice==0)
                    {
                        if (num_rgb>0)
                        {
                            dst[x,y]=Random_RGB[Rectangles_Surface[x,y]%total_colors];
                        }
                        else
                        {
                            dst[x,y]=Random_RGB[Rectangles_Surface[x,y]];
                        }                       
                    }
                    else
                    {
                        v=(byte)((int)(Math.Round((double)(Rectangles_Surface[x,y])/rescale)));
                        dst[x,y]=ColorBgra.FromBgr(v,v,v);
                    }
                }
            }
        }
    }
}

 

G'MIC

Spoiler
rep_random_rectangular_division:
skip ${2=0},${3=5},${4=95%},${5=5000},${6=}
check "$4>0"
repeat $! l[$>]
 _rep_random_rectangular_division $*
endl done
_rep_random_rectangular_division:
skip ${2=0},${3=5},${4=95%},${5=5000},${6=}

r 100%,100%,1,1

1,1,1,5 #Modifiable Rectangle Array
1,1,1,5 #Unmodifiable Rectangle Array

eval ${-math_lib}"
 if(narg($6),srand($6););
 const ww=w#-3-1;
 const hh=h#-3-1;
 const max_split=max(1,int(abs($1)));
 const internal_space=int(abs($2));
 const test_boundary=internal_space?(internal_space+1);
 const max_iter=max(2,round(abs($3)));
 const odd=cut($4,0,1);
 const arr_limit=round(abs($5));

 diff_check(a)=(
  mri=max_split;
  ds=a/mri;
  if(mri>1&&ds<1,
   while(mri>1&&ds<1,
    mri--;
    ds=a/mri;
   );
  );
  ds>1;
 );

 width_check=diff_check(ww-internal_space*2);
 height_check=diff_check(hh-internal_space*2);

 !(width_check||height_check)?run('error inv_dim');

 dar_insert(#-2,[0,ww,0,hh,0]);

 sub_column(v,point)=(
  ri=int(u(1,max_split))+1;
  mri=ri-1;
  sx=v[0]+test_boundary;
  ex=v[1]-test_boundary;
  diff=ex-sx;
  bound_check=diff>test_boundary;
  skip=0;
  dar_remove(#-2,point);
  if(bound_check,
   ds=diff/mri;
   if(mri>1&&ds<=test_boundary,
    while(mri>1&&ds<=test_boundary,
     ri--;
     mri--;
     ds=diff/mri;
    );
   );
   if(test_boundary||diff?(ds>test_boundary):1,
    py=[v[2],v[3]];
    iter=v[4]+1;
    p=v[0];
    repeat(ri,ri_ind,
     rb=odd<1?u(0,1)>odd:0;
     ri_ind==mri?(
      if(p>v[1],
       p=v[1];
       if(!(v[3]-v[2]),rb=1;);
      );
      (rb||(iter==max_iter))?(
       dar_insert(#-1,[p,v[1],py,iter]);
      ):(
       dar_insert(#-2,[p,v[1],py,iter]);
      );
     ):
     !ri_ind?(
      mx=sx+ds;
      np=min(max(sx,round(u(p,mx))),ex);
      vp=[p,np];
      (rb||(iter==max_iter))?(
       dar_insert(#-1,[vp,py,iter]);
      ):(
       dar_insert(#-2,[vp,py,iter]);
      );
      p=np+1;
      if(p>=ex,skip=1;);
     ):(
      if(skip,continue(););
      mx+=ds;
      np=min(max(p+internal_space,round(u(p,mx))),ex);
      vp=[min(p,ex),np];
      (rb||(iter==max_iter))?(
       dar_insert(#-1,[vp,py,iter]);
      ):(
       dar_insert(#-2,[vp,py,iter]);
      );
      p=np+1;
     );
    );
   ,dar_insert(#-1,v);
   );
  ,dar_insert(#-1,v);
  );
 );

 sub_row(v,point)=(
  ri=int(u(1,max_split))+1;
  mri=ri-1;
  sy=v[2]+test_boundary;
  ey=v[3]-test_boundary;
  diff=ey-sy;
  bound_check=diff>test_boundary;
  skip=0;
  dar_remove(#-2,point);
  if(bound_check,
   ds=diff/mri;
   if(mri>1&&ds<=test_boundary,
    while(mri>1&&ds<=test_boundary,
     ri--;
     mri--;
     ds=diff/mri;
    );
   );
   if(test_boundary||diff?(ds>test_boundary):1,
    px=[v[0],v[1]];
    iter=v[4]+1;
    p=v[2];
    repeat(ri,ri_ind,
     rb=odd<1?u(0,1)>odd:0;
     ri_ind==mri?(
      if(p>v[3],
       p=v[3];
       if(!(v[1]-v[0]),rb=1;);
      );
      (rb||(iter==max_iter))?(
       dar_insert(#-1,[px,p,v[3],iter]);
      ):(
       dar_insert(#-2,[px,p,v[3],iter]);
      );
     ):
     !ri_ind?(
      my=sy+ds;
      np=min(max(sy,round(u(p,my))),ey);
      vp=[p,np];
      (rb||(iter==max_iter))?(
       dar_insert(#-1,[px,vp,iter]);
      ):(
       dar_insert(#-2,[px,vp,iter]);
      );
      p=np+1;
      if(p>=ey,skip=1;);
     ):(
      if(skip,continue(););
      my+=ds;
      np=min(max(p+internal_space,round(u(p,my))),ey);
      vp=[min(p,ey),np];
      (rb||(iter==max_iter))?(
       dar_insert(#-1,[px,vp,iter]);
      ):(
       dar_insert(#-2,[px,vp,iter]);
      );
      p=np+1;
     );
    );
   ,dar_insert(#-1,v);
   );
  ,dar_insert(#-1,v);
  );
 );


 v=I[#-2,0];

 width_check&&height_check?(
  u(0,1)<=.5?(
   sub_row(v,0);
  ):(
   sub_column(v,0);
  );
 ):
 width_check?(
  sub_column(v,0);
 ):
 height_check?(
  sub_row(v,0);
 );

 arr_point=0;

 while(dar_size(#-2),
  p_ind=int(u(dar_size(#-2)));
  cv=I[#-2,p_ind];
  u(0,1)<.5?(
   sub_row(cv,p_ind);
  ):(
   sub_column(cv,p_ind);
  );
  arr_point++;
  if(arr_point>=arr_limit,break());
 );

 resize(#-2,1,dar_size(#-2),1,4,0);
 resize(#-1,1,dar_size(#-1),1,4,0);"

a[-2,-1] y

eval. :"begin(
  convert2coords(c)=(
   tl=[c[0],c[2]];
   tr=[c[1],c[2]];
   bl=[c[0],c[3]];
   br=[c[1],c[3]];
   [tl,tr,br,bl];
  );
 );
 polygon(#-2,4,convert2coords(I),1,y);"

rm.
#@gui Random Rectangle Division: fx_rep_rrd,fx_rep_rrd
#@gui :_=separator(),_=note("<b>Main</b>")
#@gui :Division=int(10,1,20)
#@gui :Additional Thickness=int(5,0,100)
#@gui :Maximum Division Iteration=int(5,2,40)
#@gui :Probability of Division(%)=float(95,20,100)
#@gui :Loop Limit=int(50000,1000,2097152)
#@gui :Seed=int(0,0,300)
#@gui :Border(%)=float(35,0,100)
#@gui :_=separator(),_=note("<b>Color</b>")
#@gui :Mode=choice(0,"Grayscale","Palette","Random")
#@gui :Normalize?=bool(1)
#@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-{40}","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 :Color Space=choice(0,"RGB","HSI")
#@gui :Number of Color=int(0,0,100)
#@gui :Seed=int(0,0,100000)
#@gui :Border=color(0,0,0)
#@gui :_=separator(),_=note("<small>Author: Reptorian. Latest Update: <i>2021/09/26</i>.</small>")
fx_rep_rrd:
border_size={max(0,round($2*$7/100))}
repeat $! l[$>]
 rep_random_rectangular_division ${1-3},$4%,${5-6}

 if $8==0
  if $9 n. 0,255 fi
  to_rgb.
 elif $8==1 pal $10 {w},1,1,1,begin(srand($13));u pixelsort.. +,x,[-1] rm.
 else
  if $11 {$12?$12:iM+1},1,1,3,begin(srand($13));[u(360),u(1),u(1)]
  else {$12?$12:iM+1},1,1,3,begin(srand($13));[u(255),u(255),u(255)]
  fi
 fi

 if $border_size +rep_create_border_for_rrd[0] $border_size fi

 if $8
  map[0] [1],2 rm[1]
  if $11&&$8==2 hsi2rgb[0] fi
 fi

 if $border_size
  eval. i?I(#0)=[${14-16}];
 fi

 k[0]
endl done
u "{$1}"\
"{$2}"\
"{$3}"\
"{$4}"\
"{$5}"\
"{$6}"\
"{$7}"\
"{$8}"\
"{$9}"_{!$8?2}\
"{$10}"_{$8==1?2}\
"{$11}"_{$8==2?2}\
"{$12}"_{$8==2?2}\
"{$13}"_{$8?2}\
"{$14,$15,$16}"_{$border_size?2:1}
+rep_create_border_for_rrd:
+f (i!=j(-1,0))||(i!=j(0,-1))
dilate. $1
f. i||x<$1||y<$1||x>(w-$1-1)||y>(h-$1-1)

 

 

Edited by Reptillian
  • Like 1
  • Upvote 2

G'MIC Filter Developer

Link to comment
Share on other sites

This is cool @Reptillian!  Reminds me of a computer chip board.  Thank you.  ☺️

 

randomrectdiv_01.png

 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...