Jump to content

pascal

Newbies
  • Posts

    6
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by pascal

  1. This plugin can be used to render Julia set fractals using a variety of settings. Adding color options would have made the UI too big, but it can be achieved using my Duotone Gradient Mapping plugin. I hope you enjoy this one! Download: Advanced Julia Fractal.zip Can be found in Effects > Render > Advanced Julia Fractal Previews: Code: (Made in a few hours, so there is probably a lot to improve) // Name: Advanced Julia Fractal // Submenu: Render // Author: Pascal // Title: Advanced Julia Fractal // Version: 1.0.0 // Desc: // Keywords: // URL: // Help: #region UICode IntSliderControl ca = 0; //[-300,300] Real part of constant IntSliderControl cb = 0; //[-300,300] Imaginary part of constant IntSliderControl zoom = 5000; // [1,100000] Zoom IntSliderControl xoff = 0; // [-10000,10000] Offset X IntSliderControl yoff = 0; // [-10000,10000] Offset Y IntSliderControl iterations = 50; //[1,200] Iterations IntSliderControl type = 0; //[0,3] Render type CheckboxControl innerCol = false; //Inner color CheckboxControl invert = false; //Invert CheckboxControl trans = false; //Transparency CheckboxControl invertTrans = false; //Invert Transparency IntSliderControl thresh = 0; //[0,1000] Clean IntSliderControl bright = 0; //[-100,100] Brightness IntSliderControl contr = 0; //[0,100] Contrast CheckboxControl alpha = false; //Preserve alpha #endregion public void Render(Surface dst, Surface src, Rectangle rect) { Rectangle selection = EnvironmentParameters.SelectionBounds; int sw = selection.Right-selection.Left; int sh = selection.Bottom-selection.Top; int dw = selection.Left; int dh = selection.Top; ColorBgra CurrentPixel; for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { if (IsCancelRequested) return; CurrentPixel = src[x,y]; double a = x-dw; double b = y-dh; double ca = this.ca/100f; double cb = this.cb/200f; double dx = (double)xoff; double dy = (double)yoff; double zoom = Math.Pow(this.zoom/100000f,2)*100000f; float val = fractal( (a-sw/2)/zoom + dx/10000f, (b-sh/2)/zoom + dy/10000f, ca, cb, iterations, type ); double thresh = this.thresh/1000f; if(val<thresh || innerCol && val >= (iterations-1)/(float)iterations){ val=0; } if(invert){ val = 1-val; } val+= bright/100f; val = limit(val,0,1); val = contrast(val,contr); val = limit(val,0,1); CurrentPixel.R = (byte)limit(val*255,0,255); CurrentPixel.G = (byte)limit(val*255,0,255); CurrentPixel.B = (byte)limit(val*255,0,255); byte A = CurrentPixel.A; CurrentPixel.A = 255; if(trans){ if(!invert^invertTrans){ CurrentPixel.A = CurrentPixel.R; } else{ CurrentPixel.A = (byte)(255-CurrentPixel.R); } } if(alpha){ CurrentPixel.A = (byte)(CurrentPixel.A*A/255); } dst[x,y] = CurrentPixel; } } } private float fractal(double x, double y,double ca, double cb, int n, int type){ if(type == 0 && x*x+y*y<n && n>0){ return fractal(x*x-y*y+ca,2*x*y+cb,ca,cb,--n,type); } if(type == 1 && Math.Abs(x+y)<2 && n>0){ return fractal(x*x-y*y+ca,2*x*y+cb,ca,cb,--n,type); } if(type == 2 && y<2 && n>0){ return fractal(x*x-y*y+ca,2*x*y+cb,ca,cb,--n,type); } if(type == 3 && x<2 && n>0){ return fractal(x*x-y*y+ca,2*x*y+cb,ca,cb,--n,type); } else{ return 1-n/(float)iterations; } } private float limit(float v, int min, int max){ if(v>max)v=max; else if(v<min)v=min; return v; } private float contrast(float x, double c){ double y; c = Math.Pow(c/2,3); if(x <= .5f){ y = .5f * Math.Pow(2*x, (c/500)+1); } else{ y = 1 - .5f * Math.Pow(2 - 2*x, (c/500)+1); } return (float)y; }
  2. No need, for some reason it works now that I tried again. Very weird.
  3. Yes, I know that. I can edit my post, but I can’t save the edit.
  4. Not sure if this is the right place to ask, but I want to edit my post of a plugin I made. I made an improved version and want to edit the original post. The ‘Edit Topic’ just doesn’t do anything for some reason, does anyone know why?
  5. Back with my second plugin. This time I made a plugin that can be used to easily and quickly create a gradient mapping effect using 2 colors. I know pyrochild already made a gradient mapping tool, but this is just a simplified version using only 2 colors for dark and light tones. I added some options for post processing as well, like contrast and blending mode. Download: DuotoneGradientMap.zip Preview: Code: (I’m still a beginner in C#, please don’t hurt me) // Name: Duotone Gradient Map // Submenu: Color // Author: Pascal // Title: Duotone Gradient Map // Version: 1.0 // Desc: Easy and quick way of gradient mapping // Keywords: // URL: // Help: #region UICode ColorWheelControl Amount1 = ColorBgra.FromBgr(0, 0, 0); // Dark ColorWheelControl Amount2 = ColorBgra.FromBgr(255, 255, 255); // Light IntSliderControl Amount3 = 100; // [0,100] Amount IntSliderControl Amount4 = 0; // [0,1000] Contrast ListBoxControl Amount5 = 0; // Blending mode|Normal|Multiply|Darken|Lighten|Additive #endregion void Render(Surface dst, Surface src, Rectangle rect) { ColorBgra Primary = Amount1; ColorBgra Secondary = Amount2; ColorBgra Cp; //current pixel ColorBgra Np; //new pixel for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { Cp = src[x,y]; //control parameters double A = ((double)Amount3)/100; //amount double C = (double)Amount4; //contrast int M = Amount5; //blending mode //get rgb double R = Cp.R; double G = Cp.G; double B = Cp.B; //value double P = ((R+G+B)/3)/255; //luminosity //get colors double Rp = Primary.R; double Rs = Secondary.R; double Gp = Primary.G; double Gs = Secondary.G; double Bp = Primary.B; double Bs = Secondary.B; //calculate new color R = Norm((P*Rs + (1-P)*Rp)*A + (1-A)*R, 255); G = Norm((P*Gs + (1-P)*Gp)*A + (1-A)*G, 255); B = Norm((P*Bs + (1-P)*Bp)*A + (1-A)*B, 255); //apply new color and contrast Np = ColorBgra.FromBgra( (byte)Norm(Con(B, C), 255), (byte)Norm(Con(G, C), 255), (byte)Norm(Con(R, C), 255), Cp.A); //BLENDING MODES //multiply if(M == 1){ Cp.R = (byte)Norm((Cp.R * Np.R/255)*A + Cp.R*(1-A), 255); Cp.G = (byte)Norm((Cp.G * Np.G/255)*A + Cp.G*(1-A), 255); Cp.B = (byte)Norm((Cp.B * Np.B/255)*A + Cp.B*(1-A), 255); } //darken else if(M == 2){ if(Np.R < Cp.R){ Cp.R = Np.R; } if(Np.G < Cp.G){ Cp.G = Np.G; } if(Np.B < Cp.B){ Cp.B = Np.B; } } //lighten else if(M == 3){ if(Np.R > Cp.R){ Cp.R = Np.R; } if(Np.G > Cp.G){ Cp.G = Np.G; } if(Np.B > Cp.B){ Cp.B = Np.B; } } //additive else if(M == 4){ Cp.R = (byte)Norm(Cp.R + Np.R*A, 255); Cp.G = (byte)Norm(Cp.G + Np.G*A, 255); Cp.B = (byte)Norm(Cp.B + Np.B*A, 255); } //normal else{ Cp = Np; } dst[x,y] = Cp; } } } //normalize double Norm(double x, int i){ if(x > i){ x = i; } if(x < 0){ x = 0; } return x; } //contrast double Con(double x, double c){ x /= 255; double y; if(x <= 0.5){ y = 0.5 * Math.Pow(2*x, (c/500)+1); } else{ y = 1 - 0.5 * Math.Pow(2 - 2*x, (c/500)+1); } return y*255; }
  6. New version available! This plugin can be used to simulate certain colorblindness types such as: protanopia, protanomaly, deuteranopia, deuteranomaly, tritanopia, tritanomaly, achromatopsia and achromatomaly. Download: Colorblindness4.zip Can be found in Effects > Color > Colorblindness Preview: Code: // Name: Colorblindness // Submenu: Color // Author: Pascal // Title: Colorblindness // Version: 4.0.0 // Desc: // Keywords: // URL: // Help: #region UICode ListBoxControl<Btype> btype = 0; //Color blindness type|Protanopia #endregion enum Btype{ Protanopia, Protanomaly, Deuteranopia, Deuteranomaly, Tritanopia, Tritanomaly, Achromatopsia, Achromatomaly, Default } void Render(Surface dst, Surface src, Rectangle rect){ for (int y = rect.Top; y < rect.Bottom; y++){ if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++){ ColorBgra CurrentPixel = src[x,y]; byte r = CurrentPixel.R, g = CurrentPixel.G, b = CurrentPixel.B; byte R, G, B; switch(btype){ case Btype.Protanopia: R = (byte)(0.567 * r + 0.433 * g); G = (byte)(0.558 * r + 0.432 * g); B = (byte)(0.242 * g + 0.758 * b); break; case Btype.Deuteranopia: R = (byte)(0.625 * r + 0.375 * g); G = (byte)(0.7 * r + 0.3 * g); B = (byte)(0.3* g + 0.7 * b); break; case Btype.Tritanopia: R = (byte)(0.950 * r + 0.05 * g); G = (byte)(0.433 * g + 0.567 * b); B = (byte)(0.475* g + 0.525 * b); break; case Btype.Protanomaly: R = (byte)(0.817 * r + 0.183 * g); G = (byte)(0.333 * r + 0.667 * g); B = (byte)(0.125 * g + 0.875 * b); break; case Btype.Deuteranomaly: R = (byte)(0.8 * r + 0.2 * g); G = (byte)(0.258 * r + 0.742 * g); B = (byte)(0.142 * g + 0.858 * b); break; case Btype.Tritanomaly: R = (byte)(0.967 * r + 0.033 * g); G = (byte)(0.733 * g + 0.267 * b); B = (byte)(0.183 * g + 0.817 * b); break; case Btype.Achromatopsia: R = (byte)(0.299 * r + 0.587 * g + 0.114 * b); G = (byte)(0.299 * r + 0.587 * g + 0.114 * b); B = (byte)(0.299 * r + 0.587 * g + 0.114 * b); break; case Btype.Achromatomaly: R = (byte)(0.618 * r + 0.32 * g + 0.062 * b); G = (byte)(0.163 * r + 0.775 * g + 0.062 * b); B = (byte)(0.163 * r + 0.32 * g + 0.516 * b); break; default: R = r; G = g; B = b; break; } dst[x,y] = ColorBgra.FromBgra(limit(B), limit(G), limit(R), CurrentPixel.A); } } } private byte limit(byte p){ if(p > 255){p = 255;} if(p < 0){p = 0;} return p; }
×
×
  • Create New...