如何改进计算器代码?

如何改进计算器代码?

我正在为我的课程编辑一份文档,我的想法是,当我谈论技术时,我会在文档中添加代码。

我希望有与所附图片类似的东西。

在此处输入图片描述

\documentclass[12pt]{standalone}

\usepackage{graphicx}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{pgf,tikz}
\usepackage{xcolor}
\usepackage{ifsym}

\newcommand{\calculator}{ %
        \begin{tikzpicture}[rounded corners=1pt]
        \draw[line width=.4pt,draw=gray!50, ball color = black!70, opacity = 0.7] (0.,0.) -- (0.44,0.) -- (0.44,0.64) -- (0.,0.64) -- cycle;
        \draw[line width=.5pt,draw=white,fill=white] (0.04,0.6) -- (0.4,0.6) -- (0.4,0.44) -- (0.04,0.44) -- cycle;
        \draw[line width=.05pt,draw=blue!50,ball color=blue!50] (0.04,0.4) -- (0.2,0.4) -- (0.2,0.24) -- (0.04,0.24) -- cycle;
        \draw[line width=.05pt,draw=blue!50,ball color=blue!50] (0.24,0.4) -- (0.4,0.4) -- (0.4,0.24) -- (0.24,0.24) -- cycle;
        \draw[line width=.05pt,draw=blue!50,fill=blue, ball color=blue!50] (0.04,0.2) -- (0.2,0.2) -- (0.2,0.04) -- (0.04,0.04) -- cycle;
        \draw[line width=.05pt,draw=orange,ball color=orange] (0.24,0.2) -- (0.4,0.2) -- (0.4,0.04) -- (0.24,0.04) -- cycle;

        \draw (-0.17,0.755) node[anchor=north west] { \scalebox{.4}{ \textifsym{123}}};

        \draw (-0.15,0.52) node[anchor=north west] {\scalebox{.4}{ $\mathbf{ \boldsymbol{+}}$}};
        \draw (0.06,0.52) node[anchor=north west] {\scalebox{.4}{ $\mathbf{-}$}};
        \draw [white] (0.06,0.28) node[anchor=north west] {\scalebox{.4}{ $\mathbf{=}$}};
        \draw (-0.08,0.3) node[anchor=north west] {\scalebox{.4}{\textbf{x}}};
        \end{tikzpicture} }

\begin{document}

\calculator  Calculadora $\boldsymbol{3x+x^2=7}$ 

\end{document}

答案1

这是一项建议。由于您使用的计算器很小,因此我先从全尺寸开始。

\documentclass{article}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{tikz}
\usetikzlibrary{shadings,fit}
\usepackage{ifsym}
\pgfdeclarelayer{bbground}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{bbground,background,main,foreground}
\definecolor{display}{RGB}{206,192,160}
\newcommand{\calculator}[1][0.1]{%
\scalebox{#1}{\begin{tikzpicture}
        \begin{scope}[local bounding box=plus]
         \shade[top color=black!50!white,bottom color=black,rounded corners]
          (0,0) rectangle ++ (1,1);
         \fill[rounded corners=1pt,gray!10] (0.2,0.5) |- (0.4,0.6) |- (0.5,0.8) -| (0.6,0.6)
         -| (0.8,0.5) |- (0.6,0.4) |- (0.5,0.2) -| (0.4,0.4) -| cycle; 
        \end{scope} 
        \begin{scope}[xshift=1.1cm,local bounding box=minus]
         \shade[top color=black!50!white,bottom color=black,rounded corners]
          (0,0) rectangle ++ (1,1);
         \fill[rounded corners=1pt,gray!10] (0.2,0.5) |- (0.5,0.6) -| (0.8,0.5) 
         |- (0.5,0.4) -| cycle; 
        \end{scope} 
        \begin{scope}[local bounding box=times,yshift=-1.1cm]
         \shade[top color=black!50!white,bottom color=black,rounded corners]
          (0,0) rectangle ++ (1,1);
         \fill[rounded corners=1pt,gray!10,rotate around={45:(0.5,0.5)}] 
         (0.2,0.5) |- (0.4,0.6) |- (0.5,0.8) -| (0.6,0.6)
         -| (0.8,0.5) |- (0.6,0.4) |- (0.5,0.2) -| (0.4,0.4) -- (0.2,0.4) -- cycle; 
        \end{scope} 
        \begin{scope}[local bounding box=equal,xshift=1.1cm,yshift=-1.1cm]
         \shade[top color=orange!70!black,bottom color=orange!90!black,rounded corners]
          (0,0) rectangle ++ (1,1);
         \fill[rounded corners=1pt,gray!10,yshift=1.5mm] (0.2,0.5) |- (0.5,0.6) -| (0.8,0.5) 
         |- (0.5,0.4) -| cycle; 
         \fill[rounded corners=1pt,gray!10,yshift=-1.5mm] (0.2,0.5) |- (0.5,0.6) -| (0.8,0.5) 
         |- (0.5,0.4) -| cycle; 
        \end{scope} 
        \begin{scope}[local bounding box=display,yshift=1.1cm]
         \shade[top color=display,bottom color=display!90!black,rounded corners]
          (0,0) rectangle ++ (2.1,1);
         \node[anchor=east,font=\Large\bfseries,text=gray,opacity=0.8] at (2,0.5){\textifsym{123}};
        \end{scope} 
        \begin{pgfonlayer}{background}
         \node[draw=gray!40,line width=0.9pt,top color=gray!70,bottom color=black,rounded corners=4pt,fit=(display) (equal)]
         (fit1){};
        \end{pgfonlayer}
        \begin{pgfonlayer}{bbground}
         \node[top color=gray!70,bottom
         color=gray!70,middle color=black,rounded corners=4pt,fit=(fit1)]
         (fit2){};
        \end{pgfonlayer}
\end{tikzpicture}}}      

\begin{document}
\calculator[1]

\calculator Ingresar la siguiente ecuaci\'{o}n en la calculadora $\boldsymbol{3x+x^2=7}$, determine la cantidad de soluciones. 

\bigskip

\calculator Con Shift 93 limpia la calculadora.

\end{document}

在此处输入图片描述

相关内容