version 1.9, 2002/08/04 00:11:25 |
version 1.11, 2002/09/10 06:18:46 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/lib/glib,v 1.8 2002/08/03 23:59:14 takayama Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2000/lib/glib,v 1.10 2002/08/08 08:56:31 takayama Exp $ */ |
/* $Id$ */ |
/* $Id$ */ |
|
|
/* BUG: this library has not yet been adapted to the new automatic launcher |
/* BUG: this library has not yet been adapted to the new automatic launcher |
Line 44 Glib_canvas_x = 400$ |
|
Line 44 Glib_canvas_x = 400$ |
|
Glib_canvas_y = 400$ |
Glib_canvas_y = 400$ |
Glib_xmin=0$ Glib_xmax=Glib_canvas_x$ |
Glib_xmin=0$ Glib_xmax=Glib_canvas_x$ |
Glib_ymin=0$ Glib_ymax=Glib_canvas_y$ |
Glib_ymin=0$ Glib_ymax=Glib_canvas_y$ |
|
Glib_math_coordinate=0$ |
#define START_SERVER \ |
#define START_SERVER \ |
extern Glib_server_started, Glib_process$ \ |
extern Glib_server_started, Glib_process$ \ |
if (type(Glib_server_started) == 0) { \ |
if (type(Glib_server_started) == 0) { \ |
Line 130 def glib_clear() { |
|
Line 131 def glib_clear() { |
|
/*&usage begin: glib_window(Xmin,Ymin,Xmax,Ymax) |
/*&usage begin: glib_window(Xmin,Ymin,Xmax,Ymax) |
It generates a window with the left top corner [{Xmin},{Ymin}] and |
It generates a window with the left top corner [{Xmin},{Ymin}] and |
the right bottom corner [{Xmax},{Ymax}]. |
the right bottom corner [{Xmax},{Ymax}]. |
|
If the global variable {Glib_math_coordinate} is set to 1, mathematical |
|
coordinate system will be employed, i.e., the left top |
|
corner will have the coordinate [{Xmin},{Ymax}]. |
example: glib_window(-1,-1,10,10); |
example: glib_window(-1,-1,10,10); |
end: */ |
end: */ |
def glib_window(Xmin,Ymin,Xmax,Ymax) { |
def glib_window(Xmin,Ymin,Xmax,Ymax) { |
Line 164 def glib_check_arg(X,Y) { |
|
Line 168 def glib_check_arg(X,Y) { |
|
end: */ |
end: */ |
def glib_putpixel(X,Y) { |
def glib_putpixel(X,Y) { |
extern Glib_process, Glib_canvas, |
extern Glib_process, Glib_canvas, |
Glib_xoffset, Glib_yoffset, Glib_xmag, Glib_ymag, Glib_ps; |
Glib_xoffset, Glib_yoffset, Glib_xmag, Glib_ymag, Glib_ps, |
|
Glib_math_coordinate, Glib_canvas_y; |
if (Glib_canvas < 0) glib_open(); |
if (Glib_canvas < 0) glib_open(); |
glib_check(); |
glib_check(); |
glib_check_arg(X,Y); |
glib_check_arg(X,Y); |
C = getopt(color); |
C = getopt(color); |
Pos = [glib_floor(Glib_xmag*(X+Glib_xoffset)), |
if (Glib_math_coordinate) { |
glib_floor(Glib_ymag*(Y+Glib_yoffset))]; |
Pos = [glib_floor(Glib_xmag*(X+Glib_xoffset)), |
|
Glib_canvas_y-glib_floor(Glib_ymag*(Y+Glib_yoffset))]; |
|
Pos2= [glib_floor(Glib_xmag*(X+Glib_xoffset)), |
|
glib_floor(Glib_ymag*(Y+Glib_yoffset))]; |
|
}else{ |
|
Pos = [glib_floor(Glib_xmag*(X+Glib_xoffset)), |
|
glib_floor(Glib_ymag*(Y+Glib_yoffset))]; |
|
Pos2= [glib_floor(Glib_xmag*(X+Glib_xoffset)), |
|
Glib_canvas_y-glib_floor(Glib_ymag*(Y+Glib_yoffset))]; |
|
} |
if ( type(C) != -1 ) { |
if ( type(C) != -1 ) { |
draw_obj(Glib_process,Glib_canvas,Pos,C); |
draw_obj(Glib_process,Glib_canvas,Pos,C); |
if (Glib_ps) glib_history(["putpixel",Pos,C]); |
if (Glib_ps) glib_history(["putpixel",Pos2,C]); |
}else{ |
}else{ |
draw_obj(Glib_process,Glib_canvas,Pos); |
draw_obj(Glib_process,Glib_canvas,Pos); |
if (Glib_ps) glib_history(["putpixel",Pos,0]); |
if (Glib_ps) glib_history(["putpixel",Pos2,0]); |
} |
} |
} |
} |
|
|
Line 199 def glib_clip_line(X0,Y0,X1,Y1,Color) { |
|
Line 213 def glib_clip_line(X0,Y0,X1,Y1,Color) { |
|
/* X0, Y0, X1, Y1 should be integers. |
/* X0, Y0, X1, Y1 should be integers. |
Coordinates are already translated. */ |
Coordinates are already translated. */ |
extern Glib_process, Glib_canvas, Glib_canvas_x, Glib_canvas_y, |
extern Glib_process, Glib_canvas, Glib_canvas_x, Glib_canvas_y, |
Glib_ps; |
Glib_ps, Glib_math_coordinate; |
if (Glib_canvas < 0) glib_open(); |
if (Glib_canvas < 0) glib_open(); |
|
|
if (Glib_ps) { |
if (Glib_ps) { |
|
|
} |
} |
|
|
glib_check(); |
glib_check(); |
Pos = [glib_floor(X0),glib_floor(Y0),glib_floor(X1),glib_floor(Y1)]; |
if (Glib_math_coordinate) { |
|
Pos = [glib_floor(X0),Glib_canvas_y-glib_floor(Y0), |
|
glib_floor(X1),Glib_canvas_y-glib_floor(Y1)]; |
|
Pos2= [glib_floor(X0),glib_floor(Y0),glib_floor(X1),glib_floor(Y1)]; |
|
}else{ |
|
Pos = [glib_floor(X0),glib_floor(Y0),glib_floor(X1),glib_floor(Y1)]; |
|
Pos2 = [glib_floor(X0),Glib_canvas_y-glib_floor(Y0), |
|
glib_floor(X1),Glib_canvas_y-glib_floor(Y1)]; |
|
} |
if ( type(Color) != -1 ) { |
if ( type(Color) != -1 ) { |
draw_obj(Glib_process,Glib_canvas,Pos,Color); |
draw_obj(Glib_process,Glib_canvas,Pos,Color); |
if (Glib_ps) glib_history(["line",Pos,Color]); |
if (Glib_ps) glib_history(["line",Pos2,Color]); |
}else{ |
}else{ |
draw_obj(Glib_process,Glib_canvas,Pos); |
draw_obj(Glib_process,Glib_canvas,Pos); |
if (Glib_ps) glib_history(["line",Pos,0]); |
if (Glib_ps) glib_history(["line",Pos2,0]); |
} |
} |
} |
} |
|
|
Line 298 def glib_clip1_y(X0,Y0,X1,Y1,Clip) { |
|
Line 320 def glib_clip1_y(X0,Y0,X1,Y1,Clip) { |
|
end: */ |
end: */ |
def glib_print(X,Y,Text) { |
def glib_print(X,Y,Text) { |
extern Glib_process, Glib_canvas, |
extern Glib_process, Glib_canvas, |
Glib_xoffset, Glib_yoffset, Glib_xmag, Glib_ymag, Glib_ps; |
Glib_xoffset, Glib_yoffset, Glib_xmag, Glib_ymag, Glib_ps, |
|
Glib_math_coordinate, Glib_canvas_y; |
if (Glib_canvas < 0) glib_open(); |
if (Glib_canvas < 0) glib_open(); |
glib_check(); |
glib_check(); |
glib_check_arg(X,Y); |
glib_check_arg(X,Y); |
if (type(Text) != 7) error("glib_print(X,Y,Text): Text must be a string."); |
if (type(Text) != 7) error("glib_print(X,Y,Text): Text must be a string."); |
C = getopt(color); |
C = getopt(color); |
Pos = [glib_floor(Glib_xmag*(X+Glib_xoffset)), |
if (Glib_math_coordinate) { |
glib_floor(Glib_ymag*(Y+Glib_yoffset))]; |
Pos = [glib_floor(Glib_xmag*(X+Glib_xoffset)), |
|
Glib_canvas_y-glib_floor(Glib_ymag*(Y+Glib_yoffset))]; |
|
Pos2= [glib_floor(Glib_xmag*(X+Glib_xoffset)), |
|
glib_floor(Glib_ymag*(Y+Glib_yoffset))]; |
|
}else{ |
|
Pos = [glib_floor(Glib_xmag*(X+Glib_xoffset)), |
|
glib_floor(Glib_ymag*(Y+Glib_yoffset))]; |
|
Pos2= [glib_floor(Glib_xmag*(X+Glib_xoffset)), |
|
Glib_canvas_y-glib_floor(Glib_ymag*(Y+Glib_yoffset))]; |
|
} |
if ( type(C) != -1 ) { |
if ( type(C) != -1 ) { |
draw_string(Glib_process,Glib_canvas,Pos,Text,C); |
draw_string(Glib_process,Glib_canvas,Pos,Text,C); |
if (Glib_ps) glib_history(["print",Pos,Text,C]); |
if (Glib_ps) glib_history(["print",Pos2,Text,C]); |
}else{ |
}else{ |
draw_string(Glib_process,Glib_canvas,Pos,Text); |
draw_string(Glib_process,Glib_canvas,Pos,Text); |
if (Glib_ps) glib_history(["print",Pos,Text,0]); |
if (Glib_ps) glib_history(["print",Pos2,Text,0]); |
} |
} |
} |
} |
|
|
def glib_history(L) { |
def glib_history(L) { |
extern Glib_h, Glib_canvas_x, Glib_canvas_y; |
extern Glib_h, Glib_canvas_x, Glib_canvas_y, |
|
Glib_math_coodinate; |
if (L[0] == "putpixel" || L[0] == "print") { |
if (L[0] == "putpixel" || L[0] == "print") { |
if (L[1][0] <= Glib_canvas_x && L[1][0] >= 0) { |
if (L[1][0] <= Glib_canvas_x && L[1][0] >= 0) { |
if (L[1][1] <= Glib_canvas_x && L[1][1] >= 0) |
if (L[1][1] <= Glib_canvas_x && L[1][1] >= 0) |
Line 387 def glib_ps(L) { |
|
Line 420 def glib_ps(L) { |
|
|
|
return PS; |
return PS; |
} |
} |
|
|
|
/*&usage begin: glib_plot(F) |
|
It plots an object {F} on the glib canvas. |
|
example: glib_plot([[0,1],[0.1,0.9],[0.2,0.7],[0.3,0.5],[0.4,0.8]]); |
|
example: glib_plot(tan(x)); |
|
end: */ |
|
/* bug, xmin, xmax, color should be optional variables. */ |
|
def glib_plot(F) { |
|
Opt = getopt(); |
|
taka_glib_plot(F,Opt); |
|
} |
|
|
end$ |
end$ |
|
|