jsonchiu
Members
Content Count
119 
Joined

Last visited
Everything posted by jsonchiu

Diagonal Lines Plugin [v2.5, September 13th, 2009]
jsonchiu replied to jsonchiu's topic in Plugins  Publishing ONLY!
V2.5 Update: 1. added color wheel, alpha slider, and an option to use/not use primary color 2. fixed some transparency issues 3. better antialias Codelab is much better than it was ! 
The 403 Forbidden error was caused by some mistake I made in server migration. Sorry for any inconveniences it caused. It should now work.

Basic Antialias version 1.1  bug fixed (January 14 2008)
jsonchiu replied to pyjo's topic in Plugins  Publishing ONLY!
One thing: on near 45 degree edges, it doesn't antialias at all. Otherwise, great plugin! 
Basic Antialias version 1.1  bug fixed (January 14 2008)
jsonchiu replied to pyjo's topic in Plugins  Publishing ONLY!
Yeah, opensource it, and we (maybe) can help you solve the bug! I met the same "coord out of range" bug too while developing my AA plugin. (fixed) It's because when looping through pixels "around" the corners, some of them will get nasty values like "1, 1" or "1281, 801." Good plugin though! Note: my AA plugin works only in "grow" mode, which means that the shape grow in size. The more it grows the more smooth it is. 7 is the optimal (if growing doesn't matter). 
Diagonal Lines Plugin [v2.5, September 13th, 2009]
jsonchiu replied to jsonchiu's topic in Plugins  Publishing ONLY!
Make sure you download the dll (and don't confuse it with the zip, which contains the source code), and then put it in the Effects folder. Then restart pdn. Make sure you delete old versions. 
Diagonal Lines Plugin [v2.5, September 13th, 2009]
jsonchiu replied to jsonchiu's topic in Plugins  Publishing ONLY!
*completed!* Finally different angles! Note: the source code is quite messy... just 'cause I haven't touched Visual Studio for months. 
For distorts, try src.GetBilinearSample(x, y). For stuff like lines...etc you just need to think of a formula of yourself... (GetBilinearSample is too blurred for that)

If anybody is interested, go to my Diagonal Lines Plugin thread page 2. I've got the script that allows different angles for the lines. The problem is that I cannot compile a 4slider plugin with Codelab. It would be very helpful if anybody can help me create the interface. (Then, instead of having 1000 plugins about lines, you only need 1)

Diagonal Lines Plugin [v2.5, September 13th, 2009]
jsonchiu replied to jsonchiu's topic in Plugins  Publishing ONLY!
I just did some modification (after reviewing trig stuff). Can anybody just do some interface work for me? Codelab doesn't allow 4 sliders... (duh) int Amount1=40; //[3,200] Scanline Interval int Amount2=1; //[1,200] Brush Width int Amount3=5; //[0,9] Antialias Level int Amount4=45; //[0,179] Angle void Render(Surface dst, Surface src, Rectangle rect) { PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra CurrentPixel; //modifying my (x + y) % Amount1 Algorithm, we multiply the x and y by certain value double xfactor = 1; double yfactor = 1; //if y is longer than x, we modify y factor, and vice versa if (Amount4 <= 45  (Amount4 > 135 && Amount4 < 225)  Amount4 > 315) { yfactor = Math.Tan(Amount4 * (3.14159/180)); } else { xfactor = 1 / Math.Tan(Amount4 * (3.14159/180)); } for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { if (selectionRegion.IsVisible(x, y)) { CurrentPixel = src[x,y]; double testnum = (x*xfactor + y*yfactor); if (testnum < 0) { //make the number a positive before doing the modular (%) operation testnum = testnum + Amount1 * 1000000; } double modular = testnum % Amount1; //if modular < thickness if (modular < Amount2) { if ((int)(PrimaryColor.A) == 255) { CurrentPixel.R = (byte)PrimaryColor.R; CurrentPixel.G = (byte)PrimaryColor.G; CurrentPixel.B = (byte)PrimaryColor.B; CurrentPixel.A = (byte)PrimaryColor.A; } else { //some code to multiply color to alpha int alpha = (int)(PrimaryColor.A); int inv_alpha = 255  alpha; CurrentPixel.R = (byte)(((int)(PrimaryColor.R) * alpha + (int)(CurrentPixel.R) * inv_alpha) / 255); CurrentPixel.G = (byte)(((int)(PrimaryColor.G) * alpha + (int)(CurrentPixel.G) * inv_alpha) / 255); CurrentPixel.B = (byte)(((int)(PrimaryColor. * alpha + (int)(CurrentPixel. * inv_alpha) / 255); if ((int)(CurrentPixel.A) < (int)255) { int temp; if ((int)(PrimaryColor.A) + (int)(CurrentPixel.A) >= 255) { temp = 255; } else { temp = (int)(PrimaryColor.A) + (int)(CurrentPixel.A); } CurrentPixel.A = (byte)(((int)(CurrentPixel.A) + temp) / 2); } else { CurrentPixel.A = (byte)255; } } } else if (Amount3 > 0) { //if pixel is beside the line, we do our antialias operation if (modular <= Amount2 + 1  modular >= Amount1  1) { double factor = 0; if (modular >= Amount1  1) { factor = 1  (modular  Amount1 + 1); } else { factor = 1  (Amount2  modular + 1); } //hacks to get around special angles if (Amount4 == 45) { factor += 0.8; } else if (Amount4 == 90) { factor = 0; } else if (Amount4 == 135) { factor = 0.7; } //our antialias routine int mul = (int)((10  Amount3) * factor); int div = mul + 1; CurrentPixel.R = (byte)(((int)(PrimaryColor.R) + mul * (int)(CurrentPixel.R)) / div); CurrentPixel.G = (byte)(((int)(PrimaryColor.G) + mul * (int)(CurrentPixel.G)) / div); CurrentPixel.B = (byte)(((int)(PrimaryColor. + mul * (int)(CurrentPixel.) / div); //alpha multiplication if ((int)(CurrentPixel.A) < (int)255) { int temp; if ((int)(PrimaryColor.A) + (int)(CurrentPixel.A) >= (int)255) { temp = 255; } else { temp = (int)(PrimaryColor.A) + (int)(CurrentPixel.A); } CurrentPixel.A = (byte)((temp + mul * (int)(CurrentPixel.A)) / div); } else { CurrentPixel.A = (byte)255; } } } //and we are done dst[x,y] = CurrentPixel; } } } } 
Rounded bevel  beta 1.0 release. Bevelirregularshape.zip Works well with small depth and single color (sort of a inner glow effect). It of course works great with rectangular selection and circular selection with any colors. I'm still trying to figure out how to blend the colors (so it transitions from highlight to shadow smoothly) Also, antialiasing is another problem... The code (pm if anybody would like to help) int Amount1=7; //[0,200]Depth int Amount2=20; //[0,100]Strength System.Collections.ArrayList sin_arr = new System.Collections.ArrayList(); System.Collections.ArrayList cos_arr = new System.Collections.ArrayList(); void Render(Surface dst, Surface src, Rectangle rect) { PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); // Delete any of these lines you don't need Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); long CenterX = (long)(((selection.Right  selection.Left) / 2)+selection.Left); long CenterY = (long)(((selection.Bottom  selection.Top) / 2)+selection.Top); int left = (int)selection.Left; int top = (int)selection.Top; int right = (int)selection.Right; int bottom = (int)selection.Bottom; ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor; int BrushWidth = (int)EnvironmentParameters.BrushWidth; ColorBgra CurrentPixel; if (cos_arr.Count == 0) { for (int v = 0; v <= 360; v++) { sin_arr.Add((float)Math.Sin((float)v * ((float)3.14159 / (float)180))); cos_arr.Add((float)Math.Cos((float)v * ((float)3.14159 / (float)180))); } } for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { if (selectionRegion.IsVisible(x, y)) { CurrentPixel = src[x,y]; //let's search for the nearest radius int prevX = 1; int prevY = 1; bool found = false; int max; float factor; for (int i = 1; i <= Amount1; i++) { max = (int)Math.Ceiling((float)i * (float)3.14159) + 1; factor = 360 / (float)max; for (int m = 0; m <= max; m++) { int element = (int)Math.Floor(factor * (float)m); int newX = (int)((float)cos_arr[element] * (float)i) + x; int newY = (int)((float)sin_arr[element] * (float)i) + y; if (newX != prevX  newY != prevY) { prevX = newX; prevY = newY; if (selectionRegion.IsVisible(prevX, prevY) == false) { found = true; if (element > 315  element < 125) { CurrentPixel = transformPixel(i, CurrentPixel, SecondaryColor); } else { CurrentPixel = transformPixel(i, CurrentPixel, PrimaryColor); } break; } } } if (found == true) { break; } } dst[x,y] = CurrentPixel; } } } } ColorBgra transformPixel(float px_from_edge, ColorBgra CurrentPixel, ColorBgra NewColor) { //set amount of background interference 0~1 (ie how much it blends to the background) float diff = (float)(0.05 + px_from_edge/Amount1); float strength = (float)((float)(100  Amount2) / 100 + (float)0.35); diff = diff * strength; if (diff > 1) { diff = 1; } else if (diff < 0) { diff = 0; } //some vars just for convenience, more readable float div = diff + 1; float invrt_diff = 1  diff; //we set the RGB to primary color if it is completely transparent (black is the default) //That should solve if (CurrentPixel.A == 0) { CurrentPixel.R = NewColor.R; CurrentPixel.G = NewColor.G; CurrentPixel.B = NewColor.B; } //and we are ready to color the pixels //ex: if 70% background interference //we have 70% of original color's R plus 30% of the new color's R CurrentPixel.R = (byte)((invrt_diff * (float)NewColor.R) + (diff * (float)CurrentPixel.R)); CurrentPixel.G = (byte)((invrt_diff * (float)NewColor.G) + (diff * (float)CurrentPixel.G)); CurrentPixel.B = (byte)((invrt_diff * (float)NewColor. + (diff * (float)CurrentPixel.); //transparency values need special manipulation to prevent badlooking renders float temp = CurrentPixel.A + NewColor.A; if (temp > 255) { temp = 255; } temp = ((int)CurrentPixel.A + temp) / 2; if (CurrentPixel.A < 255) { temp = temp * (1 + (float)invrt_diff); } if (temp > 255) { temp = 255; } CurrentPixel.A = (byte)temp; //and we are done return CurrentPixel; }

I'm working on it right now actually, expect it to come out in another week or so (if everything goes well).

Film Noir Plugin  Updated for Paint.NET 3.20
jsonchiu replied to Simon Brown's topic in Plugins  Publishing ONLY!
Um... my school computer blocked the image because it is categorized "pornography" Obviously that's some BS, but upload the example to photobucket or imageshack please. 
From my understanding, the math is quite simple  take the average color of the pixels inside the radius. It's not any high level math at all. There are 2 for loops inside the render() function where coloring takes place, and the variable x literally means the xposition of the pixel, and the variable y means the yposition of the pixel. Also, it's not that hard to learn programming. It will certainly take some time, but read a few books, do some projects, and you are set.

Fractal Mandelbrot  Updated 09/15/2007
jsonchiu replied to moc426's topic in Plugins  Publishing ONLY!
Completely unrelated to the sample script in codelab, I wrote this code myself. It continuously color the image through as a gradient and it supports zooming up to 10^16. The accuracy of the xpan/ypan is to 10^14 Paste the code into code lab, and experience with the 4 values. If you keep the values unchanged, and keep adding 0's to the Amount3, you will see a zooming sequence similar to the one in Wikipedia (and it goes to the maximum accuracy  about 10^16) which lands on an island. I couldn't do any antialias to the image, so it might look a bit too sharp. Example (I made a large image, resize it, and sharpen a little bit): long Amount1=74657146173202; //[100000000000000, 100000000000000]Xpan long Amount2=10498959565562; //[100000000000000, 100000000000000]Ypan long Amount3=256; //[50, 10000000000000000]Zoom int max = 16384; //[0, 131702]Maximum iteration (Accuracy) double mod = 256; //value doesn't matter, as long as the variable "mod" is declared void Render(Surface dst, Surface src, Rectangle rect) { PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); // Delete any of these lines you don't need Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); long CenterX = (long)(((selection.Right  selection.Left) / 2)+selection.Left); long CenterY = (long)(((selection.Bottom  selection.Top) / 2)+selection.Top); ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor; int BrushWidth = (int)EnvironmentParameters.BrushWidth; ColorBgra CurrentPixel; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { if (selectionRegion.IsVisible(x, y)) { CurrentPixel = src[x,y]; ColorBgra prevPix1; ColorBgra prevPix2; ColorBgra prevPix3; if (x > 1 && y > 1) { prevPix1 = dst[x1,y]; prevPix2 = dst[x1,y1]; prevPix3 = dst[x, y1]; } else { prevPix1 = prevPix2 = prevPix3 = dst[x,y]; } double r = (double)(x  CenterX) / Amount3 + ((double)Amount1 / 100000000000000) * (1); double i = (double)(y  CenterY) / Amount3 + ((double)Amount2 / 100000000000000) * (1); double iter = (double)(mandelbrot(r, i)); CurrentPixel.A = 255; CurrentPixel.R = (byte)(getR(iter)); CurrentPixel.G = (byte)(getG(iter)); CurrentPixel.B = (byte)(getB(iter)); dst[x,y] = CurrentPixel; } } } } double modular(double iter) { if (iter < 512) { mod = 256; return iter % 256; } else if (iter < 2048) { mod = 512; return iter % 512; } else if (iter < 8192) { mod = 4096; return iter % 4096; } else if (iter < 32768) { mod = 16384; return iter % 16384; } else { mod = 65536; return iter % 65536; } } int getR(double iter) { if (iter >= max) { return 0; } iter = modular(iter); if (iter < mod / 4) { return 0; } else if (iter < mod / 2) { double prev = mod / 4; double newIter = iter  prev; int col = (int)(newIter * (255 / mod * 4)); if (col >= 255) { return 255; } else { return col; } } else if (iter < mod / 8 * 5) { return 255; } else if (iter < mod) { return (int)(1  (iter  mod / 8 * 5) * (255 / mod * (1 / ((double)3 / 8)))); } return 0; } int getG(double iter) { if (iter >= max) { return 0; } iter = modular(iter); if (iter < mod / 8) { return 0; } else if (iter < mod / 8 * 3) { return (int)((iter  mod / 8) * (255 / mod * 4)); } else if (iter < mod / 16 * 9) { return 255; } else if (iter < mod / 8 * 6) { return (int)(1  (iter  mod / 16 * 9) / 2 * (255 / mod * 8)); } else if (iter < mod / 16 * 15) { return (int)(1  (iter  mod / 16 * 15) * (255 / mod * (1 / ((double)12 / 16)))); } return 0; } int getB(double iter) { if (iter >= max) { return 0; } iter = modular(iter); if (iter < mod / 4) { return (int)((iter + 100) * (255 / (mod / 4 + 100))); } else if (iter < mod / 2) { return 255; } else if (iter < mod / 16 * 9) { return (int)(1  (iter  mod / 2) * (255 / mod * 16)); } else { return (int)((iter  mod / 16 * 9) / 2 * (255 / mod * (1 / ((double)7 / 16)))); } return 0; } int mandelbrot(double r, double i) { double X = r; double Y = i; double X2 = X * X; double Y2 = Y * Y; int counter = 0; while ((X2 + Y2 < 4) && (counter <= max)) { Y = 2 * X * Y + i; X = X2  Y2 + r; X2 = X * X; Y2 = Y * Y; counter++; } return counter; } 
Primary Color Difference to Alpha
jsonchiu replied to Enormator's topic in Plugins  Publishing ONLY!
This plugin should be called "Primary Color to Alpha" 
Ok sure. I would like to hear your ideas.

Ok. I will explain the situation. So, one of the administrators in this site made an image For use in these widgets (sample below, cp age updates itself) Then, this site accuses us for stealing their image (a sample shown below: Stealing? I think not. Discuss.

Hmmm lots of websites use tables... what's wrong with it? Browser compatibility?

@CMD Tables and CSS are completely different things. What in the world are you talking about? I meant table + CSS. Seriously, who would design a site without CSS?

The Pictorium! Post your created or edited images here!
jsonchiu replied to aatwo's topic in The Pictorium
Should I tutorialize that? It's actually very simple to make. 
I would recommend W3School for learning HTML too. It's not hard. A tip: use tables to align your content. It's the best way. Btw, most of the time I use flash to create my website since I hate patching up code just to make it compatible for both IE and FF.

lolz I'm 13. And I think being 13 might be worse than 12, since you are entering the "dark age"... lol... Btw, highschool starts in a week... will it be any better than Elementary School?