|
@@ -1,6 +1,51 @@
|
|
|
#include "cdrapp.h"
|
|
|
#include <stdio.h>
|
|
|
|
|
|
+#define _USE_MATH_DEFINES
|
|
|
+#include <math.h> // C++ 在 math.h 中定义 M_PI 需要 _USE_MATH_DEFINES 宏
|
|
|
+
|
|
|
+bool Test_Intersect(corel* cdr){
|
|
|
+ cdr->ActiveDocument->Unit = cdrInch;
|
|
|
+ IVGShapePtr s[3];
|
|
|
+ IVGShapePtr si[3];
|
|
|
+ IVGShapePtr sm;
|
|
|
+ double x, y, radius = 1.5 ;
|
|
|
+ int r, g, b;
|
|
|
+
|
|
|
+ // 通过将 i 乘以 2.09439507 (120度的弧度),可以将三个椭圆均匀地分布在一个圆上。
|
|
|
+ // radius = 1.5 则是决定椭圆的大小。 这个数字控制椭圆的半径,也就是椭圆的大小。 // 创建3个椭圆, 填色 RGB:
|
|
|
+ for (int i = 0; i != 3; i++) {
|
|
|
+ x = cdr->ActivePage->SizeWidth / 2 + 1 * cos(i * M_PI * 2.0 / 3.0);
|
|
|
+ y = cdr->ActivePage->SizeHeight / 2 + 1 * sin(i * M_PI * 2.0 / 3.0);
|
|
|
+ s[i] = MakeEllipse(cdr, x, y, radius);
|
|
|
+ r = 255 * (i == 0);
|
|
|
+ g = 255 * (i == 1);
|
|
|
+ b = 255 * (i == 2);
|
|
|
+ s[i]->Fill->UniformColor->RGBAssign(r, g, b);
|
|
|
+ }
|
|
|
+
|
|
|
+// 创建3个相交物件, IVGShape::Intersect 函数原型
|
|
|
+// IVGShapePtr IVGShape::Intersect ( struct IVGShape * TargetShape, VARIANT_BOOL LeaveSource, VARIANT_BOOL LeaveTarget );
|
|
|
+ for (int i = 0; i != 3; i++) {
|
|
|
+ int n = (i + 1) % 3;
|
|
|
+ si[i] = s[i]->Intersect(s[n], true, true);
|
|
|
+ auto c1 = s[i]->Fill->UniformColor;
|
|
|
+ auto c2 = s[n]->Fill->UniformColor;
|
|
|
+ r = c1->RGBRed + c2->RGBRed;
|
|
|
+ g = c1->RGBGreen + c2->RGBGreen;
|
|
|
+ b = c1->RGBBlue + c2->RGBBlue;
|
|
|
+ si[i]->Fill->UniformColor->RGBAssign(r, g, b);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 建立相交物件,填充白色
|
|
|
+ sm = si[1]->Intersect(si[2], true, true);
|
|
|
+ auto c3 = cdr->CreateRGBColor(255, 255, 255);
|
|
|
+ sm->Fill->UniformColor = c3;
|
|
|
+
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
|
|
|
bool polygon_gravity_dot(corel* cdr){
|
|
|
cdr->ActiveDocument->Unit = cdrMillimeter;
|