Small & Usefull..
The Weird and The Wonderful
1
Posts
1
Posters
0
Views
1
Watching
-
As you can see I went from a maximum of 68 LOC to the current size of 41 LOC. I didn’t manage to remove half of the code, but 40 % still isn’t bad for such a small amount of code. At least I don’t have to maintain those 27 removed lines anymore. At the same time the readability has improved a lot. For completeness the final code:
using System;
using System.Collections.Generic;namespace Gimp.AverageBlur
{
class AverageBlur : Plugin
{
static void Main(string[] args)
{
new AverageBlur(args);
}AverageBlur(string[] args) : base(args, "AverageBlur")
{
}override protected IEnumerable<Procedure> ListProcedures() { yield return new Procedure("plug\_in\_average\_blur", \_("Average blur"), \_("Average blur"), "Maurits Rijk", "(C) Maurits Rijk", "2006-2009", \_("Average"), "RGB\*, GRAY\*") {MenuPath = "<Image>/Filters/Blur"}; } override protected void Render(Drawable drawable) { var iter = new RgnIterator(drawable, \_("Average")); var average = drawable.CreatePixel(); iter.IterateSrc(pixel => average.Add(pixel)); average /= iter.Count; iter.IterateDest(() => average); }
}
}Please read My Last Article and suggest some better ideas. ---------Moving ahead with joy & struggle--------- --Amit