今回もマクロを触っていく。
・穴抜きの正方形を作る(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();
}
・穴抜きの正方形を作る(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();
}