Drkcore

12 01 2010 Python Tweet

pycairoでアンパンマン

普段は娘にお絵かき先生で散々描かせられているのでアンパンマン、しょくぱんまん、バイキンまん、カレーパンまん、ドキンちゃん、ホラーマン位は鼻歌混じりでかけるようになってる。

というわけで、アンパンマンをpycairoで。

import cairo
import math

pi = math.pi
WIDTH, HEIGHT = 400, 400

# Setup Cairo
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, WIDTH, HEIGHT)
ctx = cairo.Context(surface)

# Set thickness of brush
ctx.set_line_width(15)
ctx.set_source_rgba (1, 0.2, 0.2, 0.7);
ctx.arc(200, 210, 180, 0, 360 * (pi/180.0));
ctx.stroke()

#左目と眉
ctx.arc(125, 150, 50, -180 * (pi/180.0), 0 * (pi/180.0));
ctx.stroke()
ctx.arc(125, 170, 30, -180 * (pi/180.0), 360 * (pi/180.0));
ctx.fill()

#右目と眉
ctx.arc(275, 150, 50, -180 * (pi/180.0), 0 * (pi/180.0));
ctx.stroke()
ctx.arc(275, 170, 30, -180 * (pi/180.0), 360 * (pi/180.0));
ctx.fill()

#はな
ctx.arc(200, 250, 40, 0, 360 * (pi/180.0));
ctx.stroke()

#ほっぺ
ctx.arc(90, 250, 40, -90 * (pi/180.0), 90 * (pi/180.0));
ctx.stroke()
ctx.arc(310, 250, 40, 90 * (pi/180.0), -90 * (pi/180.0));
ctx.stroke()

#くち
ctx.arc(200, 305, 60, 0 * (pi/180.0), 180 * (pi/180.0));
ctx.close_path()
ctx.stroke()

#ctx.arc(250, 100, 50, -90 * (pi/180.0), 90 * (pi/180.0));


# Output a PNG file
surface.write_to_png("anpan.png")

anpanman

pycairoで一筆書きってのも面白いかも。

あと、タブレットなお絵かき先生に、flickrっぽいアップロードサイトを組み合わせたサービスはどうだろうか?

お絵かき先生2.0ってな感じで、子供の落書きとその成長に合わせた写真をタグ付けしながら、アルバムにしたりできるサービスとデバイスを一緒に売りつけるみたいな。

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021