首页 前端知识 【 HTML5画布漂浮分子 让化学动起来!(1),2024年华为前端面经

【 HTML5画布漂浮分子 让化学动起来!(1),2024年华为前端面经

2024-05-10 08:05:24 前端知识 前端哥 168 365 我要收藏

background: -o-radial-gradient(center, ellipse cover, #2d9b95 0%,#0e1329 100%);

background: -ms-radial-gradient(center, ellipse cover, #2d9b95 0%,#0e1329 100%);

background: radial-gradient(ellipse at center, #2d9b95 0%,#0e1329 100%);

filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=‘#2d9b95’, endColorstr=‘#0e1329’,GradientType=1 );

}

index.js

window.requestAnimFrame = (function(){

return window.requestAnimationFrame ||

window.webkitRequestAnimationFrame ||

window.mozRequestAnimationFrame ||

window.oRequestAnimationFrame ||

window.msRequestAnimationFrame ||

function( callback ){

window.setTimeout(callback, 1000 / 60);

};

})();

var canvas = document.getElementsByTagName(“canvas”)[0];

var ctx = canvas.getContext(“2d”);

var w = $(document).width();

var h = $(document).height();

canvas.width = w;

canvas.height = h;

var mols = [];

function init(){

for(var i=0;i<18;i++){

var mol = new generate_mol(“C8H10N4O2”);

mols.push(mol);

var mol = new generate_mol(“C6H6O”);

mols.push(mol);

var mol = new generate_mol(“C6H6”);

mols.push(mol);

}

}

function draw(){

canvas.width = canvas.width;

for(var i=0;i<mols.length;i++){

var m = mols[i];

m.x += m.vx;

if(m.x >= w-100 || m.x <= 0){

m.vx = -m.vx;

}

m.y += m.vy;

if(m.y >= h-100 || m.y <= 0){

m.vy = -m.vy;

}

m.r += 0.005;

m.draw();

}

}

function generate_mol(mol){

this.x = Math.random()*w;

this.y = Math.random()*h;

this.vx = Math.random()*-2;

this.vy = Math.random()*2;

this.vr = 0.1;

this.r = Math.random()*Math.PI;

this.draw = function(){

if(mol == “C6H6O”){

//Phenol

ctx.save();

ctx.translate(this.x+20,this.y+80);

ctx.rotate(this.r);

ctx.translate(-this.x+20,-this.y-80);

ctx.beginPath();

ctx.moveTo(this.x,this.y + 5);

ctx.lineTo(this.x,this.y + 30);

ctx.lineTo(this.x - 26,this.y + 45);

ctx.lineTo(this.x - 26,this.y + 75);

ctx.lineTo(this.x,this.y + 90);

ctx.lineTo(this.x + 26,this.y + 75);

ctx.lineTo(this.x + 26,this.y + 45);

ctx.lineTo(this.x,this.y + 30);

ctx.moveTo(this.x - 20,this.y + 47);

ctx.lineTo(this.x - 20,this.y + 73);

ctx.moveTo(this.x,this.y + 83);

ctx.lineTo(this.x + 22,this.y + 70);

ctx.moveTo(this.x,this.y + 36);

ctx.lineTo(this.x + 22,this.y + 49);

ctx.strokeStyle = “rgba(255,255,255,0.2)”;

ctx.lineWidth = 3;

ctx.stroke();

ctx.fillStyle = “rgba(255,255,255,0.2)”;

ctx.font = “15px Arial”;

ctx.fillText(“OH”, this.x - 5, this.y);

ctx.closePath();

ctx.restore();

}

else if(mol == “C8H10N4O2”){

//Caffeine

ctx.save();

ctx.translate(this.x+20,this.y+80);

ctx.rotate(this.r);

ctx.translate(-this.x+20,-this.y-80);

ctx.beginPath();

ctx.moveTo(this.x,this.y + 5);

ctx.lineTo(this.x,this.y + 22);

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数前端工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Web前端开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加V获取:vip1024c (备注前端)
img

最后

整理面试题,不是让大家去只刷面试题,而是熟悉目前实际面试中常见的考察方式和知识点,做到心中有数,也可以用来自查及完善知识体系。

CodeChina开源项目:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

《前端基础面试题》,《前端校招面试题精编解析大全》,《前端面试题宝典》,《前端面试题:常用算法》

前端面试题宝典

前端校招面试题详解

CodeChina开源项目:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

《前端基础面试题》,《前端校招面试题精编解析大全》,《前端面试题宝典》,《前端面试题:常用算法》

[外链图片转存中…(img-y7vZRl5t-1711804435535)]

[外链图片转存中…(img-HR4VSGmR-1711804435535)]

[外链图片转存中…(img-O8d2t75M-1711804435535)]

转载请注明出处或者链接地址:https://www.qianduange.cn//article/7810.html
标签
评论
发布的文章

JSON加密的看法

2024-05-14 23:05:47

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!