Polymer-assisted fabrication of nanoparticles and nanocomposites