function allocate_color ($image, $color, $transparency
{
if (preg_match'/[0-9ABCDEF]{6}/i', $color)==0) {
throw new Exception"Invalid color code.");
}
if ($transparency<0 || $transparency>127) {
throw new Exception"Invalid transparency.");
}
$r = hexdecsubstr$color, 0, 2));
$g = hexdecsubstr$color, 2, 2));
$b = hexdecsubstr$color, 4, 2));
if ($transparency>127) $transparency = 127;
if ($transparency<=0)
return imagecolorallocate$image, $r, $g, $b);
else
return imagecolorallocatealpha$image, $r, $g, $b, $transparency);
}
Blog
eXorithm – Execute Algorithm: Discuss Algorithm fibonacci_binet
fibonacci_binet    version 0.3    Simple example of Fibonacci series algorithm using Binet
There are no comments yet
New Comment
eXorithm – Execute Algorithm: View / Run Algorithm invert_color
function invert_color ($color
{
$new = ''
for ($i=0;$i<3;$i++){
$c = 255 - hexdecsubstr$color,(2*$i),2));
$c = dechex$c);
$new .= (strlen$c) < 2) ? '0'$c : $c
}
return $new
}
eXorithm – Execute Algorithm: View / Run Algorithm unity
function unity ($passkey
{
  $ubn = array();
 Â
  while ($passkey > 9) {
    if (strlen$passkey) > 1)
      $passkey = array_sumstr_split$passkey));
    else
      $passkey = $passkey
  }Â
 Â
  $ubn[] = $passkey
 Â
  return end$ubn);
}Â
eXorithm – Execute Algorithm: History For Algorithm address_elevation
eXorithm – Execute Algorithm: Algorithms Beginning with E
eXorithm – Execute Algorithm: View / Run Algorithm rounded_rectangle
function rounded_rectangle ($height, $width, $corner_radius, $rectangle_color, $background_color, $background_transparent
{
if (($corner_radius>($height/2)) || ($corner_radius>($width/2))) {
throw new Exception'Corner radius may not exceed half the length of any of the sides.');
}
$image = image_create_alpha$width, $height);
if (!$background_transparent) {
$background_color = allocate_color$image, $background_color);
imagefilledrectangle$image, 0, 0, $width, $height, $background_color);
}
$rectangle_color = allocate_color$image, $rectangle_color);
// draw 2 rectangles that overlap (making an image like the cross on the Swiss flag)
imagefilledrectangle$image, $corner_radius, 0, $width$corner_radius-1, $height, $rectangle_color);
imagefilledrectangle$image, 0, $corner_radius, $width, $height$corner_radius-1, $rectangle_color);
// draw 4 circles for the corners
imagefilledellipse$image, $corner_radius, $corner_radius, $corner_radius*2, $corner_radius*2, $rectangle_color);
imagefilledellipse$image, $width$corner_radius-1, $corner_radius, $corner_radius*2, $corner_radius*2, $rectangle_color);
imagefilledellipse$image, $corner_radius, $height$corner_radius-1, $corner_radius*2, $corner_radius*2, $rectangle_color);
imagefilledellipse$image, $width$corner_radius-1, $height$corner_radius-1, $corner_radius*2, $corner_radius*2, $rectangle_color);
return $image
}
eXorithm – Execute Algorithm: Embed Algorithm weather_forecast
Embed This Algorithm
This page will help you embed the algorithm weather_forecast on a page on your own website. Just configure the inputs, then click the generate button to get a snippet of code you can paste onto your site. You have two options.
- You can embed the entire form. Users will be able to enter their own arguments, and will need to press the run button to execute the algorithm.
- You can add only the output of the algorithm to your website. There will be no argument inputs or run button.
eXorithm – Execute Algorithm: View / Run Algorithm radioactive_decay
function radioactive_decay ($half_life, $time
{
$lambda = log(2)/$half_life
return 100 - 100 * powexp(1), -1 * $lambda * $time);
}
eXorithm – Execute Algorithm: Embed Algorithm draw_upc_barcode
Embed This Algorithm
This page will help you embed the algorithm draw_upc_barcode on a page on your own website. Just configure the inputs, then click the generate button to get a snippet of code you can paste onto your site. You have two options.
- You can embed the entire form. Users will be able to enter their own arguments, and will need to press the run button to execute the algorithm.
- You can add only the output of the algorithm to your website. There will be no argument inputs or run button.