Jump to content
How to Install Plugins ×

Circle Fractal


AhmedElyamani

Recommended Posts

Not bad at all.

 

Here's some feedback:

-It seems using '2 angles' produces a result that is virtually identical as using '1 angel'. If that is the indented (mathematically correct) result, perhaps get ride of "1" and just make the minimum option value "2".

-The "Fill Color" color wheel should be placed directly under the "Filling" checkbox. Also don't use both "Fill" and "Filling"; use one or the other.

-The "Brush Size" slider and "Outline Color" color wheel could be disabled when the "Outline" checkbox is unchecked. Likewise with the "Fill Color" color wheel and "Filling" checkbox.

-An anti-aliasing option wouldn't hurt either.

 

The source code would be appreciated for the sake of software freedom, if nothing else. :D

Edited by toe_head2001

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
Share on other sites

@AhmedElyamani! Thanks for the effort and plugin. 9gut87cp.gif

 

3zppfqmt.png

Edited by Seerose
  • Upvote 2

Live as if you were to die tomorrow. Learn as if you were to live forever.

Gandhi

 

mae3426x.png

Link to comment
Share on other sites

Well done Ahmed.

There is a small problem with the rendering because sometimes there are some empty stripes in the image (Win8.1 Paint.net 4.05)

 

post-79572-0-92003900-1431364553_thumb.j

 

 

  • Upvote 1

midoras signature.gif

Link to comment
Share on other sites

Well done Ahmed.

There is a small problem with the rendering because sometimes there are some empty stripes in the image (Win8.1 Paint.net 4.05)

 

 

B) I do not speak English. I also wanted to say the same thing. I use google translator.

Live as if you were to die tomorrow. Learn as if you were to live forever.

Gandhi

 

mae3426x.png

Link to comment
Share on other sites

Thanks for the great feedback , everyone!

 

@toe_head2001  I've applied all of your suggestions , except for disabling the UI items , as I have no idea how to do it.

@TechnoRobbo  I've now included the option to draw polygons (which turned out a bit trickier than expected :P  )

@medora & seerose I think it should be resolved now

 

Updated version is now included in the original post. You can make more fancy shapes like these:
shape3.pngshape4.pngshape5.png

 

Also here is the source code:

 

#region UICode
int Amount1 = 8; // [1,10] Angles
int Amount2 = 6; // [2,11] Vertices , 11 = Circle
bool Amount3 = true; // [0,1] Fill
ColorBgra Amount4 = ColorBgra.FromBgr(200,120,0); // Fill Color
bool Amount5 = true; // [0,1] Outline
int Amount6 = 1; // [1,100] Brush Size
ColorBgra Amount7 = ColorBgra.FromBgr(120,0,0); // Outline Color
int Amount8 = 100; // [0,200] Zoom
bool Amount9 = true; // [0,1] rotation
bool Amount10 = false; // [0,1] anti-aliasing
#endregion
//    
//DrawShapes (Graphics g ,Brush b,  Pen p, double x , double y , double r , ColorBgra c , ColorBgra cF ,bool fill,bool outline , int verts ,int rotVal)

int lengthdirX(int length, double dir)
{
	return (int)(Math.Cos(dir/180 * Math.PI)*length);
}
int lengthdirY(int length, double dir)
{
	return (int)(Math.Sin(dir/180 * Math.PI)*length);
}

void DrawShape(Graphics g ,Brush b,Pen p, int x , int y ,int r , bool fill, bool outline , int verts , int rot)
{

	if (verts>10)
	{
		Rectangle rect1 = new Rectangle(x - r , y - r , r*2 , r*2);
		if(fill)g.FillPie( b , rect1 , 0.0f , 360.0f);
		if(outline) g.DrawArc( p , rect1 , 0.0f , 360.0f );
	}
	else
	{
		if(fill)
		{
		
			System.Drawing.PointF[] shapePoints = new System.Drawing.PointF[verts];
			int length = (int)(2*r*Math.Sin(Math.PI/verts)),
				originalAngle= (180 - (verts-2) * 180 /verts)/2 ,
			angle = rot+originalAngle;
			shapePoints[0] = new System.Drawing.PointF((float)(x-lengthdirX(r,270-rot)),(float)(y+lengthdirY(r,270-rot)));
			for(int i=1; i<verts; i++)
			{
				float xx=shapePoints[i-1].X + lengthdirX(length , angle),
				yy = shapePoints[i-1].Y + lengthdirY(length , angle);
				shapePoints[i] = new System.Drawing.PointF((float)xx,(float)yy);
						angle  = (angle +originalAngle * 2)%360 ;
			}
			System.Drawing.Drawing2D.FillMode newFillMode = System.Drawing.Drawing2D.FillMode.Winding;
			g.FillPolygon(b,shapePoints,newFillMode);
		}
		
		if(outline)
		{
			System.Drawing.Point[] shapePoints = new System.Drawing.Point[verts];
			int length = (int)(2*r*Math.Sin(Math.PI/verts)),
				originalAngle= (180 - (verts-2) * 180 /verts)/2 ,
			angle = rot+originalAngle;
			shapePoints[0] = new System.Drawing.Point(x-lengthdirX(r,270-rot),y+lengthdirY(r,270-rot));
			for(int i=1; i<verts; i++)
			{
				int xx=shapePoints[i-1].X + lengthdirX(length , angle),
				yy = shapePoints[i-1].Y + lengthdirY(length , angle);
				shapePoints[i] = new System.Drawing.Point(xx,yy);
						angle  = (angle +originalAngle * 2)%360 ;
			}
			g.DrawPolygon(p, shapePoints);
		}
		
	}
}

