第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

本節(jié)源碼,拿走不謝。

(function(){
????????????function?Vector(x,y){
????????????????this.x?=?x?||?0;
????????????????this.y?=?y?||?0;
????????????}
????????????Vector.prototype?=?{
????????????????constructor:Vector,
????????????????square:function(){
????????????????????return?this.x?*?this.x?+?this.y?*?this.y;?
????????????????},
????????????????length:function(){
????????????????????return?Math.sqrt(this.square());?
????????????????},
????????????????add:function(q){
????????????????????return?new?Vector(this.x?+?q.x,this.y+q.y);?
????????????????},
????????????????minus:function(q){
????????????????????return?new?Vector(this.x?-?q.x,this.y-q.y);??
????????????????},
????????????????multipy:function(scale){
????????????????????return?new?Vector(this.x*scale,this.y*scale);??
????????????????},
????????????????normalize:function(length){
????????????????????if(length?===?undefined){
????????????????????????length?=?1;
????????????????????}
????????????????????return?this.multipy(length?/?this.length());
????????????????}
????????????};
????????????Vector.fromPoints?=?function(p1,p2){
????????????????return?new?Vector(p2.x?-?p1.x,?p2.y?-?p1.y);
????????????};
????????????window.Vector?=?Vector;
????????})();


正在回答

2 回答

https://img1.sycdn.imooc.com//5cc142b200016c9803100264.jpgsss

0 回復(fù) 有任何疑惑可以回復(fù)我~
<!DOCTYPE?html>
<html>
<head>
????<meta?charset="UTF-8">
????<title>svg動畫</title>
????<style>
????????html,body,svg{
????????????margin:0;
????????????padding:0;
????????????width:?100%;
????????????height:100%;
????????}
????</style>
</head>
<body>
????<svg?
????????width="10000"?
????????height="1000"
????????viewBox="-400?-400?800?800"
????>
????????<path?
????????????id="links"
????????????stroke="gray"
????????????fill="none"
????????></path>
????</svg>
????
????<script?src="vector.js"></script>
????<script>
????????var?points?=?'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z'.split(',').map(function(name,index,arr){
????????????return?{
????????????????name:name,
????????????????color:'hsl('+?(360*index/arr.length)?+?',100%,60%)'
????????????};
????????});
????????var?relation?=?300;
????????var?svg?=?document.querySelector('svg');
????????var?k?=?0.05;
????????var?Vector?=?window.Vector;
????????function?random(min,max){
????????????return?Math.round(min?+(max?-?min)?*Math.random());
????????};
????????points.forEach(function(point){
????????????var?circle?=?document.createElementNS('http://www.w3.org/2000/svg','circle');
????????????var?x?=?random(-400,400);
????????????var?y?=?random(-400,400);
????????????circle.setAttribute('cx',x);
????????????circle.setAttribute('cy',y);
????????????circle.setAttribute('r',10);
????????????circle.setAttribute('fill',point.color);
????????????svg.appendChild(circle);
????????????point.circle?=?circle;
????????????point.s?=?new?Vector(x,y);
????????????point.v?=?new?Vector();
????????????point.a?=?new?Vector();
????????});
????????var?lastFrameTime?=?+new?Date();
????????function?update(){
????????????var?frameTime?=?+new?Date();
????????????var?t?=?frameTime?-?lastFrameTime;
????????????t/=200;
????????????//點(diǎn)位置更新
????????????points.forEach(function(pa){
????????????????var?f?=?new?Vector();
????????????????//計(jì)算合力
????????????????points.forEach(function(pb){
????????????????????if(pa?==?pb)?return;
????????????????????var?x?=?Vector.fromPoints(pa.s,pb.s);
????????????????????var?delta?=?x.length()?-relation;
????????????????????//f?=?k?*?x
????????????????????f?=?f.add(x.normalize(delta?*?k));
????????????????});
????????????????pa.a?=?f;
????????????????pa.v?=?pa.v.add(pa.a.multipy(t)).multipy(0.98);
????????????????pa.s?=?pa.s.add(pa.v.multipy(t));
????????????????pa.circle.setAttribute('cx',pa.s.x);
????????????????pa.circle.setAttribute('cy',pa.s.y);
????????????});
????????????//連線更新
????????????var?linkPath?=?[];
????????????points.forEach(function(pa){
????????????????var?sa?=?pa.s;
????????????????points.forEach(function(pb){
????????????????????if(pa?==?pb)?return;
????????????????????var?sb?=?pb.s;
????????????????????linkPath?=?linkPath.concat([
????????????????????????'M',sa.x,sa.y,
????????????????????????'L',sb.x,sb.y
????????????????????]);
????????????????});
????????????});
????????????document.getElementById('links').setAttribute('d',linkPath.join('?'))
????????????lastFrameTime?=?frameTime;
????????????window.requestAnimationFrame(update);
????????};
????????window.requestAnimationFrame(update);
????</script>
</body>
</html>


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
走進(jìn)SVG
  • 參與學(xué)習(xí)       52682    人
  • 解答問題       222    個

SVG是HTML5 中矢量圖的標(biāo)記語言,學(xué)習(xí)后掌握更多的干貨

進(jìn)入課程

本節(jié)源碼,拿走不謝。

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號