メニュー

pygame.gfxdraw

図形を描写するためのpygameモジュールです。

このモジュールはSDL_gfxライブラリをラッピングしたものです。

この命令は試験的に実装されているものです!:pygameのバージョンが上がると、この命令は仕様が変更されたり使えなくなったりする可能性があります。 この項目にある命令を使用してプログラムを書くと、次期pygameバージョンでは正常に動かなくなることもあります。

この項目の命令の殆どでは、color引数をRGB形式の値として設定します。また RGBA形式の値でも設定ができます。 The color argument can also be an integer pixel value that is already mapped to the Surface's pixel format.

全ての命令では引数を設定する位置が厳密に決まっています。座標と半径を設定する引数位置には整数のみしか設定できません。

rectangle のようにrect型の引数を設定する命令では(x, y, w, h)のタプル型の値を設定できます。ですが、なるべくはpygame.Rect型のインスタンスを設定するほうがよいでしょう。注意してほしいのですが、pygame.Rectには図形の右下座標を表すRect.bottomrightといったような値はありません。The right and bottom attributes of a Rect lie one pixel outside of the Rect's boarder.

この命令はpygameのバージョン1.9.0で新たに実装されました。

pygame module for drawing shapes

Wraps SDL_gfx primatives.

EXPERIMENTAL!: meaning this api may change, or dissapear in later pygame releases. If you use this, your code will break with the next pygame release.

Most of the functions accept a color argument that is an RGB triplet. These can also accept an RGBA quadruplet. The color argument can also be an integer pixel value that is already mapped to the Surface's pixel format.

For all functions the arguments are strictly positional. Only integers are accepted for coordinates and radii.

For functions like rectangle that accept a rect argument any (x, y, w, h) sequence is accepted, though pygame.Rect instances are prefered. Note that for a pygame.Rect the drawing will not include Rect.bottomright. The right and bottom attributes of a Rect lie one pixel outside of the Rect's boarder.

New in pygame 1.9.0.


pygame.gfxdraw.pixel

1ピクセルの点を描写します
pygame.gfxdraw.pixel(surface, x, y, color): return None
place a pixel
pygame.gfxdraw.pixel(surface, x, y, color): return None

pygame.gfxdraw.hline

水平方向の線を描写します
pygame.gfxdraw.hline(surface, x1, x2, y, color): return None
draw a horizontal line
pygame.gfxdraw.hline(surface, x1, x2, y, color): return None

pygame.gfxdraw.vline

垂直方向の線を描写します。
pygame.gfxdraw.vline(surface, x, y1, y2, color): return None
draw a vertical line
pygame.gfxdraw.vline(surface, x, y1, y2, color): return None

pygame.gfxdraw.rectangle

長方形を描写します。
pygame.gfxdraw.rectangle(surface, rect, color): return None
draw a rectangle
pygame.gfxdraw.rectangle(surface, rect, color): return None

pygame.gfxdraw.box

内部を塗りつぶした状態の長方形を描写します。
pygame.gfxdraw.box(surface, rect, color): return None
draw a box
pygame.gfxdraw.box(surface, rect, color): return None

pygame.gfxdraw.line

線を描写します。
pygame.gfxdraw.line(surface, x1, y1, x2, y2, color): return None
draw a line
pygame.gfxdraw.line(surface, x1, y1, x2, y2, color): return None

pygame.gfxdraw.circle

円を描写します。
pygame.gfxdraw.circle(surface, x, y, r, color): return None
draw a circle
pgyame.gfxdraw.circle(surface, x, y, r, color): return None

pygame.gfxdraw.arc

弧を描写します。
pygame.gfxdraw.arc(surface, x, y, r, start, end, color): return None
draw an arc
pygame.gfxdraw.arc(surface, x, y, r, start, end, color): return None

pygame.gfxdraw.aacircle

アンチエイリス処理のされた円を描写します。
pygame.gfxdraw.aacircle(surface, x, y, r, color): return None
draw an anti-aliased circle
pygame.gfxdraw.aacircle(surface, x, y, r, color): return None

pygame.gfxdraw.filled_circle

