Skip to content

Instantly share code, notes, and snippets.

@pedrorocha-net
Created April 24, 2018 02:01
Show Gist options
  • Save pedrorocha-net/6d566e3edc5d42a11199c7510df64d7e to your computer and use it in GitHub Desktop.
Save pedrorocha-net/6d566e3edc5d42a11199c7510df64d7e to your computer and use it in GitHub Desktop.
PHP file to randomly generate a color palette
<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