Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to return a color-value based a date and random?
    primarykey
    data
    text
    <p>The designer came up with a rather weird idea or a color-wheel (with 36 colors).</p> <p><strong>I need to write a function that is returning <code>one</code> color but based on the <code>date</code>.</strong></p> <blockquote> <p><strong>How the website should work</strong><br> Based on the current date (you see german dates on the image underneath) the site should have this background color. </p> </blockquote> <p>So on "January 1st" the first color (blueviolet or what you might call that) should be the background of the frontpage. 10 days later the next color. So within one year all 36 colors should be looped through in the order of the wheel.</p> <p>I guess untill that point an intermediate programmer could help me with this, I don't know how to do that.</p> <p><img src="https://i.stack.imgur.com/r4DdG.jpg" alt=""></p> <p><strong>But it gets slightly more complicated</strong><br> The designer wants every page of the website to be in a different color also. So imagine the site has like 10 pages (Home, About, Whatever, Gallery) every page should have one of the "closest" 10 colors.</p> <p><em>Wow, even I don't unterstand it when explainig it.</em></p> <p>So what I want to do is create a function that is returning a <em>random color</em> out of a <em>pool of 10 colors</em> that are based on the <em>current date</em>.</p> <p>So on "January 1st" I want the following the colors to be pushed in an array and return one of those colors randomly.</p> <pre><code>function colorWheel($alpha) { // 36 colors $colors = array( rgba(170, 207, 172, 1), rgba(180, 211, 164, 1), rgba(189, 214, 145, 1), rgba(196, 217, 134, 1), rgba(206, 222, 124, 1), rgba(214, 226, 124, 1), rgba(226, 233, 124, 1), rgba(234, 235, 122, 1), rgba(236, 235, 120, 1), rgba(241, 231, 118, 1), rgba(240, 224, 118, 1), rgba(240, 216, 117, 1), rgba(237, 208, 115, 1), rgba(233, 199, 112, 1), rgba(230, 191, 110, 1), rgba(226, 177, 115, 1), rgba(221, 162, 110, 1), rgba(218, 153, 116, 1), rgba(215, 141, 112, 1), rgba(209, 140, 120, 1), rgba(203, 138, 119, 1), rgba(197, 136, 126, 1), rgba(191, 138, 134, 1), rgba(186, 142, 144, 1), rgba(181, 145, 157, 1), rgba(176, 151, 170, 1), rgba(170, 135, 178, 1), rgba(164, 159, 189, 1), rgba(166, 167, 194, 1), rgba(166, 177, 201, 1), rgba(166, 182, 204, 1), rgba(163, 186, 201, 1), rgba(164, 190, 196, 1), rgba(166, 196, 191, 1), rgba(167, 198, 185, 1), rgba(168, 201, 178, 1), ); } </code></pre> <p>Any idea how to do so?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload