0
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 1 year has passed since last update.

⑤マクロ入門

Last updated at Posted at 2023-02-02

今回もマクロを触っていく。

・穴抜きの正方形を作る(boolean処理)

#!/usr/bin/layout
#name=donut array
#help=an array of donut with different parameter


int main(){
  int out=100000;                       //外側の正方形の1辺の長さ
  int in=3000;                       //内側の正方形の1辺の長さ
  //外側の正方形を形成
  layout->drawing->point(0, 0);
  layout->drawing->point(0, out);
  layout->drawing->point(out, out);
  layout->drawing->point(out, 0);
  layout->drawing->polygon();
  
  //内側の正方形を形成
  layout->drawing->point(out/2 - in/2, out/2 - in/2);
  layout->drawing->point(out/2 - in/2, out/2 + in/2);
  layout->drawing->point(out/2 + in/2, out/2 + in/2);
  layout->drawing->point(out/2 + in/2, out/2 - in/2);
  layout->drawing->polygon();
  layout->drawing->polygon();
  
  //boolean処理 外側の正方形をAにsetしてから内側の正方形をBにset
  layout->drawing->deselectAll();
  layout->drawing->point(0,0);
  layout->drawing->fSelect();
  layout->drawing->point(0,0);
  layout->drawing->cSelect();
  layout->booleanTool->setA();
  layout->drawing->deselectAll();
  layout->drawing->point(50000,50000);
  layout->drawing->fSelect();
  layout->drawing->point(50000,50000);
  layout->drawing->cSelect();
  layout->booleanTool->setB();
  layout->booleanTool->aMinusB();        
                 }

image.png

・穴抜きの正方形を作る(boolean処理を使わない場合)

#!/usr/bin/layout
#name=donut array
#help=an array of donut with different parameter


int main(){
  int out=100000;                       //外側の正方形の1辺の長さ
  int in=3000;                       //内側の正方形の1辺の長さ
  //外側の正方形を形成
  layout->drawing->point(0, 0);
  layout->drawing->point(0, out);
  layout->drawing->point(out, out);
  layout->drawing->point(out, 0);
  layout->drawing->point(out/2 - in/2, 0);      
  layout->drawing->point(out/2 - in/2, out/2 - in/2);
  layout->drawing->point(out/2 - in/2, out/2 + in/2);
  layout->drawing->point(out/2 + in/2, out/2 + in/2);
  layout->drawing->point(out/2 + in/2, out/2 - in/2);
  layout->drawing->point(out/2 - in/2, out/2 - in/2);
  layout->drawing->point(out/2 - in/2, 0);  
  layout->drawing->polygon();      
                 }

image.png

0
0
1

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
0
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?