Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, as Scott said, it is possible, but I am not a Rails programmer, so I just wanted to copy and paste the code but first I did not know where to place the Code and then it did not work. I had to play around with the snipped and expanded it to more Flexibility that I had need for:</p> <pre><code>module Sass::Script::Functions module USW_Random ## Create random Color # inspired by: http://victorcoulon.fr/generating-random-color-in-sass/ # def usw_randomColor() Sass::Script::Color.new([rand(255), rand(255), rand(255)]) end ## Create random Number # int max [optional] if max is not supplied a float between 0 and 1 is returned. # if max is supplied, an Integer between 0 and max (both inclusive) will be returned. # int min [optional] if min is supplied too, an Integer between min and max (both inclusive) will be returned. # def usw_random(max=-1, min=0) Sass::Script::Number.new( max.to_i &lt; 0 ? rand() : rand(min.to_i .. max.to_i )) end end include USW_Random end </code></pre> <p>Ths can be used in a SCSS file like this:</p> <pre><code>@debug usw_random(); @debug usw_random(10); @debug usw_random(8, 2); @debug usw_randomColor(); </code></pre> <p>and will printout:</p> <pre><code>xxx.scss:25 DEBUG: 0.42782 xxx.scss:26 DEBUG: 3 xxx.scss:27 DEBUG: 5 xxx.scss:28 DEBUG: #e7c00b </code></pre> <p>I also did not know where to put the Code for this. I use SASS within compass framework. You can place this Code directly into your Compass Config.rb file.</p> <p>Or you put it in another file and only put this line into your Compass Config.rb file:</p> <pre><code>## my "own" ruby functions. require "../SASS/RUBY/at.usw.rb" </code></pre>
    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.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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