The invention relates to a color-coding method comprising the steps of: providing a composition containing a liquid medium, and magnetic nanoparticles distributed in the liquid medium; applying a magnetic field to the composition to align the magnetic nanoparticles; and radiating a patterned energy source to solidify the composition, wherein the intensity of the magnetic field varies to sequentially solidify various components of the composition and to fix a plurality of color codes.