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 }