1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

processingでPDF出力のサンプル

Last updated at Posted at 2022-03-29

はじめに

 ProcessingにはPDF保存の機能が標準で備わっている。jpgやpngの保存に比べ、ベクター形式で保存できるので、解像度に左右されない出力が可能になる。また、Illustrator等に読み込み可能なので、再加工が容易になる。

10年前のPDFのバージョンから、3Dデータも保存できるようになっていて、ProcessingのPDF書き出しも、それに対応してる。お手軽だ。
https://processing.org/reference/libraries/pdf/index.html

円を書く

Andy gilmoreの作を例に、プログラムしてみる。
重要な部分は下記のとおり。

size(512, 512);//通常
size(512, 512, PDF, "triCircle.pdf");//PDF書き出し

triCircle.png

印刷について

 この図柄の場合、モアレが発生する。しかも、モニタ上では、拡大率によって、モアレの見え方が変わってくるうえに、印刷時のモアレとは一致しないので、印刷物としての作品とする場合、試行錯誤か必要な題材かと思う。

コード

triCircle.pde
import processing.pdf.*;

size(512, 512, PDF, "triCircle.pdf");

PVector c1;

//Background
fill(0);
noStroke();
rect(0, 0, width, height);

//
ellipseMode(RADIUS);
noFill();
strokeWeight(0.1);
stroke(255,128);

for (float th=0; th<2*PI; th+=PI*0.01) {
  c1 = new PVector(cos(th)*64+256, sin(th)*64+192);
  ellipse(c1.x, c1.y, 128, 128);

  c1 = new PVector(cos(th)*64+192, sin(th)*64+256+47);
  ellipse(c1.x, c1.y, 128, 128);

  c1 = new PVector(cos(th)*64+320, sin(th)*64+256+47);
  ellipse(c1.x, c1.y, 128, 128);
}
exit();
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?