def setup
createCanvas(100, 100)
@pg = createGraphics(100, 100)
end
def draw
background(200)
@pg.background(100)
@pg.noStroke
@pg.ellipse(@pg.width / 2, @pg.height / 2, 50, 50)
image(@pg, 50, 50)
image(@pg, 0, 0, 50, 50)
end
描画用オブジェクト(グラフィックバッファ)を生成します。
| 引数名 | 内容 | 備考 | オプション | デフォルト値 |
|---|---|---|---|---|
| w | 描画用オブジェクトの幅 | ピクセル | ||
| h | 描画用オブジェクトの高さ | ピクセル | ||
| renderer | モード | P2D : 2次元 WEBGL : 3次元 | ○ | P2D |
gr : p5graphicsオブジェクト
・以下のメソッドはおもにメインキャンバス向けに用意されているものですが、
p5graphicsオブジェクトについてもインスタンスメソッドとして使うことができます。
(使用例は上記のサンプルプログラムなどを参照してください)
| Structure (2メソッド) | ||||
| push | pop | |||
| Canvas (1メソッド) | ||||
| drawingContext | ||||
| Color (10メソッド) | ||||
| background | clear | fill | noFill | |
| stroke | noStroke | erase | noErase | |
| colorMode | color | |||
| Image (14メソッド) | ||||
| pixels | loadPixels | updatePixels | get | set |
| filter | copy | blend | ||
| image | imageMode | |||
| tint | noTint | mask | save | |
| Shape (35メソッド) | ||||
| point | line | rect | square | quad |
| ellipse | circle | arc | triangle | |
| strokeWeight | strokeCap | strokeJoin | ||
| rectMode | ellipseMode | smooth | noSmooth | |
| curve | bezier | |||
| shape | beginShape | endShape | ||
| vertex | curveVertex | bezierVertex | quadraticVertex | |
| contour | beginContour | endContour | ||
| plane | box | sphere | cylinder | cone |
| ellipsoid | torus | |||
| 3DEffect (1メソッド) | ||||
| shader | ||||
| Typography (5メソッド) | ||||
| text | textFont | textSize | textStyle | textAlign |
| Transform (8メソッド) | ||||
| translate | rotate | scale | shearX | shearY |
| rotateX | rotateY | rotateZ | ||
| Math (1メソッド) | ||||
| angleMode | ||||