Answer
$f(x)=\left\{
\begin{array}{cc}
1 & \quad x \leq -2 \\
2x & \quad -2\lt x\leq0 \\
-\frac{1}{2}x+2 & \quad x \gt 0\\
\end{array}
\right.$
Work Step by Step
Each piece of the function is linear.
When $x\leq-2$, the graph is the line given by
$y=1$.
When $-2\lt x\leq0$, $y=mx+b$ where slope
$m=\frac{y_{2}-y_{1}}{x_{2}-x_{1}}=\frac{0-(-2)}{0-(-1)}=2$ and
y-intercept $b=0$.
$\implies y=(2)x+(0)=2x$
When $x\gt 0$, the graph is the line given by $y=mx+b$ where slope
$m=\frac{1-2}{2-0}=-\frac{1}{2}$ and
y-intercept $b=2$.
$\implies y=-\frac{1}{2}x+2$
So, a piecewise function for the graph is
$f(x)=\left\{
\begin{array}{cc}
1 & \quad x \leq -2 \\
2x & \quad -2\lt x\leq0 \\
-\frac{1}{2}x+2 & \quad x \gt 0\\
\end{array}
\right.$