ChatGPT 可以使用 TikZ 创建很酷的图像

发布于 2022-12-24 08:07:30

选自这里:https://linus.space/posts/2022-12-10-chatgpt-tikz.html

image.png

由 ChatGPT 生成的长颈鹿骑自行车的图像

可以使用 ChatGPT 毕竟要画图像!您需要通过让它为您绘制一些简单的形状来使其进入流程,否则它会声明它不是为绘制图像而制作的,例如“使用 TikZ 绘制矩形”。然后,它会很乐意接受其他东西,比如“用TikZ画红鼻子驯鹿鲁道夫”:
image.png

它也可以是创造性的,无需任何进一步的规范即可绘制艺术品:
image.png

你可以用威廉·卡洛斯·威廉姆斯(William Carlos Williams)的《这只是为了说》(This is Just to Say)等诗来说明:

image.png

你可以结合数学和真实的东西,让它画出“阳光场上的交换图”:
image.png

它可以说明清晨寒冷空气的感觉:

image.png

我让它写了一首关于冰箱里橡皮鸭的诗,并用tikz来说明它:

In the cold and dark of night,
A rubber duck sat out of sight.
Nestled in the fridge so neat,
A lonely duck without a seat.

But as the days went passing by,
The duck began to catch the eye.
A lonely duck no more, it seems,
A friend in the fridge it deems.

The fridge is now a happy place,
With a duck to keep the pace.
No longer cold and dark inside,
The fridge is now a cozy hide.

So here's to you, dear rubber duck,
A loyal friend in fridge or truck.
A symbol of our love and care,
A duck that's always there.

image.png

最后,我让它发明了一个纸笔角色扮演的角色并画了出来(我在描述中添加了换行符):

image.png

代码列举如下:

自行车上的长颈鹿:

\begin{tikzpicture}

% Draw the frame
\draw[fill=gray] (0,0) rectangle (2,1);

% % Draw the wheel
\draw[fill=black] (0,0) circle (0.5);
\draw[fill=black] (2,0) circle (0.5);

% Draw the tire
\draw[fill=black!10] (0,0) circle (0.4);
\draw[fill=black!10] (2,0) circle (0.4);

% Draw the spokes
\foreach \angle in {0,30,...,360} {
    \draw (0,0) -- ({0.5*cos(\angle)},{0.5*sin(\angle)});
    \draw (2,0) -- ({2.5*cos(\angle)},{0.5*sin(\angle)});
}

% Draw the pedals
\draw[fill=gray] (0,0) -- (0.2,0.1) -- (0.2,-0.1);
\draw[fill=gray] (2,0) -- (1.8,0.1) -- (1.8,-0.1);

% Draw the giraffe
\draw[fill=yellow!50] (1,1) -- (1,3) -- (1.5,3.5) -- (0.5,3.5) -- cycle;
\draw[fill=yellow!50] (1,2) -- (1.5,2.5) -- (1.5,2) -- cycle;
\draw[fill=yellow!50] (1,3) -- (1.5,3.5) -- (1.5,3) -- cycle;
\draw[fill=yellow!50] (1,3) -- (1.5,3.5) -- (2,3.5) -- (1.5,3) -- cycle;

% Draw the neck
\draw[fill=yellow!50] (1.5,3.5) -- (1.5,4) -- (1.3,4.5) -- (1.7,4.5) -- cycle;

% Draw the head
\draw[fill=yellow!50] (1.3,4.5) -- (1.7,4.5) -- (1.8,5) -- (1.2,5) -- cycle;

% Draw the eyes
\draw[fill=black] (1.2,5) circle (0.1);
\draw[fill=black] (1.8,5) circle (0.1);

% Draw the mouth
\draw[fill=black] (1.5,4.8) circle (0.1);

\end{tikzpicture}

红鼻子驯鹿鲁道夫:

\begin{tikzpicture}

% Head
\draw (0,0) ellipse (1.5 and 2);

% Antlers
\draw (-2,2) -- (-1.5,1.5) -- (-1,1) -- (-0.5,0.5);
\draw (2,2) -- (1.5,1.5) -- (1,1) -- (0.5,0.5);

% Eyes
\draw (-0.75,-0.5) ellipse (0.25 and 0.5);
\draw (0.75,-0.5) ellipse (0.25 and 0.5);

