Converting PHP to Coldfusion

Hello,
I have a file which creates output for a swf to read.  The dynamic aspect is in PHP and I need to convert to Coldfusion.
<gauge>
 
 
	<!-- large gauge -->
	<circle x='145' y='130' radius='110' fill_color='555555' fill_alpha='100' line_thickness='6' line_color='333333' line_alpha='90' />
	<circle x='145' y='130' radius='100' start='240' end='480' fill_color='99bbff' fill_alpha='90' line_thickness='4' line_alpha='20' />
	<circle x='145' y='130' radius='94' start='50' end='115' fill_color='FF4400' fill_alpha='100' />
	<circle x='145' y='130' radius='80' start='240' end='480' fill_color='99bbff' fill_alpha='80' />
	<circle x='145' y='130' radius='40' fill_color='333333' fill_alpha='100' line_alpha='0' />
	<circle x='145' y='130' radius='90' start='130' end='230' fill_color='333333' fill_alpha='100' line_alpha='0' />
	
	<?php
	//these are PHP functions that generate the XML to to draw radial ticks and numbers
	//any script language can be used to generate the XML code like this
	RadialTicks( 145, 130, 80, 15, 250, 387, 6, 8, "000000" );
	RadialTicks( 145, 130, 80, 15, 263, 400, 6, 4, "000000" );
	RadialTicks( 145, 130, 80, 15, 55, 110, 3, 4, "99bbff" );
	RadialNumbers( 145, 130, 80, 0, 8, 245, 465, 9, 14, "444444" );
	?>
	
	<rotate x='145' y='130' start='0' span='50' step='3' shake_frequency='100' shake_span='2' shadow_alpha='15'>
		<rect x='143' y='40' width='4' height='100' fill_color='ffffff' fill_alpha='90' line_alpha='0' />
	</rotate>
	
	<circle x='145' y='130' radius='30' fill_color='111111' fill_alpha='100' line_thickness='5' line_alpha='50' />
	<text x='95' y='180' width='100' size='14' color='ffffff' alpha='70' align='center'>x1000 r/min</text>
	
	
	
	
	<!-- background elements -->
	<text x='-10' y='250' width='500' size='24' color='000000' alpha='20' align='left'>||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||</text>
	<text x='400' y='0' width='300' size='49' color='ffffff' alpha='15' align='left' rotation='90'>dashboard</text>
	
	
	
	<?php
	//====================================
	//PHP function that generates the XML code to draw radial ticks
	function RadialTicks ( $x_center, $y_center, $radius,  $length, $start_angle, $end_angle, $ticks_count, $thickness, $color ){
		
		for ( $i=$start_angle; $i<=$end_angle; $i+=($end_angle-$start_angle)/($ticks_count-1) ){
			echo "	
<line x1='".round($x_center+sin(deg2rad($i))*$radius)."' y1='".round($y_center-cos(deg2rad($i))*$radius)."' x2='".round($x_center+sin(deg2rad($i))*($radius+$length))."' y2='".round($y_center-cos(deg2rad($i))*($radius+$length))."' thickness='".$thickness."' color='".$color."' />";
		
		}
	}
	//====================================
	//PHP function that generates the XML code to draw radial numbers
	function RadialNumbers ( $x_center, $y_center, $radius,  $start_number, $end_number, $start_angle, $end_angle, $ticks_count, $font_size, $color ){
		
		$number=$start_number;
		
		for( $i=$start_angle; $i<=$end_angle; $i+=($end_angle-$start_angle)/($ticks_count-1) ){
			echo "
	<text x='".round($x_center+sin(deg2rad($i))*$radius)."' y='".round($y_center-cos(deg2rad($i))*$radius)."' width='200' size='".$font_size."' color='".$color."' align='left' rotation='".$i."'>".$number."</text>";
			$number += ($end_number-$start_number)/($ticks_count-1);
		
		}
	}
	//====================================
	?>
	
	
