Tikz vẽ táo, cam, xoài, anh đào

Lượt xem: 91

Description

Tikz vẽ trái cây (táo, cam, xoài, anh đào) phục vụ việc dạy các cháu bé!

Cách vẽ: chủ yếu dùng \fill pic

Tiếc là sẽ khó vẽ hoa ^^

https://tex.stackexchange.com/…/how-to-make-a-simple-drawin…

Code


\documentclass[tikz,border=5mm]{standalone}
\usepackage{xcolor-material}
\usetikzlibrary{fit}
\tikzset{%
apple/.pic={
\fill [MaterialBrown] (-1/8,0)
arc (180:120:1 and 3/2) coordinate [pos=3/5] (@)-- ++(1/6,-1/7)
arc (120:180:5/4 and 3/2) -- cycle;
\fill [MaterialLightGreen500] (0,-9/10)
.. controls ++(180:1/8) and ++( 0:1/4) .. (-1/3, -1)
.. controls ++(180:1/3) and ++(270:1/2) .. ( -1, 0)
.. controls ++( 90:1/3) and ++(180:1/3) .. (-1/2, 3/4)
.. controls ++( 0:1/8) and ++(135:1/8) .. ( 0, 4/7)
.. controls ++( 45:1/8) and ++(180:1/8) .. ( 1/2, 3/4)
.. controls ++( 0:1/3) and ++( 90:1/3) .. ( 1, 0)
.. controls ++(270:1/2) and ++( 0:1/3) .. ( 1/3, -1)
.. controls ++(180:1/4) and ++( 0:1/8) .. cycle;
\fill [MaterialLightGreen600] (0, 4/7)
.. controls ++( 45:1/8) and ++(180:1/8) .. ( 1/2, 3/4)
.. controls ++( 0:1/3) and ++( 90:1/3) .. ( 1, 0)
.. controls ++(270:1/2) and ++( 0:1/3) .. ( 1/3, -1)
.. controls ++(180:1/4) and ++( 0:1/8) .. ( 0,-9/10);
\fill [MaterialGreen500, shift={(@)}, rotate=-30]
(0,0) arc (45:135:3/4 and 3/5) arc (225:315:3/4 and 3/5);
\fill [MaterialGreen700, shift={(@)}, rotate=-30]
(0,0) arc (315:225:3/4 and 3/5) -- cycle;
},
orange/.pic={
\fill [MaterialOrange500] (0,0) circle [radius=1];
\fill [MaterialOrange600] (0,0) -- (45:1) arc (45:-135:1) -- cycle;
\fill [MaterialOrange700, shift={(0,3/4)}] coordinate (@)
ellipse [x radius=1/4, y radius=1/8];
\begin{scope}
\clip (0,0) circle [radius=1];
\fill [MaterialOrange700, shift=(@)] (90:1/4 and 1/8)
\foreach \i [evaluate={\j=mod(\i,2)+1/4;}]in {0,...,12}{
-- (90+\i*30:\j*3/4 and \j*3/8) } -- cycle;
\end{scope}
\fill [MaterialBrown] (-1/16, 3/4) -- ++(0,1/4) arc (180:0:1/16 and 1/32)
-- ++(0,-1/4) arc (360:180:1/16 and 1/32) -- cycle;
\fill [MaterialGreen500, shift=(@), rotate=-150]
(0,0) arc (45:135:1/2 and 4/5) arc (225:315:1/2 and 3/5);
\fill [MaterialGreen700, shift=(@), rotate=-150]
(0,0) arc (45:135:1/2 and 4/5) -- cycle;
},
lemon/.pic={
\tikzset{rotate=-45}
\fill [MaterialYellow500] (0, 0) ellipse [x radius=1/3, y radius= 1];
\fill [MaterialYellow500] (0, 0) ellipse [x radius=3/4, y radius=7/8];
\fill [MaterialYellow600] (270:1/3 and 1) arc (270:450:1/3 and 1);
\fill [MaterialYellow600] (270:3/4 and 7/8) arc (270:450:3/4 and 7/8);
\begin{scope}[shift=(90:9/10), rotate=-135]
\fill [MaterialGreen500]
(0,0) arc (45:135:1/2 and 4/5) arc (225:315:1/2 and 3/5);
\fill [MaterialGreen700]
(0,0) arc (45:135:1/2 and 4/5) -- cycle;
\tikzset{rotate=90, scale=3/4}
\fill [MaterialGreen500]
(0,0) arc (45:135:1/2 and 4/5) arc (225:315:1/2 and 3/5);
\fill [MaterialGreen700]
(0,0) arc (45:135:1/2 and 4/5) -- cycle;
\end{scope}
},
cherry/.pic={
\foreach \i in {1,2}{
\tikzset{shift={(-1+\i*3/4, -3/5+\i/5)},scale=1/2, rotate=15-\i*10}
\fill [MaterialRed700] (0,19/20)
.. controls ++(180:1/8) and ++( 0:1/4) .. (-1/3, 1)
.. controls ++(180:1/3) and ++( 90:1/2) .. ( -1, 0)
.. controls ++(270:1/2) and ++(180:1/2) .. ( 0, -1)
.. controls ++( 0:1/2) and ++(270:1/2) .. ( 1, 0)
.. controls ++( 90:1/2) and ++( 0:1/3) .. ( 1/3, 1)
.. controls ++(180:1/4) and ++( 0:1/8) .. cycle;
\fill [MaterialRed800] (0, -1)
.. controls ++( 0:1/2) and ++(270:1/2) .. ( 1, 0)
.. controls ++( 90:1/2) and ++( 0:1/3) .. ( 1/3, 1)
.. controls ++(180:1/4) and ++( 0:1/8) .. ( 0,19/20) -- cycle;
\fill [MaterialRed900] (0,3/4) coordinate (@\i)
ellipse [x radius=1/4, y radius=1/8];
}
\fill [MaterialBrown]
(1/4,11/8) -- (3/8,11/8) coordinate (@)
.. controls ++(270:1/2) and ++(135:1/3) .. (@1)
.. controls ++(135:1/2) and ++(270:1/2) .. cycle;
\fill [MaterialBrown]
(1/4,11/8) -- (3/8,11/8)
.. controls ++(315:1/2) and ++(45:1/2) .. (@2)
.. controls ++(60:1/2) and ++(315:1/2) .. cycle;
\fill [MaterialGreen500, shift={(@)}, rotate=20]
(0,0) arc (45:135:3/4 and 3/5) arc (225:315:3/4 and 3/5);
\fill [MaterialGreen700, shift={(@)}, rotate=20]
(0,0) arc (315:225:3/4 and 3/5) -- cycle;
}}
\begin{document}
\tikz\foreach \i [evaluate={\j=int(mod(\i, 4));}] in {0,...,11}
\path (\i*30:5)
\ifcase\j pic {apple} \or pic {orange}
\or pic {lemon} \or pic {cherry}\fi;
\end{document}