中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

有了域名搭建網(wǎng)站詳細步驟搜索引擎seo優(yōu)化平臺

有了域名搭建網(wǎng)站詳細步驟,搜索引擎seo優(yōu)化平臺,企業(yè)網(wǎng)站建設(shè)定制開發(fā),蘇州信網(wǎng)網(wǎng)站建設(shè)技術(shù)有限公司文章標題 01 功能說明02 使用方式 & 效果圖2.1 基礎(chǔ)用法2.2 拍照 底部定點水印 預(yù)覽2.3 拍照 整體背景水印 預(yù)覽 03 全部代碼3.1 頁面布局 html3.2 業(yè)務(wù)核心 js3.3 基礎(chǔ)樣式 css 01 功能說明 需求:小程序端需要調(diào)用前置攝像頭進行拍照,并且將拍…

文章標題

  • 01 功能說明
  • 02 使用方式 & 效果圖
    • 2.1 基礎(chǔ)用法
    • 2.2 拍照 + 底部定點水印 + 預(yù)覽
    • 2.3 拍照 + 整體背景水印 + 預(yù)覽
  • 03 全部代碼
    • 3.1 頁面布局 html
    • 3.2 業(yè)務(wù)核心 js
    • 3.3 基礎(chǔ)樣式 css

01 功能說明

需求:小程序端需要調(diào)用前置攝像頭進行拍照,并且將拍好的照片添加水印后返回。下面的代碼支持 底部定點水印整體背景水印。

技術(shù)棧uniapp、vue

迭代:后期還可以繼續(xù) 擴展多方位的定點水印 和 支持繪制多句話的背景水印。

02 使用方式 & 效果圖

文件路徑:"@/components/CameraSnap.vue"

2.1 基礎(chǔ)用法

// (1)僅拍照 + 預(yù)覽
<CameraSnap />// (4)僅給圖片添加水印 + 預(yù)覽
<CameraSnap photoSrc="xxx" :mark-list="['今天天氣很好','2023-01-01 00:00:00']" 
/>

2.2 拍照 + 底部定點水印 + 預(yù)覽

使用方式:

<CameraSnap :mark-list="['今天天氣很好','2023-01-01 00:00:00']" textSize="24" useTextMask 
/>

效果如下:
拍照_底部定點水印_預(yù)覽

2.3 拍照 + 整體背景水印 + 預(yù)覽

使用方式:

// 若不設(shè)置 markType,則默認為 底部定點水印
// 目前背景水印只會取 markList 的第一項來繪制背景水印
<CameraSnap markType="background" :mark-list="['今天天氣很好']" textColor="rgba(255,255,255,0.5)"  
/>

效果如下:
拍照_整體背景水印_預(yù)覽

03 全部代碼

uni-app camera 的官方文檔:https://uniapp.dcloud.net.cn/component/camera.html#camera

3.1 頁面布局 html

<template><view class="camera-wrapper"><!-- 拍照 --><template v-if="!snapSrc"><!-- 相機 --><camera device-position="front" flash="off" @error="handleError" class="image-size"><view class="photo-btn" @click="handleTakePhoto">拍照</view></camera><!-- 水印 --><canvas canvas-id="photoMarkCanvas" id="photoMarkCanvas" class="mark-canvas":style="{width: canvasWidth+'px',height: canvasHeight+'px'}" /></template><!-- 預(yù)覽 --><template v-else><view class="re-photo-btn" @click="handleRephotograph">重拍</view><image class="image-size" :src="snapSrc"></image></template></view>
</template>

3.2 業(yè)務(wù)核心 js

