Feature request #12482

Add random function with seed to expressions

Added by Olivier Dalang over 9 years ago. Updated over 7 years ago.

Status:Open
Priority:Normal
Assignee:-
Category:Expressions
Pull Request or Patch supplied:No Resolution:
Easy fix?:No Copied to github as #:20630

Description

Hi !

When using data defined values, it's hard to use the rand() function, because a new random number is generated all the time.

A symbol with this as polygon fill color:
color_hsl(rand(0,360),100,50)
will be changing color at each redraw, making the map look like a disco party (not saying it's not nice ;) ).

Why not add another random function where one could specify a seed, so that the random number is always the same. Typically, one would use the feature's ID as the seed.
color_hsl(rand_seed($id,0,360),100,50)
This way, the random color would always be the same, hopefully even across different setups.

Thanks !

Olivier

History

#1 Updated by Nyall Dawson over 9 years ago

fYI the expressions+ plugin has a quasirand function which allows this.

#2 Updated by Olivier Dalang over 9 years ago

Oh that's very cool, didn't know about this. So it's about moving this to core ;)

#3 Updated by Giovanni Manghi over 7 years ago

  • Easy fix? set to No

Also available in: Atom PDF