内部を塗りつぶした状態の円を描写します。
pygame.gfxdraw.filled_circle(surface, x, y, r, color): return None
draw a filled circle
pygame.gfxdraw.filled_circle(surface, x, y, r, color): return None

pygame.gfxdraw.ellipse

楕円を描写します。
pygame.gfxdraw.ellipse(surface, x, y, rx, ry, color): return None
draw an ellipse
pygame.gfxdraw.ellipse(surface, x, y, rx, ry, color): return None

pygame.gfxdraw.aaellipse

アンチエイリス処理のされた楕円を描写します。
pygame.gfxdraw.aaellipse(surface, x, y, rx, ry, color): return None
draw an anti-aliased ellipse
pygame.gfxdraw.aaellipse(surface, x, y, rx, ry, color): return None

pygame.gfxdraw.filled_ellipse

内部を塗りつぶした状態の楕円を描写します。
pygame.gfxdraw.filled_ellipse(surface, x, y, rx, ry, color): return None
draw a filled ellipse
pygame.gfxdraw.filled_ellipse(surface, x, y, rx, ry, color): return None

pygame.gfxdraw.pie

分割された状態の円を描写します。
pygame.gfxdraw.pie(surface, x, y, r, start, end, color): return None
draw a pie
pygame.gfxdraw.pie(surface, x, y, r, start, end, color): return None

pygame.gfxdraw.trigon

三角形を描写します。
pygame.gfxdraw.trigon(surface, x1, y1, x2, y2, x3, y3, color): return None
draw a triangle
pygame.gfxdraw.trigon(surface, x1, y1, x2, y2, x3, y3, color): return None

pygame.gfxdraw.aatrigon

アンチエイリス処理のされた三角形を描写します。
pygame.gfxdraw.aatrigon(surface, x1, y1, x2, y2, x3, y3, color): return None
draw an anti-aliased triangle
pygame.gfxdraw.aatrigon(surface, x1, y1, x2, y2, x3, y3, color): return None

pygame.gfxdraw.filled_trigon

内部を塗りつぶした状態の三角形を描写します。
pygame.gfxdraw.filled_trigon(surface, x1, y1, x3, y2, x3, y3, color): return None
draw a filled trigon
pygame.gfxdraw.filled_trigon(surface, x1, y1, x3, y2, x3, y3, color): return None

pygame.gfxdraw.polygon

多角形を描写します。
pygame.gfxdraw.polygon(surface, points, color): return None
draw a polygon
pygame.gfxdraw.polygon(surface, points, color): return None

pygame.gfxdraw.aapolygon

アンチエイリス処理のされた多角形を描写します。
pygame.gfxdraw.aapolygon(surface, points, color): return None
draw an anti-aliased polygon
pygame.gfxdraw.aapolygon(surface, points, color): return None

pygame.gfxdraw.filled_polygon

内部を塗りつぶした状態の多角形を描写します。
pygame.gfxdraw.filled_polygon(surface, points, color): return None
draw a filled polygon
pygame.gfxdraw.filled_polygon(surface, points, color): return None

pygame.gfxdraw.textured_polygon

テクスチャ処理のされた多角形を描写します。
pygame.gfxdraw.textured_polygon(surface, points, texture, tx, ty): return None

テクスチャー画像からsurfaceへピクセル単位でのコピー描写を行いますが、これは Surface.blit命令でのコピー描写とは異なった処理となります。また、8ビットSurfaceに対してはテクスチャ画像のピクセル単位でのコピー描写は行えません。

draw a textured polygon
pygame.gfxdraw.textured_polygon(surface, points, texture, tx, ty): return None

A per-pixel alpha texture blit to a per-pixel alpha surface will differ from a Surface.blit - draw one image onto another blit. Also, a per-pixel alpha texture cannot be used with an 8-bit per pixel destination.


pygame.gfxdraw.bezier

ベジェ曲線を描写します。
pygame.gfxdraw.bezier(surface, points, steps, color): return None
draw a bezier curve
pygame.gfxdraw.bezier(surface, points, steps, color): return None