Giancarlo Voci 7 years ago
parent
commit
17af4b37a7
1 changed files with 42 additions and 0 deletions
  1. 42 0
      src/Modules/restful/restful.php

+ 42 - 0
src/Modules/restful/restful.php

@@ -38,9 +38,51 @@ class restful extends PluginStrategy
 		$this->AddRoute("POST /api.ws.getstatus/@labelid", __NAMESPACE__ . '\restful->RESTful_GetStatus');
 		$this->AddRoute("POST /api.ws.getstatus/@labelid", __NAMESPACE__ . '\restful->RESTful_GetStatus');
 		$this->AddRoute("POST /api.ws.getlabelsfromap/@ap_id", __NAMESPACE__ . '\restful->RESTful_GetLabelsFromAP');
 		$this->AddRoute("POST /api.ws.getlabelsfromap/@ap_id", __NAMESPACE__ . '\restful->RESTful_GetLabelsFromAP');
 
 
+		// TODO NEW OMLINK TPL GENERATOR
+		$this->AddRoute("GET /api.ws.gentpl", __NAMESPACE__ . '\restful->RESTful_gentpl');
+
 		$this->findBoxCore = new FindBoxCoreSystem(...array_values($f3->get('CORE.fb')));
 		$this->findBoxCore = new FindBoxCoreSystem(...array_values($f3->get('CORE.fb')));
 	}
 	}
 
 
+	public function RESTful_gentpl($f3)
+	{
+		$varCondizione = 0;
+
+		$grafica = [
+			'BODY' => ['w' => 100, 'h' => 100],
+			'TEXT1' => [
+				'x' => '0',
+				'y' => '18',
+				'size' => 18,
+				'color' => $varCondizione == 1 ? '#FFFFFF' : '#00FF00',
+				'value' => 'ciao'
+			],
+			'TEXT2' => [
+				'x' => '0',
+				'y' => '37',
+				'size' => 12,
+				'color' => '#FF0000',
+				'value' => 'booohh'
+			]
+		];
+
+		$image = null;
+		foreach($grafica as $element => $gdElement) {
+			switch (substr($element, 0, 4)) {
+				case 'BODY':
+					$image = imagecreatetruecolor($gdElement['w'], $gdElement['h']);
+					break;
+				case 'TEXT':
+					list($r, $g, $b) = sscanf($gdElement['color'], "#%02x%02x%02x");
+					$color = imagecolorallocate($image, $r, $g, $b);
+					imagettftext($image, $gdElement['size'], 0, $gdElement['x'], $gdElement['y'], $color, 'C:\Windows\Fonts\arial.ttf', $gdElement['value']);
+			}
+		}
+
+		imagepng($image, 'c:\ciao.png');
+		imagedestroy($image);
+	}
+
 	public function RESTful_ListAPIS($f3)
 	public function RESTful_ListAPIS($f3)
 	{
 	{
 		$apiList = array_filter(array_keys($f3->ROUTES), function ($item) {
 		$apiList = array_filter(array_keys($f3->ROUTES), function ($item) {