%\NeedsTeXFormat{LaTeX2e}
%\typeout{Option Style‘qbgraph’2005 July 29 by T. Moonlight}
%\typeout{......................main style +qbgraph++++++++++}
\typeout{                       sub style         +qbgrapha+ something else}
%
\newcommand{\qbpictaxis}{
      \Div{\tmpPicW}{20}{\tmpArrowL}
      \Div{\tmpPicH}{-20}{\tmpDum}
      \Add{\tmpPicL}{\tmpPicWs}{\tmpPicRs}
      \Add{\tmpPicB}{\tmpPicHs}{\tmpPicTs}
      \qbarrow{\tmpPicL}{0}{\tmpPicRs}{0}{\tmpArrowL}
      \qbarrow{0}{\tmpPicB}{0}{\tmpPicTs}{\tmpArrowL}
      \put(\tmpPicRs,\tmpDum){$x$}
      \Div{\tmpDum}{2}{\tmpDum} \Add{\tmpPicTs}{\tmpDum}{\tmpDum}
      \put(\tmpArrowL,\tmpDum){$y$}
}
%
\newcommand{\qbpictfstfig}[6]{ % #1x+#2y+#3><0 (#4>0..>,#4=0..=,$4<0..<) の領域・直線を描く
\ifdim #2 pt=0 pt
%  ax+c >or=or< 0 の形
   \ifdim #1 pt=0 pt
%  c >or=or<= 0 だから何もしないよん、って本当は正しければ全部塗るなんだけど
   \else
      \Div{#3}{#1}{\tmpFsx} \Mul{\tmpFsx}{-1}{\tmpFsx}
      \qbline{\tmpFsx}{\tmpPicB}{\tmpFsx}{\tmpPicT}
      \qbsign{#1}{\tmpKey} \qbsign{#4}{\tmpDum} \Mul{\tmpKey}{\tmpDum}{\tmpKey}
      \ifdim \tmpKey pt<0 pt
         \qbarea{\tmpPicL}{\tmpFsx}{\tmpPicB}{\tmpPicT}{#5}{#6}
      \else
         \ifdim \tmpKey pt>0 pt
            \qbarea{\tmpFsx}{\tmpPicR}{\tmpPicB}{\tmpPicT}{#5}{#6}   
         \fi
      \fi
   \fi
\else
%  y >or=or< \tmpFigA x +\tmpFigB へ変換
   \Div{#1}{#2}{\tmpFigA} \Mul{\tmpFigA}{-1}{\tmpFigA}
   \Div{#3}{#2}{\tmpFigB} \Mul{\tmpFigB}{-1}{\tmpFigB}
   \qbpictfstfun{\tmpFigA}{\tmpFigB}
   \qbsign{#2}{\tmpKey} \qbsign{#4}{\tmpDum} \Mul{\tmpKey}{\tmpDum}{\tmpKey}
   \ifdim \tmpKey pt >0 pt
      \qbpictfstfunareaUp{\tmpFigA}{\tmpFigB}{#5}{#6}
   \else
      \ifdim \tmpKey pt <0 pt
         \qbpictfstfunareaDn{\tmpFigA}{\tmpFigB}{#5}{#6}
      \fi
   \fi
\fi
}
%
\newcommand{\qbsignrule}[3]{
   \ifcase#1 \qbdefp{1}{1}{#2}{#3} \or \qbdefp{1}{-1}{#2}{#3} \or \qbdefp{-1}{1}{#2}{#3} \or \qbdefp{-1}{-1}{#2}{#3} \fi
}
%
\newcommand{\qbsolvefst}[3]{ % #1x + #2 = 0 の解を#3に
   \ifdim #1 pt=0 pt
      \qbdef{0}{#3}
   \else
      \Div{#2}{#1}{\tmpDum} \Mul{\tmpDum}{-1}{#3}
   \fi
}
\newcommand{\qbsolvefigtwo}[8]{ % #1x+#2y+#3=0 #4x+#5y+#6=0 の交点(#7,#8) 平行なら(0,0)を返す。
   \qbmsm{#1}{#2}{#5}{#6}{\tmpDum}
   \ifdim \tmpDum pt= 0 pt
      \qbdefp{0}{0}{#7}{#8}
   \else
      \Div{#5}{\tmpDum}{\tmpMA}
      \Div{#2}{\tmpDum}{\tmpMB} \Mul{\tmpMB}{-1}{\tmpMB}
      \Div{#4}{\tmpDum}{\tmpMC} \Mul{\tmpMC}{-1}{\tmpMC}
      \Div{#1}{\tmpDum}{\tmpMD}
      \qbmam{\tmpMA}{#3}{\tmpMB}{#6}{\tmpDum} \typeout{\tmpDum} \qbdef{\tmpDum}{#7}% \Mul{tmpDum}{-1}{#7}      
      \qbmam{\tmpMC}{#3}{\tmpMD}{#6}{\tmpDum} \typeout{\tmpDum} \qbdef{\tmpDum}{#8}% \Mul{tmpDum}{-1}{#8}      
%      \qbdefp{0}{0}{#7}{#8}
   \fi
}
\newcommand{\qbpictfstfigtwo}[9]{ % #1x+#2y+#3>=<0 #4x+#5y+#6>=<0 (#7=0 >>,1 ><,2 <>,3 <<の領域・直線を描く
\qbsignrule{#7}{\tmpFDum}{\tmpGDum}
\ifdim #2 pt=0 pt
   \qbsolvefst{#1}{#3}{\tmpFlx} \qbdef{\tmpFlx}{\tmpFrx}
   \qbdefp{\tmpPicB}{\tmpPicT}{\tmpfly}{\tmpfry}
\else
   \qbsolvefst{#2}{#1}{\tmpFFigA}   \qbsolvefst{#2}{#3}{\tmpFFigB}
   \qbpictfstfunareaPt{\tmpFFigA}{\tmpFFigB}{\tmpFlx}{\tmpFly}{\tmpFrx}{\tmpFry}
\fi
\ifdim #5 pt=0 pt
   \qbsolvefst{#4}{#6}{\tmpGlx} \qbdef{\tmpGlx}{\tmpGrx}
   \qbdefp{\tmpPicB}{\tmpPicT}{\tmpGly}{\tmpGry}
\else
   \qbsolvefst{#5}{#4}{\tmpGFigA}   \qbsolvefst{#5}{#6}{\tmpGFigB}
   \qbpictfstfunareaPt{\tmpGFigA}{\tmpGFigB}{\tmpGlx}{\tmpGly}{\tmpGrx}{\tmpGry}
\fi
\qbline{\tmpFlx}{\tmpFly}{\tmpFrx}{\tmpFry}
\qbline{\tmpGlx}{\tmpGly}{\tmpGrx}{\tmpGry}
\qbsolvefigtwo{#1}{#2}{#3}{#4}{#5}{#6}{\tmpXsx}{\tmpXsy}
\qbpointb{\tmpXsx}{\tmpXsy}
\ifcase#7
\qbpictareaS{\tmpXsx}{\tmpXsy}{\tmpFrx}{\tmpFry}{\tmpGrx}{\tmpGry}{#8}{#9} \or
\qbpictareaS{\tmpXsx}{\tmpXsy}{\tmpGrx}{\tmpGry}{\tmpFlx}{\tmpFly}{#8}{#9} \or
\qbpictareaS{\tmpXsx}{\tmpXsy}{\tmpFlx}{\tmpFly}{\tmpGlx}{\tmpGly}{#8}{#9} \or
\qbpictareaS{\tmpXsx}{\tmpXsy}{\tmpGlx}{\tmpGly}{\tmpFrx}{\tmpFry}{#8}{#9} \or
\fi
}
\newcommand{\qbmax}[3]{
   \qbdef{#1}{\tmpDum}
   \ifdim #2 pt> \tmpDum pt \qbdef{#2}{\tmpDum} \fi
   \qbdef{\tmpDum}{#3}
}
\newcommand{\qbmin}[3]{
   \qbdef{#1}{\tmpDum}
   \ifdim #2 pt< \tmpDum pt \qbdef{#2}{\tmpDum} \fi
   \qbdef{\tmpDum}{#3}
}

% 一次関数　二次関数
\newcommand{\qbfuncfst}[4]{% #4=#1*#3+#2
   \Mul{#1}{#3}{\tmpf} \Add{\tmpf}{#2}{#4}
}
\newcommand{\qbfuncsec}[5]{% #5=#1*#4^2+#2*#4+#3 =(#1*#4+#2)*#4+#3
   \qbfuncfst{#1}{#2}{#4}{\tmpf} \qbfuncfst{\tmpf}{#3}{#4}{#5}
}
\newcommand{\qbsign}[2]{% #1の符号 +なら1、-なら-1、0の場合は0
   \ifdim #1 pt<0 pt \qbdef{-1}{#2} \else \ifdim #1 pt>0 pt \qbdef{1}{#2} \else \qbdef{0}{#2} \fi\fi
}
\newcommand{\qbabs}[2]{% #2=abs(#1)
   \qbsign{#1}{\tmps} \Mul{#1}{\tmps}{#2}
}
\newcommand{\qbabsd}[3]{% #3=abs(#1-#2)
   \Sub{#1}{#2}{#3} \qbabs{#3}{#3}
}
\newcommand{\qboutofarea}[7]{% (#1,#2)は #3<x<#4 #5<y<#6 の矩形内なら 0
   \qbdef{0}{\tmpAns}
   \ifdim #1 pt < #3 pt    \qbdef{1}{\tmpAns} \fi
   \ifdim #1 pt > #4 pt    \qbdef{1}{\tmpAns} \fi
   \ifdim #2 pt < #5 pt    \qbdef{1}{\tmpAns} \fi
   \ifdim #2 pt > #6 pt    \qbdef{1}{\tmpAns} \fi
   \qbdef{\tmpAns}{#7}
}
%
\endinput
% ここまでがマクロ。以下例文。