Compare commits
8 Commits
main_canva
...
main_canva
Author | SHA1 | Date | |
---|---|---|---|
7aacf24705 | |||
0a3db13862 | |||
9fc632a79d | |||
![]() |
c224ee0a44 | ||
1709abef7e | |||
8c8677aeda | |||
8cba464fc0 | |||
4242018a6d |
@ -50,7 +50,7 @@
|
||||
"quickapp" : {},
|
||||
/* 小程序特有相关 */
|
||||
"mp-weixin" : {
|
||||
"appid" : "",
|
||||
"appid" : "wx5c9edf82da6032c4",
|
||||
"setting" : {
|
||||
"urlCheck" : false
|
||||
},
|
||||
|
17
pages.json
17
pages.json
@ -1,17 +0,0 @@
|
||||
{
|
||||
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
|
||||
{
|
||||
"path": "pages/index/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "uni-app"
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "uni-app",
|
||||
"navigationBarBackgroundColor": "#F8F8F8",
|
||||
"backgroundColor": "#F8F8F8"
|
||||
},
|
||||
"uniIdRouter": {}
|
||||
}
|
@ -1,46 +1,172 @@
|
||||
<template>
|
||||
<view>
|
||||
<!-- 定义canvas画布 // 设置canvas大小为200x200像素 -->
|
||||
<canvas canvas-id="canvas" id="canvas" style="width: 200px; height: 200px;"></canvas>
|
||||
|
||||
<!-- // @touchstart="handleCanvasTouch" -->
|
||||
<canvas
|
||||
@touchstart="handleTouchStart"
|
||||
@touchmove="handleTouchMove"
|
||||
@touchend="handleTouchEnd"
|
||||
:style="{
|
||||
width: 1000 + 'px',
|
||||
height: 800 + 'px',
|
||||
transform: `translate(${offsetX}px, ${offsetY}px) scale(${scale})`
|
||||
}"
|
||||
canvas-id="canvas" id="canvas" ></canvas>
|
||||
<!-- style="border: 1px solid red;height: 600px;width: 100vw;" -->
|
||||
<image src="https://assets.sx25.troyrc.com/sx25/images/events/XBDT.jpg"></image>
|
||||
<!-- 添加一个按钮,用于触发绘图 -->
|
||||
<button @click="handleDraw()">点击绘制圆形</button>
|
||||
<button @click="handleDraw">点击绘制圆形</button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
ref
|
||||
ref,
|
||||
onMounted,
|
||||
getCurrentInstance
|
||||
} from 'vue'
|
||||
import { onReady } from '@dcloudio/uni-app'
|
||||
|
||||
// 定义绘图函数
|
||||
function draw() {
|
||||
const ctx = uni.createCanvasContext('canvas') // 创建canvas绘图上下文
|
||||
const canvasWidth = ref(375) // 动态设置Canvas宽度
|
||||
const canvasHeight = ref(400) // 动态设置Canvas高度
|
||||
const instance = getCurrentInstance()
|
||||
const scale = ref(1)
|
||||
const offsetX = ref(0)
|
||||
const offsetY = ref(0)
|
||||
const lastDistance = ref(-1)
|
||||
const startX = ref(0)
|
||||
const startY = ref(0)
|
||||
const isDragging = ref(false)
|
||||
const imgUrl = ref('https://assets.sx25.troyrc.com/sx25/images/events/XBDT.jpg'); // 修改为ref
|
||||
|
||||
// 绘制外圆
|
||||
ctx.beginPath() // 开始路径
|
||||
ctx.arc(100, 100, 80, 0, Math.PI * 2) // 在坐标(100, 100)处绘制半径为80的圆形
|
||||
ctx.setFillStyle('rgba(0, 0, 0, 1)') // 设置填充颜色为黑色,无透明度
|
||||
ctx.fill() // 填充所创建的路径
|
||||
async function draw() {
|
||||
const ctx = uni.createCanvasContext('canvas', instance) // 创建canvas绘图上下文
|
||||
ctx.scale(scale.value, scale.value);
|
||||
const res = await uni.getImageInfo({
|
||||
src: imgUrl.value,
|
||||
})
|
||||
ctx.drawImage(res.path, 0, 0);
|
||||
|
||||
// 绘制内圆以形成环形效果
|
||||
ctx.beginPath() // 开始新的路径
|
||||
ctx.arc(100, 100, 75, 0, Math.PI * 2) // 在相同中心点(100, 100),但半径为60的圆形
|
||||
ctx.setFillStyle('white') // 设置填充颜色为白色
|
||||
ctx.fill() // 填充以“清除”内部区域,形成环形
|
||||
ctx.draw() // 将上述所有操作提交到canvas进行渲染
|
||||
// ctx.beginPath();
|
||||
// ctx.moveTo(50, 50); // 左下角点
|
||||
// ctx.lineTo(150, 50); // 右下角点
|
||||
// ctx.lineTo(200, 100); // 右上角点
|
||||
// ctx.lineTo(100, 100); // 左上角点
|
||||
// ctx.closePath(); // 闭合路径
|
||||
// ctx.stroke(); // 绘制边框
|
||||
|
||||
// 先不删
|
||||
// let xoffset = 0, yoffset = 0, flag = false;
|
||||
// polygonList.forEach((level, index) => {
|
||||
// // console.log('level',level)
|
||||
// ctx.moveTo(level.polygon[0] + xoffset, level.polygon[0] + yoffset)
|
||||
// level.polygon.forEach((level2,level2Index)=>{
|
||||
// ctx.beginPath()
|
||||
// if(level2Index != level.polygon.length ){
|
||||
// ctx.lineTo(level2 + xoffset, level.polygon[level2Index+1])
|
||||
// console.log(level2 + xoffset, level.polygon[level2Index+1])
|
||||
// }else{
|
||||
// ctx.lineTo(level2 + xoffset, level.polygon[0])
|
||||
// console.log(level2 + xoffset, level.polygon[0])
|
||||
// }
|
||||
// ctx.closePath()
|
||||
// })
|
||||
// if(polygonList.length == index){
|
||||
// flag = true
|
||||
// }
|
||||
// })
|
||||
ctx.draw()
|
||||
}
|
||||
|
||||
// 处理canvas触摸事件
|
||||
function handleCanvasTouch(event) {
|
||||
// 获取触摸点的坐标
|
||||
const x = event.touches[0].x;
|
||||
const y = event.touches[0].y;
|
||||
console.log(x,y,'12');
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 触摸开始
|
||||
const handleTouchStart = (e) => {
|
||||
console.log('handleTouchStart')
|
||||
if (e.touches.length === 1) {
|
||||
// 单指拖动
|
||||
startX.value = e.touches[0].clientX - offsetX.value
|
||||
startY.value = e.touches[0].clientY - offsetY.value
|
||||
isDragging.value = true
|
||||
} else if (e.touches.length === 2) {
|
||||
// 双指缩放
|
||||
const x1 = e.touches[0].clientX
|
||||
const y1 = e.touches[0].clientY
|
||||
const x2 = e.touches[1].clientX
|
||||
const y2 = e.touches[1].clientY
|
||||
lastDistance.value = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2))
|
||||
}
|
||||
}
|
||||
|
||||
// 触摸移动
|
||||
const handleTouchMove = (e) => {
|
||||
console.log('handleTouchMove')
|
||||
if (e.touches.length === 1 && isDragging.value) {
|
||||
// 单指移动
|
||||
const currentX = e.touches[0].clientX - startX.value
|
||||
const currentY = e.touches[0].clientY - startY.value
|
||||
offsetX.value = currentX
|
||||
offsetY.value = currentY
|
||||
} else if (e.touches.length === 2) {
|
||||
// 双指缩放
|
||||
const x1 = e.touches[0].clientX
|
||||
const y1 = e.touches[0].clientY
|
||||
const x2 = e.touches[1].clientX
|
||||
const y2 = e.touches[1].clientY
|
||||
const distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2))
|
||||
|
||||
if (lastDistance.value > 0) {
|
||||
const newScale = scale.value * (distance / lastDistance.value)
|
||||
scale.value = Math.min(Math.max(newScale, 0.5), 4) // 限制缩放范围
|
||||
}
|
||||
lastDistance.value = distance
|
||||
}
|
||||
}
|
||||
|
||||
// 触摸结束
|
||||
const handleTouchEnd = () => {
|
||||
console.log('handleTouchEnd')
|
||||
lastDistance.value = -1
|
||||
isDragging.value = false
|
||||
}
|
||||
|
||||
// 按钮点击事件处理函数
|
||||
const handleDraw = () => {
|
||||
draw(); // 调用绘图函数
|
||||
}
|
||||
|
||||
// onMounted(() => {
|
||||
// setInterval(()=>{
|
||||
// draw()
|
||||
// },300)
|
||||
// // 确保在组件挂载后可以获取到Canvas元素
|
||||
// })
|
||||
onReady(() => {
|
||||
console.log('onReadyonReady');
|
||||
uni.downloadFile({
|
||||
url:imgUrl.value,
|
||||
success: function (sres) {
|
||||
console.log(sres,'sres');
|
||||
imgUrl.value = sres.tempFilePath || sres.path
|
||||
draw()
|
||||
},fail:function(fres){
|
||||
console.log('fres',fres)
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 样式部分 */
|
||||
button {
|
||||
margin-top: 10px;
|
||||
/* 给按钮设置一些上边距以避免过于紧凑 */
|
||||
}
|
||||
</style>
|
BIN
static/canvas.jpg
Normal file
BIN
static/canvas.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 191 KiB |
1
unpackage/dist/dev/.sourcemap/mp-weixin-devtools/index.js.map
vendored
Normal file
1
unpackage/dist/dev/.sourcemap/mp-weixin-devtools/index.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"names":[],"sources":[],"sourcesContent":[],"mappings":";","ignoreList":[]}
|
@ -1 +1 @@
|
||||
{"version":3,"names":["draw","ctx","common_vendor","index","createCanvasContext","beginPath","arc","Math","PI","setFillStyle","setFillRule","fill","onMounted","wx","createPage","_sfc_main"],"sources":["index.vue","cGFnZXMvaW5kZXgvaW5kZXgudnVl"],"sourcesContent":["<template>\n\t<view>\n\t\t<canvas \n\t\t\tcanvas-id=\"canvas\" \n\t\t\tstyle=\"width: 100px; height: 100px;\"\n\t\t></canvas>\n\t</view>\n</template>\n\n<script setup>\nimport { onMounted } from 'vue'\n\nfunction draw() {\n\tconst ctx = uni.createCanvasContext('canvas')\n\n\tctx.beginPath()\n\tctx.arc(50, 50, 30, 0, Math.PI * 2, true)\n\tctx.arc(50, 50, 15, 0, Math.PI * 2, true)\n\tctx.setFillStyle('black')\n\tctx.setFillRule('evenodd') // 设置填充规则\n\tctx.fill()\n\n\tctx.draw()\n}\n\nonMounted(() => {\n\tdraw()\n})\n</script>\n\n<style scoped>\n</style>","import MiniProgramPage from 'C:/Users/hp/Desktop/app/canvas/pages/index/index.vue'\nwx.createPage(MiniProgramPage)"],"mappings":";;;;;;;IAYA,SAASA,KAAA,EAAO;MACf,IAAMC,GAAA,GAAMC,aAAA,CAAAC,KAAA,CAAIC,mBAAA,CAAoB,QAAQ;MAE5CH,GAAA,CAAII,SAAA,EAAW;MACfJ,GAAA,CAAIK,GAAA,CAAI,IAAI,IAAI,IAAI,GAAGC,IAAA,CAAKC,EAAA,GAAK,GAAG,IAAI;MACxCP,GAAA,CAAIK,GAAA,CAAI,IAAI,IAAI,IAAI,GAAGC,IAAA,CAAKC,EAAA,GAAK,GAAG,IAAI;MACxCP,GAAA,CAAIQ,YAAA,CAAa,OAAO;MACxBR,GAAA,CAAIS,WAAA,CAAY,SAAS;MACzBT,GAAA,CAAIU,IAAA,EAAM;MAEVV,GAAA,CAAID,IAAA,EAAM;IACX;IAEAE,aAAA,CAAAU,SAAA,CAAU,YAAM;MACfZ,IAAA,EAAM;IACP,CAAC;;;;;;AC1BDa,EAAA,CAAGC,UAAA,CAAWC,SAAe","ignoreList":[]}
|
||||
{"version":3,"names":["wx","createPage","index","MiniProgramPage"],"sources":["cGFnZXMvaW5kZXgvaW5kZXgudnVl"],"sourcesContent":["import MiniProgramPage from 'C:/Users/hp/Desktop/app/canvas/pages/index/index.vue'\nwx.createPage(MiniProgramPage)"],"mappings":";;;;AACAA,EAAA,CAAGC,UAAA,CAAWC,KAAA,CAAeC,eAAA","ignoreList":[]}
|
@ -1 +1 @@
|
||||
{"version":3,"file":"app.js","sources":["App.vue","main.js"],"sourcesContent":["<script>\r\n\texport default {\r\n\t\tonLaunch: function() {\r\n\t\t\tconsole.log('App Launch')\r\n\t\t},\r\n\t\tonShow: function() {\r\n\t\t\tconsole.log('App Show')\r\n\t\t},\r\n\t\tonHide: function() {\r\n\t\t\tconsole.log('App Hide')\r\n\t\t}\r\n\t}\r\n</script>\r\n\r\n<style>\r\n\t/*每个页面公共css */\r\n</style>\n","import App from './App'\n\n// #ifndef VUE3\nimport Vue from 'vue'\nimport './uni.promisify.adaptor'\nVue.config.productionTip = false\nApp.mpType = 'app'\nconst app = new Vue({\n ...App\n})\napp.$mount()\n// #endif\n\n// #ifdef VUE3\nimport { createSSRApp } from 'vue'\nexport function createApp() {\n const app = createSSRApp(App)\n return {\n app\n }\n}\n// #endif"],"names":["uni","createSSRApp","App"],"mappings":";;;;;;AACC,MAAK,YAAU;AAAA,EACd,UAAU,WAAW;AACpBA,kBAAAA,MAAA,MAAA,OAAA,gBAAY,YAAY;AAAA,EACxB;AAAA,EACD,QAAQ,WAAW;AAClBA,kBAAAA,MAAY,MAAA,OAAA,gBAAA,UAAU;AAAA,EACtB;AAAA,EACD,QAAQ,WAAW;AAClBA,kBAAAA,MAAY,MAAA,OAAA,iBAAA,UAAU;AAAA,EACvB;AACD;ACIM,SAAS,YAAY;AAC1B,QAAM,MAAMC,cAAY,aAACC,SAAG;AAC5B,SAAO;AAAA,IACL;AAAA,EACD;AACH;AACC,YAAO,IAAA,MAAA,MAAA;;"}
|
||||
{"version":3,"file":"app.js","sources":["App.vue"],"sourcesContent":["<script>\n\texport default {\n\t\tonLaunch: function() {\n\t\t\tconsole.log('App Launch')\n\t\t},\n\t\tonShow: function() {\n\t\t\tconsole.log('App Show')\n\t\t},\n\t\tonHide: function() {\n\t\t\tconsole.log('App Hide')\n\t\t}\n\t}\n</script>\n\n<style>\n\t/*每个页面公共css */\n</style>\n"],"names":["uni"],"mappings":";;;;;;;;AACC,MAAK,YAAU;AAAA,EACd,UAAU,WAAW;AACpBA,kBAAAA,MAAY,MAAA,OAAA,gBAAA,YAAY;AAAA,EACxB;AAAA,EACD,QAAQ,WAAW;AAClBA,kBAAAA,MAAY,MAAA,OAAA,gBAAA,UAAU;AAAA,EACtB;AAAA,EACD,QAAQ,WAAW;AAClBA,kBAAAA,MAAY,MAAA,OAAA,iBAAA,UAAU;AAAA,EACvB;AACD;;;;;;;;;"}
|
File diff suppressed because one or more lines are too long
1
unpackage/dist/dev/.sourcemap/mp-weixin/index.js.map
vendored
Normal file
1
unpackage/dist/dev/.sourcemap/mp-weixin/index.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
@ -1 +1 @@
|
||||
{"version":3,"file":"index.js","sources":["pages/index/index.vue","../../HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvaW5kZXgvaW5kZXgudnVl"],"sourcesContent":["<template>\r\n\t<view>\r\n\t\t<!-- 定义canvas画布 // 设置canvas大小为200x200像素 -->\r\n\t\t<canvas canvas-id=\"canvas\" id=\"canvas\" style=\"width: 200px; height: 200px;\"></canvas>\r\n\r\n\t\t<!-- 添加一个按钮,用于触发绘图 -->\r\n\t\t<button @click=\"handleDraw()\">点击绘制圆形</button>\r\n\t</view>\r\n</template>\r\n\r\n<script setup>\r\n\timport {\r\n\t\tref\r\n\t} from 'vue'\r\n\r\n\t// 定义绘图函数\r\n\tfunction draw() {\r\n\t\tconst ctx = uni.createCanvasContext('canvas') // 创建canvas绘图上下文\r\n\r\n\t\t// 绘制外圆\r\n\t\tctx.beginPath() // 开始路径\r\n\t\tctx.arc(100, 100, 80, 0, Math.PI * 2) // 在坐标(100, 100)处绘制半径为80的圆形\r\n\t\tctx.setFillStyle('rgba(0, 0, 0, 1)') // 设置填充颜色为黑色,无透明度\r\n\t\tctx.fill() // 填充所创建的路径\r\n\t\t\r\n\t\t// 绘制内圆以形成环形效果\r\n\t\tctx.beginPath() // 开始新的路径\r\n\t\tctx.arc(100, 100, 75, 0, Math.PI * 2) // 在相同中心点(100, 100),但半径为60的圆形\r\n\t\tctx.setFillStyle('white') // 设置填充颜色为白色\r\n\t\tctx.fill() // 填充以“清除”内部区域,形成环形\r\n\t\tctx.draw() // 将上述所有操作提交到canvas进行渲染\r\n\t}\r\n\r\n\t// 按钮点击事件处理函数\r\n\tconst handleDraw = () => {\r\n\t\tdraw(); // 调用绘图函数\r\n\t}\r\n</script>\r\n\r\n<style scoped>\r\n\t/* 样式部分 */\r\n\tbutton {\r\n\t\tmargin-top: 10px;\r\n\t\t/* 给按钮设置一些上边距以避免过于紧凑 */\r\n\t}\r\n</style>","import MiniProgramPage from 'C:/Users/hp/Desktop/app/canvas/pages/index/index.vue'\nwx.createPage(MiniProgramPage)"],"names":["uni"],"mappings":";;;;;AAgBC,aAAS,OAAO;AACf,YAAM,MAAMA,cAAAA,MAAI,oBAAoB,QAAQ;AAG5C,UAAI,UAAW;AACf,UAAI,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,KAAK,CAAC;AACpC,UAAI,aAAa,kBAAkB;AACnC,UAAI,KAAM;AAGV,UAAI,UAAW;AACf,UAAI,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,KAAK,CAAC;AACpC,UAAI,aAAa,OAAO;AACxB,UAAI,KAAM;AACV,UAAI,KAAM;AAAA,IACV;AAGD,UAAM,aAAa,MAAM;AACxB;IACA;;;;;;;;;ACnCF,GAAG,WAAW,eAAe;"}
|
||||
{"version":3,"file":"index.js","sources":["pages/index/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/sunmeng/Desktop/canvas/pages/index/index.vue'\nwx.createPage(MiniProgramPage)"],"names":["MiniProgramPage"],"mappings":";;AACA,GAAG,WAAWA,MAAe,eAAA;"}
|
1
unpackage/dist/dev/.sourcemap/mp-weixin/pages/index/index2.js.map
vendored
Normal file
1
unpackage/dist/dev/.sourcemap/mp-weixin/pages/index/index2.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index2.js","sources":["/Users/sunmeng/Desktop/canvas/pages/index/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/sunmeng/Desktop/canvas/pages/index/index.vue'\nwx.createPage(MiniProgramPage)"],"names":["MiniProgramPage"],"mappings":";;AACA,GAAG,WAAWA,MAAe,eAAA;"}
|
1
unpackage/dist/dev/.sourcemap/mp-weixin/pages/index/indexFu.js.map
vendored
Normal file
1
unpackage/dist/dev/.sourcemap/mp-weixin/pages/index/indexFu.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"indexFu.js","sources":["pages/index/indexFu.vue","../../HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvaW5kZXgvaW5kZXhGdS52dWU"],"sourcesContent":["<template>\r\n\t<view>\r\n\t<indexZi></indexZi>\r\n\t</view>\r\n</template>\r\n\r\n<script setup>\r\n\timport indexZi from \"./index.vue\" \r\n\timport {\r\n\t\tref\r\n\t} from 'vue'\r\n\r\n</script>\r\n\r\n<style scoped>\r\n\r\n</style>","import MiniProgramPage from 'C:/Users/hp/Desktop/app/canvas/pages/index/indexFu.vue'\nwx.createPage(MiniProgramPage)"],"names":["MiniProgramPage"],"mappings":";;;;;AAOC,MAAM,UAAU,MAAW;;;;;;;;;ACN5B,GAAG,WAAWA,SAAe;"}
|
1
unpackage/dist/dev/.sourcemap/mp-weixin/pages/index/index_step4.js.map
vendored
Normal file
1
unpackage/dist/dev/.sourcemap/mp-weixin/pages/index/index_step4.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index_step4.js","sources":["pages/index/index_step4.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/sunmeng/Desktop/canvas/pages/index/index_step4.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
|
1
unpackage/dist/dev/.sourcemap/mp-weixin/pages/index/step2.js.map
vendored
Normal file
1
unpackage/dist/dev/.sourcemap/mp-weixin/pages/index/step2.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"step2.js","sources":["pages/index/step2.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/sunmeng/Desktop/canvas/pages/index/step2.vue'\nwx.createPage(MiniProgramPage)"],"names":["MiniProgramPage"],"mappings":";;;;;;;;;;;;;;AACA,GAAG,WAAWA,SAAe;"}
|
1
unpackage/dist/dev/.sourcemap/mp-weixin/static/canvas.js.map
vendored
Normal file
1
unpackage/dist/dev/.sourcemap/mp-weixin/static/canvas.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"canvas.js","sources":["static/canvas.jpg"],"sourcesContent":["export default \"__VITE_ASSET__72ea9485__\""],"names":[],"mappings":";;AAAA,MAAe,SAAA;;"}
|
2
unpackage/dist/dev/mp-weixin/app.js
vendored
2
unpackage/dist/dev/mp-weixin/app.js
vendored
@ -3,6 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const common_vendor = require("./common/vendor.js");
|
||||
if (!Math) {
|
||||
"./pages/index/index.js";
|
||||
"./pages/index/index_step4.js";
|
||||
"./pages/index/step2.js";
|
||||
}
|
||||
const _sfc_main = {
|
||||
onLaunch: function() {
|
||||
|
4
unpackage/dist/dev/mp-weixin/app.json
vendored
4
unpackage/dist/dev/mp-weixin/app.json
vendored
@ -1,6 +1,8 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/index/index"
|
||||
"pages/index/index",
|
||||
"pages/index/index_step4",
|
||||
"pages/index/step2"
|
||||
],
|
||||
"window": {
|
||||
"navigationBarTextStyle": "black",
|
||||
|
@ -1,4 +0,0 @@
|
||||
"use strict";
|
||||
const _imports_0 = "/static/logo.png";
|
||||
exports._imports_0 = _imports_0;
|
||||
//# sourceMappingURL=../../.sourcemap/mp-weixin/common/assets.js.map
|
279
unpackage/dist/dev/mp-weixin/common/vendor.js
vendored
279
unpackage/dist/dev/mp-weixin/common/vendor.js
vendored
@ -2519,21 +2519,21 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
|
||||
);
|
||||
}
|
||||
}
|
||||
const createHook = (lifecycle) => (hook, target = currentInstance) => (
|
||||
const createHook$1 = (lifecycle) => (hook, target = currentInstance) => (
|
||||
// post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
|
||||
(!isInSSRComponentSetup || lifecycle === "sp") && injectHook(lifecycle, (...args) => hook(...args), target)
|
||||
);
|
||||
const onBeforeMount = createHook("bm");
|
||||
const onMounted = createHook("m");
|
||||
const onBeforeUpdate = createHook("bu");
|
||||
const onUpdated = createHook("u");
|
||||
const onBeforeUnmount = createHook("bum");
|
||||
const onUnmounted = createHook("um");
|
||||
const onServerPrefetch = createHook("sp");
|
||||
const onRenderTriggered = createHook(
|
||||
const onBeforeMount = createHook$1("bm");
|
||||
const onMounted = createHook$1("m");
|
||||
const onBeforeUpdate = createHook$1("bu");
|
||||
const onUpdated = createHook$1("u");
|
||||
const onBeforeUnmount = createHook$1("bum");
|
||||
const onUnmounted = createHook$1("um");
|
||||
const onServerPrefetch = createHook$1("sp");
|
||||
const onRenderTriggered = createHook$1(
|
||||
"rtg"
|
||||
);
|
||||
const onRenderTracked = createHook(
|
||||
const onRenderTracked = createHook$1(
|
||||
"rtc"
|
||||
);
|
||||
function onErrorCaptured(hook, target = currentInstance) {
|
||||
@ -5902,29 +5902,11 @@ function getOSInfo(system, platform) {
|
||||
osName = platform;
|
||||
osVersion = system;
|
||||
} else {
|
||||
osName = system.split(" ")[0] || platform;
|
||||
osName = system.split(" ")[0] || "";
|
||||
osVersion = system.split(" ")[1] || "";
|
||||
}
|
||||
osName = osName.toLocaleLowerCase();
|
||||
switch (osName) {
|
||||
case "harmony":
|
||||
case "ohos":
|
||||
case "openharmony":
|
||||
osName = "harmonyos";
|
||||
break;
|
||||
case "iphone os":
|
||||
osName = "ios";
|
||||
break;
|
||||
case "mac":
|
||||
case "darwin":
|
||||
osName = "macos";
|
||||
break;
|
||||
case "windows_nt":
|
||||
osName = "windows";
|
||||
break;
|
||||
}
|
||||
return {
|
||||
osName,
|
||||
osName: osName.toLocaleLowerCase(),
|
||||
osVersion
|
||||
};
|
||||
}
|
||||
@ -5945,9 +5927,9 @@ function populateParameters(fromRes, toRes) {
|
||||
appVersion: "1.0.0",
|
||||
appVersionCode: "100",
|
||||
appLanguage: getAppLanguage(hostLanguage),
|
||||
uniCompileVersion: "4.61",
|
||||
uniCompilerVersion: "4.61",
|
||||
uniRuntimeVersion: "4.61",
|
||||
uniCompileVersion: "4.57",
|
||||
uniCompilerVersion: "4.57",
|
||||
uniRuntimeVersion: "4.57",
|
||||
uniPlatform: "mp-weixin",
|
||||
deviceBrand,
|
||||
deviceModel: model,
|
||||
@ -6096,9 +6078,9 @@ const getAppBaseInfo = {
|
||||
appLanguage: getAppLanguage(hostLanguage),
|
||||
isUniAppX: false,
|
||||
uniPlatform: "mp-weixin",
|
||||
uniCompileVersion: "4.61",
|
||||
uniCompilerVersion: "4.61",
|
||||
uniRuntimeVersion: "4.61"
|
||||
uniCompileVersion: "4.57",
|
||||
uniCompilerVersion: "4.57",
|
||||
uniRuntimeVersion: "4.57"
|
||||
};
|
||||
extend(toRes, parameters);
|
||||
}
|
||||
@ -6379,91 +6361,6 @@ function tryConnectSocket(host2, port, id) {
|
||||
});
|
||||
});
|
||||
}
|
||||
const CONSOLE_TYPES = ["log", "warn", "error", "info", "debug"];
|
||||
const originalConsole = /* @__PURE__ */ CONSOLE_TYPES.reduce((methods, type) => {
|
||||
methods[type] = console[type].bind(console);
|
||||
return methods;
|
||||
}, {});
|
||||
let sendError = null;
|
||||
const errorQueue = /* @__PURE__ */ new Set();
|
||||
const errorExtra = {};
|
||||
function sendErrorMessages(errors) {
|
||||
if (sendError == null) {
|
||||
errors.forEach((error) => {
|
||||
errorQueue.add(error);
|
||||
});
|
||||
return;
|
||||
}
|
||||
const data = errors.map((err) => {
|
||||
if (typeof err === "string") {
|
||||
return err;
|
||||
}
|
||||
const isPromiseRejection = err && "promise" in err && "reason" in err;
|
||||
const prefix = isPromiseRejection ? "UnhandledPromiseRejection: " : "";
|
||||
if (isPromiseRejection) {
|
||||
err = err.reason;
|
||||
}
|
||||
if (err instanceof Error && err.stack) {
|
||||
if (err.message && !err.stack.includes(err.message)) {
|
||||
return `${prefix}${err.message}
|
||||
${err.stack}`;
|
||||
}
|
||||
return `${prefix}${err.stack}`;
|
||||
}
|
||||
if (typeof err === "object" && err !== null) {
|
||||
try {
|
||||
return prefix + JSON.stringify(err);
|
||||
} catch (err2) {
|
||||
return prefix + String(err2);
|
||||
}
|
||||
}
|
||||
return prefix + String(err);
|
||||
}).filter(Boolean);
|
||||
if (data.length > 0) {
|
||||
sendError(JSON.stringify(Object.assign({
|
||||
type: "error",
|
||||
data
|
||||
}, errorExtra)));
|
||||
}
|
||||
}
|
||||
function setSendError(value, extra = {}) {
|
||||
sendError = value;
|
||||
Object.assign(errorExtra, extra);
|
||||
if (value != null && errorQueue.size > 0) {
|
||||
const errors = Array.from(errorQueue);
|
||||
errorQueue.clear();
|
||||
sendErrorMessages(errors);
|
||||
}
|
||||
}
|
||||
function initOnError() {
|
||||
function onError2(error) {
|
||||
try {
|
||||
if (typeof PromiseRejectionEvent !== "undefined" && error instanceof PromiseRejectionEvent && error.reason instanceof Error && error.reason.message && error.reason.message.includes(`Cannot create property 'errMsg' on string 'taskId`)) {
|
||||
return;
|
||||
}
|
||||
if (true) {
|
||||
originalConsole.error(error);
|
||||
}
|
||||
sendErrorMessages([error]);
|
||||
} catch (err) {
|
||||
originalConsole.error(err);
|
||||
}
|
||||
}
|
||||
if (typeof index.onError === "function") {
|
||||
index.onError(onError2);
|
||||
}
|
||||
if (typeof index.onUnhandledRejection === "function") {
|
||||
index.onUnhandledRejection(onError2);
|
||||
}
|
||||
return function offError2() {
|
||||
if (typeof index.offError === "function") {
|
||||
index.offError(onError2);
|
||||
}
|
||||
if (typeof index.offUnhandledRejection === "function") {
|
||||
index.offUnhandledRejection(onError2);
|
||||
}
|
||||
};
|
||||
}
|
||||
function formatMessage(type, args) {
|
||||
try {
|
||||
return {
|
||||
@ -6496,16 +6393,7 @@ function formatArg(arg, depth = 0) {
|
||||
case "boolean":
|
||||
return formatBoolean(arg);
|
||||
case "object":
|
||||
try {
|
||||
return formatObject(arg, depth);
|
||||
} catch (e) {
|
||||
return {
|
||||
type: "object",
|
||||
value: {
|
||||
properties: []
|
||||
}
|
||||
};
|
||||
}
|
||||
return formatObject(arg, depth);
|
||||
case "undefined":
|
||||
return formatUndefined();
|
||||
case "function":
|
||||
@ -6651,21 +6539,14 @@ function formatObject(value, depth) {
|
||||
}
|
||||
}
|
||||
}
|
||||
let entries = Object.entries(value);
|
||||
if (isHarmonyBuilderParams(value)) {
|
||||
entries = entries.filter(([key]) => key !== "modifier" && key !== "nodeContent");
|
||||
}
|
||||
return {
|
||||
type: "object",
|
||||
className,
|
||||
value: {
|
||||
properties: entries.map((entry) => formatObjectProperty(entry[0], entry[1], depth + 1))
|
||||
properties: Object.entries(value).map((entry) => formatObjectProperty(entry[0], entry[1], depth + 1))
|
||||
}
|
||||
};
|
||||
}
|
||||
function isHarmonyBuilderParams(value) {
|
||||
return value.modifier && value.modifier._attribute && value.nodeContent;
|
||||
}
|
||||
function isComponentPublicInstance(value) {
|
||||
return value.$ && isComponentInternalInstance(value.$);
|
||||
}
|
||||
@ -6743,11 +6624,10 @@ function formatMapEntry(value, depth) {
|
||||
value: formatArg(value[1], depth)
|
||||
};
|
||||
}
|
||||
const CONSOLE_TYPES = ["log", "warn", "error", "info", "debug"];
|
||||
let sendConsole = null;
|
||||
const messageQueue = [];
|
||||
const messageExtra = {};
|
||||
const EXCEPTION_BEGIN_MARK = "---BEGIN:EXCEPTION---";
|
||||
const EXCEPTION_END_MARK = "---END:EXCEPTION---";
|
||||
function sendConsoleMessages(messages) {
|
||||
if (sendConsole == null) {
|
||||
messageQueue.push(...messages);
|
||||
@ -6767,6 +6647,10 @@ function setSendConsole(value, extra = {}) {
|
||||
sendConsoleMessages(messages);
|
||||
}
|
||||
}
|
||||
const originalConsole = /* @__PURE__ */ CONSOLE_TYPES.reduce((methods, type) => {
|
||||
methods[type] = console[type].bind(console);
|
||||
return methods;
|
||||
}, {});
|
||||
const atFileRegex = /^\s*at\s+[\w/./-]+:\d+$/;
|
||||
function rewriteConsole() {
|
||||
function wrapConsole(type) {
|
||||
@ -6781,18 +6665,6 @@ function rewriteConsole() {
|
||||
{
|
||||
originalConsole[type](...originalArgs);
|
||||
}
|
||||
if (type === "error" && args.length === 1) {
|
||||
const arg = args[0];
|
||||
if (typeof arg === "string" && arg.startsWith(EXCEPTION_BEGIN_MARK)) {
|
||||
const startIndex = EXCEPTION_BEGIN_MARK.length;
|
||||
const endIndex = arg.length - EXCEPTION_END_MARK.length;
|
||||
sendErrorMessages([arg.slice(startIndex, endIndex)]);
|
||||
return;
|
||||
} else if (arg instanceof Error) {
|
||||
sendErrorMessages([arg]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
sendConsoleMessages([formatMessage(type, args)]);
|
||||
};
|
||||
}
|
||||
@ -6837,10 +6709,87 @@ function isConsoleWritable() {
|
||||
console.log = value;
|
||||
return isWritable;
|
||||
}
|
||||
let sendError = null;
|
||||
const errorQueue = /* @__PURE__ */ new Set();
|
||||
const errorExtra = {};
|
||||
function sendErrorMessages(errors) {
|
||||
if (sendError == null) {
|
||||
errors.forEach((error) => {
|
||||
errorQueue.add(error);
|
||||
});
|
||||
return;
|
||||
}
|
||||
const data = errors.map((err) => {
|
||||
const isPromiseRejection = err && "promise" in err && "reason" in err;
|
||||
const prefix = isPromiseRejection ? "UnhandledPromiseRejection: " : "";
|
||||
if (isPromiseRejection) {
|
||||
err = err.reason;
|
||||
}
|
||||
if (err instanceof Error && err.stack) {
|
||||
if (err.message && !err.stack.includes(err.message)) {
|
||||
return `${prefix}${err.message}
|
||||
${err.stack}`;
|
||||
}
|
||||
return `${prefix}${err.stack}`;
|
||||
}
|
||||
if (typeof err === "object" && err !== null) {
|
||||
try {
|
||||
return prefix + JSON.stringify(err);
|
||||
} catch (err2) {
|
||||
return prefix + String(err2);
|
||||
}
|
||||
}
|
||||
return prefix + String(err);
|
||||
}).filter(Boolean);
|
||||
if (data.length > 0) {
|
||||
sendError(JSON.stringify(Object.assign({
|
||||
type: "error",
|
||||
data
|
||||
}, errorExtra)));
|
||||
}
|
||||
}
|
||||
function setSendError(value, extra = {}) {
|
||||
sendError = value;
|
||||
Object.assign(errorExtra, extra);
|
||||
if (value != null && errorQueue.size > 0) {
|
||||
const errors = Array.from(errorQueue);
|
||||
errorQueue.clear();
|
||||
sendErrorMessages(errors);
|
||||
}
|
||||
}
|
||||
function initOnError() {
|
||||
function onError2(error) {
|
||||
try {
|
||||
if (typeof PromiseRejectionEvent !== "undefined" && error instanceof PromiseRejectionEvent && error.reason instanceof Error && error.reason.message && error.reason.message.includes(`Cannot create property 'errMsg' on string 'taskId`)) {
|
||||
return;
|
||||
}
|
||||
if (true) {
|
||||
originalConsole.error(error);
|
||||
}
|
||||
sendErrorMessages([error]);
|
||||
} catch (err) {
|
||||
originalConsole.error(err);
|
||||
}
|
||||
}
|
||||
if (typeof index.onError === "function") {
|
||||
index.onError(onError2);
|
||||
}
|
||||
if (typeof index.onUnhandledRejection === "function") {
|
||||
index.onUnhandledRejection(onError2);
|
||||
}
|
||||
return function offError2() {
|
||||
if (typeof index.offError === "function") {
|
||||
index.offError(onError2);
|
||||
}
|
||||
if (typeof index.offUnhandledRejection === "function") {
|
||||
index.offUnhandledRejection(onError2);
|
||||
}
|
||||
};
|
||||
}
|
||||
function initRuntimeSocketService() {
|
||||
const hosts = "192.168.160.1,192.168.229.1,172.10.0.126,127.0.0.1";
|
||||
const hosts = "127.0.0.1,172.10.0.117";
|
||||
const port = "8090";
|
||||
const id = "mp-weixin_Q6XvSB";
|
||||
const id = "mp-weixin_c9b8fP";
|
||||
const lazy = typeof swan !== "undefined";
|
||||
let restoreError = lazy ? () => {
|
||||
} : initOnError();
|
||||
@ -6856,19 +6805,13 @@ function initRuntimeSocketService() {
|
||||
restoreError();
|
||||
restoreConsole();
|
||||
originalConsole.error(wrapError("开发模式下日志通道建立 socket 连接失败。"));
|
||||
{
|
||||
originalConsole.error(wrapError("小程序平台,请勾选不校验合法域名配置。"));
|
||||
}
|
||||
originalConsole.error(wrapError("如果是小程序平台,请勾选不校验合法域名配置。"));
|
||||
originalConsole.error(wrapError("如果是运行到真机,请确认手机与电脑处于同一网络。"));
|
||||
return false;
|
||||
}
|
||||
{
|
||||
initMiniProgramGlobalFlag();
|
||||
}
|
||||
initMiniProgramGlobalFlag();
|
||||
socket.onClose(() => {
|
||||
{
|
||||
originalConsole.error(wrapError("开发模式下日志通道 socket 连接关闭,请在 HBuilderX 中重新运行。"));
|
||||
}
|
||||
originalConsole.error(wrapError("开发模式下日志通道 socket 连接关闭,请在 HBuilderX 中重新运行。"));
|
||||
restoreError();
|
||||
restoreConsole();
|
||||
});
|
||||
@ -7785,8 +7728,16 @@ const createSubpackageApp = initCreateSubpackageApp();
|
||||
wx.createPluginApp = global.createPluginApp = createPluginApp;
|
||||
wx.createSubpackageApp = global.createSubpackageApp = createSubpackageApp;
|
||||
}
|
||||
const createHook = (lifecycle) => (hook, target = getCurrentInstance()) => {
|
||||
!isInSSRComponentSetup && injectHook(lifecycle, hook, target);
|
||||
};
|
||||
const onReady = /* @__PURE__ */ createHook(ON_READY);
|
||||
exports._export_sfc = _export_sfc;
|
||||
exports.createSSRApp = createSSRApp;
|
||||
exports.getCurrentInstance = getCurrentInstance;
|
||||
exports.index = index;
|
||||
exports.o = o;
|
||||
exports.onMounted = onMounted;
|
||||
exports.onReady = onReady;
|
||||
exports.ref = ref;
|
||||
//# sourceMappingURL=../../.sourcemap/mp-weixin/common/vendor.js.map
|
||||
|
229
unpackage/dist/dev/mp-weixin/index.js
vendored
Normal file
229
unpackage/dist/dev/mp-weixin/index.js
vendored
Normal file
@ -0,0 +1,229 @@
|
||||
"use strict";
|
||||
const common_vendor = require("./common/vendor.js");
|
||||
const _sfc_main = {
|
||||
__name: "index",
|
||||
setup(__props) {
|
||||
<<<<<<< HEAD
|
||||
const translateX = common_vendor.ref(0);
|
||||
const translateY = common_vendor.ref(0);
|
||||
const scale = common_vendor.ref(1);
|
||||
const canvasWidth = common_vendor.ref(375);
|
||||
const canvasHeight = common_vendor.ref(400);
|
||||
const instance = common_vendor.getCurrentInstance();
|
||||
const blocks = common_vendor.ref([{
|
||||
points: [
|
||||
{
|
||||
x: 50,
|
||||
y: 50
|
||||
},
|
||||
// 左下角点
|
||||
{
|
||||
x: 150,
|
||||
y: 50
|
||||
},
|
||||
// 右下角点
|
||||
{
|
||||
x: 200,
|
||||
y: 100
|
||||
},
|
||||
// 右上角点
|
||||
{
|
||||
x: 100,
|
||||
y: 100
|
||||
}
|
||||
// 左上角点
|
||||
],
|
||||
message: "点击了四边形",
|
||||
type: "quadrilateral"
|
||||
}]);
|
||||
async function draw() {
|
||||
const imgUrl = "https://assets.sx25.troyrc.com/sx25/images/events/XBDT.jpg";
|
||||
const ctx = common_vendor.index.createCanvasContext("canvas", instance);
|
||||
ctx.translate(translateX.value, translateY.value);
|
||||
ctx.scale(scale.value, scale.value);
|
||||
const res = await common_vendor.index.getImageInfo({
|
||||
src: imgUrl
|
||||
});
|
||||
ctx.drawImage(res.path, 0, 0, canvasWidth.value, canvasHeight.value);
|
||||
blocks.value.forEach((block) => {
|
||||
ctx.beginPath();
|
||||
ctx.fillStyle = block.color;
|
||||
switch (block.type) {
|
||||
case "quadrilateral":
|
||||
ctx.moveTo(block.points[0].x, block.points[0].y);
|
||||
for (let i = 1; i < block.points.length; i++) {
|
||||
ctx.lineTo(block.points[i].x, block.points[i].y);
|
||||
}
|
||||
ctx.closePath();
|
||||
break;
|
||||
}
|
||||
ctx.stroke();
|
||||
});
|
||||
ctx.draw();
|
||||
}
|
||||
function handleCanvasTouchMove(event) {
|
||||
if (event.touches.length === 1) {
|
||||
translateX.value += event.touches[0].x - event.touches[0].startX;
|
||||
translateY.value += event.touches[0].y - event.touches[0].startY;
|
||||
} else if (event.touches.length === 2) {
|
||||
const distance1 = Math.sqrt(
|
||||
(event.touches[0].x - event.touches[1].x) ** 2 + (event.touches[0].y - event.touches[1].y) ** 2
|
||||
);
|
||||
const distance2 = Math.sqrt(
|
||||
(event.touches[0].startX - event.touches[1].startX) ** 2 + (event.touches[0].startY - event.touches[1].startY) ** 2
|
||||
);
|
||||
scale.value *= distance1 / distance2;
|
||||
}
|
||||
draw();
|
||||
}
|
||||
function handleCanvasTouchEnd(event) {
|
||||
event.touches.forEach((touch) => {
|
||||
touch.startX = touch.x;
|
||||
touch.startY = touch.y;
|
||||
});
|
||||
}
|
||||
function handleCanvasTouch(event) {
|
||||
const x = event.touches[0].x;
|
||||
const y = event.touches[0].y;
|
||||
blocks.value.forEach((block) => {
|
||||
if (isPointInQuadrilateral(x, y, block.points)) {
|
||||
common_vendor.index.showModal({
|
||||
title: "提示",
|
||||
content: block.message,
|
||||
showCancel: true,
|
||||
// 显示取消按钮
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
common_vendor.index.__f__("log", "at pages/index/index.vue:128", "用户点击了“确定”按钮");
|
||||
} else if (res.cancel) {
|
||||
common_vendor.index.__f__("log", "at pages/index/index.vue:130", "用户点击了“取消”按钮");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
const handleDraw = () => {
|
||||
draw();
|
||||
};
|
||||
common_vendor.onMounted(() => {
|
||||
draw();
|
||||
=======
|
||||
common_vendor.ref(375);
|
||||
common_vendor.ref(400);
|
||||
const instance = common_vendor.getCurrentInstance();
|
||||
const scale = common_vendor.ref(1);
|
||||
const offsetX = common_vendor.ref(0);
|
||||
const offsetY = common_vendor.ref(0);
|
||||
const lastDistance = common_vendor.ref(-1);
|
||||
const startX = common_vendor.ref(0);
|
||||
const startY = common_vendor.ref(0);
|
||||
const isDragging = common_vendor.ref(false);
|
||||
const imgUrl = common_vendor.ref("https://assets.sx25.troyrc.com/sx25/images/events/XBDT.jpg");
|
||||
async function draw() {
|
||||
const ctx = common_vendor.index.createCanvasContext("canvas", instance);
|
||||
ctx.scale(scale.value, scale.value);
|
||||
const res = await common_vendor.index.getImageInfo({
|
||||
src: imgUrl.value
|
||||
});
|
||||
ctx.drawImage(res.path, 0, 0);
|
||||
ctx.draw();
|
||||
}
|
||||
const handleTouchStart = (e) => {
|
||||
common_vendor.index.__f__("log", "at pages/index/index.vue:93", "handleTouchStart");
|
||||
if (e.touches.length === 1) {
|
||||
startX.value = e.touches[0].clientX - offsetX.value;
|
||||
startY.value = e.touches[0].clientY - offsetY.value;
|
||||
isDragging.value = true;
|
||||
} else if (e.touches.length === 2) {
|
||||
const x1 = e.touches[0].clientX;
|
||||
const y1 = e.touches[0].clientY;
|
||||
const x2 = e.touches[1].clientX;
|
||||
const y2 = e.touches[1].clientY;
|
||||
lastDistance.value = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
|
||||
}
|
||||
};
|
||||
const handleTouchMove = (e) => {
|
||||
common_vendor.index.__f__("log", "at pages/index/index.vue:111", "handleTouchMove");
|
||||
if (e.touches.length === 1 && isDragging.value) {
|
||||
const currentX = e.touches[0].clientX - startX.value;
|
||||
const currentY = e.touches[0].clientY - startY.value;
|
||||
offsetX.value = currentX;
|
||||
offsetY.value = currentY;
|
||||
} else if (e.touches.length === 2) {
|
||||
const x1 = e.touches[0].clientX;
|
||||
const y1 = e.touches[0].clientY;
|
||||
const x2 = e.touches[1].clientX;
|
||||
const y2 = e.touches[1].clientY;
|
||||
const distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
|
||||
if (lastDistance.value > 0) {
|
||||
const newScale = scale.value * (distance / lastDistance.value);
|
||||
scale.value = Math.min(Math.max(newScale, 0.5), 4);
|
||||
}
|
||||
lastDistance.value = distance;
|
||||
}
|
||||
};
|
||||
const handleTouchEnd = () => {
|
||||
common_vendor.index.__f__("log", "at pages/index/index.vue:136", "handleTouchEnd");
|
||||
lastDistance.value = -1;
|
||||
isDragging.value = false;
|
||||
};
|
||||
const handleDraw = () => {
|
||||
draw();
|
||||
};
|
||||
common_vendor.onReady(() => {
|
||||
common_vendor.index.__f__("log", "at pages/index/index.vue:153", "onReadyonReady");
|
||||
common_vendor.index.downloadFile({
|
||||
url: imgUrl.value,
|
||||
success: function(sres) {
|
||||
common_vendor.index.__f__("log", "at pages/index/index.vue:157", sres, "sres");
|
||||
imgUrl.value = sres.tempFilePath || sres.path;
|
||||
draw();
|
||||
},
|
||||
fail: function(fres) {
|
||||
common_vendor.index.__f__("log", "at pages/index/index.vue:161", "fres", fres);
|
||||
}
|
||||
});
|
||||
>>>>>>> c224ee0a440c37a515ef0081348c5d861d979aee
|
||||
});
|
||||
function isPointInQuadrilateral(px, py, points) {
|
||||
let inside = false;
|
||||
const n = points.length;
|
||||
let p1 = points[0];
|
||||
for (let i = 1; i <= n; i++) {
|
||||
let p2 = points[i % n];
|
||||
if (py > Math.min(p1.y, p2.y) && py <= Math.max(p1.y, p2.y) && px <= Math.max(p1.x, p2.x)) {
|
||||
if (p1.y !== p2.y) {
|
||||
let xinters = (py - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x;
|
||||
if (p1.x === p2.x || px <= xinters) {
|
||||
inside = !inside;
|
||||
}
|
||||
}
|
||||
}
|
||||
p1 = p2;
|
||||
}
|
||||
return inside;
|
||||
}
|
||||
return (_ctx, _cache) => {
|
||||
return {
|
||||
<<<<<<< HEAD
|
||||
a: common_vendor.o(handleCanvasTouch),
|
||||
b: common_vendor.o(handleCanvasTouchMove),
|
||||
c: common_vendor.o(handleCanvasTouchEnd),
|
||||
d: common_vendor.o(handleDraw)
|
||||
=======
|
||||
a: common_vendor.o(handleTouchStart),
|
||||
b: common_vendor.o(handleTouchMove),
|
||||
c: common_vendor.o(handleTouchEnd),
|
||||
d: "1000px",
|
||||
e: "800px",
|
||||
f: `translate(${offsetX.value}px, ${offsetY.value}px) scale(${scale.value})`,
|
||||
g: common_vendor.o(handleDraw)
|
||||
>>>>>>> c224ee0a440c37a515ef0081348c5d861d979aee
|
||||
};
|
||||
};
|
||||
}
|
||||
};
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1cf27b2a"]]);
|
||||
exports.MiniProgramPage = MiniProgramPage;
|
||||
//# sourceMappingURL=../.sourcemap/mp-weixin/index.js.map
|
@ -1,30 +1,4 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const _sfc_main = {
|
||||
__name: "index",
|
||||
setup(__props) {
|
||||
function draw() {
|
||||
const ctx = common_vendor.index.createCanvasContext("canvas");
|
||||
ctx.beginPath();
|
||||
ctx.arc(100, 100, 80, 0, Math.PI * 2);
|
||||
ctx.setFillStyle("rgba(0, 0, 0, 1)");
|
||||
ctx.fill();
|
||||
ctx.beginPath();
|
||||
ctx.arc(100, 100, 75, 0, Math.PI * 2);
|
||||
ctx.setFillStyle("white");
|
||||
ctx.fill();
|
||||
ctx.draw();
|
||||
}
|
||||
const handleDraw = () => {
|
||||
draw();
|
||||
};
|
||||
return (_ctx, _cache) => {
|
||||
return {
|
||||
a: common_vendor.o(($event) => handleDraw())
|
||||
};
|
||||
};
|
||||
}
|
||||
};
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1cf27b2a"]]);
|
||||
wx.createPage(MiniProgramPage);
|
||||
const index = require("../../index.js");
|
||||
wx.createPage(index.MiniProgramPage);
|
||||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/index.js.map
|
||||
|
@ -1 +1 @@
|
||||
<view class="data-v-1cf27b2a"><canvas class="data-v-1cf27b2a" canvas-id="canvas" id="canvas" style="width:200px;height:200px"></canvas><button class="data-v-1cf27b2a" bindtap="{{a}}">点击绘制圆形</button></view>
|
||||
<view class="data-v-1cf27b2a"><block wx:if="{{r0}}"><canvas class="data-v-1cf27b2a" bindtouchstart="{{a}}" bindtouchmove="{{b}}" bindtouchend="{{c}}" style="{{'width:' + d + ';' + ('height:' + e) + ';' + ('transform:' + f)}}" canvas-id="canvas" id="canvas"></canvas></block><image class="data-v-1cf27b2a" src="https://assets.sx25.troyrc.com/sx25/images/events/XBDT.jpg"></image><button class="data-v-1cf27b2a" bindtap="{{g}}">点击绘制圆形</button></view>
|
@ -1,6 +1,4 @@
|
||||
|
||||
/* 样式部分 */
|
||||
button.data-v-1cf27b2a {
|
||||
margin-top: 10px;
|
||||
/* 给按钮设置一些上边距以避免过于紧凑 */
|
||||
}
|
||||
|
4
unpackage/dist/dev/mp-weixin/pages/index/index2.js
vendored
Normal file
4
unpackage/dist/dev/mp-weixin/pages/index/index2.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
const index = require("../../index.js");
|
||||
wx.createPage(index.MiniProgramPage);
|
||||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/index2.js.map
|
42
unpackage/dist/dev/mp-weixin/pages/index/index_step4.js
vendored
Normal file
42
unpackage/dist/dev/mp-weixin/pages/index/index_step4.js
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const _sfc_main = {
|
||||
__name: "index_step4",
|
||||
setup(__props) {
|
||||
const canvasWidth = common_vendor.ref(200);
|
||||
const canvasHeight = common_vendor.ref(200);
|
||||
const instance = common_vendor.getCurrentInstance();
|
||||
function draw() {
|
||||
const ctx = common_vendor.index.createCanvasContext("canvas", instance);
|
||||
common_vendor.index.__f__("log", "at pages/index/index_step4.vue:20", ctx, "12");
|
||||
ctx.beginPath();
|
||||
ctx.arc(100, 100, 80, 0, Math.PI * 2);
|
||||
ctx.setFillStyle("rgba(100, 220, 0, 1)");
|
||||
ctx.fill();
|
||||
ctx.beginPath();
|
||||
ctx.arc(100, 100, 75, 0, Math.PI * 2);
|
||||
ctx.setFillStyle("white");
|
||||
ctx.fill();
|
||||
ctx.draw();
|
||||
}
|
||||
const handleDraw = () => {
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/pages/index/step2"
|
||||
});
|
||||
draw();
|
||||
};
|
||||
common_vendor.onMounted(() => {
|
||||
draw();
|
||||
});
|
||||
return (_ctx, _cache) => {
|
||||
return {
|
||||
a: canvasWidth.value,
|
||||
b: canvasHeight.value,
|
||||
c: common_vendor.o(handleDraw)
|
||||
};
|
||||
};
|
||||
}
|
||||
};
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-7e4ca425"]]);
|
||||
wx.createPage(MiniProgramPage);
|
||||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/index_step4.js.map
|
4
unpackage/dist/dev/mp-weixin/pages/index/index_step4.json
vendored
Normal file
4
unpackage/dist/dev/mp-weixin/pages/index/index_step4.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "step",
|
||||
"usingComponents": {}
|
||||
}
|
1
unpackage/dist/dev/mp-weixin/pages/index/index_step4.wxml
vendored
Normal file
1
unpackage/dist/dev/mp-weixin/pages/index/index_step4.wxml
vendored
Normal file
@ -0,0 +1 @@
|
||||
<view class="data-v-7e4ca425"><canvas class="data-v-7e4ca425" canvas-id="canvas" id="canvas" style="width:200px;height:200px;border:1px solid red" width="{{a}}" height="{{b}}"></canvas><button class="data-v-7e4ca425" bindtap="{{c}}">跳转step2</button></view>
|
4
unpackage/dist/dev/mp-weixin/pages/index/index_step4.wxss
vendored
Normal file
4
unpackage/dist/dev/mp-weixin/pages/index/index_step4.wxss
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
button.data-v-7e4ca425 {
|
||||
margin-top: 10px;
|
||||
}
|
16
unpackage/dist/dev/mp-weixin/pages/index/step2.js
vendored
Normal file
16
unpackage/dist/dev/mp-weixin/pages/index/step2.js
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
require("../../common/vendor.js");
|
||||
if (!Math) {
|
||||
indexstep2();
|
||||
}
|
||||
const indexstep2 = () => "./index2.js";
|
||||
const _sfc_main = {
|
||||
__name: "step2",
|
||||
setup(__props) {
|
||||
return (_ctx, _cache) => {
|
||||
return {};
|
||||
};
|
||||
}
|
||||
};
|
||||
wx.createPage(_sfc_main);
|
||||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/step2.js.map
|
6
unpackage/dist/dev/mp-weixin/pages/index/step2.json
vendored
Normal file
6
unpackage/dist/dev/mp-weixin/pages/index/step2.json
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"navigationBarTitleText": "fu",
|
||||
"usingComponents": {
|
||||
"indexstep2": "./index"
|
||||
}
|
||||
}
|
1
unpackage/dist/dev/mp-weixin/pages/index/step2.wxml
vendored
Normal file
1
unpackage/dist/dev/mp-weixin/pages/index/step2.wxml
vendored
Normal file
@ -0,0 +1 @@
|
||||
<view><indexstep2 u-i="4f007cb8-0" bind:__l="__l"></indexstep2></view>
|
0
unpackage/dist/dev/mp-weixin/pages/index/step2.wxss
vendored
Normal file
0
unpackage/dist/dev/mp-weixin/pages/index/step2.wxss
vendored
Normal file
@ -19,7 +19,7 @@
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"libVersion": "3.8.3",
|
||||
"appid": "touristappid",
|
||||
"appid": "wx5c9edf82da6032c4",
|
||||
"projectname": "canvas",
|
||||
"condition": {},
|
||||
"editorSetting": {
|
||||
|
@ -2,6 +2,7 @@
|
||||
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
||||
"projectname": "canvas",
|
||||
"setting": {
|
||||
"compileHotReLoad": true
|
||||
"compileHotReLoad": true,
|
||||
"urlCheck": false
|
||||
}
|
||||
}
|
BIN
unpackage/dist/dev/mp-weixin/static/canvas.jpg
vendored
Normal file
BIN
unpackage/dist/dev/mp-weixin/static/canvas.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 191 KiB |
Loading…
x
Reference in New Issue
Block a user