box[x_,y_,L_]:={Line[{{x,y},{x+L,y}}],Line[{{x+L,y},{x+L,y+L}}],Line[{{x+L,y+L},{x,y+L}}],Line[{{x,y+L},{x,y}}]}

and[x_,y_]:=Graphics[{AbsoluteThickness[1],Line[{{x,y},{x+1,y}}],Line[{{x,y+1},{x+1,y+1}}],box[x+1,y-1/2,2],Text[StyleForm[" & ",FontSize->32],{x+2,y+1/2}],Line[{{x+3,y+1/2},{x+4,y+1/2}}]}]

or[x_,y_]:=Graphics[{AbsoluteThickness[1],Line[{{x,y},{x+1,y}}],Line[{{x,y+1},{x+1,y+1}}],box[x+1,y-1/2,2],Text[StyleForm[" OR ",FontSize->32],{x+2,y+1/2}],Line[{{x+3,y+1/2},{x+4,y+1/2}}]}]

xor[x_,y_]:=Graphics[{AbsoluteThickness[1],Line[{{x,y},{x+1,y}}],Line[{{x,y+1},{x+1,y+1}}],box[x+1,y-1/2,2],Text[StyleForm[" XOR ",FontSize->32],{x+2,y+1/2}],Line[{{x+3,y+1/2},{x+4,y+1/2}}]}]

half[x_,y_]:=Graphics[{AbsoluteThickness[1],Line[{{x,y},{x+1,y}}],Line[{{x,y+1},{x+1,y+1}}],box[x+1,y-1/2,2],Text[StyleForm[" HA ",FontSize->32],{x+2,y+1/2}],Line[{{x+3,y+1},{x+4,y+1}}],Line[{{x+3,y},{x+4,y}}]}]

fulldraw[x_,y_]:={Graphics[Text[" c ",{x,y+0.2}]],Graphics[Text[" y ",{x,y+1.2}]],Graphics[Text[" x ",{x,y+2.2}]],half[x,y+1],Graphics[Line[{{x,y},{x+3,y}}]],half[x+3,y],Graphics[Line[{{x+3,y+2},{x+7,y+2}}]],Graphics[Line[{{x+6,y},{x+11,y}}]],or[x+7,y+1],Graphics[Text[" x⊕y⊕c ",{x+10,y+0.2}]],Graphics[Text[" c' ",{x+11,y+1.2}]]}

halfdraw[]:={Graphics[{Text["y0",{1,2.2}]}],Graphics[{Text["x0",{1,3.2}]}],xor[1,2],Graphics[{Line[{{1.25,7},{1.5,7}}],Line[{{1.25,3},{1.25,7}}],Line[{{1.5,2},{1.5,6}}]}],and[1.5,6],Graphics[{Text["S",{4.5,2}],Text["C",{5.0,7}]}]}

full[x_,y_]:=Graphics[{AbsoluteThickness[1],Line[{{x,y-0.25},{x+1,y-0.25}}],Line[{{x,y+1.25},{x+1,y+1.25}}],Line[{{x,y+0.5},{x+1,y+0.5}}],box[x+1,y-1/2,2],Text[StyleForm[" FA ",FontSize->32],{x+2,y+1/2}],Line[{{x+3,y+1},{x+4,y+1}}],Line[{{x+3,y},{x+4,y}}]}]

fourbitdraw:=Show[{half[1,1],Graphics[Line[{{1,2.75},{4,2.75}}]],Graphics[Line[{{1,3.5},{4,3.5}}]],Graphics[Line[{{1,4.0},{7,4.0}}]],Graphics[Line[{{1,4.75},{7,4.75}}]],Graphics[Line[{{1,5.25},{11,5.25}}]],Graphics[Line[{{1,6.0},{11,6.0}}]],full[4,2.25],full[7.0,3.5],full[10,4.75],
Graphics[Text["y0",{1,0.75}]], Graphics[Text["x0",{1,1.75}]],Graphics[Text["y1",{1,2.5}]],Graphics[Text["x1",{1,3.25}]],Graphics[Text["y2",{1,3.75}]],Graphics[Text["x2",{1,4.5}]] , Graphics[Text["y3",{1,5.0}]] ,Graphics[Text["x3",{1,5.75}]]  }]

Qgate[x_,y_,string_]:=Graphics[{AbsoluteThickness[1],Line[{{x,y+1/2},{x+1,y+1/2}}],box[x+1,y-1/2,2],Text[StyleForm[string ,FontSize->32],{x+2,y+1/2}],Line[{{x+3,y+1/2},{x+4,y+1/2}}]}]

Qgate[x_,y_,string_]:=Graphics[{AbsoluteThickness[1],Line[{{x,y+1/2},{x+1,y+1/2}}],Box[x+1,y-1/2,2],Text[StyleForm[string ,FontSize->32],{x+2,y+1/2}],Line[{{x+3,y+1/2},{x+4,y+1/2}}]}]

had1[x_,y_]:=Graphics[{AbsoluteThickness[1],Line[{{x,y+1/2},{x+1,y+1/2}}],Text[StyleForm["|0>" ,FontSize->18],{x+1/2,y+1}],box[x+1,y-1/2,2],Text[StyleForm["H" ,FontSize->32],{x+2,y+1/2}],Text[StyleForm["(|0>+|1>)/(Sqrt[2])" ,FontSize->16],{x+5,y+1}],Line[{{x+3,y+1/2},{x+7,y+1/2}}]}]

had0[x_,y_]:=Graphics[{AbsoluteThickness[1],Line[{{x-1,y+1/2},{x+1,y+1/2}}],box[x+1,y-1/2,2],Text[StyleForm["H" ,FontSize->32],{x+2,y+1/2}],Line[{{x+3,y+1/2},{x+7,y+1/2}}]}]

twoQgate[x_,y_,string_]:=Graphics[{AbsoluteThickness[1],Line[{{x,y},{x+1,y}}],Line[{{x,y+0.75},{x+1,y+0.75}}],box[x+1,y-1/2,2],Text[StyleForm[string ,FontSize->32],{x+2,y+1/2}],Line[{{x+3,y},{x+4,y}}],Line[{{x+3,y+0.75},{x+4,y+0.75}}]}]