Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What is going on with this article?
@Hyperbolic_____

PShapeで任意の多角形を描く

PShapeで"図形型"を扱う

PShape型とは図形を扱うためのクラスです。
beginShape(始点)→vertex(点)->endShape(終点)のようにして形を定義することができます。


PShape square;
void makeSquare() {
  square = createShape();
  square.beginShape();
  square.noStroke();
  square.vertex(0, 0);
  square.vertex(0, 50);
  square.vertex(50, 50);
  square.vertex(50, 0);
  square.endShape(CLOSE);
}

そして,定義した形はshape(PShape型,x座標,y座標)で描画することができます。

void setup() {
  size(1000, 1000);
  makeSquare();
  shape(square,0,0);
}

ソースコード

コピペしてそのまま使えます。

PShape square;  

void setup() {
  size(1000, 1000);
  makeSquare();
  shape(square,0,0);
}

void makeSquare() {
  square = createShape();
  square.beginShape();
  square.noStroke();
  square.vertex(0, 0);
  square.vertex(0, 50);
  square.vertex(50, 50);
  square.vertex(50, 0);
  square.endShape(CLOSE);
}
0
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Hyperbolic_____
記事について誤っているところがあればコメントして欲しいです。m._.m まとまった記事はZennに書くようにしています。(https://zenn.dev/hyperbola) iOSアプリやGeoGebra、ビジュアルプログラミングが好きです。

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
0
Help us understand the problem. What is going on with this article?