abr
26
2010

Bordes redondeados con PHP

Este es un excelente script en el cual puedes generar por medio de PHP bordes redondeados.

1
2
3
4
5
6
7
8
9
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
<?
// initial some default values
if ( !$s || $s < 407)
  $s=407;
if ( !$ci )
  $ci="336699";
if ( !$co )
  $co="FFFFFF";
 
// hex rgb translation, don't put # 
function hex2rgb($hex) {
    for($i=0; $i<3; $i++) {
        $temp = substr($hex,2*$i,2);
        $rgb[$i] = 16 * hexdec(substr($temp,0,1)) +
                   hexdec(substr($temp,1,1));
    }
    return $rgb;
}
 
$myrgbi = hex2rgb($ci);
$myrgbo = hex2rgb($co);
 
if ( $lt ) {
	$fill=$s-1;
	$center_x = $s-1;
	$center_y = $s-1;
	$start = 180;
	$end = 270;
}
 
if ( $lb ) {
	$fill=$s/2;
	$center_x = $s-1;
	$center_y = 0;
	$start = 90;
	$end = 0;
}
 
if ( $rt ) {
	$fill=$s/2;
	$center_x = 0;
	$center_y = $s-1;
	$start = 270;
	$end = 360;
}
 
if ( $rb ) {
	$fill=$s/2;
	$center_x = 0;
	$center_y = 0;
	$start = 180;
	$end = 90;
}
 
$im = ImageCreate($s, $s);
$ci = ImageColorAllocate($im, $myrgbi[0], $myrgbi[1], $myrgbi[2]);
$co = ImageColorAllocate($im, $myrgbo[0], $myrgbo[1], $myrgbo[2]);
 
$width = $s*2;
$height = $s*2;
 
ImageFill($im, 0, 0, $co);
ImageArc($im, $center_x, $center_y, $width, $height, $start, $end, $ci);
ImageFillToBorder($im, $fill,$fill, $ci, $ci);
 
if ( $ti ) 
  imagecolortransparent( $im, $ci);
 
if ( $to ) 
  imagecolortransparent( $im, $co);
 
// output to browser
// Header("Content-Type: image/png");
// ImagePng($im);
Header("Content-Type: image/gif");
ImageGif($im);
?>

Ahora solo llamas a este escrip de la siguiente manera para que imprima la imagen.

1
2
//  a. zoneartcss.php?lt=1&s=20&ci=ffffff&co=330000         (20x20 left top corner)
//  b. zoneartcss.php?rb=1&s=20&ci=ffffff&co=330000&ti=1    (20x20 right bottom corner transparnet)

Espero que les sea de utilidad.

Enlace: Bordes redondeados

About the Author: Miguel Angel Ortega Acosta

Leave a comment

Patrocinador

Siguenos

Suscribete

Escribe tu correo:

Recibirás un correo con todos los articulos escritos en ZoneArtCss durante el día.

Correo @zoneartcss.com

Obtén una cuenta de @zoneartcss.com gratuita