Color To VRML Format

[Total: 0    Average: 0/5]

This will convert from HTML color codes to VRML color codes.

Body Code:

<SCRIPT language="javascript">
<!--
function convert_H2V(input_num) {
  var x, new_num;
  
  if(input_num <= 'ff')
   {
     x = parseInt(input_num, 16);
     new_num = x/255;
   }
  return(new_num);
}

function convert (form) {
  form.VRMLred.value = convert_H2V(form.red.value)
  form.VRMLgreen.value = convert_H2V(form.green.value)
  form.VRMLblue.value = convert_H2V(form.blue.value)

}
//end of script-->
</SCRIPT>
COMMENTS:
<BR><FONT SIZE=+2>HTML to VRML color code converter</FONT>
<BR>This script converts hex codes to the proper float values to be used
in VRML.&nbsp;
<HR>
<TABLE>
<CAPTION><FORM name="color">


<TR>
<TD></TD>

<TD>Red</TD>

<TD>Green</TD>

<TD>Blue</TD>

<TD></TD>
</TR>

<TR>
<TD></TD>

<TD><INPUT type="text" name="red" size="3"></TD>

<TD><INPUT type="text" name="green" size="3"></TD>

<TD><INPUT type="text" name="blue" size="3"></TD>

<TD><INPUT type="button" value="Convert" onclick="convert(this.form)"></TD>
</TR>

<TR>
<TD>Result:</TD>

<TD><INPUT type="text" name="VRMLred" size="5"></TD>

<TD><INPUT type="text" name="VRMLgreen" size="5"></TD>

<TD><INPUT type="text" name="VRMLblue" size="5"></TD>

<TD><INPUT type="RESET" value="Clear Form"></TD>
</TR>
</TABLE>

</FORM></CAPTION>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *