Sign in to follow this  
TechnoRobbo

TR's Pixel Puller v1.1 (9-3-2013)

Recommended Posts

Technorobbo's Pixel Puller


Designed to be a companion piece to the Pixel Pusher


Pull the image around to emphasize or de-emphasize perspective.


 


 


V1.1 faster code - Extreme warping


 


Menu: Effects->Distort


 


TrsPixelPullerMenu.png?raw=1


 





 


ToyTiger


TrsPixelPuller.png?raw=1


 


The 3 Zebra Stooges


TrsPixelPullerX.png?raw=1


 


The Menagerie


Menagerie.png?raw=1


 


 


The Code


 


Hidden Content:


// Submenu: Distort

// Name: TR's Pixel Puller v1.1

// Title: Pixel Puller - v1.1

// Author: TechnoRobbo


 

 

#region UICode

Pair<double, double> Amount1 = Pair.Create( 0.0 , 0.0 ); // Image Control

byte Amount2 = 0; // [1] Warp Type|Bezier (smooth)|Exponential (Extreme)

#endregion 

 

 

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

{

    Rectangle sel = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();

    //Pull===================================

    float controlx =(float)((Amount1.First + 1)/2);

    float controly =(float)((Amount1.Second + 1)/2);

    bool bezier = (Amount2==0);

    float nx = 0;

    float ny = 0;

    for (int y = rect.Top; y <rect.Bottom; y++){

        for (int x=rect.Left ; x< rect.Right ;x++){

            float spanx =((float)x - (float)sel.Left)/(float)sel.Width;

            float spany =((float)y - (float)sel.Top)/(float)sel.Height;

            

            if (bezier){

                nx =sel.Left + (1-((controlx * (1 - spanx)) * spanx + (1 - spanx) * (controlx * spanx + (1 - spanx)))) * sel.Width;

                ny =sel.Top + (1-((controly * (1 - spany)) * spany + (1 - spany) * (controly * spany + (1 - spany)))) * sel.Height;

            }else{

                nx =sel.Left + (float)Math.Pow(spanx,controlx * 4.90 +.1) * sel.Width;

                ny =sel.Top +  (float)Math.Pow(spany,controly * 4.90 +.1) * sel.Height;

            }

            ColorBgra CP= src.GetBilinearSampleClamped(nx,ny);

            dst[x,y]=CP;

       }

    }

}

 


 


TRsPixelPuller.zip

Edited by TechnoRobbo
  • Upvote 2

Share this post


Link to post
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.

Sign in to follow this