Historique des modifications [retour]
cliquez ici pour masquer/afficher la révision 4
mineure

12 Oct '19, 06:57

Pathe's gravatar image

Pathe
7.6k49210252

Interrupteur booléen

Comment créer un booléen (« orientation ») et une variable (« \n \\n » qui vaut 1 si orientation=true `orientation=true` et 2 sinon) qui permettent de dessiner selon les valeurs une figure (la partie intitulée « Vis » dans le code ci-dessous) vers la droite ou vers la gauche ? \documentclass[12pt,a4paper]{article} \usepackage[latin1,utf8]{inputenc} \usepackage[french]{babel} \usepackage[T1]{fontenc} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{lmodern} \usepackage{fourier} \usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry} \usepackage{tikz} \usetikzlibrary{patterns} \usepackage{tkz-euclide} \usetkzobj{all} \usepackage{xkeyval} \usepackage{ifthen} \makeatletter %----------> \CrayonGris <---------- \definecolor{wood}{cmyk}{0.00,0.12,0.35,0.05} \define@cmdkey [DES] {CrayonGris} {inclinaison}{} \define@cmdkey [DES] {CrayonGris} {mine}{} \define@cmdkey [DES] {CrayonGris} {corps}{} \define@cmdkey [DES] {CrayonGris} {couleur}{} \define@cmdkey [DES] {CrayonGris} {xscale}{} \define@cmdkey [DES] {CrayonGris} {yscale}{} \define@boolkey [DES] {CrayonGris} {bague}[true]{} \define@boolkey+ [DES] [CrayonGris} {orientation}[true]{} \presetkeys [DES] {CrayonGris} {inclinaison = 0, mine = red, corps = blue, couleur = wood, xscale=1, yscale=1}{} % \newcommand{\CrayonGris}[2][]{% \setkeys[DES]{CrayonGris}{#1} \begin{scope}[shift={(#2)},rotate=\cmdDES@CrayonGris@inclinaison, xscale=\cmdDES@CrayonGris@xscale, yscale=\cmdDES@CrayonGris@yscale] % Pointe ouverte \draw[fill=\cmdDES@CrayonGris@couleur] (-0.3,0.6) -- (0,0) -- (0.3,0.6) arc(-90:-180:0.1) arc(0:-180:0.1) arc(0:-180:0.1) arc(0:-90:0.1); % Mine \draw[fill=\cmdDES@CrayonGris@mine] (-0.1,0.2) -- (0.1,0.2) -- (0,0) -- cycle; % Corps du crayon \draw[fill=\cmdDES@CrayonGris@corps] (0.3,0.6) arc(-90:-180:0.1) arc(0:-180:0.1) arc(0:-180:0.1) arc(0:-90:0.1) -- (-0.3,6) -- (0.3,6) -- cycle; % Traits verticaux \draw (-0.2,6) -- (-0.2,0.65) (0,6) -- (0,0.65) (0.2,6) -- (0.2,0.65); % Bague \if \cmdDES@CrayonGris@bague \draw[fill=gray!20,opacity=0.5] (-0.4,1.5)rectangle(0.4,2.5); % Vis \if \cmdDES@CrayonGris@orientation let \n = 1 \else let \n = 2 \fi \draw[fill=gray!20] (0.4*(-1)^{\n},1.9)--(0.6*(-1)^{\n},1.9)--(0.6*(-1)^{\n},1.8)--(0.8*(-1)^{\n},1.8)--(0.8*(-1)^{\n},2.2)--(0.6*(-1)^{\n},2.2)--(0.6*(-1)^{\n},2.1)--(0.4*(-1)^{\n},2.1)--cycle; %\draw[fill=gray!20] (0.4*(-1)^{\n},1.9)--(0.6,1.9)--(0.6,1.8)--(0.8,1.8)--(0.8,2.2)--(0.6,2.2)--(0.6,2.1)--(0.4,2.1)--cycle; \fi \end{scope} } \makeatother
cliquez ici pour masquer/afficher la révision 3
mineure

11 Oct '19, 12:27

Pathe's gravatar image

Pathe
7.6k49210252

interrupteur booleenInterrupteur booléen

Comment créer un booléen ("orientation") (« orientation ») et une variable ("\n" (« \n » qui vaut 1 si orientation=true et 2 sinon) qui permettent de dessiner selon les valeurs une figure (la partie intitulée "Vis" « Vis » dans le code ci-dessous) vers la droite ou vers la gauche ? \documentclass[12pt,a4paper]{article} \usepackage[latin1,utf8]{inputenc} \usepackage[french]{babel} \usepackage[T1]{fontenc} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{lmodern} \usepackage{fourier} \usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry} \usepackage{tikz} \usetikzlibrary{patterns} \usepackage{tkz-euclide} \usetkzobj{all} \usepackage{xkeyval} \usepackage{ifthen} \makeatletter %----------> \CrayonGris <---------- \definecolor{wood}{cmyk}{0.00,0.12,0.35,0.05} \define@cmdkey [DES] {CrayonGris} {inclinaison}{} \define@cmdkey [DES] {CrayonGris} {mine}{} \define@cmdkey [DES] {CrayonGris} {corps}{} \define@cmdkey [DES] {CrayonGris} {couleur}{} \define@cmdkey [DES] {CrayonGris} {xscale}{} \define@cmdkey [DES] {CrayonGris} {yscale}{} \define@boolkey [DES] {CrayonGris} {bague}[true]{} \define@boolkey+ [DES] [CrayonGris} {orientation}[true]{} \presetkeys [DES] {CrayonGris} {inclinaison = 0, mine = red, corps = blue, couleur = wood, xscale=1, yscale=1}{} % \newcommand{\CrayonGris}[2][]{% \setkeys[DES]{CrayonGris}{#1} \begin{scope}[shift={(#2)},rotate=\cmdDES@CrayonGris@inclinaison, xscale=\cmdDES@CrayonGris@xscale, yscale=\cmdDES@CrayonGris@yscale] % Pointe ouverte \draw[fill=\cmdDES@CrayonGris@couleur] (-0.3,0.6) -- (0,0) -- (0.3,0.6) arc(-90:-180:0.1) arc(0:-180:0.1) arc(0:-180:0.1) arc(0:-90:0.1); % Mine \draw[fill=\cmdDES@CrayonGris@mine] (-0.1,0.2) -- (0.1,0.2) -- (0,0) -- cycle; % Corps du crayon \draw[fill=\cmdDES@CrayonGris@corps] (0.3,0.6) arc(-90:-180:0.1) arc(0:-180:0.1) arc(0:-180:0.1) arc(0:-90:0.1) -- (-0.3,6) -- (0.3,6) -- cycle; % Traits verticaux \draw (-0.2,6) -- (-0.2,0.65) (0,6) -- (0,0.65) (0.2,6) -- (0.2,0.65); % Bague \if \cmdDES@CrayonGris@bague \draw[fill=gray!20,opacity=0.5] (-0.4,1.5)rectangle(0.4,2.5); % Vis \if \cmdDES@CrayonGris@orientation let \n = 1 \else let \n = 2 \fi \draw[fill=gray!20] (0.4*(-1)^{\n},1.9)--(0.6*(-1)^{\n},1.9)--(0.6*(-1)^{\n},1.8)--(0.8*(-1)^{\n},1.8)--(0.8*(-1)^{\n},2.2)--(0.6*(-1)^{\n},2.2)--(0.6*(-1)^{\n},2.1)--(0.4*(-1)^{\n},2.1)--cycle; %\draw[fill=gray!20] (0.4*(-1)^{\n},1.9)--(0.6,1.9)--(0.6,1.8)--(0.8,1.8)--(0.8,2.2)--(0.6,2.2)--(0.6,2.1)--(0.4,2.1)--cycle; \fi \end{scope} } \makeatother
cliquez ici pour masquer/afficher la révision 2

10 Oct '19, 12:17

samcarter's gravatar image

samcarter
8.6k2817

cliquez ici pour masquer/afficher la révision 1

10 Oct '19, 12:02

pdesmons's gravatar image

pdesmons
294919