% Nose
\draw (0,0) ellipse (0.5 and 0.75);
\draw (0,0) ellipse (0.25 and 0.375);

% Mouth
\draw (0,-1) ellipse (1 and 0.25);

% Body
\draw (0,-2) rectangle (3,-4);

% Legs
\draw (1,-4) -- (1.5,-5) -- (2,-5);
\draw (2,-4) -- (2.5,-5) -- (3,-5);

\end{tikzpicture}
创意艺术品:
\begin{tikzpicture}

% Set the color palette
\definecolor{c1}{RGB}{255,0,0}
\definecolor{c2}{RGB}{0,255,0}
\definecolor{c3}{RGB}{0,0,255}
\definecolor{c4}{RGB}{255,255,0}
\definecolor{c5}{RGB}{0,255,255}
\definecolor{c6}{RGB}{255,0,255}

% Draw the first row of shapes
\fill[c1] (0,0) circle (0.5);
\fill[c2] (1,0) circle (0.5);
\fill[c3] (2,0) circle (0.5);
\fill[c4] (3,0) circle (0.5);
\fill[c5] (4,0) circle (0.5);

% Draw the second row of shapes
\fill[c2] (0.5,-1) circle (0.5);
\fill[c3] (1.5,-1) circle (0.5);
\fill[c4] (2.5,-1) circle (0.5);
\fill[c5] (3.5,-1) circle (0.5);
\fill[c6] (4.5,-1) circle (0.5);

% Draw the third row of shapes
\fill[c3] (1,-2) circle (0.5);
\fill[c4] (2,-2) circle (0.5);
\fill[c5] (3,-2) circle (0.5);
\fill[c6] (4,-2) circle (0.5);
\fill[c1] (5,-2) circle (0.5);

% Draw the fourth row of shapes
\fill[c4] (1.5,-3) circle (0.5);
\fill[c5] (2.5,-3) circle (0.5);
\fill[c6] (3.5,-3) circle (0.5);
\fill[c1] (4.5,-3) circle (0.5);
\fill[c2] (5.5,-3) circle (0.5);

% Draw the fifth row of shapes
\fill[c5] (2,-4) circle (0.5);
\fill[c6] (3,-4) circle (0.5);
\fill[c1] (4,-4) circle (0.5);
\fill[c2] (5,-4) circle (0.5);
\fill[c3] (6,-4) circle (0.5);

\end{tikzpicture}
诗《这只是说说而已》:
\begin{tikzpicture}

% Set the font size and style
\fontsize{16}{18}\selectfont
\sffamily

% Draw the first line of the poem
\draw (0,0) node[align=center] {This is just to say};

% Draw the second line of the poem
\draw (0,-1) node[align=center] {I have eaten};

% Draw the plate to hold the plums
\draw (0,-2) rectangle (1,-3);

% Draw the plums on the plate
\fill[purple] (0.25,-2.25) circle (0.1);
\fill[purple] (0.75,-2.25) circle (0.1);
\fill[purple] (0.25,-2.75) circle (0.1);
\fill[purple] (0.75,-2.75) circle (0.1);

% Draw the fourth line of the poem
\draw (0,-4) node[align=center] {that were in};

% Draw an icebox to represent the fifth line of the poem
\draw (0,-5) rectangle (1,-6);
\draw (0.5,-5.5) -- (0.5,-6) -- (1,-6);

% Draw the sixth line of the poem
\draw (0,-7) node[align=center] {and which};

% Draw the seventh line of the poem
\draw (0,-8) node[align=center] {you were probably};

% Draw the eighth line of the poem
\draw (0,-9) node[align=center] {saving};

% Draw the ninth line of the poem
\draw (0,-10) node[align=center] {for breakfast};

% Draw the tenth line of the poem
\draw (0,-11) node[align=center] {Forgive me};

% Draw the eleventh line of the poem
\draw (0,-12) node[align=center] {they were delicious};

% Draw the twelfth line of the poem
\draw (0,-13) node[align=center] {so sweet};

% Draw the thirteenth line of the poem
\draw (0,-14) node[align=center] {and so cold};

\end{tikzpicture}

阳光场上的交换图:

\begin{tikzpicture}

