悪趣味ではあるが,今話題のあの図形を描いてみる
http://nlab.itmedia.co.jp/nl/articles/1508/03/news114.html
に,akihiro kubota(@hemokosa)さんが,ビジュアルデザインなどの分野に特化したプログラミング言語「Processing」を使って描いた例が載っている。
R だと,単に白と黒を入れ替えるだけでは不細工。
emblem = function(type = 1) {
rect = function(x1, y1, x2, y2, col) {
graphics:::rect(x1, y1, x2, y2, col = col, border = col)
}
ellipse = function(x, y, r, col) {
t = seq(0, 2 * pi, by = 0.01)
x1 = cos(t)
y1 = sin(t)
polygon(x + r * x1, y + r * y1, col = col, border = col)
}
a = 200
a2 = 2 * a
a3 = 3 * a
par(mar = rep(1, 4))
plot(0:a3, 0:a3, type = "n", xaxt = "n", yaxt = "n",
xlab = "", ylab = "", bty = "n", asp = 1)
rect(0, a2, a, a3, "#FFD700")
rect(a2, 0, a3, a, "#808080")
r = sqrt(1.5 ^ 2 + 0.5 ^ 2) * a
if (type == 1) {
ellipse(1.5 * a, 1.5 * a, r, "white")
rect(a, 0, a2, a3, col = "black")
} else {
ellipse(1.5 * a, 1.5 * a, r, "black")
rect(a2, a2, a3, a3, "black")
rect(0, 0, a, a, "black")
r = 1.01 * r
rect(a, 1.5 * a - r, a2, 1.5 * a + r, col = "white")
rect(1.5 * a - r, 0, 0, a3, col = "white")
rect(a3, 0, 1.5 * a + r, a3, col = "white")
}
ellipse(2.5 * a, 2.5 * a, 0.5 * a, "red")
}
layout(matrix(1:2, 1))
emblem(1)
emblem(2)
layout(1)