A diffraction grating is proposed by periodically defining the liquid-crystal director distribution to form alternate parallel aligned and twist nematic regions in a cell placed between two crossed polarizers. Based on the combined phase and amplitude modulation, both 1D and 2D tunable gratings are demonstrated. Low voltage ON/OFF switching of 1st order diffracted light with extinction ratio over 80 is achieved within a small voltage interval of 0.15 Vrms. Unique four-state feature of the cell is obtained and their applications in optical logic devices are discussed.