From: mental Date: Tue, 21 Aug 2007 03:46:10 +0000 (+0000) Subject: experimental: add some noise to the gradient function X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9c18d225f0a9a7bdb34edf2c00532edc7ff8af38;p=inkscape.git experimental: add some noise to the gradient function --- diff --git a/src/libnr/nr-gradient.cpp b/src/libnr/nr-gradient.cpp index d4ce764c1..cd771e7de 100644 --- a/src/libnr/nr-gradient.cpp +++ b/src/libnr/nr-gradient.cpp @@ -20,6 +20,8 @@ #include #include #include +#include +#include /* Common */ @@ -28,6 +30,15 @@ #define NRG_MASK (NR_GRADIENT_VECTOR_LENGTH - 1) #define NRG_2MASK ((long long) ((NR_GRADIENT_VECTOR_LENGTH << 1) - 1)) +static guint32 msr_state=0xfefefefe; + +inline guint32 msr_next() { + guint32 lsb = msr_state & 1; + guint32 msb = ( lsb << 31 ) ^ ( ( msr_state & 2) << 30 ); + msr_state = ( msr_state >> 1 ) | msb; + return lsb; +} + inline unsigned char const *index_to_pointer(int idx, unsigned char const *vector) { @@ -37,18 +48,21 @@ inline unsigned char const *index_to_pointer(int idx, inline unsigned char const *r_to_pointer_pad(NR::Coord r, unsigned char const *vector) { + r += msr_next(); return index_to_pointer((int)CLAMP(r, 0, (double)(NR_GRADIENT_VECTOR_LENGTH - 1)), vector); } inline unsigned char const *r_to_pointer_repeat(NR::Coord r, unsigned char const *vector) { + r += msr_next(); return index_to_pointer((int)((long long)r & NRG_MASK), vector); } inline unsigned char const *r_to_pointer_reflect(NR::Coord r, unsigned char const *vector) { + r += msr_next(); int idx = (int) ((long long)r & NRG_2MASK); if (idx > NRG_MASK) idx = NRG_2MASK - idx; return index_to_pointer(idx, vector);