<script>export default {name: 'CameraSnap',props: {// 照片地址(若傳遞了照片地址,則默認為預(yù)覽該照片或添加水印后預(yù)覽)photoSrc: {type: String,default: ""},// 水印類型markType: {type: String,default: "fixed", // 定點水印 fixed,背景水印 background},// 水印文本列表(支持多行)markList: {type: Array,default: () => []},textColor: {type: String,default: "#FFFFFF"},textSize: {type: Number,default: 32},// 定點水印的遮罩(為了讓水印更清楚)useTextMask: {type: Boolean,default: true}},data() {return {snapSrc: "",canvasWidth: "",canvasHeight: "",}},watch: {photoSrc: {handler: function(newValue, oldValue) {if (newValue) {this.getWaterMarkImgPath(newValue)}},immediate: true}},methods: {handleTakePhoto() {const ctx = uni.createCameraContext();ctx.takePhoto({quality: 'high',success: (res) => {const imgPath = res.tempImagePathif (this.markList.length) {this.getWaterMarkImgPath(imgPath)} else {this.snapSrc = imgPath;console.log("default", this.snapSrc)this.$emit('complete', imgPath)}}});},handleRephotograph() {this.snapSrc = ""},handleError(err) {uni.showModal({title: '警告',content: '若不授權(quán)使用攝像頭,將無法使用拍照功能!',cancelText: '不授權(quán)',confirmText: '授權(quán)',success: (res) => {if (res.confirm) {// 允許打開授權(quán)頁面,調(diào)起客戶端小程序設(shè)置界面,返回用戶設(shè)置的操作結(jié)果uni.openSetting({success: (res) => {res.authSetting = { "scope.camera": true }},})} else if (res.cancel) {// 拒絕打開授權(quán)頁面uni.showToast({ title: '您已拒絕授權(quán),無法進行拍照', icon: 'error', duration: 2500 });}}})},setWaterMark(context, image) {const listLength = this.markList?.lengthswitch (this.markType) {case 'fixed':const spacing = 4 // 行間距const paddingTopBottom = 20 // 整體上下間距// 默認每行的高度 = 字體高度 + 向下間隔const lineHeight = this.textSize + spacingconst allLineHeight = lineHeight * listLength// 矩形遮罩的 Y 坐標const maskRectY = image.height - allLineHeight// 繪制遮罩層if (this.useTextMask) {context.setFillStyle('rgba(0,0,0,0.4)');context.fillRect(0, maskRectY - paddingTopBottom, image.width, allLineHeight + paddingTopBottom)}// 文本與 x 軸之間的間隔const textX = 10// 文本一行的最大寬度(減去 20 是為了一行的左右留間隙)const maxWidth = image.width - 20context.setFillStyle(this.textColor)context.setFontSize(this.textSize)this.markList.forEach((item, index) => {// 因為文本的 Y 坐標是指文本基線的 Y 軸坐標,所以要獲取文本頂部的 Y 坐標const textY = maskRectY - paddingTopBottom / 2 + this.textSize + lineHeight * indexcontext.fillText(item, textX, textY, maxWidth);})break;case 'background':context.translate(0, 0);context.rotate(30 * Math.PI / 180);context.setFillStyle(this.textColor)context.setFontSize(this.textSize)const colSize = parseInt(image.height / 6)const rowSize = parseInt(image.width / 2)let x = -rowSizelet y = -colSize// 循環(huán)繪制 5 行 6 列 的文字for (let i = 1; i <= 6; i++) {for (let j = 1; j <= 5; j++) {context.fillText(this.markList[0], x, y, rowSize)// 每個水印間隔 20x += rowSize + 20}y += colSizex = -rowSize}break;}context.save();},getWaterMarkImgPath(src) {const _this = thisuni.getImageInfo({src,success: (image) => {this.canvasWidth = image.widththis.canvasHeight = image.heightconst context = uni.createCanvasContext("photoMarkCanvas", this)context.drawImage(src, 0, 0, image.width, image.height)// 設(shè)置水印this.setWaterMark(context, image)// 若還需其他操作,可在操作之后疊加保存:context.restore()// 將畫布上的圖保存為圖片context.draw(false, () => {setTimeout(() => {uni.canvasToTempFilePath({destWidth: image.width,destHeight: image.height,canvasId: 'photoMarkCanvas',fileType: 'jpg',success: function(res) {_this.snapSrc = res.tempFilePathconsole.log("water", _this.snapSrc)_this.$emit('complete', _this.snapSrc)}},_this);}, 200)});}})},}}
</script>

3.3 基礎(chǔ)樣式 css

<style lang="scss" scoped>.camera-wrapper {position: relative;}.mark-canvas {position: absolute;/* 將畫布移出展示區(qū)域 */top: -200vh;left: -200vw;}.image-size {width: 100%;height: 100vh;}.photo-btn {position: absolute;bottom: 100rpx;left: 50%;transform: translateX(-50%);width: 140rpx;height: 140rpx;line-height: 140rpx;text-align: center;background-color: #000000;border-radius: 50%;border: 10rpx solid #ffffff;color: #fff;}.re-photo-btn {position: absolute;bottom: 80rpx;right: 40rpx;padding: 10rpx 20rpx;background-color: #000000;border-radius: 10%;border: 6rpx solid #ffffff;color: #fff}
</style>
http://m.risenshineclean.com/news/60275.html

相關(guān)文章:

  • 網(wǎng)絡(luò)服務(wù)器租賃費一般多少錢seo怎么做
  • 建立自己的網(wǎng)站步驟深圳公司網(wǎng)絡(luò)推廣該怎么做
  • 使用dw做門戶網(wǎng)站今天國際新聞
  • 品牌網(wǎng)站策劃書互聯(lián)網(wǎng)媒體廣告公司
  • 畢業(yè)論文網(wǎng)站鹽城seo優(yōu)化
  • 注冊網(wǎng)站入口西安百度關(guān)鍵詞優(yōu)化
  • 做淘客網(wǎng)站 備案煙臺seo快速排名
  • wordpress 汽車 模板下載蘇州搜索引擎優(yōu)化
  • html5 css3網(wǎng)站模板百度流量推廣項目
  • 鳥人 網(wǎng)站建設(shè)移動網(wǎng)站推廣如何優(yōu)化
  • 建筑工程網(wǎng)上考試答案重慶seo黃智
  • 濰坊做網(wǎng)站的網(wǎng)絡(luò)公司品牌網(wǎng)絡(luò)推廣運營公司
  • 重慶企業(yè)網(wǎng)站優(yōu)化營銷管理制度范本
  • 網(wǎng)站建設(shè)的淘寶模板南寧seo費用服務(wù)
  • 圖片演示dw做網(wǎng)站手機如何創(chuàng)建網(wǎng)站
  • 網(wǎng)站ip訪問做圖表中國十大新聞網(wǎng)站排名
  • 石家莊網(wǎng)絡(luò)公司行業(yè)深圳百度seo怎么做
  • 微網(wǎng)站做的比較好搜索引擎營銷的主要方式有
  • 南京網(wǎng)站網(wǎng)站建設(shè)學(xué)校如何發(fā)布一個網(wǎng)站
  • 做金融必看網(wǎng)站谷歌在線瀏覽器免費入口
  • 網(wǎng)站建設(shè)欄目說明百度一下就知道官網(wǎng)
  • 企業(yè)網(wǎng)站建設(shè)的思路最優(yōu)化方法
  • 一些做的好的網(wǎng)站東營百度推廣電話
  • 曲阜公司網(wǎng)站建設(shè)價格便宜ui設(shè)計培訓(xùn)班哪家好
  • 淘寶客網(wǎng)站還可以做嗎牛奶軟文廣告營銷
  • 長沙今天最新招聘信息臺州關(guān)鍵詞優(yōu)化平臺
  • 阿里巴巴做網(wǎng)站的電話號碼西安百度推廣怎么做
  • 金融投資網(wǎng)站開發(fā)站長工具是干嘛的
  • 產(chǎn)品經(jīng)理培訓(xùn)哪個機構(gòu)好湖南正規(guī)seo優(yōu)化
  • 做網(wǎng)站的人還能做什么公司網(wǎng)站建設(shè)要多少錢