<del id="d4fwx"><form id="d4fwx"></form></del>
      <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

            <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
          • 使用electron怎么制作一個(gè)滿(mǎn)屏心特效-創(chuàng)新互聯(lián)

            這篇文章給大家介紹使用electron怎么制作一個(gè)滿(mǎn)屏心特效,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。

            員工經(jīng)過(guò)長(zhǎng)期磨合與沉淀,具備了協(xié)作精神,得以通過(guò)團(tuán)隊(duì)的力量開(kāi)發(fā)出優(yōu)質(zhì)的產(chǎn)品。成都創(chuàng)新互聯(lián)堅(jiān)持“專(zhuān)注、創(chuàng)新、易用”的產(chǎn)品理念,因?yàn)椤皩?zhuān)注所以專(zhuān)業(yè)、創(chuàng)新互聯(lián)網(wǎng)站所以易用所以簡(jiǎn)單”。公司專(zhuān)注于為企業(yè)提供網(wǎng)站制作、成都做網(wǎng)站、微信公眾號(hào)開(kāi)發(fā)、電商網(wǎng)站開(kāi)發(fā),重慶小程序開(kāi)發(fā)公司,軟件按需網(wǎng)站開(kāi)發(fā)等一站式互聯(lián)網(wǎng)企業(yè)服務(wù)。
            import {BrowserWindow, app, ipcMain} from 'electron'
            
            createWindow();
            
            ipcMain.on('quitApp', () => {
              app.quit();
            });
            
            function createWindow() {
            
              const loginURL = process.env.NODE_ENV === 'development' ? `http://localhost:9080` : `file://${__dirname}/index.html`;
              const win = new BrowserWindow({
            
                alwaysOnTop: true,
                modal: true,
                width: 1200,
                height: 6500,
                frame: false,
                show: false,
                darkTheme: true,
                resizable: false,
                minimizable: false,
                maximizable: false,
                transparent: true,
                type: 'toolbar',
                webPreferences: {
                  devTools: false,
                }
              });
              win.loadURL(loginURL);
              win.once('ready-to-show', () => {
                win.show();
              });
            }

            渲染進(jìn)程代碼

            界面代碼

            <template>
              <div >
                <canvas ref="drawHeart" id="drawHeart"></canvas>
              </div>
            </template>

            js代碼

             mounted() {
                  var hearts = [];
                  var canvas = this.$refs.drawHeart;
                  var wW = 1920;
                  var wH = 1040;
                  // 創(chuàng)建畫(huà)布
                  var ctx = canvas.getContext('2d');
                  // 創(chuàng)建圖片對(duì)象
                  var heartImage = new Image();
                  heartImage.src = img;
                  var num = 100;
            
                  init();
            
                  window.addEventListener('resize', function(){
                    wW = window.innerWidth;
                    wH = window.innerHeight;
                  });
                  // 初始化畫(huà)布大小
                  function init(){
                    canvas.width = wW;
                    canvas.height = wH;
                    for(var i = 0; i < num; i++){
                      hearts.push(new Heart(i%5));
                    }
                    requestAnimationFrame(render);
                  }
            
                  function getColor(){
                    var val = Math.random() * 10;
                    if(val > 0 && val <= 1){
                      return '#00f';
                    } else if(val > 1 && val <= 2){
                      return '#f00';
                    } else if(val > 2 && val <= 3){
                      return '#0f0';
                    } else if(val > 3 && val <= 4){
                      return '#368';
                    } else if(val > 4 && val <= 5){
                      return '#666';
                    } else if(val > 5 && val <= 6){
                      return '#333';
                    } else if(val > 6 && val <= 7){
                      return '#f50';
                    } else if(val > 7 && val <= 8){
                      return '#e96d5b';
                    } else if(val > 8 && val <= 9){
                      return '#5be9e9';
                    } else {
                      return '#d41d50';
                    }
                  }
            
                  function getText(){
                    var val = Math.random() * 10;
                    if(val > 1 && val <= 3){
                      return '愛(ài)你一輩子';
                    } else if(val > 3 && val <= 5){
                      return '感謝你';
                    } else if(val > 5 && val <= 8){
                      return '喜歡你';
                    } else{
                      return 'I Love You';
                    }
                  }
            
                  function Heart(type){
                    this.type = type;
                    // 初始化生成范圍
                    this.x = Math.random() * wW;
                    this.y = Math.random() * wH;
            
                    this.opacity = Math.random() * .5 + .5;
            
                    // 偏移量
                    this.vel = {
                      x: (Math.random() - .5) * 5,
                      y: (Math.random() - .5) * 5
                    }
            
                    this.initialW = wW * .5;
                    this.initialH = wH * .5;
                    // 縮放比例
                    this.targetScale = Math.random() * .15 + .02; // 最小0.02
                    this.scale = Math.random() * this.targetScale;
            
                    // 文字位置
                    this.fx = Math.random() * wW;
                    this.fy = Math.random() * wH;
                    this.fs = Math.random() * 10;
                    this.text = getText();
            
                    this.fvel = {
                      x: (Math.random() - .5) * 5,
                      y: (Math.random() - .5) * 5,
                      f: (Math.random() - .5) * 2
                    }
                  }
            
                  Heart.prototype.draw = function(){
                    ctx.save();
                    ctx.globalAlpha = this.opacity;
                    ctx.drawImage(heartImage, this.x, this.y, this.width, this.height);
                    ctx.scale(this.scale + 1, this.scale + 1);
                    if(!this.type){
                      // 設(shè)置文字屬性
                      ctx.fillStyle = getColor();
                      ctx.font = 'italic ' + this.fs + 'px sans-serif';
                      // 填充字符串
                      ctx.fillText(this.text, this.fx, this.fy);
                    }
                    ctx.restore();
                  }
                  Heart.prototype.update = function(){
                    this.x += this.vel.x;
                    this.y += this.vel.y;
            
                    if(this.x - this.width > wW || this.x + this.width < 0){
                      // 重新初始化位置
                      this.scale = 0;
                      this.x = Math.random() * wW;
                      this.y = Math.random() * wH;
                    }
                    if(this.y - this.height > wH || this.y + this.height < 0){
                      // 重新初始化位置
                      this.scale = 0;
                      this.x = Math.random() * wW;
                      this.y = Math.random() * wH;
                    }
            
                    // 放大
                    this.scale += (this.targetScale - this.scale) * .1;
                    this.height = this.scale * this.initialH;
                    this.width = this.height * 1.4;
            
                    // -----文字-----
                    this.fx += this.fvel.x;
                    this.fy += this.fvel.y;
                    this.fs += this.fvel.f;
            
                    if(this.fs > 50){
                      this.fs = 2;
                    }
            
                    if(this.fx - this.fs > wW || this.fx + this.fs < 0){
                      // 重新初始化位置
                      this.fx = Math.random() * wW;
                      this.fy = Math.random() * wH;
                    }
                    if(this.fy - this.fs > wH || this.fy + this.fs < 0){
                      // 重新初始化位置
                      this.fx = Math.random() * wW;
                      this.fy = Math.random() * wH;
                    }
                  }
            
                  function render(){
                    ctx.clearRect(0, 0, wW, wH);
                    for(var i = 0; i < hearts.length; i++){
                      hearts[i].draw();
                      hearts[i].update();
                    }
                    requestAnimationFrame(render);
                  }
            
                }

            擴(kuò)展功能

            全屏展示

            const size = screen.getPrimaryDisplay().workAreaSize;  //獲取顯示器的寬高
            win.setSet(size.width size.height);
            win.setPosition(0,0);

            這樣就會(huì)讓窗口全屏 但是有一個(gè)問(wèn)題 就是這樣做界面不會(huì)正確響應(yīng) 我們可以使用進(jìn)程通信去解決

            win.webContents.sen('windowSize',size);

            關(guān)于使用electron怎么制作一個(gè)滿(mǎn)屏心特效就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。

            網(wǎng)站名稱(chēng):使用electron怎么制作一個(gè)滿(mǎn)屏心特效-創(chuàng)新互聯(lián)
            網(wǎng)頁(yè)地址:http://www.jbt999.com/article20/djpdco.html

            成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊(cè)、Google、網(wǎng)頁(yè)設(shè)計(jì)公司、網(wǎng)站營(yíng)銷(xiāo)、品牌網(wǎng)站建設(shè)虛擬主機(jī)

            廣告

            聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

            外貿(mào)網(wǎng)站建設(shè)

              <del id="d4fwx"><form id="d4fwx"></form></del>
              <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

                    <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
                  • 性爱9999| 黄色性爱视频欧美 | 国产黄永久| 在线免费观看黄色片 | 午夜操逼视频 |