Measure your foam cushion precisely and cut two matching fabric pieces, adding seam allowance all around for a snug fit.
Cut fabric strips on the bias to encase the piping cord for your cushion. Wrap and glue the fabric securely around the cord. Measure the foam cushion's circumference, then cut a long side strip to match the cushion's height plus seam allowances and full circumference. Sew the piping cord along both edges of this strip.
Turn the pieces right sides together. Sew the top and bottom fabric panels to the piped side strip, leaving an opening for the foam. Turn right side out, insert the cushion, then pin and sew the opening closed.

Cut two fabric pieces to your desired pillow size, incorporating seam allowance.
Place the two pieces right sides together and sew along three sides. On the fourth side, sew the corners for a neat finish while leaving an opening for the insert. Turn right side out, stuff with foam, pin the opening, and stitch it shut.