1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務時間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      【圣誕快樂】如何用代碼畫一顆圣誕樹?-創(chuàng)新互聯(lián)
      文章目錄
        • 一、前言
        • 二、創(chuàng)意角度
        • 三、java swing版 效果展示
        • 四、java swing版 實現(xiàn)步驟&代碼
        • 五、springboot項目banner版 效果展示
        • 六、springboot項目banner版 實現(xiàn)步驟
        • 七、 linux shell界面打印版 效果展示
        • 八、 linux shell界面打印版 實現(xiàn)步驟

      貴港ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書合作)期待與您的合作!一、前言

      一年一度的圣誕節(jié)來了 讓我們一起動動小手 給平凡而普通的生活 添加一筆色彩吧
      看看誰敢說程序員不懂浪漫? 程序員一天能new 1024個對象(GC 此時有話要說)

      二、創(chuàng)意角度

      從代碼,項目標簽,linux等多方面 畫一顆圣誕樹,讓圣誕變得花里胡哨!

      三、java swing版 效果展示

      (播放有音樂)
      在這里插入圖片描述

      四、java swing版 實現(xiàn)步驟&代碼

      (基于jdk11)

      1. main方法
      package view;
      
      public class Main {// 程序入口,運行此處
         public static void main(String[] args) {   try {   new MyFrame();
             } catch (Exception e) {   e.printStackTrace();
             }
         }
      }
      
      1. JFrame方法
      package view;
      
      import javax.swing.*;
      
      public class MyFrame extends JFrame {MyPanel p;
      
          MyFrame() throws Exception {p = new MyPanel();
              add(p);
              setBounds(400, 200, 800, 800);
              setVisible(true);
              validate();
              setDefaultCloseOperation(MyFrame.EXIT_ON_CLOSE);
          }
      }
      
      1. Jpanel方法(核心實現(xiàn))
      package view;
      
      import javax.sound.sampled.AudioInputStream;
      import javax.sound.sampled.AudioSystem;
      import javax.sound.sampled.Clip;
      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import java.io.File;
      import java.net.MalformedURLException;
      import java.net.URI;
      import java.net.URL;
      
      public class MyPanel extends JPanel implements ActionListener {// 圖片、音樂路徑 音樂推薦wav格式 
          static final String MUSIC = "src/resouce/music.wav";
          static final String STAR_SHINE = "src/resouce/STAR_SHINE.png";
          static final String STAR_NOT_SHINE = "src/resouce/STAR_NOT_SHINE.png";
          static final String ON = "src/resouce/ON.png";
          static final String OFF = "src/resouce/OFF.png";
      
          int x, y;
          JButton onOff;
          Timer time;
          boolean flag;
          boolean color;
          File file = new File(MUSIC);
          URL url = null;
          URI uri = null;
          //   since jdk9 : Clip (jdk9 before : AudioClip)
          Clip clip = null;
          AudioInputStream ais = null;
      
          MyPanel() throws Exception {setLayout(null);
              ImageIcon icon = new ImageIcon(OFF);
              icon.setImage(icon.getImage().getScaledInstance(50, 50, 0));
              onOff = new JButton();
              onOff.addActionListener(this);
              onOff.setIcon(icon);
              onOff.setBorder(null);
              onOff.setContentAreaFilled(false);
              onOff.setBounds(0, 0, 50, 50);
              add(onOff);
              flag = true;
              color = true;
              time = new Timer(300, this);
              time.stop();
              try {uri = file.toURI();
                  url = uri.toURL();
              } catch (MalformedURLException e1) {System.out.println(e1);
              }
              clip = AudioSystem.getClip();
              ais = AudioSystem.getAudioInputStream(file);
              clip.open(ais);
      
          }
      
          public void paintComponent(Graphics g) {x = 380;
              y = 100;
              if (color) {ImageIcon image1 = new ImageIcon(STAR_NOT_SHINE);
                  g.drawImage(image1.getImage(), x - 3, y - 25, 28, 26, null);
              } else {ImageIcon image1 = new ImageIcon(STAR_SHINE);
                  g.drawImage(image1.getImage(), x - 3, y - 25, 25, 25, null);
              }
              Color red = new Color(255, 0, 0);
              Color yellow = new Color(255, 241, 0);
              drawTree(1, 4, g);
              if (color) {drawDecoration(x + 22, y - 44, 6, yellow, g);
                  drawDecoration(x, y - 22, 8, red, g);
              } else {drawDecoration(x + 22, y - 44, 6, red, g);
                  drawDecoration(x, y - 22, 8, yellow, g);
              }
              x = 380 - 2 * 22;
              drawTree(3, 6, g);
              if (color) {drawDecoration(x + 22, y - 44, 10, yellow, g);
                  drawDecoration(x, y - 22, 12, red, g);
              } else {drawDecoration(x + 22, y - 44, 10, red, g);
                  drawDecoration(x, y - 22, 12, yellow, g);
              }
              x = 380 - 4 * 22;
              drawTree(5, 8, g);
              if (color) {drawDecoration(x + 22, y - 44, 14, yellow, g);
                  drawDecoration(x, y - 22, 16, red, g);
              } else {drawDecoration(x + 22, y - 44, 14, red, g);
                  drawDecoration(x, y - 22, 16, yellow, g);
              }
              x = 380 - 1 * 22;
              drwaRoot(g);
          }
      
          void drawTree(int from, int to, Graphics g) {Color c = new Color(9, 124, 37);
              g.setColor(c);
              for (int i = from; i<= to; i++) {for (int j = 0; j< (i * 2 - 1); j++) {g.fillRect(x, y, 20, 20);
                      x += 22;
                  }
                  x = 380 - i * 22;
                  y += 22;
              }
          }
      
          void drawDecoration(int tx, int ty, int num, Color c, Graphics g) {g.setColor(c);
              g.fillRoundRect(tx, ty, 18, 18, 18, 18);
              g.fillRoundRect(tx + num * 22, ty, 18, 18, 18, 18);
          }
      
          void drwaRoot(Graphics g) {Color c = new Color(131, 78, 0);
              g.setColor(c);
              for (int i = 0; i< 4; i++) {for (int j = 0; j< 3; j++) {g.fillRect(x, y, 20, 20);
                      x += 22;
                  }
                  x = 380 - 1 * 22;
                  y += 22;
              }
          }
      
          public void actionPerformed(ActionEvent e) {if (e.getSource() == onOff) {if (flag) {ImageIcon icon = new ImageIcon(ON);
                      icon.setImage(icon.getImage().getScaledInstance(50, 50, 0));
                      onOff.setIcon(icon);
                      try {clip.start();
                      } catch (Exception exc) {exc.printStackTrace();
                      }
                      flag = false;
                      clip.setLoopPoints(0, -1);
                      time.restart();
                  } else {ImageIcon icon = new ImageIcon(OFF);
                      icon.setImage(icon.getImage().getScaledInstance(50, 50, 0));
                      onOff.setIcon(icon);
                      flag = true;
                      time.stop();
                      clip.stop();
                  }
              } else if (e.getSource() == time) {repaint();
                  color = !color;
              }
          }
      }
      
      1. 目錄結(jié)構(gòu)、資源路徑:
        在這里插入圖片描述
        音樂推薦wav格式,且開關(guān)圖片、星星圖片、音樂可以自由替換 ,替換后注意文件名保持一致 或在代碼里面將相應文件名更改。

      2. 靜態(tài)資源、代碼地址:
        https://github.com/qiuhuanhen/christmasTree

      五、springboot項目banner版 效果展示

      想想你把這個效果提交到git dev分支之后,同事啟動項目時會不會覺得小驚喜呢
      在這里插入圖片描述

      六、springboot項目banner版 實現(xiàn)步驟
      1. 在resources目錄下新建banner.txt文件 文件名必須是這個,這是springboot的機制,根據(jù)名字讀取。(和我們的application.yml處于同級目錄)

      2. 將符號文字復制進去,啟動項目即可。同樣的 符號文字也是可以隨意替換的 我們可以在網(wǎng)上找更好看的符號 或者動手能力強的同學可以自己設(shè)計

      ∵∴∵︿︿︿︿︿︿..∴∵∴∵∴∵∴☆∵∴∵
      ∴∵/     \\∵∴聖∵∴∵/\∴∵∴
      ∵/       \\∵∴∵∴/ .\∵∴
      ╭~~~~~~~~~╮○誕∴-/ .  \∵
      ╰~~~~~~~~~╯∵∴/ .  ★ \
      /         \∴快○-- ̄/. \ ̄○
      |  ∩   ∩  ---|∵∴∵/★ . \∵
      | ?     ? ---|∴樂-/    . \
      \    ﹏    -/∴∵--○ ̄/ ̄ ̄\ ̄○
      ∵\       --/∴∵!∴∵|  |∵∴
      ∴∵ ̄ ̄ ̄ ̄ ̄ ̄ ̄∵∴∵--∴∵∴╰--╯∵∴
      〓〓〓◇◇◇〓〓〓○○○〓〓〓☆☆☆〓〓〓〓
      
      七、 linux shell界面打印版 效果展示

      在這里插入圖片描述

      八、 linux shell界面打印版 實現(xiàn)步驟
      1. 我們首先找到張圣誕樹圖片
        在這里插入圖片描述

      2. 圖片需要轉(zhuǎn)換成pnm格式 可以利用在線轉(zhuǎn)換網(wǎng)站或者工具進行轉(zhuǎn)換 , 轉(zhuǎn)換后的文件名字 重命名 例如叫 merry.pnm

      3. 將圖片上傳至linux,

      4. centos使用ascillview merry.pnm命令
        Ubuntu使用aview merry.pnm命令

      注: 使用命令前需要先安裝aa-lib,aview,ImageMagick等環(huán)境 ,
      具體教程可以在我博客主頁搜索 : 如何實現(xiàn)將圖片用代碼打印出來

      你是否還在尋找穩(wěn)定的海外服務器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機房具備T級流量清洗系統(tǒng)配攻擊溯源,準確流量調(diào)度確保服務器高可用性,企業(yè)級服務器適合批量采購,新人活動首月15元起,快前往官網(wǎng)查看詳情吧


      網(wǎng)站標題:【圣誕快樂】如何用代碼畫一顆圣誕樹?-創(chuàng)新互聯(lián)
      網(wǎng)站鏈接:http://www.ef60e0e.cn/article/csodhc.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        兴仁县| 南部县| 开化县| 肥城市| 涟水县| 南雄市| 呼伦贝尔市| 抚远县| 兴山县| 绥德县| 新郑市| 崇州市| 鹤山市| 大安市| 湘潭县| 富宁县| 泰来县| 左权县| 上蔡县| 万宁市| 沙洋县| 兴宁市| 兴业县| 会东县| 开阳县| 上思县| 衡阳县| 天津市| 宜宾市| 普陀区| 札达县| 桐柏县| 湘潭县| 宜兰县| 普安县| 凤山市| 志丹县| 旬阳县| 精河县| 综艺| 长垣县|