2013-08-13 23:32:30
乘情人節還沒有過去,作為一個屌絲程序員,從來沒有過過情人節。不過我們也有自己的樂趣,這個時候貌似只有海子的《面朝大海》能夠啊Q式慰藉自己。
不多說了,早上上班的時候看到google首頁,就感覺很有愛,不過當時沒怎么玩,只是點點了,聽聽背景音樂,感覺甚好。話說作為程序員,看看國內某著名搜索引擎的情況就顯得捉襟見肘了。咱沒鄙視它的權利,沒准它還會鄙視我等屌絲程序員,有zf支持,能賺錢才是硬道理啊!作為屌絲程序員還是先玩玩谷歌的小游戲,不為搜索,只想玩玩,呵呵,誰叫咱單身屌絲。上傳幾張圖片,祝福哪些牛郎、織女們!!!

first

second

third.
作為成員員,怎么也不能只玩玩這個吧,搞個小程序也許更有愛!呵呵。
1 /** 2 * filename:Star.java 3 * 4 * CopyRight: 5 * Date:2013-8-13 6 * Copyright JanneLee Corporation 2013 7 * Copyright 8 * version 1.0 9 */ 10 import java.awt.Color; 11 import java.awt.Graphics; 12 import java.awt.Image; 13 import java.awt.Toolkit; 14 import javax.swing.JFrame; 15 16 public class StarTwo extends JFrame implements Runnable { 17 private static final long serialVersionUID = 1L; 18 public static final int GAME_WIDTH = 500; 19 public static final int GAME_HEIGHT = 500; 20 public static final int WIDTH = Toolkit.getDefaultToolkit() 21 .getScreenSize().width; 22 public static final int HEIGHT = Toolkit.getDefaultToolkit() 23 .getScreenSize().height; 24 25 public StarTwo() { 26 this.setTitle("情人節快樂"); 27 this.setLocation((WIDTH - GAME_WIDTH) / 2, (HEIGHT - GAME_HEIGHT) / 2); 28 this.setSize(GAME_WIDTH, GAME_HEIGHT); 29 this.setBackground(Color.BLACK); 30 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 31 this.setVisible(true); 32 } 33 34 @Override 35 public void paint(Graphics g) { 36 37 double x, y, r; 38 Image OffScreen = createImage(GAME_WIDTH, GAME_HEIGHT); 39 Graphics drawOffScreen = OffScreen.getGraphics(); 40 41 for (int i = 0; i < 90; i++) { 42 for (int j = 0; j < 90; j++) { 43 r = Math.PI / 45 * i * (1 - Math.sin(Math.PI / 45 * j)) * 18; 44 x = r * Math.cos(Math.PI / 45 * j) * Math.sin(Math.PI / 45 * i) 45 + GAME_WIDTH / 2; 46 y = -r * Math.sin(Math.PI / 45 * j) + GAME_HEIGHT / 4; 47 48 drawOffScreen.setColor(Color.RED); 49 drawOffScreen.fillOval((int) x, (int) y, 2, 2); 50 } 51 g.drawImage(OffScreen, 0, 0, this); 52 } 53 } 54 55 public static void main(String[] args) { 56 StarTwo demo = new StarTwo(); 57 Thread t = new Thread(demo); 58 t.start(); 59 } 60 61 @Override 62 public void run() { 63 while (true) { 64 try { 65 Thread.sleep(4000); 66 this.repaint(); 67 } catch (InterruptedException e) { 68 e.printStackTrace(); 69 } 70 } 71 } 72 }
作為玩,還體驗了一下javafx.perfect啊。
1 2 /** 3 * filename:Star.java 4 * 5 * CopyRight: 6 * Date:2013-8-13 7 * Copyright JanneLee Corporation 2013 8 * Copyright 9 * version 1.0 10 */ 11 12 import javafx.application.Application; 13 import javafx.scene.Scene; 14 import javafx.scene.canvas.Canvas; 15 import javafx.scene.canvas.GraphicsContext; 16 import javafx.scene.layout.StackPane; 17 import javafx.scene.paint.Color; 18 import javafx.stage.Stage; 19 20 public class Star extends Application { 21 22 @Override 23 public void start(Stage primaryStage) { 24 int width, height; 25 Canvas canvas = new Canvas(350, 350); 26 width = (int) canvas.getWidth(); 27 height = (int) canvas.getHeight(); 28 29 GraphicsContext gc = canvas.getGraphicsContext2D(); 30 double x, y, r; 31 for (int i = 0; i <= 90; i++ ) { 32 for (int j = 0; j <= 90; j++ ) { 33 //轉換為直角坐標系,設置偏移量,使圖畫居中 34 r = Math.PI / 45 * i * (1 - Math.sin(Math.PI / 45 * j)) * 19; 35 x = r * Math.cos(Math.PI / 45 * j) * Math.sin(Math.PI / 45 * i)+width / 2; 36 y = -r * Math.sin(Math.PI / 45 * j)+height / 4; 37 38 gc.setFill(Color.RED); 39 gc.fillOval(x, y, 2, 2); 40 gc.fillOval(x, y, 1, 1); 41 } 42 } 43 44 StackPane root = new StackPane(); 45 root.getChildren().add(canvas); 46 Scene scene = new Scene(root, Color.BLACK); 47 System.out.println("r=a(1-sinθ)"); 48 primaryStage.setTitle("情人節快樂!"); 49 primaryStage.setScene(scene); 50 primaryStage.show(); 51 } 52 53 public static void main(String[] args) { 54 launch(args); 55 } 56 }
