import static java.lang.Math.PI; import static java.lang.Math.cos; import static java.lang.Math.sin; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.anotherbigidea.flash.SWFConstants; import com.anotherbigidea.flash.interfaces.SWFShape; import com.anotherbigidea.flash.interfaces.SWFTagTypes; import com.anotherbigidea.flash.structs.Color; import com.anotherbigidea.flash.structs.Matrix; import com.anotherbigidea.flash.structs.Rect; import com.anotherbigidea.flash.writers.SWFWriter; import com.anotherbigidea.flash.writers.TagWriter; public class SWFTest extends HttpServlet { final static int TWIPS = SWFConstants.TWIPS; final static int SCALE = 100; @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { int numPoints=5; // 規定値を代入しておく try { numPoints = Integer.parseInt(request.getParameter("n")); } catch (Exception e) {} int numFrames = 24; // 規定値を代入しておく try { numFrames = Integer.parseInt(request.getParameter("d")); } catch (Exception e) {} response.setContentType("application/x-shockwave-flash"); SWFWriter writer = new SWFWriter(response.getOutputStream()); SWFTagTypes swf = new TagWriter(writer); swf.header(5, //Flash versions -1, //unknown length 2 * SCALE * TWIPS, //width in twips 2 * SCALE * TWIPS, //height in twips 6, //frames per sec -1); //frame count to be determined swf.tagSetBackgroundColor(new Color(255, 255, 255)); // 図形(赤い四角形)の定義 SWFShape shape = swf.tagDefineShape2(1, new Rect(-SCALE*TWIPS, -SCALE*TWIPS, SCALE * TWIPS, SCALE * TWIPS)); shape.defineLineStyle(2 * TWIPS, new Color(0, 0, 255)); shape.setLineStyle(1); int i, j; for (i=0; i