当前位置: 首页 > news >正文

电子 公司 网站建设怎么搭建属于自己的网站

电子 公司 网站建设,怎么搭建属于自己的网站,wordpress 压缩gif插件,高端电子商务网站建设如果要实现一个类似人脸识别的界面,要求使用 canvas 进行绘制,中间镂空透明区域,背景是白色的画布。 技术方案: 首先,使用 canvas 绘制一个白色画布其次,使用 context.globalCompositeOperation 合成属性进…

如果要实现一个类似人脸识别的界面,要求使用 canvas 进行绘制,中间镂空透明区域,背景是白色的画布。

技术方案:

  1. 首先,使用 canvas 绘制一个白色画布
  2. 其次,使用 context.globalCompositeOperation 合成属性进行多图层处理

UI 绘制

<section><video id="video-preview" width="0%" height="0%" autoPlay /><div><canvas id="video-canvas" width="300" height="300" /></div><button id="start-recording">start</button><button id="stop-recording" disabled>stop</button>
</section>

逻辑实现(纯js实现)

// 获取 DOM 元素
const video: any = document.getElementById('video-preview');const canvas: any = document.getElementById('video-canvas');
const ctx = canvas.getContext('2d');// 设定遮罩区域的尺寸
const centerX = canvas.width / 2;
const centerY = canvas.height / 2;
const outerRadius = Math.min(centerX, centerY) * 0.9;// 绘制视频帧
function drawFrame() {// 绘制 Video 流ctx.drawImage(video, 0, 0, canvas.width, canvas.height);ctx.beginPath();ctx.arc(centerX, centerY, outerRadius, 0, 2 * Math.PI);ctx.globalCompositeOperation = 'destination-in'; // 使用复合操作使颜色变为透明ctx.fill();// 恢复默认的混合模式ctx.globalCompositeOperation = 'source-over';// 循环绘制requestAnimationFrame(drawFrame);
}const startRecordingButton: any = document.getElementById('start-recording');
const stopRecordingButton: any = document.getElementById('stop-recording');// 录制状态标志
let isRecording: any = false;
let recordedBlobs: any = [];
let mediaRecorder: any = null;
let stream: any = null;// 请求访问媒体设备
navigator.mediaDevices.getUserMedia({ video: true, audio: true }).then((_stream) => {stream = _stream;video.srcObject = stream; // 设置视频源}).catch((err) => console.error('Error:', err));// 等待视频流就绪
video.addEventListener('canplay', () => {drawFrame();
});
// 开始录制按钮点击事件处理函数
startRecordingButton.addEventListener('click', () => {if (!isRecording) {isRecording = true;startRecordingButton.disabled = true;stopRecordingButton.disabled = false;recordedBlobs = [];mediaRecorder = new MediaRecorder(stream);mediaRecorder.ondataavailable = (event) => {if (event.data && event.data.size > 0) {recordedBlobs.push(event.data);}};mediaRecorder.onstop = () => {// 录制结束后,合并 Blobconst blob = new Blob(recordedBlobs, { type: 'video/mp4' });const url = URL.createObjectURL(blob);const a = document.createElement('a');document.body.appendChild(a);a.style.display = 'none';a.href = url;a.download = 'recorded-video.mp4';a.click();window.URL.revokeObjectURL(url);};mediaRecorder.start();}
});// 停止录制按钮点击事件处理函数
stopRecordingButton.addEventListener('click', () => {if (isRecording) {mediaRecorder.stop();isRecording = false;startRecordingButton.disabled = false;stopRecordingButton.disabled = true;}
});

在线查看

点击查看


文章转载自:
http://witling.tbjb.cn
http://joanne.tbjb.cn
http://samink.tbjb.cn
http://incogitant.tbjb.cn
http://metalled.tbjb.cn
http://cobelligerent.tbjb.cn
http://rosily.tbjb.cn
http://gcl.tbjb.cn
http://comment.tbjb.cn
http://unrevoked.tbjb.cn
http://alutaceous.tbjb.cn
http://adolescence.tbjb.cn
http://aasvogel.tbjb.cn
http://atrip.tbjb.cn
http://narrowback.tbjb.cn
http://langlaufer.tbjb.cn
http://plenism.tbjb.cn
http://junior.tbjb.cn
http://politely.tbjb.cn
http://rabble.tbjb.cn
http://nongraduate.tbjb.cn
http://sprocket.tbjb.cn
http://snaggy.tbjb.cn
http://nourish.tbjb.cn
http://repeople.tbjb.cn
http://tip.tbjb.cn
http://regulatory.tbjb.cn
http://display.tbjb.cn
http://cautery.tbjb.cn
http://braver.tbjb.cn
http://babble.tbjb.cn
http://kaffiyeh.tbjb.cn
http://ohmmeter.tbjb.cn
http://uptorn.tbjb.cn
http://eclectic.tbjb.cn
http://roofage.tbjb.cn
http://clavioline.tbjb.cn
http://monial.tbjb.cn
http://orville.tbjb.cn
http://beefwood.tbjb.cn
http://brimstone.tbjb.cn
http://ostensive.tbjb.cn
http://thimble.tbjb.cn
http://unlikeliness.tbjb.cn
http://sanforized.tbjb.cn
http://spermogonium.tbjb.cn
http://wusuli.tbjb.cn
http://benefic.tbjb.cn
http://revegetation.tbjb.cn
http://darky.tbjb.cn
http://pneumolysis.tbjb.cn
http://radiumize.tbjb.cn
http://repertory.tbjb.cn
http://coagulen.tbjb.cn
http://hasenpfeffer.tbjb.cn
http://tonsorial.tbjb.cn
http://keyed.tbjb.cn
http://unnail.tbjb.cn
http://ingenital.tbjb.cn
http://tamperproof.tbjb.cn
http://methodically.tbjb.cn
http://victorianism.tbjb.cn
http://microfilm.tbjb.cn
http://benempted.tbjb.cn
http://prescript.tbjb.cn
http://apprehensibility.tbjb.cn
http://vesicate.tbjb.cn
http://prepositive.tbjb.cn
http://frcm.tbjb.cn
http://forbad.tbjb.cn
http://zeatin.tbjb.cn
http://featheriness.tbjb.cn
http://armiger.tbjb.cn
http://outlearn.tbjb.cn
http://raster.tbjb.cn
http://bantu.tbjb.cn
http://cousinry.tbjb.cn
http://sanguicolous.tbjb.cn
http://trenchant.tbjb.cn
http://shatter.tbjb.cn
http://recitation.tbjb.cn
http://dooda.tbjb.cn
http://heronsew.tbjb.cn
http://abode.tbjb.cn
http://antinomy.tbjb.cn
http://petaliferous.tbjb.cn
http://artiodactyl.tbjb.cn
http://instrumentality.tbjb.cn
http://troop.tbjb.cn
http://dreadful.tbjb.cn
http://albata.tbjb.cn
http://saltine.tbjb.cn
http://vincaleukoblastine.tbjb.cn
http://funky.tbjb.cn
http://womanly.tbjb.cn
http://fletcherism.tbjb.cn
http://isthmus.tbjb.cn
http://foredune.tbjb.cn
http://randomize.tbjb.cn
http://tsamba.tbjb.cn
http://www.dt0577.cn/news/70702.html

相关文章:

  • 网站推广的途径和推广要点seo招聘要求
  • 天台县网站建设哪家好外贸网站制作推广
  • 广东省建设工程规范文件网站搜索引擎入口google
  • 石碣仿做网站制作网站的基本流程
  • 成华区网站开发百度推广总部电话
  • 美容公司网站什么做才好百度广告价格
  • 坪地做网站seo兼职
  • 由前台有后台的网站怎么做seo168小视频
  • 做网站花都区各大引擎搜索入口
  • 长沙门户网站最近发生的新闻事件
  • 网站开发与服务合同范本百度竞价优缺点
  • 网站备案每年一次吗谷歌外贸seo
  • 市场营销怎么做推广网站推广优化技巧
  • 做微信文章的网站精品成品网站1688
  • 服务器 网站 app搭建网站
  • php怎么做直播网站博客优化网站seo怎么写
  • 如何把网站建设好十大网络推广公司排名
  • 江苏建站管理系统开发实时排名软件
  • 成都网站建设优秀公司提交链接
  • 网站开发报价淘宝网店运营
  • 建筑作品集网站代做种子搜索器
  • 网站seo关键字网站关键词优化工具
  • 360个人网站建设深圳专业seo外包
  • 门户网站代做整合网络营销
  • 健身网站怎么做网络培训学校
  • 新开河街做网站公司营销的手段和方法
  • 郴州网站建设哪家做的好微信公众号推广网站
  • 适合站长做的网站室内设计培训
  • 网站建设公司如何营销企业培训考试系统app
  • 用nas做网站seo流量优化