% Set the color palette
\definecolor{c1}{RGB}{255,255,0}
\definecolor{c2}{RGB}{255,128,0}
\definecolor{c3}{RGB}{0,255,0}
\definecolor{c4}{RGB}{0,0,255}
\definecolor{c5}{RGB}{255,0,0}

% Draw the sun
\fill[c1] (0,0) circle (1);
\fill[c2] (0,0) circle (0.5);

% Draw the sky
\fill[c1,c2] (0,0) rectangle (4,-4) {};

% Draw the grass
\fill[c3] (0,-4) rectangle (4,0) {};

% Draw the first object in the diagram
\draw (-1,-2) node[circle, draw=c4, fill=c4!30, minimum size=1cm] (A) {$A$};

% Draw the second object in the diagram
\draw (1,-2) node[circle, draw=c5, fill=c5!30, minimum size=1cm] (B) {$B$};

% Draw the first arrow in the diagram
\draw[->,>=stealth, shorten >=2pt, shorten <=2pt, c4] (A) to node[above] {$f$} (B);

% Draw the second arrow in the diagram
\draw[->,>=stealth, shorten >=2pt, shorten <=2pt, c5] (B) to node[below] {$g$} (A);

\end{tikzpicture}

清晨寒冷空气的感觉:

\begin{tikzpicture}

% Set the color palette
\definecolor{c1}{RGB}{0,0,255}
\definecolor{c2}{RGB}{128,128,255}

% Draw the sky
\fill[c1,c2] (0,0) rectangle (4,-4) {};

% Draw the ground
\fill[black!20] (0,-4) rectangle (4,0) {};

% Draw the trees
\draw (-2,-1) -- (-1.5,-3) -- (-1,-1) -- cycle;
\draw (-1,-1) -- (-0.5,-3) -- (0,-1) -- cycle;
\draw (0,-1) -- (0.5,-3) -- (1,-1) -- cycle;
\draw (1,-1) -- (1.5,-3) -- (2,-1) -- cycle;

% Draw the text
\fontsize{16}{18}\selectfont
\sffamily
\draw (0,-2) node[align=center] {The cold morning air};
\draw (0,-3) node[align=center] {brings a chill to my bones};

\end{tikzpicture}

冰箱里的橡皮鸭诗插图

\begin{tikzpicture}

% Set the color palette
\definecolor{c1}{RGB}{255,255,0}
\definecolor{c2}{RGB}{255,0,0}
\definecolor{c3}{RGB}{255,128,0}

% Draw the fridge
\draw (0,0) rectangle (3,-3);
\draw (1.5,-1.5) -- (1.5,-3) -- (3,-3);

% Draw the duck
\fill[c1] (1,-1) circle (0.5);
\fill[c2] (1,-1) ellipse (0.4 and 0.2);
\draw (1,-1.4) -- (1,-1.6);

% Draw the text
\fontsize{16}{18}\selectfont
\sffamily
\draw (1,-2.25) node[align=center] {In the cold and dark of night};
\draw (1,-2.75) node[align=center] {A rubber duck sat out of sight};
\draw (1,-3.25) node[align=center] {Nestled in the fridge so neat};
\draw (1,-3.75) node[align=center] {A lonely duck without a seat};

\end{tikzpicture}

精灵扎拉:

\begin{tikzpicture}

% Set the color palette
\definecolor{c1}{RGB}{0,255,0}
\definecolor{c2}{RGB}{128,255,128}
\definecolor{c3}{RGB}{255,255,0}

% Draw the character
\fill[c1] (0,0) ellipse (0.75 and 1);
\fill[c2] (0,0) ellipse (0.5 and 0.75);
\fill[c3] (0,0.5) circle (0.1);
\draw (-0.75,0) -- (0.75,0);
\draw (0,0.25) -- (0,-1);
\draw (0,-0.5) -- (0.5,-1);

% Draw the text
\fontsize{16}{18}\selectfont
\sffamily
\draw (0,-1.5) node[align=center] {Zara the Wise};
\draw (0,-2) node[align=center] {Race: Elf};
\draw (0,-2.5) node[align=center] {Class: Mage};
\draw (0,-4) node[align=center] {Appearance: Zara is a tall and slender elf,\\ with long silver hair and piercing green eyes.\\ She wears a flowing blue robe adorned with silver embroidery,\\ and carries a staff topped with a glowing crystal.};

\end{tikzpicture}
0 条评论

发布
问题