Creating Text WordArt Effects

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
TheBuzzer

Re: Creating Text WordArt Effects

Post by TheBuzzer »

hey fred,

Just wondering do you have the formulas written more clear in languages like actionscript.

I am trying to do the effects in flash now.

It is very hard i think to read the bash script but it is possible. I already made two of the stuff into actionscript

I am not completely sure if I written them correct or not thats why I am wondering if there are those fx scripts written in other languages.

Code: Select all

			public function pinbarrel(source:BitmapData,ax:Number = 1,bx:Number = 0,cx:Number = 0,dx:Number = 0,ex:Number = 0,ay:Number = 1 ,by:Number = 0,cy:Number = 0,dy:Number = 0,ey:Number = 0):BitmapData {
				
				var newimage:BitmapData = new BitmapData(source.width, source.height);
				
				var width:int = source.width;
				var height:int = source.height;
				var w2:Number = width/2;
				var h2:Number = height/2;
				var xc:int = (width / 2) - 0.5;
				var yc:int = (height / 2) - 0.5;
				var sf:Number;
				if (w2 > h2) {
					sf = h2;
				} else {
					sf = w2;
				}
				

				for (var i:int = 0; i < source.width; i++) {
					var xd:Number = i - xc;
					for (var j:int = 0; j < source.height; j++) {
						var yd:Number = j - yc;
						
						var rd:Number = Math.sqrt(xd*xd + yd*yd)/sf;
						var rrd:Number = rd*rd;
						var rrrd:Number = rd*rd*rd;
						var rrrrd:Number = rd*rd*rd*rd;
						
						var ctermx:Number = ax + bx*rd + cx*rrd + dx*rrrd + ex*rrrrd;
						var ctermy:Number = ay + by*rd + cy*rrd + dy*rrrd + ey*rrrrd;
						var fdx:Number = ctermx;
						var fdy:Number = ctermy;
						var xs:Number = fdx*xd+xc;
						var ys:Number = fdy*yd+yc;
						
						newimage.setPixel32(i,j,source.getPixel32(xs,ys));
					}
				}
				
				return newimage;
				
				
				//"xd=(i-$xc); yd=(j-$yc); $rd $rterm $fdx $fdy xs=fdx*xd+$xc; ys=fdy*yd+$yc; u.p{xs,ys}"
			}
			
			
			
			public function barreleffect(source:BitmapData, distortamount:Number):BitmapData {
				var newimage:BitmapData = new BitmapData(source.width, source.height);
				
				// Distortamount should be range -1.0 to 1.0
				var d:Number = distortamount;
				var a:Number = 1+d
				var b:Number = -d
				var width:int = source.width;
				var height:int = source.height;
				var w2:Number = width/2;
				var h2:Number = height/2;
				var sf:Number =(w2+h2)/2;
				var xc:Number = w2;
				var yc:Number = h2;
				
				
				for (var i:int = 0; i < source.width; i++) {
					var xd:Number = i - xc;
					for (var j:int = 0; j < source.height; j++) {
						var yd:Number = j - yc;
						var rd:Number = Math.sqrt(xd*xd+yd*yd)/sf;
						var ys:Number = (yd/(a+b*rd))+yc;
						newimage.setPixel32(i,j,source.getPixel32(i,ys));
					}
				}
				
				return newimage;
			}
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating Text WordArt Effects

Post by fmw42 »

TheBuzzer wrote:hey fred,

Just wondering do you have the formulas written more clear in languages like actionscript.

I am trying to do the effects in flash now.

It is very hard i think to read the bash script but it is possible. I already made two of the stuff into actionscript

I am not completely sure if I written them correct or not thats why I am wondering if there are those fx scripts written in other languages.

Code: Select all

			public function pinbarrel(source:BitmapData,ax:Number = 1,bx:Number = 0,cx:Number = 0,dx:Number = 0,ex:Number = 0,ay:Number = 1 ,by:Number = 0,cy:Number = 0,dy:Number = 0,ey:Number = 0):BitmapData {
				
				var newimage:BitmapData = new BitmapData(source.width, source.height);
				
				var width:int = source.width;
				var height:int = source.height;
				var w2:Number = width/2;
				var h2:Number = height/2;
				var xc:int = (width / 2) - 0.5;
				var yc:int = (height / 2) - 0.5;
				var sf:Number;
				if (w2 > h2) {
					sf = h2;
				} else {
					sf = w2;
				}
				

				for (var i:int = 0; i < source.width; i++) {
					var xd:Number = i - xc;
					for (var j:int = 0; j < source.height; j++) {
						var yd:Number = j - yc;
						
						var rd:Number = Math.sqrt(xd*xd + yd*yd)/sf;
						var rrd:Number = rd*rd;
						var rrrd:Number = rd*rd*rd;
						var rrrrd:Number = rd*rd*rd*rd;
						
						var ctermx:Number = ax + bx*rd + cx*rrd + dx*rrrd + ex*rrrrd;
						var ctermy:Number = ay + by*rd + cy*rrd + dy*rrrd + ey*rrrrd;
						var fdx:Number = ctermx;
						var fdy:Number = ctermy;
						var xs:Number = fdx*xd+xc;
						var ys:Number = fdy*yd+yc;
						
						newimage.setPixel32(i,j,source.getPixel32(xs,ys));
					}
				}
				
				return newimage;
				
				
				//"xd=(i-$xc); yd=(j-$yc); $rd $rterm $fdx $fdy xs=fdx*xd+$xc; ys=fdy*yd+$yc; u.p{xs,ys}"
			}
			
			
			
			public function barreleffect(source:BitmapData, distortamount:Number):BitmapData {
				var newimage:BitmapData = new BitmapData(source.width, source.height);
				
				// Distortamount should be range -1.0 to 1.0
				var d:Number = distortamount;
				var a:Number = 1+d
				var b:Number = -d
				var width:int = source.width;
				var height:int = source.height;
				var w2:Number = width/2;
				var h2:Number = height/2;
				var sf:Number =(w2+h2)/2;
				var xc:Number = w2;
				var yc:Number = h2;
				
				
				for (var i:int = 0; i < source.width; i++) {
					var xd:Number = i - xc;
					for (var j:int = 0; j < source.height; j++) {
						var yd:Number = j - yc;
						var rd:Number = Math.sqrt(xd*xd+yd*yd)/sf;
						var ys:Number = (yd/(a+b*rd))+yc;
						newimage.setPixel32(i,j,source.getPixel32(i,ys));
					}
				}
				
				return newimage;
			}

Sorry I know nothing about flash actionscripts. I have only coded them in bash shell scripts.

Fred
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating Text WordArt Effects

Post by fmw42 »

Just curious! Is it possible to link Flash (action scripts or otherwise) to IM rather than writing code from scratch?
Post Reply