From 87ba012b38de8afdff4a40fe393af2ead4745c29 Mon Sep 17 00:00:00 2001 From: Cameron Ball Date: Thu, 9 Jul 2015 14:55:10 +0800 Subject: [PATCH] Initial commit --- .gitignore | 1 + public_html/index.html | 23 +++++++++++++++ public_html/upload.php | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 .gitignore create mode 100644 public_html/index.html create mode 100644 public_html/upload.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..80f408e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +nbproject/ diff --git a/public_html/index.html b/public_html/index.html new file mode 100644 index 0000000..8dc8c4f --- /dev/null +++ b/public_html/index.html @@ -0,0 +1,23 @@ + + + + + TODO supply a title + + + + + All measurements to be in metres

+
+ Select image to upload:
+ Wood size (for nxn enter n):
+ Wood length:
+ Wood cost/length:
+ +
+ + diff --git a/public_html/upload.php b/public_html/upload.php new file mode 100644 index 0000000..45b39ad --- /dev/null +++ b/public_html/upload.php @@ -0,0 +1,76 @@ +"; + for($i=0; $i<$check[1]; $i++) { + echo ''; + for($j=0; $j<$check[0]; $j++) { + $rgb = imagecolorsforindex($image, imagecolorat($image, $j, $i)); + $r = $rgb['red']; + $g = $rgb['green']; + $b = $rgb['blue']; + $a = $rgb['alpha']; + $hex = '#' . + str_pad(dechex($rgb['red']), 2, '0', STR_PAD_LEFT) . + str_pad(dechex($rgb['green']), 2, '0', STR_PAD_LEFT) . + str_pad(dechex($rgb['blue']), 2, '0', STR_PAD_LEFT); + if($a == 127) $hex = "#ffffff"; + echo ""; + + if($a == 0) + $colour_count[$hex] = isset($colour_count[$hex]) ? $colour_count[$hex]+1 : 1; + } + echo ''; + } + echo ''; + + $total_blocks = array_sum($colour_count); + $lengths_required = ceil($total_blocks*$wood_size/$wood_length); + echo '
'; + echo '
'; + + echo 'Physical dimensions (metres)
'; + echo 'Width: ' . $check[0] * $wood_size . '
';; + echo 'Height: ' . $check[1] * $wood_size; + + echo '

'; + + echo 'Cost breakdown
'; + echo ' + + + + + + + + + + +
Total blocksNo of ' . $wood_length . 'm lengths requiredCost @ ' . $cost_per_length . ' per length
' . $total_blocks . '' . $lengths_required . '' . $lengths_required * $cost_per_length . '
'; + + echo '

'; + echo 'Colour breakdown
'; + + echo ' + + + + + '; + foreach($colour_count as $colour => $qty) { + echo ""; + } + + echo '
ColourRGBQuantity
$colour$qty
'; + } +} +?> -- 2.11.0