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.

  1. 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.
  2. You can add only the output of the algorithm to your website. There will be no argument inputs or run button.

number Argument info
show numbers Argument info
Embed the form Embed only the output

eXorithm – Execute Algorithm: View / Run Algorithm pixelate

function pixelate ($image$blocksize
{
  // Based on http://www.tuxradar.com/practicalphp/11/2/24
  
  $imagex = imagesx$image);
  $imagey = imagesy$image);
  
  $image2 = imagecreatetruecolor$imagex$imagey);
  imagesavealpha$image2, true);
  imagealphablending$image2, false);
  
  if ($blocksize<1) {
    $blocksize = 1;
  }
  
  for ($x = 0; $x < $imagex$x += $blocksize) {
    for ($y = 0; $y < $imagey$y += $blocksize) {
      // get the pixel colour at the top-left of the square
      $colour = imagecolorat$image$x$y);
      
      // set the new red, green, blue and alpha values to 0
      $newr = 0;
      $newg = 0;
      $newb = 0;
      $newt = 0;
      
      // create an empty array for the colours
      $colours = array();
      
      // cycle through each pixel in the block
      for ($k = $x$k < $x + $blocksize; ++$k) {
        for ($l = $y$l < $y + $blocksize; ++$l) {
          // if we are outside the valid bounds of the image, use a safe colour
          if ($k < 0) { $colours[] = $colourcontinue; }
          if ($k >= $imagex) { $colours[] = $colourcontinue; }
          if ($l < 0) { $colours[] = $colourcontinue; }
          if ($l >= $imagey) { $colours[] = $colourcontinue; }
          
          // if not outside the image bounds, get the colour at this pixel
          $colours[] = imagecolorat$image$k$l);
        }
      }
      
      // cycle through all the colours we can use for sampling
      foreach$colours as $colour) {
        $colour = imagecolorsforindex$image$colour);
        // add their red, green, and blue values to our master numbers
        $newr += $colour'red'];
        $newg += $colour'green'];
        $newb += $colour'blue'];
        $newt += $colour'alpha'];
      }
      
      // now divide the master numbers by the number of valid samples to get an average
      $numelements = count$colours);
      $newr /= $numelements
      $newg /= $numelements
      $newb /= $numelements
      $newt /= $numelements
      
      // and use the new numbers as our colour
      $newcol = imagecolorallocatealpha$image2$newr$newg$newb$newt);
      imagefilledrectangle$image2$x$y$x + $blocksize - 1, $y + $blocksize - 1, $newcol);
    }
  }
  
  return $image2

eXorithm – Execute Algorithm: View / Run Algorithm quick_sort

function quick_sort ($array
{
  if (count$array)<=1) {
    return $array
  } else {
    $pivot = $array[0];
    $lesser = array();
    $greater = array();
    for ($i=1;$icount$array);$i++) {
      if ($array$i]<=$pivot) {
        $lesser[] = $array$i];
      } else {
        $greater[] = $array$i];
      }
    }  
    return array_mergequick_sort$lesser), array$pivot), quick_sort$greater));
  }

eXorithm – Execute Algorithm: View / Run Algorithm tag_cloud

function tag_cloud ($tags$min_size$max_size$link$link_class
{
  $min = minarray_values$tags));
  $max = maxarray_values$tags));
  $spread = $max - $min
  $cloud = ''
  
  if ($link_class != ''$link_class = "class="$link_class" "
  if ($spread == 0) $spread = 1;
  
  foreach$tags as $tag => $count)  {
    $size = $min_size + ($count - $min) * ($max_size - $min_size) / $spread
    $cloud .= '<a style="font-size:'floor$size).'px" '$link_class
      .'href="'$linkurlencode$tag).'">'$tag"</a>n"
  }
  
  return $cloud

eXorithm – Execute Algorithm: Embed Algorithm show_address


Embed This Algorithm

This page will help you embed the algorithm show_address 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.

  1. 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.
  2. You can add only the output of the algorithm to your website. There will be no argument inputs or run button.
address Argument info
Embed the form Embed only the output

eXorithm – Execute Algorithm: View / Run Algorithm random_name_caption

function random_name_caption ($image$your_name
{
  $sizey = imagesy$image);
  $sizex = imagesx$image);
  
  if (mt_rand(0,1)==1)
    $color = imagecolorallocate$image, 254, 0, 0);
  else
    $color = imagecolorallocate$image, 0, 0, 254);
  
  $y = mt_rand(0,$sizey-10);
  $x = mt_rand(0,$sizex-10);
  
  imagestring$image, 4, $x$y$your_name$color);
  
  $return = array
    'return' => $image
    'arguments' => array$image$your_name
  );
  
  return $return

eXorithm – Execute Algorithm: View / Run Algorithm next_prime

function next_prime ($start
{
  $primes = -1;
  for$i = $start+1; ; $i++)
  {
    $is_prime = true;
    for$j = 2; $j < floor$i/2); $j++)
    {
      if(($i % $j) == 0)
      {
        $is_prime = false;
        break
       }
    }
    if ($is_prime
    {
      $prime = $i
      break
    }
  }
  return $prime