sys5923812@126.com 1 週間 前
コミット
1958b55208

+ 5 - 0
src/router/router_wakeup.js

@@ -70,6 +70,11 @@ const router = [
     },
     //彩虹图绘制页面
     {
+        path: '/xjc-integratedmachine/wakeup/rainbow/index2',
+        component: () => import('@/views/xjc-integratedmachine/wakeup/rainbow/index2.vue'),
+    },
+    //彩虹图绘制页面
+    {
         path: '/xjc-integratedmachine/wakeup/rainbow/index',
         component: () => import('@/views/xjc-integratedmachine/wakeup/rainbow/index.vue'),
     },

+ 302 - 84
src/views/xjc-integratedmachine/common/ai/TouchColorCanvas.vue

@@ -1,12 +1,13 @@
 <template>
-    <div>
+    <div style="display: flex;justify-content: center">
         <div style="position: absolute;top:10px;right: 4px">
             <el-button @click="changePaintState">{{paintStateFlagText}}</el-button>
             <el-button @click="clear">清空</el-button>
             <el-button @click="save">保存</el-button>
         </div>
-        <div style="height: 1700px; height: 900px;display: flex;justify-content: center">
-            <canvas width="1700" height="900" style="border: 1px solid blue; background-color: white;" id="can"></canvas>
+        <div style="display: flex;justify-content: center">
+            <canvas width="1700" height="900" style="border: 1px solid blue; background-color: white;"
+                    id="can"></canvas>
         </div>
     </div>
 </template>
@@ -14,14 +15,15 @@
     import {onMounted} from 'vue'
     import * as echarts from "echarts";
     import html2canvas from 'html2canvas';
+    import { ElMessage} from 'element-plus'
 
     const backgroundImage = new Image();
-    backgroundImage.src = 'http://192.168.3.100/screenshot.png'; // 替换为你的背景图片路径
+    // backgroundImage.src = 'http://192.168.3.100/screenshot.png'; // 替换为你的背景图片路径
 
     let CENTER_X = 850;
     let CENTER_Y = 900;
-    let startMouse = { x: 0, y: 0 };
-    let moveMouse = { x: 0, y: 0 };
+    let startMouse = {x: 0, y: 0};
+    let moveMouse = {x: 0, y: 0};
 
     // 画笔橡皮擦状态,true画笔,false橡皮
     let paintStateFlag = true;
@@ -37,6 +39,31 @@
     let startAngle22 = 0;
     let startAngle23 = 0;
 
