diff --git a/.gitignore b/.gitignore index 9234953..e6781ed 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,7 @@ compressed # Composer "vendor" libraries vendor/ + +# Dynamically created images +render/image.bmp +render/image_1.bmp diff --git a/bmp/README.md b/bmp/README.md new file mode 100644 index 0000000..53b3e03 --- /dev/null +++ b/bmp/README.md @@ -0,0 +1,4 @@ +# Test files in the bitmap format + +* Black and white lillys: [flower.bmp](flower.bmp) +* Black and white lillys rotated 90 degrees: [flower2.bmp](flower2.bmp) diff --git a/bmp/flower.bmp b/bmp/flower.bmp new file mode 100755 index 0000000..0131777 Binary files /dev/null and b/bmp/flower.bmp differ diff --git a/bmp/flower2.bmp b/bmp/flower2.bmp new file mode 100755 index 0000000..edba8a5 Binary files /dev/null and b/bmp/flower2.bmp differ diff --git a/imagebmp.php b/imagebmp.php new file mode 100644 index 0000000..add7888 --- /dev/null +++ b/imagebmp.php @@ -0,0 +1,99 @@ +conditions["icon"], 0, 2) . "_solid.png"); +imagefilter($icon, IMG_FILTER_NEGATE); +$icon_x = imagesx($icon); +$icon_y = imagesy($icon); +imageantialias($image, true); + +$background = $white; +$line_color = $black; +$highlight_color = $red; + +imagefill($image, 0, 0, $white); + +/* +imagesetthickness($image, 3); +imageline($image, 0, 1, 479, 1, $line_color); +imageline($image, 478, 0, 478, 799, $line_color); +imageline($image, 1, 0, 1, 799, $line_color); +imageline($image, 0, 798, 479, 798, $line_color); + */ + +imagesetthickness($image, 1); +$taskStartY = 3; +$taskCurrentY = $taskStartY; +$taskHeightY = 80; +for ( $i=0; $i<8; $i++ ) { + if ( !isset($tasks[$i]) ) break; + if ( $tasks[$i]->isOverdue() ) { + $color = $red; + } else { + $color = $black; + } + imagerectangle($image, 3, $taskCurrentY, 476, ($taskCurrentY + $taskHeightY), $color); + imagettftext($image, 20, 0, 7, ($taskCurrentY + 18 + 6), $color, $font, $tasks[$i]->getTitle()); + $daysLeftX = 420; + if ( $tasks[$i]->getDaysLeft() > 9 ) $daysLeftX -= 54; + $lines = array("", ""); + $words = explode(" ", $tasks[$i]->getDescription()); + $currentWord = 0; + $currentLine = 0; + while ( ($currentWord < count($words)) && ($currentLine < 2) ) { + $testLine = $lines[$currentLine] . $words[$currentWord] . " "; + $box = imagettfbbox(14, 0, $font, $testLine); + if ( $box[2] >= $daysLeftX ) { + $currentLine++; + } else { + $lines[$currentLine] = $testLine; + $currentWord++; + } + } + imagettftext($image, 14, 0, 7, ($taskCurrentY + 18 + 6 + 23), $color, $font, $lines[0]); + imagettftext($image, 14, 0, 7, ($taskCurrentY + 18 + 6 + 23 + 21), $color, $font, $lines[1]); + imagettftext($image, 70, 0, $daysLeftX, ($taskCurrentY + $taskHeightY - 5), $color, $font, $tasks[$i]->getDaysLeft()); + $taskCurrentY += $taskHeightY + $taskStartY + 1; +} +//imagestring($image, 1, 20, 20, "This is some text", $line_color); +//imagestring($image, 2, 20, 50, "This is some text", $line_color); +//imagestring($image, 3, 20, 80, "This is some text", $line_color); +//imagestring($image, 4, 20, 110, "This is some text", $line_color); +//imagestring($image, 5, 20, 140, "This is some text", $line_color); +//imagettftext($image, 20, -45, 20, 270, $line_color, $font, "This is some text"); +imagesetthickness($image, 3); +imagerectangle($image, 250, 675, 472, 792, $line_color); +imagecopymerge($image, $icon, 400, 680, 0, 0, $icon_x, $icon_y, 100); +imagettftext($image, 55, 0, 260, 735, $line_color, $font, intval($weather->temps["current"]) . html_entity_decode("°")); +imagettftext($image, 18, 0, 345, 735, $line_color, $font, "/ " . intval($weather->stats["feels_like"]) . $deg); +imagettftext($image, 15, 0, 256, 762, $line_color, $font, "High: " . intval($weather->temps["max"]) . $deg); +imagettftext($image, 15, 0, 261, 782, $line_color, $font, "Low: " . intval($weather->temps["min"]) . $deg); +imagettftext($image, 15, 0, 350, 762, $line_color, $font, "Humid: " . $weather->stats["humidity"] . "%"); +imagettftext($image, 15, 0, 364, 782, $line_color, $font, "Wind: " . intval($weather->stats["wind_speed"])); + +//imagefilter($image, IMG_FILTER_GRAYSCALE); +imagefilter($image, IMG_FILTER_CONTRAST, -1000); + +//header("Content-type: image/bmp"); +//imagebmp($image); +imagebmp($image, __DIR__ . '/render/image.bmp'); +$b = new Imagick(__DIR__ . '/render/image.bmp'); +$b->setImageType(Imagick::IMGTYPE_BILEVEL); +$b->setFormat('bmp'); +$b->writeImage(__DIR__ . '/render/image_1.bmp'); + +exit(); diff --git a/render/README.md b/render/README.md new file mode 100644 index 0000000..ec57b8a --- /dev/null +++ b/render/README.md @@ -0,0 +1,3 @@ +# Folder for dynamically created images + +This folder is the destination for the pre-rendered bitmaps used to display on the ePaper.