Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Changed size and aligning

  • Loading branch information...
commit be60361beb4179262b437f4dc569751cff59b835 1 parent 699ec5b
Ovidiu Cherecheș authored February 26, 2012

Showing 1 changed file with 17 additions and 9 deletions. Show diff stats Hide diff stats

  1. 26  index.php
26  index.php
@@ -12,11 +12,11 @@
12 12
 
13 13
 // Img
14 14
 
15  
-$img = imagecreatetruecolor(800, count($cities) * 72 + 15);
  15
+$img = imagecreatetruecolor(320, ceil(count($cities) / 2) * 46 + 6);
16 16
 
17 17
 // Background
18 18
 
19  
-$bg = imagecolorallocate($img, 11, 11, 11);
  19
+$bg = imagecolorallocate($img, 10, 10, 10);
20 20
 
21 21
 imagefill($img, 0, 0, $bg);
22 22
 
@@ -25,12 +25,14 @@
25 25
 $bold_font = 'OpenSans-Bold.ttf';
26 26
 $light_font = 'OpenSans-Light.ttf';
27 27
 
28  
-$m_size = 15;
29  
-$c_size = 22;
  28
+$m_size = 10;
  29
+$c_size = 14;
30 30
 
31 31
 // Text
32 32
 
33 33
 $i = 0;
  34
+$x = 0;
  35
+$y = 0;
34 36
 
35 37
 foreach($cities as $city)
36 38
 {
@@ -43,11 +45,17 @@
43 45
 	$gray = imagecolorallocate($img, $g, $g, $g);
44 46
 	$dark = imagecolorallocate($img, 75, 75, 75);
45 47
 
46  
-	$offset = $i++ * 72;
47  
-
48  
-	imagettftext($img, $m_size, 0, 16, 30 + $offset, $gray, "fonts/{$city->font}", $city->get_message());
49  
-	imagettftext($img, $c_size, 0, 15, 62 + $offset, $dark, "fonts/$light_font", '#');
50  
-	imagettftext($img, $c_size, 0, 35, 62 + $offset, $white, "fonts/$bold_font", $city->name);
  48
+	if($i && $i % 2 == 0)
  49
+	{
  50
+		$x = 0;
  51
+		$y += 46;
  52
+	}
  53
+	imagettftext($img, $m_size, 0, 10 + $x, 20 + $y, $gray, "fonts/{$city->font}", $city->get_message());
  54
+	imagettftext($img, $c_size, 0, 10 + $x, 40 + $y, $dark, "fonts/$light_font", '#');
  55
+	imagettftext($img, $c_size, 0, 22 + $x, 40 + $y, $white, "fonts/$bold_font", $city->name);
  56
+
  57
+	$i++;
  58
+	$x += 140;
51 59
 }
52 60
 
53 61
 // Header

0 notes on commit be60361

Please sign in to comment.
Something went wrong with that request. Please try again.