liwei 1 year ago
parent
commit
446ae48e7a

+ 3 - 3
src/modules/editor/components/CompUI/basicUI/Polygon/index.ts

@@ -14,9 +14,9 @@ export const options = {
 export const { createComp, useCompData } = createCompHooks({
   value: {
     lineColor: "black",
-    lineWidth: 1,
-    isFill: false,
-    fillColor: "black",
+    lineWidth: 0,
+    isFill: true,
+    fillColor: "#A4A4A4",
     points: [],
     isClose: true,
     reverseFill: false,

+ 1 - 1
src/modules/editor/components/CompUI/basicUI/PolygonNormal/component.tsx

@@ -64,7 +64,7 @@ export const Component = defineComponent({
         ctx.beginPath();
         let degree = (2 *Math.PI) / n 
         for (let i = 0; i<n; i++) {
-            const a = i*degree - Math.PI / 2.0;
+            const a = i*degree + Math.PI / 180.0 * data.value.baseAngle;
             const x = Math.cos(a), y = Math.sin(a);
             ctx.lineTo(x*size + cx, y*size + cy)
         }

+ 16 - 4
src/modules/editor/components/CompUI/basicUI/PolygonNormal/index.ts

@@ -15,13 +15,14 @@ export const options = {
 export const { createComp, useCompData } = createCompHooks({
   value: {
     lineColor: "black",
-    lineWidth: 1,
-    isFill: false,
-    fillColor: "black",
+    lineWidth: 0,
+    isFill: true,
+    fillColor: "#A4A4A4",
     points: [],
     isClose: true,
     reverseFill: false,
-    edges: 6
+    edges: 6,
+    baseAngle: 0,
   },
   layout: {
     size: [400, 400],
@@ -41,6 +42,17 @@ export const Form = createAttrsForm([
             step: 1,
           },
     },
+    {
+        label: "角度",
+        dataIndex: "value.baseAngle",
+        component: Slider,
+        props: {
+            defaultValue: 0,
+            min: 0,
+            max: 180,
+            step: 1,
+        },
+    },
 
   {
     label: "线宽",

+ 6 - 4
src/modules/editor/components/CompUI/basicUI/Rectage/component.tsx

@@ -42,9 +42,8 @@ export const Component = defineComponent({
           ctx.fillStyle = data.value.fillColor;
           ctx.fillRect(0, 0, canvas.width, canvas.height);
         }
-
-    
-        const padding = Math.max(10, data.value.lineWidth);
+        
+        const padding =  data.value.lineWidth / 2.0;
         ctx.lineJoin = "round";
         ctx.beginPath();
         ctx.moveTo(padding, padding);
@@ -53,7 +52,10 @@ export const Component = defineComponent({
         ctx.lineTo(padding, height - padding);
         ctx.lineTo(padding, padding);
         ctx.closePath();
-        ctx.stroke();
+
+        if (data.value.lineWidth != 0) {
+          ctx.stroke();
+        }
        
         if (data.value.isFill)    {
             let bColor = data.value.fillColor;

+ 3 - 3
src/modules/editor/components/CompUI/basicUI/Rectage/index.ts

@@ -14,9 +14,9 @@ export const options = {
 export const { createComp, useCompData } = createCompHooks({
   value: {
     lineColor: "black",
-    lineWidth: 1,
-    isFill: false,
-    fillColor: "black",
+    lineWidth: 0,
+    isFill: true,
+    fillColor: "#A4A4A4",
     reverseFill: false,
   },
   layout: {

+ 7 - 4
src/modules/editor/components/CompUI/basicUI/Triangle/component.tsx

@@ -37,20 +37,23 @@ export const Component = defineComponent({
         ctx.lineWidth = data.value.lineWidth;
         
         ctx.strokeStyle = data.value.lineColor;
-        const padding = Math.max(10, data.value.lineWidth);
+        const padding =  data.value.lineWidth / 2.0;
+
         ctx.lineJoin = "round";
         if (data.value.reverseFill) {
           ctx.fillStyle = data.value.fillColor;
           ctx.fillRect(0, 0, canvas.width, canvas.height);
         }
-        
+
         ctx.beginPath();
         ctx.moveTo(width / 2.0, padding);
         ctx.lineTo(width - padding, height - padding);
         ctx.lineTo(padding, height - padding);
         ctx.closePath();
-        ctx.stroke();
-    
+        if (data.value.lineWidth != 0) {
+            ctx.stroke();
+        }
+        
         if (data.value.isFill) {
             let bColor = data.value.fillColor;
             if (!bColor) bColor = data.value.lineColor;

+ 3 - 3
src/modules/editor/components/CompUI/basicUI/Triangle/index.ts

@@ -14,9 +14,9 @@ export const options = {
 export const { createComp, useCompData } = createCompHooks({
   value: {
     lineColor: "black",
-    lineWidth: 1,
-    isFill: false,
-    fillColor: "black",
+    lineWidth: 0,
+    isFill: true,
+    fillColor: "#A4A4A4",
     reverseFill: false,
   },
   layout: {

+ 2 - 2
src/modules/editor/components/Viewport/Slider/SliderLeft/Shapes.tsx

@@ -16,8 +16,8 @@ export default defineComponent({
           "Arc",
           "Curve",
           "Ellipse",
-          // "Triangle",
-          // "Rectage",
+          "Triangle",
+          "Rectage",
           "PolygonNormal",
           "Polygon",
         ].map((key) => compUICtrl.state.components.get(key) as any);

+ 9 - 1
src/modules/editor/module/actions/edit.tsx

@@ -129,6 +129,7 @@ export const editActions = EditorModule.action({
   );
    const currCard = this.helper.findComp(cardId) as DesignComp;
   
+   debugger
     const comp =  this.store.addUserCard(result);
 
     const compId = comp.id;
@@ -396,6 +397,13 @@ export const editActions = EditorModule.action({
       this.helper.clearUnusedComps(data.compMap, comp.id);
       data.compMap.root = data.compMap[comp.id];
       data.compMap.root.id = "root";
+
+      //清除平移距离
+      const mtx = Matrix.createFromMatrixStr(data.compMap.root.layout.transformMatrix as string);
+      mtx.tx = 0;
+      mtx.ty = 0;
+      data.compMap.root.layout.transformMatrix = mtx.getMatrixStr();
+
       delete data.compMap[comp.id];
 
       queenApi.showLoading("保存中");
@@ -557,7 +565,7 @@ export const editActions = EditorModule.action({
     const parentChilds = (card.children.default || []).filter(item=>item != groupComp.id);
     parentChilds.push(...childs);
     card.children.default = childs;
-    
+
     this.actions.selectObjs([childs[0]]);
   },