Created
April 24, 2018 02:01
-
-
Save pedrorocha-net/6d566e3edc5d42a11199c7510df64d7e to your computer and use it in GitHub Desktop.
PHP file to randomly generate a color palette
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
div { | |
float: left; | |
width: 12.5%; | |
padding: 40px 0; | |
line-height: 30px; | |
text-align: center; | |
color: #fff; | |
font-family: Verdana; | |
} | |
</style> | |
<?php | |
if (isset($_GET['amount'])) { | |
$amount = $_GET['amount']; | |
} else { | |
$amount = 40; | |
} | |
$colors = []; | |
for ($i = 0 ; $i < $amount ; $i++) { | |
$colors[] = [rand(0, 255), rand(0, 255), rand(0, 255)]; | |
} | |
foreach($colors as $color) { | |
$rgba = 'rgba(' . $color[0] . ', ' . $color[1] . ', ' . $color[2] . ', 1)'; | |
print '<div style="background-color:' . $rgba . '">' . $rgba . '</div>'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment