StormChaser
Mitglied
Das sieht doch schon mal gut aus.
Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
function drawRoad($href, $name,
$xstart, $ystart, $length, $width,
$fillcolor, $rot = 0) {
$x = $xstart - $width / 2;
$y = $ystart - $width / 2;
$rx = $ry = $width / 2;
$w = $length + $width;
$h = $width;
$xtxt = $x + $length / 2;
$ytxt = $ystart;
$transform = ' transform="rotate(' . $rot . ',' . $xstart . ',' . $ystart . ')"';
$text = '<text alignment-baseline="central" text-anchor="middle"';
$text .= ' fill="white"';
$text .= ' x="' . $xtxt . '" y="' . $ytxt . '"';
$text .= $transform . '>';
$text .= $name . '</text>';
$rect = '<rect height="' . $h . '" width="' . $w;
$rect .= '" x="' . $x . '" y="' . $y;
$rect .= '" rx="' . $rx . '" ry="' . $ry;
$rect .= '" fill="' . $fillcolor . '"';
$rect .= $transform . '>';
$rect .= '</rect>';
echo '<a xlink:href="' . $href . '">' . $rect . $text . '</a>';
}
function drawRoadStartDest($href, $name,
$xstart, $ystart, $xend, $yend, $width,
$fillcolor) {
$length = hypot($xend - $xstart, $yend - $ystart);
$angle = asin(($yend - $ystart) / $length);
$rot = ($angle / pi()) * 180;
drawRoad($href, $name,
$xstart, $ystart, $length, $width,
$fillcolor, $rot);
}
drawRoad('https://wiki.selfhtml.org', 'Hauptstraße', 20, 20, 200, 20, '#ff0000', 0);
drawRoad('https://wiki.selfhtml.org', 'Unterstraße', 20, 20, 200, 20, '#ff0000', 90);
drawRoadStartDest('https://wiki.selfhtml.org', 'Startzielstraße', 20, 20, 220, 220, 20, '#0000ff');
?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="640" height="480" version="1.1" viewBox="0 0 640 480">
width="640" height="480"
private function drawRoad($id, $name, $xstart, $ystart, $length, $width, $fillcolor, $rot = 0) {
$x = $xstart - $width / 2;
$y = $ystart - $width / 2;
$rx = $ry = $width / 2;
$w = $length + $width;
$h = $width;
$xtxt = $x + $length / 2;
$ytxt = $ystart+2;
$transform = ' transform="rotate(' . $rot . ',' . $xstart . ',' . $ystart . ')"';
$text = '<text alignment-baseline="central" text-anchor="middle" style="font-size:8px;"';
$text .= ' fill="black"';
$text .= ' x="' . $xtxt . '" y="' . $ytxt . '"';
$text .= $transform . '>';
$text .= $name . '</text>';
$rect = '<rect height="' . $h . '" width="' . $w;
$rect .= '" x="' . $x . '" y="' . $y;
$rect .= '" rx="' . $rx . '" ry="' . $ry;
$rect .= '" fill="' . $fillcolor . '" fill-opacity="0.4"';
$rect .= $transform . '>';
$rect .= '</rect>';
$this->karte .= '<a xlink:href="#" onclick="alert('. $id .');">' . $rect . $text . '</a>';
}
private function drawRoadStartDest($name, $xstart, $ystart, $xend, $yend, $width, $fillcolor) {
$length = hypot($xend - $xstart, $yend - $ystart);
$angle = asin(($yend - $ystart) / $length);
$rot = ($angle / pi()) * 180;
drawRoad($href, $name, $xstart, $ystart, $length, $width, $fillcolor, $rot);
}
public function StrResponsiv(){
$str = $this->db->get_results("SELECT * FROM ". STR ." ORDER BY rand()");
$y = 20;
for($i = 1; $i <= 20; $i++){
if($this->db->num_rows("SELECT id FROM ". STRI ." WHERE str_id = '". $str->{$i}->id ."' AND std_id = '". $this->user['stadt'] ."' AND besitzer = '". $this->session['uid'] ."' ") == 1){
$bgcolor = 'green';
}else{
$bgcolor = 'red';
}
if($i <= 10){
$this->drawRoad($str->{$i}->id,$str->{$i}->name, 0, $y, 500, 10, $bgcolor);
}elseif($i > 10){
$this->drawRoad($str->{$i}->id,$str->{$i}->name, $y, 0, 500, 10, $bgcolor, 90);
}
if($i == 10){ $y = 20; }else{ $y += 50;}
}
return $this->karte;
}