package com.bjsxt.controller;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.sql.rowset.serial.SerialException;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
@WebServlet("/codeServlet")
class CodeServlet extends HttpServlet{
@override
protected void service(HttpServletRequest req,HttpServletResponse resp)throws SerialException, IOException {
int width = 110,height = 30;
BufferedImage image = new BufferedImage(width,herght,BufferedImage,TYPE_INT_RGB);
Graphics g = image.getGraphics();
g.setColor(getRandColor(fc:200,bc:250));
g.fillRect(x:0,y:0,width,height);
g.setFont(new Font(name:"Times New Roman", Font.PLAIN,size:20));
g.setColor(getRandColor(fc:160,bc:200));
for(int i=0;i<155;i++){
int x = randdom.nextInt(width);
int y = randdom.nextInt(height);
int x1 = randdom.nextInt(12);
int y1 = randdom.nextInt(12);
g.drawLine(x,y,x2:x+x1,y2:y+y1);
}
String sRand = "";
for(int i = 0;i<6;i++){
String rand = String.valueOf(randm.nextInt(10));
sRand+=rand;
g.setColor(new Color(20 + random.nextInt(100),20 + rand.nexInt(110),20 + rand.nextInt(110)));
g.drawString(rand,13 * i +6,16);
}
g.dispose();
}
}