[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[mgp-users-jp 01386] Re: baseline offset for %newimage



ありがとうございます。
微妙に %valignと被る機能ですが、微調整したいときには便利そうですね。
ちょっとコードをチェックしてから commitしておきます。
--
Yoshifumi Nishida
nishida@csl.sony.co.jp

From: Hirotsugu Kakugawa <h.kakugawa@computer.org>
Subject: [mgp-users-jp 01385] baseline offset for %newimage 
Date: Sat, 04 Sep 2004 23:47:54 +0900 (JST)
Message-ID: <>

 > 角川(広島大学)です。
 > こんにちは。 
 > 
 > %newimage にて、図のベースラインを上下するオプションをつけました。
 > インラインで数式などを入れた時、ベースラインのずれが調節できます。
 > 
 >    %newimage -raise YYY ...
 > 
 > というぐあいに、 -raise オプションを追加し、
 > YYY はどれだけ図のベースラインを上にずらすかを指定します。
 > 0 で移動なし, 100 だと図の縦サイズ分を上にずらします。
 > マイナスの値の指定も可能です。 
 > 
 > # 雰囲気は http://kakugawa.aial.hiroshima-u.ac.jp/hacks/mgp-raise/ 
 > # を参照下さい。
 > 
 > 最後に MagicPoint 1.10a 用のパッチをつけます。
 > では
 > -- 
 > 角川裕次(乙女座/B型/未年)  
 > 広島大学大学院工学研究科情報工学専攻
 > 
 > 
 > 
 > 
 > diff -rNc magicpoint-1.10a/draw.c magicpoint-1.10a-x/draw.c
 > *** magicpoint-1.10a/draw.c	Wed May 14 16:45:35 2003
 > --- magicpoint-1.10a-x/draw.c	Thu Apr  8 15:18:53 2004
 > ***************
 > *** 103,110 ****
 > --- 103,115 ----
 >   	char *, int));
 >   
 >   static void back_gradation __P((struct render_state *, struct ctrl_grad *));
 > + #if 1  /* by h.kakugawa@computer.org */
 > + static void image_load __P((struct render_state *, char *, int, int, int, int, int, int, int));
 > + static void image_load_ps __P((struct render_state *, char *, int, int, int, int, int, int, int));
 > + #else
 >   static void image_load __P((struct render_state *, char *, int, int, int, int, int, int));
 >   static void image_load_ps __P((struct render_state *, char *, int, int, int, int, int, int));
 > + #endif
 >   static void process_icon __P((struct render_state *, struct ctrl *));
 >   static void draw_bar __P((struct render_state *, struct ctrl *));
 >   static void process_system __P((struct render_state *, struct ctrl *));
 > ***************
 > *** 598,610 ****
 > --- 603,627 ----
 >   
 >   		/* quickhack for postscript */
 >   		if (ispsfilename(cp->ctm_fname)) {
 > + #if 1  /* by h.kakugawa@computer.org */
 > + 			image_load_ps(state, cp->ctm_fname, cp->ctm_numcolor,
 > + 				cp->ctm_ximagesize, cp->ctm_yimagesize, 0,
 > + 				cp->ctm_zoomflag, 0, cp->ctm_raise);
 > + #else
 >   			image_load_ps(state, cp->ctm_fname, cp->ctm_numcolor,
 >   				cp->ctm_ximagesize, cp->ctm_yimagesize, 0,
 >   				cp->ctm_zoomflag, 0);
 > + #endif
 >   		} else {
 > + #if 1  /* by h.kakugawa@computer.org */
 > + 			image_load(state, cp->ctm_fname, cp->ctm_numcolor,
 > + 				cp->ctm_ximagesize, cp->ctm_yimagesize, 0,
 > + 				cp->ctm_zoomflag, 0, cp->ctm_raise);
 > + #else
 >   			image_load(state, cp->ctm_fname, cp->ctm_numcolor,
 >   				cp->ctm_ximagesize, cp->ctm_yimagesize, 0,
 >   				cp->ctm_zoomflag, 0);
 > + #endif
 >   		}
 >   		state->brankline = 0;
 >   	    }
 > ***************
 > *** 2801,2807 ****
 >   }
 >   
 >   static void
 > ! image_load(state, filename, numcolor, ximagesize, yimagesize, backflag, zoomflag, centerflag)
 >   	struct render_state *state;
 >   	char *filename;
 >   	int numcolor;
 > --- 2818,2824 ----
 >   }
 >   
 >   static void
 > ! image_load(state, filename, numcolor, ximagesize, yimagesize, backflag, zoomflag, centerflag, raise)
 >   	struct render_state *state;
 >   	char *filename;
 >   	int numcolor;
 > ***************
 > *** 2815,2821 ****
 >   	Pixmap mypixmap;
 >   	XImageInfo *ximageinfo;
 >   	u_int image_posx;
 > ! 	int width, height;
 >   	float xzoomrate, yzoomrate;
 >   	int	private = mgp_flag & FL_PRIVATE;
 >   	static Cursor curs;
 > --- 2832,2838 ----
 >   	Pixmap mypixmap;
 >   	XImageInfo *ximageinfo;
 >   	u_int image_posx;
 > ! 	int width, height, yoffset;
 >   	float xzoomrate, yzoomrate;
 >   	int	private = mgp_flag & FL_PRIVATE;
 >   	static Cursor curs;
 > ***************
 > *** 2916,2921 ****
 > --- 2933,2957 ----
 >   		goto end;
 >   	}
 >   
 > + #if 1  /* by h.kakugawa@computer.org */
 > + 	switch(valign){
 > + 	case VL_TOP:
 > + 		draw_line_itemsize(state, 
 > + 				   (height * raise) * yzoomrate / 10000,
 > + 				   height * (100 + raise) * yzoomrate / 10000);
 > + 		break;
 > + 	case VL_BOTTOM:
 > + 		draw_line_itemsize(state, 
 > + 				   height * (100 + raise) * yzoomrate / 10000,
 > + 				   (height * raise) * yzoomrate / 10000);
 > + 		break;
 > + 	case VL_CENTER:
 > + 		draw_line_itemsize(state, 
 > + 				   height * (100 + raise) * yzoomrate / 20000,
 > + 				   height * (100 + raise) * yzoomrate / 20000);
 > + 		break;
 > + 	}
 > + #else
 >   	switch(valign){
 >   	case VL_TOP:
 >   		draw_line_itemsize(state, 0, height * yzoomrate / 100);
 > ***************
 > *** 2928,2933 ****
 > --- 2964,2970 ----
 >   			height * yzoomrate / 200);
 >   		break;
 >   	}
 > + #endif
 >   
 >   	if (centerflag)
 >   		image_posx = char_size[caching] / 2 - (width * xzoomrate / 100) / 2;
 > ***************
 > *** 2946,2952 ****
 >   }
 >   
 >   static void
 > ! image_load_ps(state, filename, numcolor, ximagesize, yimagesize, backflag, zoomflag, centerflag)
 >   	struct render_state *state;
 >   	char *filename;
 >   	int numcolor;
 > --- 2983,2989 ----
 >   }
 >   
 >   static void
 > ! image_load_ps(state, filename, numcolor, ximagesize, yimagesize, backflag, zoomflag, centerflag, raise)
 >   	struct render_state *state;
 >   	char *filename;
 >   	int numcolor;
 > ***************
 > *** 3035,3041 ****
 >   			filename, gsdevice, imagefile);
 >   	}
 >   	image_load(state, imagefile, numcolor, 100, 100, backflag,
 > ! 		Z_NORMAL | (Z_NORMAL << Z_YSHIFT), centerflag);
 >   	/* XXX: unlink imagefile in /tmp */
 >   	if ((p = strrchr(imagefile, '/')) != NULL)
 >   		p++;
 > --- 3072,3078 ----
 >   			filename, gsdevice, imagefile);
 >   	}
 >   	image_load(state, imagefile, numcolor, 100, 100, backflag,
 > ! 		Z_NORMAL | (Z_NORMAL << Z_YSHIFT), centerflag, raise);
 >   	/* XXX: unlink imagefile in /tmp */
 >   	if ((p = strrchr(imagefile, '/')) != NULL)
 >   		p++;
 > ***************
 > *** 3141,3147 ****
 >   		if (icon_y == 0) icon_y = 1;
 >   		tmp_color = fore_color[caching];
 >   		fore_color[caching] = cp->ctic_color;
 > ! 		image_load(state, cp->ctic_value, 0, icon_x, icon_y, 0, 0, 1);
 >   		fore_color[caching] = tmp_color;
 >   		break;
 >   
 > --- 3178,3184 ----
 >   		if (icon_y == 0) icon_y = 1;
 >   		tmp_color = fore_color[caching];
 >   		fore_color[caching] = cp->ctic_color;
 > ! 		image_load(state, cp->ctic_value, 0, icon_x, icon_y, 0, 0, 1, 0);
 >   		fore_color[caching] = tmp_color;
 >   		break;
 >   
 > ***************
 > *** 4244,4250 ****
 >   		case CTL_BIMAGE: 
 >   			image_load(state, ctl->ctm_fname, ctl->ctm_numcolor,
 >   						ctl->ctm_ximagesize, ctl->ctm_yimagesize, 1,
 > ! 						ctl->ctm_zoomflag, 0);
 >   			break;
 >   		case CTL_BGRAD:
 >   			back_gradation(state, &ctl->ct_val.ctrl_grad);
 > --- 4281,4287 ----
 >   		case CTL_BIMAGE: 
 >   			image_load(state, ctl->ctm_fname, ctl->ctm_numcolor,
 >   						ctl->ctm_ximagesize, ctl->ctm_yimagesize, 1,
 > ! 						ctl->ctm_zoomflag, 0, 0);
 >   			break;
 >   		case CTL_BGRAD:
 >   			back_gradation(state, &ctl->ct_val.ctrl_grad);
 > diff -rNc magicpoint-1.10a/grammar.y magicpoint-1.10a-x/grammar.y
 > *** magicpoint-1.10a/grammar.y	Sat Apr 12 07:05:42 2003
 > --- magicpoint-1.10a-x/grammar.y	Thu Apr  8 15:04:47 2004
 > ***************
 > *** 320,325 ****
 > --- 320,326 ----
 >   	ct->ctm_ximagesize = 100;
 >   	ct->ctm_yimagesize = 100;
 >   	ct->ctm_zoomflag = Z_NORMAL | (Z_NORMAL << Z_YSHIFT);
 > + 	ct->ctm_raise = 0;
 >   
 >   	for (p = arg; p; p = p->ct_next) {
 >   		if (p->ctc_value[0] != '-')
 > ***************
 > *** 369,374 ****
 > --- 370,378 ----
 >   			p = p->ct_next;
 >   			ct->ctm_yimagesize = atoi(p->ctc_value);
 >   			ct->ctm_zoomflag = Z_SCREEN | (Z_SCREEN << Z_YSHIFT);
 > + 		} else if (strcmp(p->ctc_value, "-raise") == 0 && p->ct_next) {
 > + 			p = p->ct_next;
 > + 			ct->ctm_raise = atoi(p->ctc_value);
 >   		} else {
 >   			yyerror("invalid argument %s specified for newimage",
 >   				p->ctc_value);
 > diff -rNc magicpoint-1.10a/mgp.c magicpoint-1.10a-x/mgp.c
 > *** magicpoint-1.10a/mgp.c	Tue Jun 24 14:26:33 2003
 > --- magicpoint-1.10a-x/mgp.c	Thu Apr  8 15:28:28 2004
 > ***************
 > *** 1082,1087 ****
 > --- 1082,1091 ----
 >   			}
 >   			break;
 >   
 > + #if 1  /* by h.kakugawa@computer.org */
 > + 		case MapNotify:
 > + 		  goto repaint;
 > + #endif
 >   		case Expose:
 >   			if (e.xexpose.window != window) 
 >   				break;
 > diff -rNc magicpoint-1.10a/mgp.h magicpoint-1.10a-x/mgp.h
 > *** magicpoint-1.10a/mgp.h	Fri Jun  6 16:18:25 2003
 > --- magicpoint-1.10a-x/mgp.h	Thu Apr  8 14:45:17 2004
 > ***************
 > *** 223,228 ****
 > --- 223,229 ----
 >   	u_int ct_ximagesize;
 >   	u_int ct_yimagesize;
 >   	u_int ct_zoomflag;
 > + 	u_int ct_raise;
 >   #define Z_XMASK		0x0f
 >   #define Z_YMASK		0xf0
 >   #define Z_YSHIFT	4
 > ***************
 > *** 313,318 ****
 > --- 314,320 ----
 >   #define ctm_ximagesize	ct_val.ctrl_image.ct_ximagesize
 >   #define ctm_yimagesize	ct_val.ctrl_image.ct_yimagesize
 >   #define ctm_zoomflag	ct_val.ctrl_image.ct_zoomflag
 > + #define ctm_raise	ct_val.ctrl_image.ct_raise
 >   #define ctd_colors	ct_val.ctrl_grad.colors
 >   #define ctd_g_colors	ct_val.ctrl_grad.ct_g_colors
 >   #define ctd_numcolor	ct_val.ctrl_grad.ct_numcolor
 >