小小程序

纯粹无聊  ⁄(⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄ (〃'▽'〃)

package com;

import javax.swing.*;
import java.awt.*;

public class ForFunny extends JFrame {

    private static final int width = 500;
    private static final int height = 500;

    private static int window_width = Toolkit.getDefaultToolkit().getScreenSize().width;
    private static int window_height = Toolkit.getDefaultToolkit().getScreenSize().height;

    public ForFunny(){
        super("I love you");
        this.setBackground(Color.BLACK);
        this.setLocation((window_width -width)/2,(window_height-height)/2);
        this.setSize(width, height);
        this.setLayout(getLayout());
        this.setVisible(true);
        this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    }

    public void paint(Graphics g){
        double x, y, r;
        Image image = this.createImage(width, height);
        Graphics pic = image.getGraphics();
        for(int i=-2; i<90; i++){
            for (int j=-2; j<90; j++){
                r = Math.PI/45 + Math.PI/45*i*(1-Math.sin(Math.PI/45*j))*18;
                x = r*Math.cos(Math.PI/45*j)*Math.sin(Math.PI/45*i)+width/2;
                y = -r*Math.sin(Math.PI/45*j)+height/3;
                pic.setColor(Color.MAGENTA);
                pic.fillOval((int)x, (int)y, 2, 2);
            }
            g.drawImage(image, 0, 0, this);
        }
    }
    public static void main(String[] args){
        new ForFunny();
    }
}

小小程序