| 01 | | | 02 | | | 03 | | | 04 | | | 05 | | | 06 | | | 07 | | | 08 | | | 09 | | | 10 | | | 11 | | | 12 | | | 13 | | | 14 | | | 15 | | | 16 | | | 17 | | | 18 | | | 19 | | | 20 | | | 21 | | | 22 | | | 23 | | | 24 | | | 25 | | | 26 | | | 27 | | | 28 | | | 29 | | | 30 | | | 31 | | | 32 | | | 33 | | | 34 | | | 35 | | | 36 | | | 37 | | | 38 | | | 39 | | | 40 | | | 41 | | | 42 | | | 43 | | | 44 | | | 45 | | | 46 | | | 47 | | | 48 | | | 49 | | | 50 | | | 51 | | | 52 | | | 53 | | | 54 | | | 55 | | | 56 | | | 57 | | | 58 | | | 59 | | | 60 | | | 61 | | | 62 | | | 63 | | | 64 | | | 65 | | | 66 | | | 67 | | | 68 | | | 69 | | | 70 | | | 71 | | | 72 | | | 73 | | | 74 | | | 75 | | | 76 | | | 77 | | | 78 | | | 79 | | | 80 | | | 81 | | | 82 | | | 83 | | | 84 | | | 85 | | | 86 | | | 87 | | | 88 | | | 89 | | | 90 | | | 91 | | | 92 | | | 93 | | | 94 | | | 95 | | | 96 | | | 97 | | | 98 | | | 99 | | | 100 | | | 101 | | | 102 | | | 103 | | | 104 | | | 105 | | | 106 | | | 107 | | | 108 | | | 109 | | | 110 | | | 111 | | | 112 | | | 113 | | | 114 | | | 115 | | | 116 | | | 117 | | | 118 | | | 119 | | | 120 | | | 121 | | | 122 | | | 123 | | | 124 | | | 125 | | | 126 | | | 127 | | | 128 | | | 129 | | | 130 | | | 131 | | | 132 | | | 133 | | | 134 | | | 135 | | | 136 | | | 137 | | | 138 | | | 139 | | | 140 | | | 141 | | | 142 | | | 143 | | | 144 | | | 145 | | | 146 | | | 147 | |
|
<?php
| /*---------------------------------------------------------------*/
| /*
| Titre : Générer une image aléatoire
|
| URL : https://phpsources.net/code_s.php?id=255
| Auteur : Cam
| Date édition : 04 Mars 2007
| Date mise à jour : 12 Aout 2019
| Rapport de la maj:
| - fonctionnement du code vérifié
| - maintenance du code
| - modification de la description
| */
| /*---------------------------------------------------------------*/
|
| Header('Content-type: image/png');
| $img = ImageCreate( 200, 200);
| $colorbackgr = ImageColorAllocate( $img, 0, 0, 0);
| //nombre de cercles
| $u1 = Rand( 10, 20);
| for( $i=1; $i < $u1; $i++)
| {
| //couleurs
| $col1 = Rand( 71, 255);
| $col2 = Rand( 71, 255);
| $col3 = Rand( 71, 255);
| //position des centres x y
| $a1 = Rand( -5, 105);
| $a2 = Rand( -5, 105);
| //largeur et hauteur x y
| $a3 = Rand( 5, 150);
| $a4 = Rand( 5, 150);
| //début du cercle et fin
| $deg1 = Rand( 0, 360);
| $deg2 = Rand( 0, 360);
| //type de cercle
| $a5 = Rand( 0, 1);
|
| if($a5 == 0)
| {
| ImageArc( $img, $a1, $a2, $a3, $a4, $deg1, $deg2, ImageColorAllocate( $img,
| $col1, $col2, $col3));
| ImageArc( $img, $a1+1, $a2+1, $a3+1, $a4+1, $deg1+1, $deg2-1,
| ImageColorAllocate( $img, $col1-10, $col2-10, $col3-10));
| ImageArc( $img, $a1-1, $a2-2, $a3-1, $a4-1, $deg1+1, $deg2-1,
| ImageColorAllocate( $img, $col1-10, $col2-10, $col3-10));
| ImageArc( $img, $a1+2, $a2+2, $a3+2, $a4+2, $deg1+2, $deg2-2,
| ImageColorAllocate( $img, $col1-20, $col2-20, $col3-20));
| ImageArc( $img, $a1-2, $a2-2, $a3-2, $a4-2, $deg1+2, $deg2-2,
| ImageColorAllocate( $img, $col1-20, $col2-20, $col3-20));
| ImageArc( $img, $a1+3, $a2+3, $a3+3, $a4+3, $deg1+3, $deg2-3,
| ImageColorAllocate( $img, $col1-30, $col2-30, $col3-30));
| ImageArc( $img, $a1-3, $a2-3, $a3-3, $a4-3, $deg1+3, $deg2-3,
| ImageColorAllocate( $img, $col1-30, $col2-30, $col3-30));
| ImageArc( $img, $a1+4, $a2+4, $a3+4, $a4+4, $deg1+4, $deg2-4,
| ImageColorAllocate( $img, $col1-40, $col2-40, $col3-40));
| ImageArc( $img, $a1-4, $a2-4, $a3-4, $a4-4, $deg1+4, $deg2-4,
| ImageColorAllocate( $img, $col1-40, $col2-40, $col3-40));
| ImageArc( $img, $a1+5, $a2+5, $a3+5, $a4+5, $deg1+5, $deg2-5,
| ImageColorAllocate( $img, $col1-50, $col2-50, $col3-50));
| ImageArc( $img, $a1-5, $a2-5, $a3-5, $a4-5, $deg1+5, $deg2-5,
| ImageColorAllocate( $img, $col1-50, $col2-50, $col3-50));
| ImageArc( $img, $a1+6, $a2+6, $a3+6, $a4+6, $deg1+6, $deg2-6,
| ImageColorAllocate( $img, $col1-60, $col2-60, $col3-60));
| ImageArc( $img, $a1-6, $a2-6, $a3-6, $a4-6, $deg1+6, $deg2-6,
| ImageColorAllocate( $img, $col1-60, $col2-60, $col3-60));
| ImageArc( $img, $a1+7, $a2+7, $a3+7, $a4+7, $deg1+7, $deg2-7,
| ImageColorAllocate( $img, $col1-70, $col2-70, $col3-70));
| ImageArc( $img, $a1-7, $a2-7, $a3-7, $a4-7, $deg1+7, $deg2-7,
| ImageColorAllocate( $img, $col1-70, $col2-70, $col3-70));
| }
| else
| {
| ImageArc( $img, $a1, $a2, $a3, $a4, $deg1, $deg2, ImageColorAllocate( $img,
| $col1, $col2, $col3));
| ImageArc( $img, $a1+1*Rand(-1,1), $a2+1*Rand(-1,1), $a3+1*Rand(-1,1), $a4+1*
| Rand(-1,1), $deg1+1, $deg2-1, ImageColorAllocate( $img, $col1-10, $col2-10,
| $col3-10));
| ImageArc( $img, $a1-1*Rand(-1,1), $a2-2*Rand(-1,1), $a3-1*Rand(-1,1), $a4-1*
| Rand(-1,1), $deg1+1, $deg2-1, ImageColorAllocate( $img, $col1-10, $col2-10,
| $col3-10));
| ImageArc( $img, $a1+2*Rand(-1,1), $a2+2*Rand(-1,1), $a3+2*Rand(-1,1), $a4+2*
| Rand(-1,1), $deg1+2, $deg2-2, ImageColorAllocate( $img, $col1-20, $col2-20,
| $col3-20));
| ImageArc( $img, $a1-2*Rand(-1,1), $a2-2*Rand(-1,1), $a3-2*Rand(-1,1), $a4-2*
| Rand(-1,1), $deg1+2, $deg2-2, ImageColorAllocate( $img, $col1-20, $col2-20,
| $col3-20));
| ImageArc( $img, $a1+3*Rand(-1,1), $a2+3*Rand(-1,1), $a3+3*Rand(-1,1), $a4+3*
| Rand(-1,1), $deg1+3, $deg2-3, ImageColorAllocate( $img, $col1-30, $col2-30,
| $col3-30));
| ImageArc( $img, $a1-3*Rand(-1,1), $a2-3*Rand(-1,1), $a3-3*Rand(-1,1), $a4-3*
| Rand(-1,1), $deg1+3, $deg2-3, ImageColorAllocate( $img, $col1-30, $col2-30,
| $col3-30));
| ImageArc( $img, $a1+4*Rand(-1,1), $a2+4*Rand(-1,1), $a3+4*Rand(-1,1), $a4+4*
| Rand(-1,1), $deg1+4, $deg2-4, ImageColorAllocate( $img, $col1-40, $col2-40,
| $col3-40));
| ImageArc( $img, $a1-4*Rand(-1,1), $a2-4*Rand(-1,1), $a3-4*Rand(-1,1), $a4-4*
| Rand(-1,1), $deg1+4, $deg2-4, ImageColorAllocate( $img, $col1-40, $col2-40,
| $col3-40));
| ImageArc( $img, $a1+5*Rand(-1,1), $a2+5*Rand(-1,1), $a3+5*Rand(-1,1), $a4+5*
| Rand(-1,1), $deg1+5, $deg2-5, ImageColorAllocate( $img, $col1-50, $col2-50,
| $col3-50));
| ImageArc( $img, $a1-5*Rand(-1,1), $a2-5*Rand(-1,1), $a3-5*Rand(-1,1), $a4-5*
| Rand(-1,1), $deg1+5, $deg2-5, ImageColorAllocate( $img, $col1-50, $col2-50,
| $col3-50));
| ImageArc( $img, $a1+6*Rand(-1,1), $a2+6*Rand(-1,1), $a3+6*Rand(-1,1), $a4+6*
| Rand(-1,1), $deg1+6, $deg2-6, ImageColorAllocate( $img, $col1-60, $col2-60,
| $col3-60));
| ImageArc( $img, $a1-6*Rand(-1,1), $a2-6*Rand(-1,1), $a3-6*Rand(-1,1), $a4-6*
| Rand(-1,1), $deg1+6, $deg2-6, ImageColorAllocate( $img, $col1-60, $col2-60,
| $col3-60));
| ImageArc( $img, $a1+7*Rand(-1,1), $a2+7*Rand(-1,1), $a3+7*Rand(-1,1), $a4+7*
| Rand(-1,1), $deg1+7, $deg2-7, ImageColorAllocate( $img, $col1-70, $col2-70,
| $col3-70));
| ImageArc( $img, $a1-7*Rand(-1,1), $a2-7*Rand(-1,1), $a3-7*Rand(-1,1), $a4-7*
| Rand(-1,1), $deg1+7, $deg2-7, ImageColorAllocate( $img, $col1-70, $col2-70,
| $col3-70));
| }
| }
| //image 100x100 a été crée
| //symétrie
| $x = 0; $y = 0;
| while( $x <= 100)
| {
| for( $y=0; $y<=100; $y++)
| {
| //image de droite
| ImageSetPixel( $img, 200-($x), $y, ImageColorAt( $img, $x ,$y));
| //image dessous gauche
| ImageSetPixel( $img, $x, 200-$y, ImageColorAt( $img, $x, $y));
| //image dessous droite
| ImageSetPixel( $img, 200-$x, 200-$y, ImageColorAt( $img, $x, $y));
| }
| $x++;
| }
| //transparent ?
|
| ImageColorTransparent( $img, ImageColorClosest( $img, 0, 0, 0));
|
| // On crée l'image
| ImagePng($img);
| // On libère l'espace mémoire alloué à  l'image
| ImageDestroy($img);
| ?>
|
| |
|