//
/* ----------------------------------------------------------------------------------------------
outlinefont.java アウトラインフォント ver. 3.00 (JDK 1.02)
ueyama@infonet.co.jp 2001.07.21
update: 2007.09.07
---------------------------------------------------------------------------------------------- */
import java.applet.*;
import java.awt.*;
public class outlinefont extends Applet
{
// フォントデータ (端点・曲線制御点 座標初期値)
int Lx0[][]={{-102,16,90,55,102,16,-102,-102}, {-54,10,41,10,-54,-54,0,0},{-54,10,51,17,-54,-54,0,0},
{-36,88,95,105,106,-43,-102,0},{-22,44,42,-22,-54,0,0,0},{-22,50,52,-18,-54,0,0,0}};
int Ly0[][]={{-122,-122,-62,-7,53,123,123,-122}, {-82,-82,-54,-25,-25,-82,0,0},{16,16,48,81,81,16,0,0},
{-122,-116,-22,9,122,123,0,0},{-82,-76,-30,-25,-54,0,0,0},{16,20,76,81,48,0,0,0}};
boolean T=true, F=false;
boolean Sp[][]={{F,T,T,T,T,F,F,F},{F,T,T,F,F,F,F,F},{F,T,T,F,F,F,F,F}}; // T: 曲線 F: 直線
int Lx[][] =new int[6][8], Ly[][] =new int[6][8]; // 端点座標値
int Lx1[][]=new int[6][8], Ly1[][]=new int[6][8]; // 端点座標値 (for backup)
int Lq[]={7,5,5,7,5,5}; // 線の本数
int Cx=252, Cy=180; // 文字 (B) の中心の座標値
double Dx=1.0, Dy=1.0; // 拡大・縮小率
double It=0.0, Ra=0.0; // 傾斜、回転
int Bx[]={102,132,167,197,237,277,307,342,372}; // ボタン表示 X 座標値
int By=362; // ボタン表示 Y 座標値
int Mb=9; // クリックされたボタン No. (0〜8)
int Mj, Ml; // クリックされた端点・制御点の No.
Image Img, Buf;
public void init()
{
String bg=getParameter("bgcolor"); // 背景色の読み込み
int bgc=Integer.valueOf(bg,16).intValue();
setBackground(new Color(bgc));
MediaTracker mt=new MediaTracker(this);
Img=getImage(getCodeBase(), getParameter("figure")); // gif ファイルの読み込み
mt.addImage(Img, 0);
try
{
mt.waitForID(0);
}
catch(InterruptedException e){};
Buf=createImage(500,363);
initialize();
}
public void update(Graphics g)
{
paint(g);
}
public boolean inside(int x, int a, int b)
{
return (x<=Math.max(a,b) && x>=Math.min(a,b)) ? T:F;
}
public void dsp_btn(int m, int c) // ボタンの表示
{
Graphics gx=getGraphics();
gx.clipRect(Bx[c],By,26,23);
gx.drawImage(Img,Bx[c]-(52*c+26*m),By,this);
gx.dispose();
}
public void dsp_font(int l, int m, Graphics g) // フォントの表示
{
double t, x1,y1, x0=(double)Lx[l][m], y0=(double)Ly[l][m];
g.setColor(Color.black);
if(l<3)
{
if(Sp[l][m]) // 曲線の表示
{
for(t=0.0; t<1.0; t+=0.01)
{
x1=(1-t)*(1-t)*(double)Lx[l][m] + 2*(1-t)*t*(double)Lx[l+3][m] + t*t*(double)Lx[l][m+1];
y1=(1-t)*(1-t)*(double)Ly[l][m] + 2*(1-t)*t*(double)Ly[l+3][m] + t*t*(double)Ly[l][m+1];
g.drawLine((int)x0+Cx, (int)y0+Cy, (int)x1+Cx, (int)y1+Cy);
x0=x1; y0=y1;
}
}
else g.drawLine((int)x0+Cx, (int)y0+Cy, Lx[l][m+1]+Cx, Ly[l][m+1]+Cy); // 直線の表示
}
g.setColor((l<3)? Color.blue:Color.red);
if(l<3) g.drawRect(Lx[l][m]-4+Cx, Ly[l][m]-4+Cy, 8,8); // 端点の表示
else if(Sp[l-3][m]) g.drawOval(Lx[l][m]-4+Cx, Ly[l][m]-4+Cy, 8,8); // 制御点の表示
}
public void deform() // フォントの変形
{
int i,j;
double x,y,l,m,a;
for(j=0;j<6;j++) for(i=0;i=0) // 端点・制御点がドラッグされていれば
{
Lx[Mj][Ml]=x-Cx; Ly[Mj][Ml]=y-Cy; // 座標データの変更
if(Ml==0) {Lx[Mj][Lq[Mj]]=x-Cx; Ly[Mj][Lq[Mj]]=y-Cy;}
Graphics gr=getGraphics();
Graphics mg=Buf.getGraphics(); // 変更された図をバッファに描く
mg.clearRect(0,0,500,363);
for(j=0;j<6;j++) for(i=0;i戻る