热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

HTML53D衣服摇摆动画特效分享!

这又是一款基于HTML5Canvas的3D动画杰作,它是一个可以随风飘动的3D衣服摇摆动画特效,非常逼真。当我们将鼠标滑过衣服时,衣服将会出现摇摆的动画,点击鼠标时,衣服将会更加剧

这又是一款基于HTML5 Canvas的3D动画杰作,它是一个可以随风飘动的3D衣服摇摆动画特效,非常逼真。当我们将鼠标滑过衣服时,衣服将会出现摇摆的动画,点击鼠标时,衣服将会更加剧烈地摆动。

HTML5 3D衣服摇摆动画特效

在线演示  源码下载

HTML代码

XML/HTML Code复制内容到剪贴板

  1. <div style="width:500px;margin:10px auto">  
  2.  <canvas id="cv" width="480" height="300">canvas>  
  3.  <p>"3D on 2D Canvas" demop>  
  4.  <p>move cursor to pan / click to swingp>  
  5. div>  

P3D库JS代码,主要用来处理3D效果的

Javascript Code复制内容到剪贴板

  1. window.P3D = {   
  2.  texture: null,   
  3.  g: null  
  4. };   
  5.   
  6. P3D.clear = function(f, w, h) {   
  7.  var g = this.g;   
  8.  g.beginPath();   
  9.  g.fillStyle = f;   
  10.  g.fillRect(0, 0, w, h);   
  11.   
  12. }   
  13.   
  14. P3D.num_cmp = function(a,b){return a-b;}   
  15.   
  16. P3D.drawTriangle = function(poss, uvs, shade_clr) {   
  17.  var w = this.texture.width;   
  18.  var h = this.texture.height;   
  19.   
  20.  var g = this.g;   
  21.   
  22.  var vAd = [ poss[1].x – poss[0].x , poss[1].y – poss[0].y ];   
  23.  var vBd = [ poss[2].x – poss[0].x , poss[2].y – poss[0].y ];   
  24.   
  25.  var vA = [ uvs[1].u – uvs[0].u , uvs[1].v – uvs[0].v ];   
  26.  var vB = [ uvs[2].u – uvs[0].u , uvs[2].v – uvs[0].v ];   
  27.   
  28.  vA[0] *= w;   
  29.  vA[1] *= h;   
  30.   
  31.  vB[0] *= w;   
  32.  vB[1] *= h;   
  33.   
  34.  var m = new M22();   
  35.  m._11 = vA[0];   
  36.  m._12 = vA[1];   
  37.  m._21 = vB[0];   
  38.  m._22 = vB[1];   
  39.   
  40.  var im = m.getInvert();   
  41.  if (!im) return false;   
  42.   
  43.  var a = im._11 * vAd[0] + im._12 * vBd[0];   
  44.  var b = im._21 * vAd[0] + im._22 * vBd[0];   
  45.   
  46.  var c = im._11 * vAd[1] + im._12 * vBd[1];   
  47.  var d = im._21 * vAd[1] + im._22 * vBd[1];   
  48.   
  49.  var wu = uvs[0].u * w;   
  50.  var hv = uvs[0].v * h;   
  51.  var du = wu * a + hv * b;   
  52.  var dv = wu * c + hv * d;   
  53.   
  54.  g.save();   
  55.   
  56.  g.beginPath();   
  57.  g.moveTo(poss[0].x, poss[0].y);   
  58.  g.lineTo(poss[1].x, poss[1].y);   
  59.  g.lineTo(poss[2].x, poss[2].y);   
  60.  g.clip();   
  61.   
  62.  g.transform(a, c, b, d, poss[0].x – du, poss[0].y – dv);   
  63.   
  64.  // bounds   
  65.  var bx = [wu, wu+vA[0], wu+vB[0]];   
  66.  var by = [hv, hv+vA[1], hv+vB[1]];   
  67.   
  68.  bx.sort(P3D.num_cmp);   
  69.  by.sort(P3D.num_cmp);   
  70.   
  71.  var bw = bx[2] – bx[0];   
  72.  var bh = by[2] – by[0];   
  73.   
  74.  if ((bx[0]+bw) <= (w-1)) bw++;   
  75.  if ((by[0]+bh) <= (h-1)) bh++;   
  76.  if (bx[0] >= 1) {bx[0]–; bw++;}   
  77.  if (by[0] >= 1) {by[0]–; bh++;}   
  78.   
  79.  g.drawImage(this.texture, bx[0], by[0], bw, bh, bx[0], by[0], bw, bh);   
  80.   
  81.  if (shade_clr) {   
  82.   g.fillStyle = shade_clr;   
  83.   g.fillRect(bx[0], by[0], bw, bh);   
  84.  }   
  85.   
  86.  g.restore();   
  87.   
  88.  return true;   
  89. }   
  90.   
  91. P3D.drawTestByIndexBuffer = function(pos_buf, ix_buf, culling) {   
  92.  var g = this.g;   
  93.   
  94.  if ((ix_buf.length%3) != 0)   
  95.   throw "invalid index buffer length!";   
  96.   
  97.  var len = ix_buf.length/3;   
  98.   
  99.  var i, ibase, vbase;   
  100.  var poss = [{},{},{}];   
  101.  g.strokeWidth = 1;   
  102.  for (i = 0, ibase = 0;i < len;++i)   
  103.  {   
  104.   vbase = ix_buf[ibase++] << 2;   
  105.   poss[0].x = pos_buf[vbase++];   
  106.   poss[0].y = pos_buf[vbase  ];   
  107.   
  108.   vbase = ix_buf[ibase++] << 2;   
  109.   poss[1].x = pos_buf[vbase++];   
  110.   poss[1].y = pos_buf[vbase  ];   
  111.   
  112.   vbase = ix_buf[ibase++] << 2;   
  113.   poss[2].x = pos_buf[vbase++];   
  114.   poss[2].y = pos_buf[vbase  ];   
  115.   
  116.   // z component of cross product < 0 ?   
  117.   
  118.   var Ax = poss[1].x – poss[0].x;   
  119.   var Ay = poss[1].y – poss[0].y;   
  120.   var Cx = poss[2].x – poss[1].x;   
  121.   var Cy = poss[2].y – poss[1].y;   
  122.   
  123.   var cull = ( (((Ax * Cy) – (Ay * Cx))*culling) < 0);   
  124.   
  125.   g.beginPath();   
  126.   g.strokeStyle = cull ? "#592" : "#0f0";   
  127.   g.moveTo(poss[0].x, poss[0].y);   
  128.   g.lineTo(poss[1].x, poss[1].y);   
  129.   g.lineTo(poss[2].x, poss[2].y);   
  130.   g.lineTo(poss[0].x, poss[0].y);   
  131.   g.stroke();   
  132.  }   
  133. }   
  134.   
  135. P3D.drawByIndexBuffer = function(pos_buf, ix_buf, tx_buf, culling, z_clip) {   
  136.  var w, h;   
  137.  var color_polygon = !this.texture;   
  138.  if (this.texture) {   
  139.   w = this.texture.width;   
  140.   h = this.texture.height;   
  141.  }   
  142.   
  143.  var g = this.g;   
  144.  var m = new M22();   
  145.   
  146.  if (!culling) culling = 0;   
  147.   
  148.  if ((ix_buf.length%3) != 0)   
  149.   throw "invalid index buffer length!";   
  150.   
  151.  var i, ibase, vbase, tbase, poss = [{},{},{}];   
  152.  var len = ix_buf.length/3;   
  153.  var uv_0u, uv_0v, uv_1u, uv_1v, uv_2u, uv_2v;   
  154.   
  155.  for (i = 0, ibase = 0;i < len;++i)   
  156.  {   
  157.   tbase = ix_buf[ibase++] << 1   
  158.   vbase = tbase << 1;   
  159.   poss[0].x = pos_buf[vbase++]; uv_0u = tx_buf[tbase++];   
  160.   poss[0].y = pos_buf[vbase++]; uv_0v = tx_buf[tbase];   
  161.   if (z_clip && (pos_buf[vbase] < 0 || pos_buf[vbase] > 1)) {ibase += 2; continue;}   
  162.   
  163.   tbase = ix_buf[ibase++] << 1   
  164.   vbase = tbase << 1;   
  165.   poss[1].x = pos_buf[vbase++]; uv_1u = tx_buf[tbase++];   
  166.   poss[1].y = pos_buf[vbase++]; uv_1v = tx_buf[tbase];   
  167.   if (z_clip && (pos_buf[vbase] < 0 || pos_buf[vbase] > 1)) {++ibase; continue;}   
  168.   
  169.   tbase = ix_buf[ibase++] << 1   
  170.   vbase = tbase << 1;   
  171.   poss[2].x = pos_buf[vbase++]; uv_2u = tx_buf[tbase++];   
  172.   poss[2].y = pos_buf[vbase++]; uv_2v = tx_buf[tbase];   
  173.   if (z_clip && (pos_buf[vbase] < 0 || pos_buf[vbase] > 1)) {continue;}   
  174.   
  175.   var vAd = [ poss[1].x – poss[0].x , poss[1].y – poss[0].y ];   
  176.   var vBd = [ poss[2].x – poss[0].x , poss[2].y – poss[0].y ];   
  177.   
  178.   var vCd = [ poss[2].x – poss[1].x , poss[2].y – poss[1].y ];   
  179.   
  180.   // z component of cross product < 0 ?   
  181.   if( (((vAd[0] * vCd[1]) – (vAd[1] * vCd[0]))*culling) < 0)   
  182.    continue;   
  183.   
  184.   if (color_polygon) {   
  185.    g.fillStyle = uv_0u;   
  186.   
  187.    g.beginPath();   
  188.    g.moveTo(poss[0].x, poss[0].y);   
  189.    g.lineTo(poss[1].x, poss[1].y);   
  190.    g.lineTo(poss[2].x, poss[2].y);   
  191.    g.fill();   
  192.    continue;   
  193.   }   
  194.   
  195.   var vA = [ uv_1u – uv_0u , uv_1v – uv_0v ];   
  196.   var vB = [ uv_2u – uv_0u , uv_2v – uv_0v ];   
  197.   
  198.   vA[0] *= w;   
  199.   vA[1] *= h;   
  200.   
  201.   vB[0] *= w;   
  202.   vB[1] *= h;   
  203.   
  204.   m._11 = vA[0];   
  205.   m._12 = vA[1];   
  206.   m._21 = vB[0];   
  207.   m._22 = vB[1];   
  208.   
  209.   var im = m.getInvert();   
  210.   if (!im) { continue;}   
  211.   
  212.   var a = im._11 * vAd[0] + im._12 * vBd[0];   
  213.   var b = im._21 * vAd[0] + im._22 * vBd[0];   
  214.   
  215.   var c = im._11 * vAd[1] + im._12 * vBd[1];   
  216.   var d = im._21 * vAd[1] + im._22 * vBd[1];   
  217.   
  218.   var wu = uv_0u * w;   
  219.   var hv = uv_0v * h;   
  220.   var du = wu * a + hv * b;   
  221.   var dv = wu * c + hv * d;   
  222.   
  223.   g.save();   
  224.   
  225.   g.beginPath();   
  226.   g.moveTo(poss[0].x, poss[0].y);   
  227.   g.lineTo(poss[1].x, poss[1].y);   
  228.   g.lineTo(poss[2].x, poss[2].y);   
  229.   g.clip();   
  230.   g.transform(a, c, b, d, poss[0].x – du, poss[0].y – dv);   
  231.   
  232.   // bounds   
  233.   var bx = [wu, wu+vA[0], wu+vB[0]];   
  234.   var by = [hv, hv+vA[1], hv+vB[1]];   
  235.   
  236.   bx.sort(P3D.num_cmp);   
  237.   by.sort(P3D.num_cmp);   
  238.   
  239.   var bw = bx[2] – bx[0];   
  240.   var bh = by[2] – by[0];   
  241.   
  242.   if ((bx[0]+bw) <= (w-1)) bw++;   
  243.   if ((by[0]+bh) <= (h-1)) bh++;   
  244.   if (bx[0] >= 1) {bx[0]–; bw++;}   
  245.   if (by[0] >= 1) {by[0]–; bh++;}   
  246.   
  247.   g.drawImage(this.texture, bx[0], by[0], bw, bh, bx[0], by[0], bw, bh);   
  248. /*  
  249.   if (shade_clr) {  
  250.    g.fillStyle = shade_clr;  
  251.    g.fillRect(bx[0], by[0], bw, bh);  
  252.   }  
  253. */  
  254.   g.restore();   
  255.   
  256.  }   
  257.   
  258. }   
  259.   
  260. function Vec3(_x, _y, _z)   
  261. {   
  262.  this.x = _x || 0;   
  263.  this.y = _y || 0;   
  264.  this.z = _z || 0;   
  265. }   
  266.   
  267. Vec3.prototype = {   
  268.  zero: function() {   
  269.   this.x = this.y = this.z = 0;   
  270.  },   
  271.   
  272.  sub: function(v) {   
  273.   this.x -= v.x;   
  274.   this.y -= v.y;   
  275.   this.z -= v.z;   
  276.   
  277.   return this;   
  278.  },   
  279.   
  280.  add: function(v) {   
  281.   this.x += v.x;   
  282.   this.y += v.y;   
  283.   this.z += v.z;   
  284.   
  285.   return this;   
  286.  },   
  287.   
  288.  copyFrom: function(v) {   
  289.   this.x = v.x;   
  290.   this.y = v.y;   
  291.   this.z = v.z;   
  292.   
  293.   return this;   
  294.  },   
  295.   
  296.  norm:function() {   
  297.   return Math.sqrt(this.x*this.x + this.y*this.y + this.z*this.z);   
  298.  },   
  299.   
  300.  normalize: function() {   
  301.   var nrm = Math.sqrt(this.x*this.x + this.y*this.y + this.z*this.z);   
  302.   if (nrm != 0)   
  303.   {   
  304.    this.x /= nrm;   
  305.    this.y /= nrm;   
  306.    this.z /= nrm;   
  307.   }   
  308.   return this;   
  309.  },   
  310.   
  311.  smul: function(k) {   
  312.   this.x *= k;   
  313.   this.y *= k;   
  314.   this.z *= k;   
  315.   
  316.   return this;   
  317.  },   
  318.   
  319.  dpWith: function(v) {   
  320.   return this.x*v.x + this.y*v.y + this.z*v.z;   
  321.  },   
  322.   
  323.  cp: function(v, w) {   
  324.   this.x = (w.y * v.z) – (w.z * v.y);   
  325.   this.y = (w.z * v.x) – (w.x * v.z);   
  326.   this.z = (w.x * v.y) – (w.y * v.x);   
  327.   
  328.   return this;   
  329.  },   
  330.   
  331.  toString: function() {   
  332.   return this.x + ", " + this.y + "," + this.z;   
  333.  }   
  334. }   
  335.   
  336. function M44(cpy)   
  337. {   
  338.  if (cpy)   
  339.   this.copyFrom(cpy);   
  340.  else {   
  341.   this.ident();   
  342.  }   
  343. }   
  344.   
  345. M44.prototype = {   
  346.  ident: function() {   
  347.      this._12 = this._13 = this._14 = 0;   
  348.   this._21 =       this._23 = this._24 = 0;   
  349.   this._31 = this._32 =       this._34 = 0;   
  350.   this._41 = this._42 = this._43 =       0;   
  351.   
  352.   this._11 = this._22 = this._33 = this._44 = 1;   
  353.   
  354.   return this;   
  355.  },   
  356.   
  357.  copyFrom: function(m) {   
  358.   this._11 = m._11;   
  359.   this._12 = m._12;   
  360.   this._13 = m._13;   
  361.   this._14 = m._14;   
  362.   
  363.   this._21 = m._21;   
  364.   this._22 = m._22;   
  365.   this._23 = m._23;   
  366.   this._24 = m._24;   
  367.   
  368.   this._31 = m._31;   
  369.   this._32 = m._32;   
  370.   this._33 = m._33;   
  371.   this._34 = m._34;   
  372.   
  373.   this._41 = m._41;   
  374.   this._42 = m._42;   
  375.   this._43 = m._43;   
  376.   this._44 = m._44;   
  377.   
  378.   return this;   
  379.  },   
  380.   
  381.  transVec3: function(out, x, y, z) {   
  382.   out[0] = x * this._11 + y * this._21 + z * this._31 + this._41;   
  383.   out[1] = x * this._12 + y * this._22 + z * this._32 + this._42;   
  384.   out[2] = x * this._13 + y * this._23 + z * this._33 + this._43;   
  385.   out[3] = x * this._14 + y * this._24 + z * this._34 + this._44;   
  386.  },   
  387.   
  388.  transVec3Rot: function(out, x, y, z) {   
  389.   out[0] = x * this._11 + y * this._21 + z * this._31;   
  390.   out[1] = x * this._12 + y * this._22 + z * this._32;   
  391.   out[2] = x * this._13 + y * this._23 + z * this._33;   
  392.  },   
  393.   
  394.  perspectiveLH: function(vw, vh, z_near, z_far) {   
  395.   this._11 = 2.0*z_near/vw;   
  396.   this._12 = 0;   
  397.   this._13 = 0;   
  398.   this._14 = 0;   
  399.   
  400.   this._21 = 0;   
  401.   this._22 = 2*z_near/vh;   
  402.   this._23 = 0;   
  403.   this._24 = 0;   
  404.   
  405.   this._31 = 0;   
  406.   this._32 = 0;   
  407.   this._33 = z_far/(z_far-z_near);   
  408.   this._34 = 1;   
  409.   
  410.   this._41 = 0;   
  411.   this._42 = 0;   
  412.   this._43 = z_near*z_far/(z_near-z_far);   
  413.   this._44 = 0;   
  414.   
  415.   return this;   
  416.  },   
  417.   
  418.  lookAtLH: function(aUp, aFrom, aAt) {   
  419.   var aX = new Vec3();   
  420.   var aY = new Vec3();   
  421.   
  422.   var aZ = new Vec3(aAt.x, aAt.y, aAt.z);   
  423.   aZ.sub(aFrom).normalize();   
  424.   
  425.   aX.cp(aUp, aZ).normalize();   
  426.   aY.cp(aZ, aX);   
  427.   
  428.   this._11 = aX.x;  this._12 = aY.x;  this._13 = aZ.x;  this._14 = 0;   
  429.   this._21 = aX.y;  this._22 = aY.y;  this._23 = aZ.y;  this._24 = 0;   
  430.   this._31 = aX.z;  this._32 = aY.z;  this._33 = aZ.z;  this._34 = 0;   
  431.   
  432.   this._41 = -aFrom.dpWith(aX);   
  433.   this._42 = -aFrom.dpWith(aY);   
  434.   this._43 = -aFrom.dpWith(aZ);   
  435.   this._44 = 1;   
  436.   
  437.      return this;   
  438.  },   
  439.   
  440.  mul: function(A, B) {   
  441.   this._11 = A._11*B._11  +  A._12*B._21  +  A._13*B._31  +  A._14*B._41;   
  442.   this._12 = A._11*B._12  +  A._12*B._22  +  A._13*B._32  +  A._14*B._42;   
  443.   this._13 = A._11*B._13  +  A._12*B._23  +  A._13*B._33  +  A._14*B._43;   
  444.   this._14 = A._11*B._14  +  A._12*B._24  +  A._13*B._34  +  A._14*B._44;   
  445.   
  446.   this._21 = A._21*B._11  +  A._22*B._21  +  A._23*B._31  +  A._24*B._41;   
  447.   this._22 = A._21*B._12  +  A._22*B._22  +  A._23*B._32  +  A._24*B._42;   
  448.   this._23 = A._21*B._13  +  A._22*B._23  +  A._23*B._33  +  A._24*B._43;   
  449.   this._24 = A._21*B._14  +  A._22*B._24  +  A._23*B._34  +  A._24*B._44;   
  450.   
  451.   this._31 = A._31*B._11  +  A._32*B._21  +  A._33*B._31  +  A._34*B._41;   
  452.   this._32 = A._31*B._12  +  A._32*B._22  +  A._33*B._32  +  A._34*B._42;   
  453.   this._33 = A._31*B._13  +  A._32*B._23  +  A._33*B._33  +  A._34*B._43;   
  454.   this._34 = A._31*B._14  +  A._32*B._24  +  A._33*B._34  +  A._34*B._44;   
  455.   
  456.   this._41 = A._41*B._11  +  A._42*B._21  +  A._43*B._31  +  A._44*B._41;   
  457.   this._42 = A._41*B._12  +  A._42*B._22  +  A._43*B._32  +  A._44*B._42;   
  458.   this._43 = A._41*B._13  +  A._42*B._23  +  A._43*B._33  +  A._44*B._43;   
  459.   this._44 = A._41*B._14  +  A._42*B._24  +  A._43*B._34  +  A._44*B._44;   
  460.   
  461.   return this;   
  462.  },   
  463.   
  464.  translate: function(x, y, z) {   
  465.   this._11 = 1;  this._12 = 0;  this._13 = 0;  this._14 = 0;   
  466.   this._21 = 0;  this._22 = 1;  this._23 = 0;  this._24 = 0;   
  467.   this._31 = 0;  this._32 = 0;  this._33 = 1;  this._34 = 0;   
  468.   
  469.   this._41 = x;  this._42 = y;  this._43 = z;  this._44 = 1;   
  470.   return this;   
  471.  },   
  472.   
  473.  transpose33: function() {   
  474.   var t;   
  475.   
  476.   t = this._12;   
  477.   this._12 = this._21;   
  478.   this._21 = t;   
  479.   
  480.   t = this._13;   
  481.   this._13 = this._31;   
  482.   this._31 = t;   
  483.   
  484.   t = this._23;   
  485.   this._23 = this._32;   
  486.   this._32 = t;   
  487.   
  488.   return this;   
  489.  },   
  490.   
  491.  // OpenGL style rotation   
  492.  glRotate: function(angle, x, y, z) {   
  493.   var s = Math.sin( angle );   
  494.   var c = Math.cos( angle );   
  495.   
  496.   var xx = x * x;   
  497.   var yy = y * y;   
  498.   var zz = z * z;   
  499.   var xy = x * y;   
  500.   var yz = y * z;   
  501.   var zx = z * x;   
  502.   var xs = x * s;   
  503.   var ys = y * s;   
  504.   var zs = z * s;   
  505.   var one_c = 1.0 – c;   
  506. /*  
  507.   this._11 = (one_c * xx) + c;  
  508.   this._21 = (one_c * xy) – zs;  
  509.   this._31 = (one_c * zx) + ys;  
  510.   this._41 = 0;  
  511.  
  512.   this._12 = (one_c * xy) + zs;  
  513.   this._22 = (one_c * yy) + c;  
  514.   this._32 = (one_c * yz) – xs;  
  515.   this._42 = 0;  
  516.  
  517.   this._13 = (one_c * zx) – ys;  
  518.   this._23 = (one_c * yz) + xs;  
  519.   this._33 = (one_c * zz) + c;  
  520.   this._43 = 0;  
  521.  
  522.   this._14 = 0;  
  523.   this._24 = 0;  
  524.   this._34 = 0;  
  525.   this._44 = 1;  
  526. */  
  527.   
  528.   this._11 = (one_c * xx) + c;   
  529.   this._12 = (one_c * xy) – zs;   
  530.   this._13 = (one_c * zx) + ys;   
  531.   this._14 = 0;   
  532.   
  533.   this._21 = (one_c * xy) + zs;   
  534.   this._22 = (one_c * yy) + c;   
  535.   this._23 = (one_c * yz) – xs;   
  536.   this._24 = 0;   
  537.   
  538.   this._31 = (one_c * zx) – ys;   
  539.   this._32 = (one_c * yz) + xs;   
  540.   this._33 = (one_c * zz) + c;   
  541.   this._34 = 0;   
  542.   
  543.   this._41 = 0;   
  544.   this._42 = 0;   
  545.   this._43 = 0;   
  546.   this._44 = 1;   
  547.   
  548.   return this;   
  549.  }   
  550.   
  551. }   
  552.   
  553. // matrix 2×2   
  554. function M22()   
  555. {   
  556.  this._11 = 1;   
  557.  this._12 = 0;   
  558.  this._21 = 0;   
  559.  this._22 = 1;   
  560. }   
  561.   
  562. M22.prototype.getInvert = function()   
  563. {   
  564.  var out = new M22();   
  565.  var det = this._11 * this._22 – this._12 * this._21;   
  566.  if (det > -0.0001 && det < 0.0001)   
  567.   return null;   
  568.   
  569.  out._11 = this._22 / det;   
  570.  out._22 = this._11 / det;   
  571.   
  572.  out._12 = –this._12 / det;   
  573.  out._21 = –this._21 / det;   
  574.   
  575.  return out;   
  576. }   
  • 1
  • 2

