The purpose of this example is to demonstrate the dynamically growing and shrinking of an E\+Physics\+\_\+\+Body -\/ The code applies the growth of a ball and the shrink of another.

 
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth,height=\textheight/2,keepaspectratio=true]{growing_balls}}
\end{DoxyImageNoCaption}


For this example we\textquotesingle{}ll have an E\+Physics\+\_\+\+World and three E\+Physics\+\_\+\+Bodys with different sizes associated with an evas\+\_\+object.

The basic concepts like -\/ defining an E\+Physics\+\_\+\+World, render geometry, physics limiting boundaries, add an E\+Physics\+\_\+\+Body, associate it to evas objects, change restitution, friction and impulse properties, were already covered in \hyperlink{tutorial_ephysics_bouncing_ball}{E\+Physics -\/ Bouncing Ball}\hypertarget{tutorial_ephysics_growing_balls_add-growshrink}{}\section{Adding the growing/shrinking}\label{tutorial_ephysics_growing_balls_add-growshrink}


In this example we\textquotesingle{}ll use a timer to handle the callback function.


\begin{DoxyCodeInclude}
   test\_data->data = \hyperlink{group__Ecore__Timer__Group_ga7b9cb9d24ecebfdbb957436e2e669402}{ecore\_timer\_add}(1, \_grow\_cb, test\_data);

\end{DoxyCodeInclude}


In this callback, we\textquotesingle{}ll pass through a list with 3 balls and apply the growth and the shrink between the limit we\textquotesingle{}ll set. Note that the variable i receives different values on each iteration (-\/1, 0, 1). For the first iteration it will decrease the size variable, the second will keep the same value, and the last one will increase the size variable.




\begin{DoxyCodeInclude}
\_grow\_cb(\textcolor{keywordtype}{void} *data)
\{
   Test\_Data *test\_data = data;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *obj;
   \hyperlink{struct__Eina__List}{Eina\_List} *l;
   \textcolor{keywordtype}{int} size, i = -1;

   \hyperlink{group__Eina__List__Group_gad02f746a08ee0b12b7ed66d4bc0d71d8}{EINA\_LIST\_FOREACH}(test\_data->evas\_objs, l, obj)
     \{
        \hyperlink{group__Evas__Object__Group__Basic_ga6f52fab1a96dc58c85ee481d84bac871}{evas\_object\_geometry\_get}(obj, NULL, NULL, &size, NULL);
        size += i * 8;
        i++;

        \textcolor{keywordflow}{if} ((size < 20) || (size > 120))
          \textcolor{keywordflow}{continue};

        \hyperlink{group__Evas__Font__Group_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(obj, size, size);
     \}

   \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE};
\}

\end{DoxyCodeInclude}


Here we finish the example. The full source code can be found at \hyperlink{test_growing_balls_c}{test\+\_\+growing\+\_\+balls.\+c}. 