samcarter
# Merry Chrismas to all of you!
In case you'd like to take a short break from the holidays and play a bit with tex:
What's the shortest code (measured in byte) you can come up to draw a Christmas tree?
![](https://www.amsterdamduckstore.com/wp-content/uploads/2015/07/X-mas-tree-rubber-duck-front.jpg)
(image from https://www.amsterdamduckstore.com/wp-content/uploads/2015/07/X-mas-tree-rubber-duck-front.jpg)
The Christmas tree needs to have
- a star at the top
- at least six branches
- at least five bubbles
You may use
- any engine distributed with miktex/texlive
- any default format for these engines
- any package available on ctan
- don't worry about best practises :)
(in case your editor does not already show you the size in byte, you could e.g. use https://www.atatus.com/tools/byte-counter )
Top Answer
Skillmon
Everybody knows that there are only two forms of true art. Of course I mean pixel-art and ASCII-art. Since the plain ugly tree is already some kind of ASCII-art, pixel-art is still missing in this thread!
# LaTeX pdfTeX, 175 bytes
```
\documentclass{cd}\usepackage{pxpic}\document\pxpic[colors={o=red,#=green,*=yellow,b=brown},skip=.]{{...*}{...#}{..#o#}{...b}{..o##}{.###o#}{...b}{.o####}{###o##o}{...b}}\stop
```
![xmastree-1.png](/image?hash=095b772d84026d3dc2b5c4ce3036127919c5a960f7ea7332010ac43162b8809c)
# LaTeX pdfTeX, 160 bytes
Now that Christmas is over the tree fell over:
```
\documentclass{cd}\usepackage{pxpic}\document\pxpic[colors={o=red,#=green,*=yellow,b=brown},skip=.]{{.#}{.#o.#}{.##.#o.#}{bo#b##bo#*}{.##.o#.#}{.##.#}{.o}}\stop
```
![pxpiccg-1.png](/image?hash=7430810310000bdd6f05ccff1ab463d9bf0526728007e9149bd1c8ad57249510)
# LaTeX pdfTeX, 152 bytes
I'm afraid it'll turn all brown in a couple of days:
```
\documentclass{cd}\usepackage{pxpic}\document\pxpic[colors={o=red,*=yellow,b=brown},skip=.]{{.b}{.bo.b}{.bb.bo.b}{bobbbbbob*}{.bb.ob.b}{.bb.b}{.o}}\stop
```
![pxpiccg-1.png](/image?hash=67165861b2e338421fc34786639fa3c51bc0016785f5abdbd9832e4ae64bc726)
-----
Nicer to read version (of the upright tree):
```
\documentclass{cd}
\usepackage{pxpic}
\document
\pxpic[colors={o=red,#=green,*=yellow,b=brown},skip=.]
{
{...*}
{...#}
{..#o#}
{...b}
{..o##}
{.###o#}
{...b}
{.o####}
{###o##o}
{...b}
}
\stop
```
Answer #2
Skillmon
The same tree as samcarter's ugly one, but this one is plain ugly.
# plain pdfTeX, 43 bytes.
```
\let~\centerline~*~{-o-}~{-oo-}~{-ooo-}\bye
```
![xmastree.png](/image?hash=5f2d6d5a9c92db8f6d61bb3e7baf355a3b213f60f4c759e55e1e4237f6f8d372)
Another version of the same plain ugly tree:
# plain pdfTeX, 43 bytes.
```
\leftskip0ptplus1fil*
-o-
-oo-
-ooo-\bye
```
Answer #3
samcarter
Contender in the category "ugliest tree" :)
```
\documentclass{cd}\document\center*\\-o-\\-oo-\\-ooo-\stop
```
(58 bytes)
![Screenshot 2022-12-23 at 14.41.41.png](/image?hash=30d9e60f2c9e3ff965126feb7634fedad0c0b8db963a16c34a7cf2af683f7598)
Answer #4
Skillmon
My attempt at a plain Ti*k*Zed tree. Not pretty, but a tree in Ti*k*Z.
# plain pdfTeX, ~~203~~197 bytes
```
\input tikz\def~{)--(}\tikz{\fill[green](,~13,~7,4)(2,3~12,3~7,6)(3,5~11,5~7,7);\let~\foreach~\x/~in{3/3,9/3,5/5,8/5,6/2}\fill[red](\x,~)circle(.3);~~in{0,3,...,33}\draw[yellow](7,7)--+(~0:1);}\bye
```
![xmastree.png](/image?hash=49e23bf472ccb26e55cbf8dc0e7b49d88f0e656b8fe8986a8f90628d042000c5)
Answer #5
samcarter
Long, but with colours:
```
\documentclass[tikz]{standalone}\usetikzlibrary{shapes.geometric}\begin{document}\tikz{\fill[green!70!black](-1,-0.8)..controls(-0.6,-1)and(-0.3,-1)..(-0.3,-1)..controls(-0.3,-1)and(-0.5,-1.5)..(-1.5,-1.8)..controls(-1.1,-2)and(-0.6,-2)..(-0.6,-2)..controls(-0.6,-2)and(-0.8,-2.7)..(-1.85,-2.9)..controls(-1.3,-3.7)and(1.6,-3.5)..(1.9,-2.9)..controls(0.8,-2.7)and(0.6,-2)..(0.6,-2)..controls(0.6,-2)and(1.1,-2)..(1.5,-1.8)..controls(0.5,-1.5)and(0.3,-1)..(0.3,-1)..controls(0.3,-1)and(0.6,-1)..(1,-0.8)..controls(0.3,-0.6)and(0,0)..(0,0)..controls(0,0)and(-0.3,-0.6)..(-1,-0.8)--cycle;\node[fill=yellow!90!red,star]at(0,0.1){};\fill[red](0,-1)circle(0.1)(0.8,-1.8)circle(0.1)(-0.8,-1.8)circle(0.1)(0,-2.5)circle(0.1)(1,-3)circle(0.1)(-1,-3)circle(0.1);}\end{document}
```
(767 bytes)
![xmas2.png](/image?hash=03711ca6fec3210634fadc4d5251683bbf064b04d469825216e90b7d2bbc531d)