I want to apply a nonlinear transformation to the following image
Whose code is
\begin{tikzpicture}
\draw (-4,-2) grid [step=1] (4,2);
\draw[
fill=green!30, draw=blue, very thick, rounded corners=5ex, opacity=.5, dashed] (-2.,-1.) rectangle (2.,1.);
\end{tikzpicture}
With the nonlinear transformation I found there I get

The code is
\documentclass[tikz,border=3mm]{standalone}
\usepgfmodule{nonlineartransformations}
\makeatletter
\def\mytransformation{%
\pgfmathsetmacro{\myX}{\pgf@x + 4sin(4\pgf@y) }
\pgfmathsetmacro{\myY}{\pgf@y}
\setlength{\pgf@x}{\myX pt}
\setlength{\pgf@y}{\myY pt}
}
\makeatother
\begin{document}
\begin{tikzpicture}
\begin{scope}%Inside the scope transformation is active
\pgftransformnonlinear{\mytransformation}
\draw (-4,-2) grid [step=1] (4,2);
\draw[
fill=green!30, draw=blue, very thick, rounded corners=5ex, opacity=.5, dashed] (-2.,-1.) rectangle (2.,1.);
\end{scope}
\end{tikzpicture}
\end{document}
How is it possible to let the edges transform well ?




\newcommand\xx{1}or like this\def\xx{0.8}In addition you can change control points or add new ones if needed. – kabenyuk Jul 27 '22 at 14:50