</gauge>

Open in new window

CalDevAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

duncancummingCommented:
Coldfusion doesn't have a built-in degrees to radians function, but someone else has already written one ( http://www.cflib.org/udf/DegToRad )

This code is completely untested, but should give you the general idea.  Normally you wouldn't use WriteOutput like this, but for simplicity I have done so to mimic as close as possible the original PHP.
<cfscript>
/**
* Converts degrees to radians.
*
* @param degrees      Angle (in degrees) you want converted to radians.
* @return Returns a simple value
* @author Rob Brooks-Bilson (rbils@amkor.com)
* @version 1.0, July 18, 2001
*/
function deg2rad(degrees)
{
Return (degrees*(Pi()/180));
}
	//Coldfusion function that generates the XML code to draw radial ticks
	function RadialTicks ( x_center, y_center, radius, length, start_angle, end_angle, ticks_count, thickness, color ){
		var i = 0; 
		for ( i=arguments.start_angle; i LTE arguments.end_angle; i = i + (arguments.end_angle-arguments.start_angle)/(arguments.ticks_count-1) ){
			WriteOutput("  
<line x1='#round(arguments.x_center+sin(deg2rad(i))*arguments.radius)#' y1='#round(arguments.y_center-cos(deg2rad(i))*arguments.radius)#' x2='#round(arguments.x_center+sin(deg2rad(i))*(arguments.radius+arguments.length))#' y2='#round(arguments.y_center-cos(deg2rad(i))*(arguments.radius+arguments.length))#' thickness='#arguments.thickness#' color='arguments.color#' />");
		
		}
	}
	
	//Coldfusion function that generates the XML code to draw radial numbers
	function RadialNumbers ( x_center, y_center, radius,  start_number, end_number, start_angle, end_angle, ticks_count, font_size, color ){
		
		var number = arguments.start_number;
		var i = 0; 
		
		for( i= arguments.start_angle; i  LTE end_angle; i = i + (arguments.end_angle-arguments.start_angle)/(arguments.ticks_count-1) ){
			WriteOutput("
	<text x='#round(arguments.x_center+sin(deg2rad(i))*arguments.radius)#' y='#round(arguments.y_center-cos(deg2rad(i))*arguments.radius)#' width='200' size='#arguments.font_size#' color='#arguments.color#' align='left' rotation='#i#'>#number#</text>");
			number = number + (arguments.end_number-arguments.start_number)/(arguments.ticks_count-1);
		
		}
	}
	</cfscript>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
black0psCommented:
You are missing a pound sign on line 18 in front of arguments.
0
duncancummingCommented:
So I have.  Correct line is:
<line x1='#round(arguments.x_center+sin(deg2rad(i))*arguments.radius)#' y1='#round(arguments.y_center-cos(deg2rad(i))*arguments.radius)#' x2='#round(arguments.x_center+sin(deg2rad(i))*(arguments.radius+arguments.length))#' y2='#round(arguments.y_center-cos(deg2rad(i))*(arguments.radius+arguments.length))#' thickness='#arguments.thickness#' color='#arguments.color#' />");

I'd missed the opening # in front of arguments.color
0
duncancummingCommented:
I also missed out how you would call these functions:

<!---
        these are Coldfusion functions that generate the XML to to draw radial ticks and numbers
        any script language can be used to generate the XML code like this --->
<cfoutput>
        #RadialTicks( 145, 130, 80, 15, 250, 387, 6, 8, "000000" )#
        #RadialTicks( 145, 130, 80, 15, 263, 400, 6, 4, "000000" )#
        #RadialTicks( 145, 130, 80, 15, 55, 110, 3, 4, "99bbff" )#
        #RadialNumbers( 145, 130, 80, 0, 8, 245, 465, 9, 14, "444444" )#
</cfoutput>
0
CalDevAuthor Commented:
perfect, got me pointed in the correct direction, thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.