午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁技術文章
文章詳情頁

vue 實現無規則截圖

瀏覽:113日期:2022-09-30 16:38:46

大家所見到的大多數都是有規則截圖,可以應付大部分的應用場景,但是對于圖片處理,想要將規則交給用戶,普通的截圖已經滿足不了用戶了,那我們能不能前端實現圖片的任意規則截取,接下來讓我一起探討一下吧!

vue 實現無規則截圖

通過 svg 實現 圖片截取

使用svg中clipPath image標簽 通過id 映射, 動態位置polygon的坐標,實現圖片的截取

<div><div @mousemove='mousemove' @mouseup='(e) => {mouseup(e);}'> <!-- 畫布展示 --> <svg ref='blackSvg' xmlns='http://www.w3.org/2000/svg' > <defs> <clipPath id='clippath'><polygon :points='points'></polygon> </clipPath> </defs> <image xmlns:link='http://www.w3.org/1999/xlink' rel='external nofollow' preserveAspectRatio='none' ></image> </svg> <!-- 拖拽點 --> <ul class='interception'> <li v-for='item in 4' :ref='`li${item}`' :key='item' @mousedown='(e) => {mousedown(e, item);}' ></li> </ul> <!-- 底圖展示 --> <img src='https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3228549874,2173006364&fm=26&gp=0.jpg' alt='' /> <!-- 遮罩層 --> <div class='blackDiv'></div> </div> </div>css部分

<style lang='sass'>.blackDiv width: 100% height: 100% position: absolute top: 0 z-index: 2 background: rgba(0,0,0, 1).content width:300px height:300px text-align: left position: relative .blackSvgposition: absolutetop: 0z-index: 3 .blackImgeposition: absolutetop: 0left: 0width: 300pxheight: 300px .interceptionlist-style: noneposition: absolutetop: 0margin: 0padding: 0z-index: 3>li position: absolute width: 10px height: 10px background: blue border-radius: 50% cursor: pointer &:hovertransform: scale(1.2)transition-duration: .2>li:nth-child(1) top: 10px left: 10px>li:nth-child(2) top: 10px left: 100px>li:nth-child(3) top: 100px left: 100px>li:nth-child(4) top: 100px left: 10px</style><script>

export default { name: ’Canvas’, data() { return { points: ’0 0,300 0,300 300,0 300’, // 圖片展示初始化 status: false, index: 0, disX: 0, disY: 0, coordinates: { // 初始化拖拽點1: [0, 0],2: [300, 0],3: [300, 300],4: [0, 300], }, }; }, mounted() { this.$nextTick(() => { for (let key in this.coordinates) {const left = this.coordinates[key][0];const top = this.coordinates[key][1];this.$refs[`li${key}`].style.left = `${left}px`;this.$refs[`li${key}`].style.top = `${top}px`;if (key == 2 || key == 3) { this.$refs[`li${key}`].style.left = `${left - 10}px`;}if (key == 3 || key == 4) { this.$refs[`li${key}`].style.top = `${top - 10}px`;} } document.onmouseup = () => {this.status = false; }; }); }, methods: { //鼠標按下 mousedown(e, index) { this.status = true; this.index = index; this.disX = e.clientX - this.$refs[`li${index}`].offsetLeft; this.disY = e.clientY - this.$refs[`li${index}`].offsetTop; }, // 鼠標抬起 mouseup(e) { this.status = false; }, // 鼠標移動 mousemove(e) { if (this.status) {let left = e.clientX - this.disX;let top = e.clientY - this.disY;this.$refs[`li${this.index}`].style.left = `${left}px`;this.$refs[`li${this.index}`].style.top = `${top}px`;this.coordinates[this.index] = [left, top];const pointsArr = [];for (let item in this.coordinates) { pointsArr.push( Array.from(this.coordinates[item], (e) => { return e + 5; }) );}this.points = pointsArr.join(’ ’); } }, },};效果圖展示

vue 實現無規則截圖

源碼地址

github地址--> github.com/lgxin/captu…

以上就是vue 實現無規則截圖的詳細內容,更多關于vue 無規則截圖的資料請關注好吧啦網其它相關文章!

標簽: Vue
相關文章:
主站蜘蛛池模板: 欧美中文字幕 | 美女黄页在线观看 | 国产在线观看www | 国产精品第6页 | 日本黄色视屏 | 亚洲永久av | 伊人手机视频 | 欧美成人精品一级 | 中文字幕日韩在线观看 | 国产69精品久久久久久久久久 | 91精品国产欧美一区二区 | 久久精彩视频 | 五月婷婷激情综合网 | 久久永久免费视频 | 欧美一区二区三区四区五区 | 欧洲精品在线观看 | 国产精品果冻传媒 | 免费黄色一级片 | 日本黄色视 | 久久午夜国产精品 | 国产成人精品一区二区 | 日韩中文字幕网站 | 欧美在线视频一区二区三区 | 免费观看的av网站 | 成人毛片在线播放 | 久久亚洲视频 | 久久精品在线观看视频 | 男人疯狂高潮呻吟视频 | 免费视频99 | 成人福利在线视频 | 日本特黄一级片 | 亚洲99 | 国产美女在线观看 | 69激情网 | 一区二区三区国产在线 | 在线视频 中文字幕 | 精品国产一区二区三区在线观看 | 国产精品毛片久久 | 五月婷婷免费视频 | 午夜天堂视频 | 一区二区三区四区在线观看视频 |