• Das Erstellen neuer Accounts wurde ausgesetzt. Bei berechtigtem Interesse bitte Kontaktaufnahme über die üblichen Wege. Beste Grüße der Admin

Besessen von schönen Kurven

Die Hoffnung stirbt zuletzt: Ein Bild mit CSS

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Ein Bild mit CSS</title>
</head>
<body>
<?php 

$bild = imagecreatefrompng("./frau.png");

$hoehe = imagesy($bild);
$breite = imagesx($bild);

$black = imagecolorclosest($bild, 0, 0, 0);

$divs = array();

for ($y = 0; $y < $hoehe; $y++){
	for($x = 0; $x < $breite; $x++){
		if (imagecolorat($bild, $x, $y) == $black){
			$div = array('y' => $y, 'x' => $x);
			while(imagecolorat($bild, $x, $y) == $black && $x < $breite){ $x++; }
			$div['breite'] = $x - $div['x'];
			
			array_push($divs, $div);
		}
	}
}
?>
	<div style="border: 1px red dashed; position: relative; width: <?php echo $breite;?>px; height: <?php echo $hoehe;?>px;"><?php
foreach ($divs as $div){?>

		<div style="position: absolute; background-color: #000000; height: 1px; top: <?php echo $div['y'];?>px; left: <?php echo $div['x'];?>px; width: <?php echo $div['breite'];?>px;"></div><?php } ?>

	</div>
</body>

PS: Was man doch nicht für einen Blödsinn macht, wenn man eigentlich lernen sollte.
 
Superstark, kann's kaum glauben: CSS!
orangesmilewinkgrin.gif

Da lohnt es tatsächlich, mal nen Tag frei zu nehmen und den Source zu lesen. :D
 
hehe, kannst du mal den sourcecode posten für die Umwandlung? ich nehme an, du hast eine Pixel-Grafik genommen und die Punkte in div-Container umgewandelt oder?

PS ich steh auf die alte :eek:
 
PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Ein Bild mit CSS</title>
</head>
<body>
<?php 

$bild = imagecreatefrompng("./frau_farbig.png");

$hoehe = imagesy($bild);
$breite = imagesx($bild);

$black = imagecolorclosest($bild, 0, 0, 0);
$white = imagecolorclosest($bild, 255, 255, 255);

$divs = array();

for ($y = 0; $y < $hoehe; $y++){
	for($x = 0; $x < $breite; $x++){
		if (imagecolorat($bild, $x, $y) != $white){
			$div = array('y' => $y, 'x' => $x, 'breite' => 1);
			
			$farben = imagecolorsforindex($bild, imagecolorat($bild, $x, $y));
			
			$div['farbe'] = "rgb(" . $farben['red'] . ", " . $farben['green'] . ", " . $farben['blue'] . ")";
			
			array_push($divs, $div);
		}
	}
}
?>
	<div style="border: 1px red dashed; position: relative; background-color: #FFFFFF; width: <?php echo $breite;?>px; height: <?php echo $hoehe;?>px;"><?php
foreach ($divs as $div){?>

		<div style="position: absolute; background-color: <?php echo $div['farbe'];?>; height: 1px; top: <?php echo $div['y'];?>px; left: <?php echo $div['x'];?>px; width: <?php echo $div['breite'];?>px;"></div><?php } ?>

	</div>
</body>
 
Zurück
Oben