void DrawShapes (Graphics g ,Brush b,  Pen p, double x , double y , double r , ColorBgra c , ColorBgra cF ,bool fill,bool outline , int verts ,int rotVal)
{
    if(r<=1) return;

    DrawShape(g, b,p, (int)x , (int)y,(int)r , fill , outline , verts ,rotVal);
    Pen newPen = new Pen(c);
    SolidBrush newBrush = new SolidBrush(cF);
    newPen.Width=Amount6;
    for(double Ang=360; Ang>=0; Ang-=Math.Ceiling((double)(360.00/(Amount1))))
    {
        DrawShapes(g,newBrush, newPen, x + (2 * r) * Math.Cos( Ang / 180 * Math.PI) , 
        y + (2* r) * Math.Sin( Ang / 180 * Math.PI) , r/3 ,c ,cF,fill,outline ,verts , (Amount9?(int)Ang:0));
    }
}

void Render(Surface dst, Surface src, Rectangle rect)
{

    Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
    dst.CopySurface(src,rect.Location,rect);
    int CenterX = ((selection.Right - selection.Left) / 2)+selection.Left;
    int CenterY = ((selection.Bottom - selection.Top) / 2)+selection.Top;
    ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
    Graphics canvas = new RenderArgs(dst).Graphics;
    
    canvas.SmoothingMode = Amount10? System.Drawing.Drawing2D.SmoothingMode.AntiAlias:System.Drawing.Drawing2D.SmoothingMode.None;
    int BrushWidth = (int)EnvironmentParameters.BrushWidth;
    Pen myPen = new Pen(Amount7);
    SolidBrush myBrush = new SolidBrush(Amount4);
    myPen.Width=Amount6;   
    double r = ((double)Amount8/100.00) * Math.Min(selection.Right - selection.Left , selection.Bottom - selection.Top)/6;
	DrawShapes(canvas, myBrush,  myPen ,CenterX, CenterY , r , Amount7 , Amount4,Amount3,Amount5 ,Amount2 ,0);
   
    ColorBgra CurrentPixel;
    for (int y = rect.Top; y < rect.Bottom; y++)
    {
        if (IsCancelRequested) return;
        for (int x = rect.Left; x < rect.Right; x++)
        {
            CurrentPixel = src[x,y];
            dst[x,y] = CurrentPixel;
        }
    }
} 

 

 

circleFractal2.zip

  • Upvote 1
Link to comment
Share on other sites

@toe_head2001  I've applied all of your suggestions , except for disabling the UI items , as I have no idea how to do it.

 

It's supported by IndirectUI, but CodeLab doesn't expose the functionality; you'd have to use VisualStudio.

http://forums.getpaint.net/index.php?/topic/22046-tutorial-how-to-use-indirectui-rules/

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
Share on other sites

Don't forget to Dispose() unmanaged resources like pens and brushes.

Best is to use a using statement like

 

using (var pen = new Pen(...))

{

  // use the pen

}

  • Upvote 1

midoras signature.gif

Link to comment
Share on other sites

When rendering, I still see empty stripes that can seen be with or without using the anti-aliasing feature.

Link to comment
Share on other sites

Does this effect only work in 4.05 ?  I'm still using the old version and cannot find this effect after downloading.  It's such a cool effect and I'd really like to use it in a current project I'm working on.

Edited by Rainiqui
Link to comment
Share on other sites

When rendering, I still see empty stripes that can seen be with or without using the anti-aliasing feature.

 

Same here, using the latest version.

Link to comment
Share on other sites

 

When rendering, I still see empty stripes that can seen be with or without using the anti-aliasing feature.

 

Same here, using the latest version.

Try commenting out the last set of loops - lines 110 to 119 and rebuild. (the dst surface is already copied in line 96). Seems to work for me anyway.

The graphics objects should really be disposed as Midora suggested too.

Clever effect though! ;)

 

Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings

 

PdnForumSig2.jpg

Link to comment
Share on other sites

  • 1 year later...

Here is a little something for all you fractal lovers. I like the way it provides an ability to test the blending of different colors. Thank you Ahmed. Hope you come back soon.

 

URsrFNk.png

 

Edited by AndrewDavid
Refreshed Link
  • Upvote 2

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

  • 1 month later...
  • 1 year later...

Hello @Makc I have just tested this Plugin and it is working for me.

 

I notice that you have your cuboids 'selected' with the magic wand.  Please run the Plugin on its own layer without anything selected.

 

circle-fractal.png    ~clickable ~

30b8T8B.gif

How I made Jennifer & Halle in Paint.net

My Gallery | My Deviant Art

"Rescuing one animal may not change the world, but for that animal their world is changed forever!" anon.

 
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.

×
×
  • Create New...