推荐阅读
  • JavaScript和HTML之间的交互是经由过程事宜完成的。事宜:文档或浏览器窗口中发作的一些特定的交互霎时。能够运用侦听器(或处置惩罚递次来预订事宜),以便事宜发作时实行相应的 ... [详细]
  • 用Vue实现的Demo商品管理效果图及实现代码
    本文介绍了一个使用Vue实现的Demo商品管理的效果图及实现代码。 ... [详细]
  • 本文总结了在编写JS代码时,不同浏览器间的兼容性差异,并提供了相应的解决方法。其中包括阻止默认事件的代码示例和猎取兄弟节点的函数。这些方法可以帮助开发者在不同浏览器上实现一致的功能。 ... [详细]
  • PHP中的单例模式与静态变量的区别及使用方法
    本文介绍了PHP中的单例模式与静态变量的区别及使用方法。在PHP中,静态变量的存活周期仅仅是每次PHP的会话周期,与Java、C++不同。静态变量在PHP中的作用域仅限于当前文件内,在函数或类中可以传递变量。本文还通过示例代码解释了静态变量在函数和类中的使用方法,并说明了静态变量的生命周期与结构体的生命周期相关联。同时,本文还介绍了静态变量在类中的使用方法,并通过示例代码展示了如何在类中使用静态变量。 ... [详细]
  • 如何在HTML中获取鼠标的当前位置
    本文介绍了在HTML中获取鼠标当前位置的三种方法,分别是相对于屏幕的位置、相对于窗口的位置以及考虑了页面滚动因素的位置。通过这些方法可以准确获取鼠标的坐标信息。 ... [详细]
  • 本文介绍了pack布局管理器在Perl/Tk中的使用方法及注意事项。通过调用pack()方法,可以控制部件在显示窗口中的位置和大小。同时,本文还提到了在使用pack布局管理器时,应注意将部件分组以便在水平和垂直方向上进行堆放。此外,还介绍了使用Frame部件或Toplevel部件来组织部件在窗口内的方法。最后,本文强调了在使用pack布局管理器时,应避免在中间切换到grid布局管理器,以免造成混乱。 ... [详细]
  • OpenMap教程4 – 图层概述
    本文介绍了OpenMap教程4中关于地图图层的内容,包括将ShapeLayer添加到MapBean中的方法,OpenMap支持的图层类型以及使用BufferedLayer创建图像的MapBean。此外,还介绍了Layer背景标志的作用和OMGraphicHandlerLayer的基础层类。 ... [详细]
  • 使用freemaker生成Java代码的步骤及示例代码
    本文介绍了使用freemaker这个jar包生成Java代码的步骤,通过提前编辑好的模板,可以避免写重复代码。首先需要在springboot的pom.xml文件中加入freemaker的依赖包。然后编写模板,定义要生成的Java类的属性和方法。最后编写生成代码的类,通过加载模板文件和数据模型,生成Java代码文件。本文提供了示例代码,并展示了文件目录结构。 ... [详细]
  • Java序列化对象传给PHP的方法及原理解析
    本文介绍了Java序列化对象传给PHP的方法及原理,包括Java对象传递的方式、序列化的方式、PHP中的序列化用法介绍、Java是否能反序列化PHP的数据、Java序列化的原理以及解决Java序列化中的问题。同时还解释了序列化的概念和作用,以及代码执行序列化所需要的权限。最后指出,序列化会将对象实例的所有字段都进行序列化,使得数据能够被表示为实例的序列化数据,但只有能够解释该格式的代码才能够确定数据的内容。 ... [详细]
  • 目录实现效果:实现环境实现方法一:基本思路主要代码JavaScript代码总结方法二主要代码总结方法三基本思路主要代码JavaScriptHTML总结实 ... [详细]
  • Voicewo在线语音识别转换jQuery插件的特点和示例
    本文介绍了一款名为Voicewo的在线语音识别转换jQuery插件,该插件具有快速、架构、风格、扩展和兼容等特点,适合在互联网应用中使用。同时还提供了一个快速示例供开发人员参考。 ... [详细]
  • 利用Visual Basic开发SAP接口程序初探的方法与原理
    本文介绍了利用Visual Basic开发SAP接口程序的方法与原理,以及SAP R/3系统的特点和二次开发平台ABAP的使用。通过程序接口自动读取SAP R/3的数据表或视图,在外部进行处理和利用水晶报表等工具生成符合中国人习惯的报表样式。具体介绍了RFC调用的原理和模型,并强调本文主要不讨论SAP R/3函数的开发,而是针对使用SAP的公司的非ABAP开发人员提供了初步的接口程序开发指导。 ... [详细]
  • 闭包一直是Java社区中争论不断的话题,很多语言都支持闭包这个语言特性,闭包定义了一个依赖于外部环境的自由变量的函数,这个函数能够访问外部环境的变量。本文以JavaScript的一个闭包为例,介绍了闭包的定义和特性。 ... [详细]
  • Html5-Canvas实现简易的抽奖转盘效果
    本文介绍了如何使用Html5和Canvas标签来实现简易的抽奖转盘效果,同时使用了jQueryRotate.js旋转插件。文章中给出了主要的html和css代码,并展示了实现的基本效果。 ... [详细]
  • 本文介绍了一个从入门到高手的VB.NET源代码,通过学习这些源代码,可以在21天内成为VB.NET高手。文章提供了下载地址,并提醒读者加入作者的QQ群和收藏作者的博客。 ... [详细]
author-avatar
小小蜘蛛侠
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有