Changeset 54298 in spip-zone
- Timestamp:
- Nov 10, 2011, 9:14:17 PM (8 years ago)
- Location:
- _plugins_/jeux
- Files:
-
- 81 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/jeux/jeux/diag_echecs.php
r35403 r54298 79 79 $flip = jeux_config('flip'); 80 80 $taille = intval(jeux_config('taille')); 81 // ************* case en surbrillance ************* 82 $caserouge = jeux_config('rouge'); 83 $casebleu = jeux_config('bleu'); 84 $casevert = jeux_config('vert'); 85 $casejaune = jeux_config('jaune'); 86 81 87 $bordure = intval(jeux_config('bordure')); 82 88 $board_size = intval(jeux_config('board_size')); … … 118 124 if (in_array('r', $table)) $flip = true; 119 125 126 127 // *************** CASE A COLORIER ************************* 128 if (strlen($casebleu)>0 ) { 129 $lescases=explode(",",$casebleu); 130 for ($j=0 ; $j<count($lescases) ; $j++) { 131 $square=$lescases[$j]; 132 $hilite = "hbleu"; 133 diag_echecs_hilite_square($chessboard,$square,$hilite,$flip); 134 } 135 } 136 if (strlen($caserouge)>0 ) { 137 $lescases=explode(",",$caserouge); 138 for ($j=0 ; $j<count($lescases) ; $j++) { 139 $square=$lescases[$j]; 140 $hilite = "hrouge"; 141 diag_echecs_hilite_square($chessboard,$square,$hilite,$flip); 142 } 143 } 144 if (strlen($casevert)>0 ) { 145 $lescases=explode(",",$casevert); 146 for ($j=0 ; $j<count($lescases) ; $j++) { 147 $square=$lescases[$j]; 148 $hilite = "hvert"; 149 diag_echecs_hilite_square($chessboard,$square,$hilite,$flip); 150 } 151 } 152 if (strlen($casejaune)>0 ) { 153 $lescases=explode(",",$casejaune); 154 for ($j=0 ; $j<count($lescases) ; $j++) { 155 $square=$lescases[$j]; 156 $hilite = "hjaune"; 157 diag_echecs_hilite_square($chessboard,$square,$hilite,$flip); 158 } 159 } 120 160 for ($i=0 ; $i<count($table) ; $i++) { 121 161 $sub_table = preg_split("/[:,]/",$table[$i]); … … 168 208 if (jeux_config('coords')) { 169 209 $fond = $jeux_couleurs[jeux_config('fond')]; 170 $big_chessboard = imagecreate ($board_size+2*$bordure+$taille,$board_size+2*$bordure+$taille);210 $big_chessboard = imagecreatetruecolor($board_size+2*$bordure+$taille,$board_size+2*$bordure+$taille); 171 211 $bg_color = imagecolorallocate($big_chessboard,$fond[0],$fond[1],$fond[2]); 172 imagecolortransparent($big_chessboard,$bg_color); 212 //imagecolortransparent($big_chessboard,$bg_color); 213 imagefill($big_chessboard,0,0,$bg_color); 173 214 imagecopy($big_chessboard,$chessboard,$taille,0,0,0,$board_size+2*$bordure,$board_size+2*$bordure); 174 215 $width = imagefontwidth($font); … … 176 217 $center = intval($taille/2); 177 218 for ($i=1 ; $i<=8 ; $i++) { 178 $empty_coord = imagecreate ($taille,$taille);219 $empty_coord = imagecreatetruecolor($taille,$taille); 179 220 $bg_color = imagecolorallocate($empty_coord,$fond[0],$fond[1],$fond[2]); 180 imagecolortransparent($empty_coord,$bg_color); 221 //imagecolortransparent($empty_coord,$bg_color); 222 imagefill($empty_coord,0,0,$bg_color); 181 223 $font_color = imagecolorallocate($empty_coord,0,0,0); 182 224 if (!$flip) { … … 188 230 } 189 231 for ($i=1 ; $i<=8 ; $i++) { 190 $empty_coord = imagecreate ($taille,$taille);232 $empty_coord = imagecreatetruecolor($taille,$taille); 191 233 $bg_color = imagecolorallocate($empty_coord,$fond[0],$fond[1],$fond[2]); 192 imagecolortransparent($empty_coord,$bg_color); 234 //imagecolortransparent($empty_coord,$bg_color); 235 imagefill($empty_coord,0,0,$bg_color); 193 236 $font_color = imagecolorallocate($empty_coord,0,0,0); 194 237 if (!$flip) { … … 202 245 } // if (jeux_config('coords')) 203 246 204 $img($chessboard, $fichier_dest); 247 // ************* redimensionement final ************* 248 if (strlen(jeux_config('redim'))>0) { 249 if (jeux_config('coords')) { $nbcases=9; } else { $nbcases=8; } 250 $newsize = intval(jeux_config('redim'))*$nbcases+2*$bordure; 251 if ($newsize>639) {$newsize=640;}; // taille maximale pour éviter les confusion taille de case et taille de l'image 252 $img_finale = imagecreatetruecolor($newsize,$newsize); 253 imagecopyresampled($img_finale,$chessboard,0,0,0,0,$newsize,$newsize,$taille*$nbcases+2*$bordure,$taille*$nbcases+2*$bordure); 254 $img($img_finale, $fichier_dest); 255 } 256 else { 257 $img($chessboard, $fichier_dest); 258 } 259 205 260 return $image; 206 261 } -
_plugins_/jeux/jeux/diag_echecs_inc.php
r18809 r54298 58 58 $board_size = intval(jeux_config('board_size')); 59 59 60 $board = imagecreate($board_size,$board_size); 61 $light_color = imagecolorallocate($board,$light[0],$light[1],$light[2]); 62 imagefill($board,0,0,$light_color); 63 $square = imagecreate($taille,$taille); 64 $dark_color = imagecolorallocate($square,$dark[0],$dark[1],$dark[2]); 65 imagefill($square,0,0,$dark_color); 66 for ($i=0 ; $i<8 ; $i++) 67 for ($j=0 ; $j<8 ; $j++) 68 if (($i+$j) & 1) imagecopy($board,$square,$i*$taille,$j*$taille,0,0,$taille,$taille); 69 $chessboard = imagecreate($board_size+2*$bordure,$board_size+2*$bordure); 60 61 // ***************** Ouvre une image pour l'échiquier ******************* 62 if (strlen(jeux_config('plateau'))>1 ) { 63 // si une image d'échiqier est utilisé 64 //$url = jeux_config('base_url').jeux_config('plateau'); 65 $url = _DIR_PLUGIN_JEUX.'img/echiquiers/'.jeux_config('plateau'); 66 if (file_exists($url)) { 67 $board=imagecreatefrompng($url); 68 if(!$board) { die("Erreur lors de l'ouverture du fichier : ".jeux_config('plateau')); } 69 } 70 71 } 72 else { 73 $board = imagecreatetruecolor($board_size,$board_size); 74 $light_color = imagecolorallocate($board,$light[0],$light[1],$light[2]); 75 imagefill($board,0,0,$light_color); 76 $square = imagecreatetruecolor($taille,$taille); 77 $dark_color = imagecolorallocate($square,$dark[0],$dark[1],$dark[2]); 78 imagefill($square,0,0,$dark_color); 79 for ($i=0 ; $i<8 ; $i++) 80 for ($j=0 ; $j<8 ; $j++) 81 if (($i+$j) & 1) imagecopy($board,$square,$i*$taille,$j*$taille,0,0,$taille,$taille); 82 } 83 $chessboard = imagecreatetruecolor($board_size+2*$bordure,$board_size+2*$bordure); 70 84 $black_color = imagecolorallocate($chessboard,0,0,0); 71 85 imagefill($chessboard,0,0,$black_color); … … 113 127 114 128 $color = $diag_echecs_globales[$hilite]; 115 $square = imagecreate ($taille,$taille);116 $hilite_color = imagecolorallocate ($square,$color[0],$color[1],$color[2]);129 $square = imagecreatetruecolor($taille,$taille); 130 $hilite_color = imagecolorallocatealpha($square,$color[0],$color[1],$color[2],50); 117 131 imagefill($square,0,0,$hilite_color); 118 132 if (!$flip) { -
_plugins_/jeux/jeux/diag_echecs_init.php
r33704 r54298 15 15 $diag_echecs_globales = Array( 16 16 // Codes RGB des couleurs predefinies 17 'hrouge' => array(255, 170,170),18 'hbleu' => array( 101,128,230),19 'hvert' => array( 51,153,102),20 'hjaune' => array(255,255, 102),17 'hrouge' => array(255,64,64), 18 'hbleu' => array(96,96,255), 19 'hvert' => array(96,255,96), 20 'hjaune' => array(255,255,32), 21 21 // diverses initialisations 22 22 'colonnes' => "abcdefgh", -
_plugins_/jeux/jeux_config.php
r53933 r54298 146 146 // fr 147 147 'blanc' => array(255,255,255), 148 'noir' => array( 0,0,0),149 'gris' => array(2 11,209,209),148 'noir' => array(170,170,170), 149 'gris' => array(209,209,209), 150 150 'vert' => array(191,220,192), 151 151 'bleu' => array(152,192,218),
Note: See TracChangeset
for help on using the changeset viewer.