jsonchiu

Members
  • Content count

    119
  • Joined

  • Last visited

Community Reputation

0

About jsonchiu

  • Birthday 01/01/1970
  1. 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 anti-alias Codelab is much better than it was !
  2. Nice Job on the bevel :wink: Could you release the source code? I would like to see how you implemented this.
  3. Bevel Plugin [v1.4, August 22]

    The 403 Forbidden error was caused by some mistake I made in server migration. Sorry for any inconveniences it caused. It should now work.
  4. One thing: on near 45 degree edges, it doesn't antialias at all. Otherwise, great plugin!
  5. Yeah, open-source 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).
  6. 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.
  7. *completed!* Finally different angles! Note: the source code is quite messy... just 'cause I haven't touched Visual Studio for months.
  8. Asmageddon Tools Pack v3

    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)
  9. Simple Lines Plugin

    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 4-slider 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)
  10. 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; } } } }
  11. Well, the current codelab let you create plugins with a few predefined UI. The other way is to get Visual C# Express, and use the package (see stickied threads) to create your plugin.
  12. Bevel Plugin [v1.4, August 22]

    Rounded bevel - beta 1.0 release. Bevel-irregularshape.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, anti-aliasing 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 bad-looking 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; }
  13. Bevel Plugin [v1.4, August 22]

    I'm working on it right now actually, expect it to come out in another week or so (if everything goes well).
  14. 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.
  15. Looking through effect codes

    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 x-position of the pixel, and the variable y means the y-position 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.