1. #1
    Avatar von exception
    Registriert seit
    27.03.2012
    Beiträge
    198
    Thanked 57 Times in 36 Posts

    Standard [PHP] ein Script schnell abändern(2min für php'ler)

    Hallo,
    es geht um folgendes Script:

    Spoiler:
    PHP-Code:
    <?
      $theColorBegin 
    = (isset($_REQUEST['cbegin'])) ? hexdec($_REQUEST['cbegin']) : 0x000000;
      
    $theColorEnd = (isset($_REQUEST['cend'])) ? hexdec($_REQUEST['cend']) : 0xffffff;
      
    $theNumSteps = (isset($_REQUEST['steps'])) ? intval($_REQUEST['steps']) : 16;

      
    $theColorBegin = (($theColorBegin >= 0x000000) && ($theColorBegin <= 0xffffff)) ? $theColorBegin 0x000000;
      
    $theColorEnd = (($theColorEnd >= 0x000000) && ($theColorEnd <= 0xffffff)) ? $theColorEnd 0xffffff;
      
    $theNumSteps = (($theNumSteps 0) && ($theNumSteps 256)) ? $theNumSteps 16;
    ?>
      <form method="GET">
        <table border='1'>
          <tr>
            <td>variable:</td>
            <td>number type</td>
            <td>minimum</td>
            <td>maximum</td>
            <td>value</td>
          </tr>
          <tr>
            <td>color begin:</td>
            <td>hex</td>
            <td>0x000000</td>
            <td>0xFFFFFF</td>
            <td><input name="cbegin" value="<? printf("%06X"$theColorBegin); ?>"></td>
          </tr>
          <tr>
            <td>color end:</td>
            <td>hex</td>
            <td>0x000000</td>
            <td>0xFFFFFF</td>
            <td><input name="cend" value="<? printf("%06X"$theColorEnd); ?>"></td>
          </tr>
          <tr>
            <td>number of steps:</td>
            <td>dec</td>
            <td>1</td>
            <td>255</td>
            <td><input name="steps" value="<? echo $theNumSteps?>"></td>
          </tr>
        </table>
        <input type="submit" value="generate color gradient">
      </form>
    <?
      printf
    ("<p>values are: (color begin: 0x%06X), (color end: 0x%06X), (number of steps: %d)</p>\n"$theColorBegin$theColorEnd$theNumSteps);

      
    $theR0 = ($theColorBegin 0xff0000) >> 16;
      
    $theG0 = ($theColorBegin 0x00ff00) >> 8;
      
    $theB0 = ($theColorBegin 0x0000ff) >> 0;

      
    $theR1 = ($theColorEnd 0xff0000) >> 16;
      
    $theG1 = ($theColorEnd 0x00ff00) >> 8;
      
    $theB1 = ($theColorEnd 0x0000ff) >> 0;

      
    // return the interpolated value between pBegin and pEnd
      
    function interpolate($pBegin$pEnd$pStep$pMax) {
        if (
    $pBegin $pEnd) {
          return ((
    $pEnd $pBegin) * ($pStep $pMax)) + $pBegin;
        } else {
          return ((
    $pBegin $pEnd) * (- ($pStep $pMax))) + $pEnd;
        }
      }  

      
    // generate gradient swathe now
      
    echo "<table width='100%' cellpadding='8' style='border-collapse:collapse'>\n";
      for (
    $i 0$i <= $theNumSteps$i++) {
        
    $theR interpolate($theR0$theR1$i$theNumSteps);
        
    $theG interpolate($theG0$theG1$i$theNumSteps);
        
    $theB interpolate($theB0$theB1$i$theNumSteps);
        
        
    $theVal = ((($theR << 8) | $theG) << 8) | $theB;

        
    $theTDTag sprintf("<td bgcolor='#%06X'>"$theVal);
        
    $theTDARTag sprintf("<td bgcolor='#%06X' align='right'>"$theVal);

        
    $theFC0Tag "<font color='#000000'>";
        
    $theFC1Tag "<font color='#ffffff'>";
        
    printf("<tr>$theTDTag$theFC0Tag%d</font></td>$theTDTag$theFC0Tag%d%%</font></td>$theTDARTag$theFC0Tag%d</font></td>$theTDARTag$theFC0Tag%06X</font></td>"$i, ($i/$theNumSteps) * 100$theVal$theVal);
        
    printf("$theTDTag$theFC1Tag%06X</font></td>$theTDTag$theFC1Tag%d</font></td>$theTDARTag$theFC1Tag%d%%</font></td>$theTDARTag$theFC1Tag%d</font></td></tr>\n"$theVal$theVal, ($i/$theNumSteps) * 100$i);
      }
      echo 
    "</table>\n";
    ?>
    Keine Ahnung mehr von wo ich das kopiert habe aber dieses Script erstellt einfach nur Farbverläufe.

    Was ich brauche:
    Das die HEX Werte der Farben einfach in folgendem Format im Body ALS KLARTEXT ausgegeben werden:

    colors = ["#hexwert1", "#hexwert2", "#hexwert3", usw];



    Hab da jz glaub ich 20 Minuten herumgeschissen und kriegs nicht hin lol..
    Wäre sehr nett wenn mir das schnell wer machen könnte

    MfG

    //Edit: Hat sich erdledigt!
    Geändert von exception (13.10.2013 um 22:21 Uhr)
    Ich will Geld haben und zwar so viel, das ich auch mal sagen kann das es Wichtigeres gibt...

Ähnliche Themen

  1. 31 km/h zu schnell auf der Autbahn....
    Von DnL im Forum Fahrzeuge
    Antworten: 10
    Letzter Beitrag: 27.08.2012, 10:46
  2. Schnell 9 Proxyips!
    Von Generous im Forum Internet und Technik
    Antworten: 5
    Letzter Beitrag: 01.05.2012, 11:54
  3. Schnell abnehmen, wie!?
    Von ZneeD im Forum Sport & Gesundheit
    Antworten: 13
    Letzter Beitrag: 25.04.2012, 21:20
  4. [Shell Script]Upload Script (7z & ncftp)
    Von Sq252 im Forum Showroom
    Antworten: 0
    Letzter Beitrag: 08.01.2012, 18:12
Diese Seite nutzt Cookies, um das Nutzererlebnis zu verbessern. Klicken Sie hier, um das Cookie-Tracking zu deaktivieren.