+    // 第三个职业
+    let startAngle31 = 0;
+    let startAngle32 = 0;
+    let startAngle33 = 0;
+
+    // 第四个职业
+    let startAngle41 = 0;
+    let startAngle42 = 0;
+    let startAngle43 = 0;
+
+    // 第五个职业
+    let startAngle51 = 0;
+    let startAngle52 = 0;
+    let startAngle53 = 0;
+
+    // 第六个职业
+    let startAngle61 = 0;
+    let startAngle62 = 0;
+    let startAngle63 = 0;
+
+    // 第七个职业
+    let startAngle71 = 0;
+    let startAngle72 = 0;
+    let startAngle73 = 0;
+
     // 所有轨道绘画限制
     let paintFlagList = [
         false, false, false,
@@ -60,7 +87,7 @@
                 moveMouse.y = startMouse.y;
                 startMouse.x = e.targetTouches[0].pageX - this.offsetLeft;
                 startMouse.y = e.targetTouches[0].pageY - this.offsetTop;
-                if(startMouse.x !== moveMouse.x && startMouse.y !== moveMouse.y){
+                if (startMouse.x !== moveMouse.x && startMouse.y !== moveMouse.y) {
                     return;
                 }
                 calcEndRadius();
@@ -72,36 +99,80 @@
     }
 
     /*计算起始点*/
-    function calcStartRadius(){
-        let sum = Math.pow(startMouse.x-CENTER_X, 2)+ Math.pow(CENTER_Y-startMouse.y, 2);
+    function calcStartRadius() {
+        let sum = Math.pow(startMouse.x - CENTER_X, 2) + Math.pow(CENTER_Y - startMouse.y, 2);
         // 第一个职业
-        if(sum < Math.pow(100,2) && sum > Math.pow(50,2)){
+        if (sum < Math.pow(50, 2) && sum > Math.pow(10, 2)) {
             startAngle11 = calcAngle();
             calcPaintCircleFlag(0)
-        }else if(sum < Math.pow(150,2) && sum > Math.pow(100,2)){
+        } else if (sum < Math.pow(90, 2) && sum > Math.pow(50, 2)) {
             startAngle12 = calcAngle();
             calcPaintCircleFlag(1)
-        }else if(sum < Math.pow(200,2) && sum > Math.pow(150,2)){
+        } else if (sum < Math.pow(130, 2) && sum > Math.pow(90, 2)) {
             startAngle13 = calcAngle();
             calcPaintCircleFlag(2)
         }
         // 第二个职业
-        else if(sum < Math.pow(300,2) && sum > Math.pow(250,2)){
+        else if (sum < Math.pow(185, 2) && sum > Math.pow(145, 2)) {
             startAngle21 = calcAngle();
             calcPaintCircleFlag(3)
-        }else if(sum < Math.pow(350,2) && sum > Math.pow(300,2)){
+        } else if (sum < Math.pow(225, 2) && sum > Math.pow(185, 2)) {
             startAngle22 = calcAngle();
             calcPaintCircleFlag(4)
-        }else if(sum < Math.pow(400,2) && sum > Math.pow(350,2)){
+        } else if (sum < Math.pow(265, 2) && sum > Math.pow(225, 2)) {
             startAngle23 = calcAngle();
             calcPaintCircleFlag(5)
         }
+        // 第三个职业
+        else if (sum < Math.pow(320, 2) && sum > Math.pow(280, 2)) {
+            startAngle31 = calcAngle();
+            calcPaintCircleFlag(6)
+        } else if (sum < Math.pow(360, 2) && sum > Math.pow(320, 2)) {
+            startAngle32 = calcAngle();
+            calcPaintCircleFlag(7)
+        } else if (sum < Math.pow(400, 2) && sum > Math.pow(360, 2)) {
+            startAngle33 = calcAngle();
+            calcPaintCircleFlag(8)
+        }
+        // 第四个职业
+        else if (sum < Math.pow(455, 2) && sum > Math.pow(415, 2)) {
+            startAngle41 = calcAngle();
+            calcPaintCircleFlag(9)
+        } else if (sum < Math.pow(495, 2) && sum > Math.pow(455, 2)) {
+            startAngle42 = calcAngle();
+            calcPaintCircleFlag(10)
+        } else if (sum < Math.pow(535, 2) && sum > Math.pow(495, 2)) {
+            startAngle43 = calcAngle();
+            calcPaintCircleFlag(11)
+        }
+        // 第五个职业
+        else if (sum < Math.pow(590, 2) && sum > Math.pow(550, 2)) {
+            startAngle51 = calcAngle();
+            calcPaintCircleFlag(12)
+        } else if (sum < Math.pow(630, 2) && sum > Math.pow(590, 2)) {
+            startAngle52 = calcAngle();
+            calcPaintCircleFlag(13)
+        } else if (sum < Math.pow(670, 2) && sum > Math.pow(630, 2)) {
+            startAngle53 = calcAngle();
+            calcPaintCircleFlag(14)
+        }
+        // 第六个职业
+        else if (sum < Math.pow(725, 2) && sum > Math.pow(685, 2)) {
+            startAngle61 = calcAngle();
+            calcPaintCircleFlag(15)
+        } else if (sum < Math.pow(765, 2) && sum > Math.pow(725, 2)) {
+            startAngle62 = calcAngle();
+            calcPaintCircleFlag(16)
+        } else if (sum < Math.pow(805, 2) && sum > Math.pow(765, 2)) {
+            startAngle63 = calcAngle();
+            calcPaintCircleFlag(17)
+        }
     }
 
     /**
      * 只有起始点所在轨道可以绘制
      **/
-    function calcPaintCircleFlag(index){
+    function calcPaintCircleFlag(index) {
         paintFlagList = [
             false, false, false,
             false, false, false,
@@ -114,63 +185,209 @@
     }
 
     /*计算终点*/
-    function calcEndRadius(){
-        let sum = Math.pow(moveMouse.x-CENTER_X, 2)+ Math.pow(CENTER_Y-moveMouse.y, 2);
+    function calcEndRadius() {
+        let sum = Math.pow(moveMouse.x - CENTER_X, 2) + Math.pow(CENTER_Y - moveMouse.y, 2);
         let ret = calcAngle();
         // 第一个职业
-        if(sum < Math.pow(100,2) && sum > Math.pow(50,2)){
-            if(paintFlagList[0]){
+        if (sum < Math.pow(50, 2) && sum > Math.pow(10, 2)) {
+            if (paintFlagList[0]) {
+                if (paintStateFlag) {
+                    paint("green", 30, startAngle11, ret);
+                } else {
+                    paint("white", 30, startAngle11, ret);
+                    paint("white", 70, startAngle11, ret);
+                    paint("white", 110, startAngle11, ret);
+                }
+            }
+        } else if (sum < Math.pow(90, 2) && sum > Math.pow(50, 2)) {
+            if (paintFlagList[1]) {
+                if (paintStateFlag) {
+                    paint("green", 30, startAngle12, ret);
+                    paint("green", 70, startAngle12, ret);
+                } else {
+                    paint("white", 70, startAngle12, ret);
+                    paint("white", 110, startAngle12, ret);
+                }
+            }
+        } else if (sum < Math.pow(130, 2) && sum > Math.pow(90, 2)) {
+            if (paintFlagList[2]) {
+                if (paintStateFlag) {
+                    paint("green", 30, startAngle13, ret);
+                    paint("green", 70, startAngle13, ret);
+                    paint("green", 110, startAngle13, ret);
+                } else {
+                    paint("white", 110, startAngle13, ret);
+                }
+            }
+        }
+        // 第二个职业
+        else if (sum < Math.pow(185, 2) && sum > Math.pow(145, 2)) {
+            if (paintFlagList[3]) {
+                if(paintStateFlag) {
+                    paint("#ffd309", 165, startAngle21, ret);
+                }else{
+                    paint("white", 165, startAngle21, ret);
+                    paint("white", 205, startAngle21, ret);
+                    paint("white", 245, startAngle21, ret);
+                }
+            }
+        } else if (sum < Math.pow(225, 2) && sum > Math.pow(185, 2)) {
+            if (paintFlagList[4]) {
+                if(paintStateFlag) {
+                    paint("#ffd309", 165, startAngle22, ret);
+                    paint("#ffd309", 205, startAngle22, ret);
+                }else{
+                    paint("white", 205, startAngle22, ret);
+                    paint("white", 245, startAngle22, ret);
+                }
+            }
+        } else if (sum < Math.pow(265, 2) && sum > Math.pow(225, 2)) {
+            if (paintFlagList[5]) {
                 if(paintStateFlag){
-                    paint("green", 75, startAngle11 ,ret);
+                    paint("#ffd309", 165, startAngle23, ret);
+                    paint("#ffd309", 205, startAngle23, ret);
+                    paint("#ffd309", 245, startAngle23, ret);
+                }else{
+                    paint("white", 245, startAngle23, ret);
+                }
+            }
+        }
+        //第三个职业
+        else if (sum < Math.pow(320, 2) && sum > Math.pow(280, 2)) {
+            if (paintFlagList[6]) {
+                if(paintStateFlag) {
+                    paint("#ffd309", 300, startAngle31, ret);
+                }else{
+                    paint("white", 300, startAngle31, ret);
+                    paint("white", 340, startAngle31, ret);
+                    paint("white", 380, startAngle31, ret);
+                }
+            }
+        } else if (sum < Math.pow(360, 2) && sum > Math.pow(320, 2)) {
+            if (paintFlagList[7]) {
+                if(paintStateFlag) {
+                    paint("#ffd309", 300, startAngle31, ret);
+                    paint("#ffd309", 340, startAngle31, ret);
                 }else{
-                    paint("white", 75, startAngle11 ,ret);
-                    paint("white", 125, startAngle11 ,ret);
-                    paint("white", 175, startAngle11 ,ret);
+                    paint("white", 340, startAngle32, ret);
+                    paint("white", 380, startAngle32, ret);
                 }
             }
-        }else if(sum < Math.pow(150,2) && sum > Math.pow(100,2)){
-            if(paintFlagList[1]){
+        } else if (sum < Math.pow(400, 2) && sum > Math.pow(360, 2)) {
+            if (paintFlagList[8]) {
                 if(paintStateFlag){
-                    paint("green", 125, startAngle12 ,ret);
-                    paint("green", 75, startAngle12 ,ret);
+                    paint("#ffd309", 300, startAngle33, ret);
+                    paint("#ffd309", 340, startAngle33, ret);
+                    paint("#ffd309", 380, startAngle33, ret);
                 }else{
-                    paint("white", 125, startAngle12 ,ret);
-                    paint("white", 175, startAngle12 ,ret);
+                    paint("white", 380, startAngle33, ret);
                 }
             }
-        }else if(sum < Math.pow(200,2) && sum > Math.pow(150,2)){
-            if(paintFlagList[2]){
+        }
+        //第四个职业
+        else if (sum < Math.pow(455, 2) && sum > Math.pow(415, 2)) {
+            if (paintFlagList[9]) {
+                if(paintStateFlag) {
+                    paint("#ffd309", 435, startAngle41, ret);
+                }else{
+                    paint("white", 435, startAngle41, ret);
+                    paint("white", 475, startAngle41, ret);
+                    paint("white", 515, startAngle41, ret);
+                }
+            }
+        } else if (sum < Math.pow(495, 2) && sum > Math.pow(455, 2)) {
+            if (paintFlagList[10]) {
+                if(paintStateFlag) {
+                    paint("#ffd309", 435, startAngle42, ret);
+                    paint("#ffd309", 475, startAngle42, ret);
+                }else{
+                    paint("white", 475, startAngle42, ret);
+                    paint("white", 515, startAngle42, ret);
+                }
+            }
+        } else if (sum < Math.pow(535, 2) && sum > Math.pow(495, 2)) {
+            if (paintFlagList[11]) {
                 if(paintStateFlag){
-                    paint("green", 175, startAngle13 ,ret);
-                    paint("green", 125, startAngle13 ,ret);
-                    paint("green", 75, startAngle13 ,ret);
+                    paint("#ffd309", 435, startAngle43, ret);
+                    paint("#ffd309", 475, startAngle43, ret);
+                    paint("#ffd309", 515, startAngle43, ret);
                 }else{
-                    paint("white", 175, startAngle13 ,ret);
+                    paint("white", 515, startAngle43, ret);
                 }
             }
         }
-        // 第二个职业
-        else if(sum < Math.pow(300,2) && sum > Math.pow(250,2)){
-            if(paintFlagList[3]){
-                paint("#ffd309", 275, startAngle21 ,ret);
+
+        //第五个职业
+        else if (sum < Math.pow(590, 2) && sum > Math.pow(550, 2)) {
+            if (paintFlagList[12]) {
+                if(paintStateFlag) {
+                    paint("#ffd309", 570, startAngle51, ret);
+                }else{
+                    paint("white", 570, startAngle51, ret);
+                    paint("white", 610, startAngle51, ret);
+                    paint("white", 650, startAngle51, ret);
+                }
+            }
+        } else if (sum < Math.pow(630, 2) && sum > Math.pow(590, 2)) {
+            if (paintFlagList[13]) {
+                if(paintStateFlag) {
+                    paint("#ffd309", 570, startAngle52, ret);
+                    paint("#ffd309", 610, startAngle52, ret);
+                }else{
+                    paint("white", 610, startAngle52, ret);
+                    paint("white", 650, startAngle52, ret);
+                }
+            }
+        } else if (sum < Math.pow(670, 2) && sum > Math.pow(630, 2)) {
+            if (paintFlagList[14]) {
+                if(paintStateFlag){
+                    paint("#ffd309", 570, startAngle53, ret);
+                    paint("#ffd309", 610, startAngle53, ret);
+                    paint("#ffd309", 650, startAngle53, ret);
+                }else{
+                    paint("white", 650, startAngle53, ret);
+                }
+            }
+        }
+
+        //第六个职业
+        else if (sum < Math.pow(725, 2) && sum > Math.pow(685, 2)) {
+            if (paintFlagList[15]) {
+                if(paintStateFlag) {
+                    paint("#ffd309", 705, startAngle61, ret);
+                }else{
+                    paint("white", 705, startAngle61, ret);
+                    paint("white", 745, startAngle61, ret);
+                    paint("white", 785, startAngle61, ret);
+                }
             }
-        }else if(sum < Math.pow(350,2) && sum > Math.pow(300,2)){
-            if(paintFlagList[4]){
-                paint("#ffd309", 325, startAngle22 ,ret);
-                paint("#ffd309", 275, startAngle22 ,ret);
+        } else if (sum < Math.pow(765, 2) && sum > Math.pow(725, 2)) {
+            if (paintFlagList[16]) {
+                if(paintStateFlag) {
+                    paint("#ffd309", 705, startAngle62, ret);
+                    paint("#ffd309", 745, startAngle62, ret);
+                }else{
+                    paint("white", 745, startAngle62, ret);
+                    paint("white", 785, startAngle62, ret);
+                }
             }
-        }else if(sum < Math.pow(400,2) && sum > Math.pow(350,2)){
-            if(paintFlagList[5]){
-                paint("#ffd309", 375, startAngle23 ,ret);
-                paint("#ffd309", 325, startAngle23 ,ret);
-                paint("#ffd309", 275, startAngle23 ,ret);
+        } else if (sum < Math.pow(805, 2) && sum > Math.pow(765, 2)) {
+            if (paintFlagList[17]) {
+                if(paintStateFlag){
+                    paint("#ffd309", 705, startAngle63, ret);
+                    paint("#ffd309", 745, startAngle63, ret);
+                    paint("#ffd309", 785, startAngle63, ret);
+                }else{
+                    paint("white", 785, startAngle63, ret);
+                }
             }
         }
+
     }
 
     /*计算角度0-180度*/
-    function calcAngle(){
-        let number = Math.atan2(Math.abs(CENTER_Y-startMouse.y), CENTER_X-startMouse.x);
+    function calcAngle() {
+        let number = Math.atan2(Math.abs(CENTER_Y - startMouse.y), CENTER_X - startMouse.x);
         let ret = number * 180 / Math.PI; //弧度转角度,方便调试
         if (ret > 360) {
             ret -= 360;
@@ -178,78 +395,78 @@
         if (ret < 0) {
             ret += 450;
         }
-        let num = ret * Math.PI/180 +Math.PI;
-        console.log('角度:'+num);
+        let num = ret * Math.PI / 180 + Math.PI;
+        console.log('角度:' + num);
         return num;
     }
 
     let can = "";
     let context = "";
-    function init(){
+
+    function init() {
         can = document.getElementById('can');
         context = can.getContext('2d');
-        backgroundImage.onload = function() {
-            context.drawImage(backgroundImage, 0, 0, can.width, can.height);
-        };
+        // backgroundImage.onload = function() {
+        //     context.drawImage(backgroundImage, 0, 0, can.width, can.height);
+        // };
     }
 
-    function arc(num){
+    function arc(num) {
         context.lineWidth = 1;
         context.strokeStyle = 'black'
         context.beginPath();
-        context.arc(CENTER_X, CENTER_Y, num,  Math.PI,  2*Math.PI, false);
+        context.arc(CENTER_X, CENTER_Y, num, Math.PI, 2 * Math.PI, false);
         context.stroke();
     }
 
 
-    function paint(color, radius, startAngle, endAngle){
+    function paint(color, radius, startAngle, endAngle) {
         // 结束角度不能小于起始角度
-        if(endAngle <= startAngle){
+        if (endAngle <= startAngle) {
+            ElMessage.error("只能顺时针画")
             return;
         }
-        context.lineWidth = 48;
+        context.lineWidth = 37;
         context.strokeStyle = color;
         context.beginPath();
         context.arc(CENTER_X, CENTER_Y, radius, startAngle, endAngle, false);
         context.stroke();
     }
 
-    function changePaintState(){
-        if(paintStateFlag){
+    function changePaintState() {
+        if (paintStateFlag) {
             paintStateFlag = false;
             paintStateFlagText.value = '橡皮擦'
-        }else{
+        } else {
             paintStateFlag = true;
             paintStateFlagText.value = '画笔'
         }
     }
 
-    function eraserState(){
+    function eraserState() {
         paintStateFlag = false;
     }
 
-    function clear(){
+    function clear() {
         context.clearRect(0, 0, can.width, can.height);
         drawBackground();
     }
 
-    function drawBackground(){
-        arc(50);
-        arc(100);
-        arc(150);
-        arc(200);
-
-        arc(250);
-        arc(300);
-        arc(350);
-        arc(400);
-
-        arc(450);
-        arc(500);
-        arc(550);
-        arc(600);
+    function drawBackground() {
+        let radius = 10;
+        arc(radius);
+        for (let i = 1; i < 24; i++) {
+            radius = drawBackgroundOne(radius, i);
+            arc(radius);
+        }
+    }
 
-        arc(700);
+    function drawBackgroundOne(innerRadius, i) {
+        if (i % 4 == 0) {
+            return innerRadius + 15;
+        } else {
+            return innerRadius + 40;
+        }
     }
 
     function save() {
@@ -282,6 +499,7 @@
     onMounted(() => {
         init();
         changes();
+        console.log("mmmmm")
         drawBackground();
     });
 </script>
@@ -291,4 +509,4 @@
         width: 500px;
         height: 400px;
     }
-</style>
+</style>

ファイルの差分が大きいため隠しています
+ 453 - 888
src/views/xjc-integratedmachine/wakeup/rainbow/index.vue