Jump to content

AhmedElyamani

Members
  • Posts

    201
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by AhmedElyamani

  1. 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
  2. just to clarify something:

    Paint.NET has four ways of Resampling images when resizing .

    PDNhelp.png

    I assume that you've used the 'Nearest neighbor' option , that option does no smoothing at all , it's used to have the image with all the pixels almost in their places.

    if you want the result to be similar to the original , with the most smoothing , 'Best Quality' is your cup of tea :

    resizedIMG.png

    Here is how the result would look if you use the 'Best Quality' option:

    Hope that was helpful..

    ps: i prefer your new one xD

    Ahmed

  3. Unfortunately that has absolutely nothing in common with the multisampling algorithm which is configured via the "Quality" slider. (Fortunately that doesn't imply your idea is worthless or anything, that's not what I mean) What you describe is essentially a smoothing effect accomplished with post-processing, which reminds me a bit of FXAA or Quincunx. Multisampling works by gathering samples within the same pixel. Without it you get all the shimmering artifacts typically associated with Nearest Neighbor resampling when you shrink an image (and, in fact, they are the exact same thing).

    wait , you meant smoothing works on each pixel ?

    can you link me to a wikipedia topic, please ?

  4. if you need some simple smoothness effect you can simple pick the color of the surrounding pixels of each pixel and use the average as your pixel color .

    this actually simulates Paint.NET's built-in Median effect , and it gives a nice smooth for your effects .

    this might be coded like so:

    	    ColorBgra CurrentPixel,pxl1,pxl2,pxl3,pxl4,pxl5,pxl6,pxl7,pxl8;
    	    CurrentPixel = src[x,y];
    	    pxl1= src[Math.Min(x+1,rect.Right-1),y];
    	    pxl2= src[Math.Max(x-1,rect.Left),y];
    	    pxl3= src[x,Math.Min(y+1,rect.Bottom-1)];
    	    pxl4= src[x,Math.Max(y-1,rect.Top)];
    	    pxl5= src[Math.Min(x+1,rect.Right-1),Math.Min(y+1,rect.Bottom-1)];
    	    pxl6= src[Math.Min(x+1,rect.Right-1),Math.Max(y-1,rect.Top)];
    	    pxl7= src[Math.Max(x-1,rect.Left),Math.Min(y+1,rect.Bottom-1)];
    	    pxl8= src[Math.Max(x-1,rect.Left),Math.Max(y-1,rect.Top)];
    	    CurrentPixel.R=(byte)((CurrentPixel.R+pxl1.R+pxl2.R+pxl3.R+pxl4.R+pxl5.R+pxl6.R+pxl7.R+pxl8.R)/9);
    	    CurrentPixel.G=(byte)((CurrentPixel.G+pxl1.G+pxl2.G+pxl3.G+pxl4.G+pxl5.G+pxl6.G+pxl7.G+pxl8.G)/9);
    	    CurrentPixel.B=(byte)((CurrentPixel.B+pxl1.B+pxl2.B+pxl3.B+pxl4.B+pxl5.B+pxl6.B+pxl7.B+pxl8.B)/9);
    

    Hope you find this helpful :D .

    Ahmed.

  5. Your "hidden content" is still not showing (for me anyhow) :/

    lol i haven't updated it yet .

    i mean i don't have a lot of free time , my TODO list is quite full , so for now you can install them all in the zip file .

    i'll update them really soon :D

    thanks for passing by!

    Ahmed.

  6. .Ahmed's Plugins.

    Hello again !

    This topic shall Contain all my PDN plugins or other additions .

    Plugins:

    You can download the .zip file that has them all :

     

    Ahmed\'s Plugins.zip

     

    (all the plugins are put in alphabetical order.)

     

    Apply Color.dll: Effects----->Color------>Apply Color

    a simple plugin that allows you to (Apply) a color to your image.

    Example:

    testImage_applyColor.png

     

    Cartoonize.dll: Effects----->Artistic------>Cartoonize

    a plugin that turns realistic photos into cartoony style (with some simple dithering ).

    Example:

    testImage_Cartoonize.png

     

    Clarifaction+.dll: Effects----->Photo------>Clarifaction+

    a plugin to clarify your image.

    Example:

    testImage_clarify.png

     

    InkSketch+.dll: Effects----->Artistic------>InkSketch+

    an artistic effect that redraws your image as if drawn with ink.

    Example:

    testImage_InkSketch.png

     

    Posterize+.dll: Adjustment----->Posterize+

    a very useful, customizable effect , it allows you to limit the output of any channel , including HSV , RGB !

    Example:

    testImage_posterize.png

     

    Quick Gravity.dll: Effects----->Distort------>Quick Gravity

    a quick effect that will drag your image down while stretching it , giving it a gravity effect .

    Example:

    testImage_gravity.png

     

    Vibration.dll: Effects----->Distort------>Vibration.

    an effect that well blur and then thick the insides of your image , gives a nice vibration effect.

    Example:

    testImage_vibration.png

    ------------------------------------------------------------------------------------------------------------------------------------------------------------ -- --------

    If you need the source of any of my plugins , please PM me !

    if you have a plugin suggestion , please write it down here .

    please report any errors in this topic.

    Thanks for passing by!

    Ahmed.

     

    • Like 1
    • Upvote 3
×
×
  • Create New...