From 5b64db0aa0e39e773f50858bc61e7d64247cd08a Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 15 Sep 2016 13:18:36 +0100 Subject: [PATCH] revise example --- whatsnew.md => whatsnew-8.4.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) rename whatsnew.md => whatsnew-8.4.md (89%) diff --git a/whatsnew.md b/whatsnew-8.4.md similarity index 89% rename from whatsnew.md rename to whatsnew-8.4.md index 7f5d9113..72d534be 100644 --- a/whatsnew.md +++ b/whatsnew-8.4.md @@ -7,7 +7,8 @@ make Perlin and Worley noise. They are useful for generating synthetic random textures. The implementations in vips can generate images of any size very quickly. -Here's an example of a marble texture simulated with a Perlin noise generator. +Here's an example of a marble texture simulated with a Perlin noise generator +using the Ruby libvips binding. ``` #!/usr/bin/ruby @@ -29,25 +30,25 @@ def turbulence(size) layers.reduce(:+) end -# make a gradient colour map ... a smooth fade from start to stop, with start and -# stop as CIELAB colours, the output map as sRGB +# make a 256 element colour map: a linear fade from start to stop, with +# start and stop as CIELAB colours, the output map as sRGB def gradient(start, stop) lut = Vips::Image.identity / 255 lut = lut * start + (lut * -1 + 1) * stop lut.colourspace(:srgb, :source_space => :lab) end -# make a turbulent stripe pattern -stripe = (Vips::Image.xyz(size, size)[0] * 360 * 4 / size + turbulence(size) * 700).sin +# an image where the pixel value is 0 .. 4 * 360 across +angles = Vips::Image.xyz(size, size)[0] * 360 * 4 / size -# make a colour map ... we want a smooth gradient from white to dark brown -# colours here in CIELAB +# make a turbulent stripe pattern using 0 .. 255 +stripe = ((angles + turbulence(size) * 700).sin + 1) * 128 + +# make a colour map (a smooth gradient from white to dark brown) then map +# our turbulent image through it dark_brown = [7.45, 4.3, 8] white = [100, 0, 0] -lut = gradient(dark_brown, white) - -# rescale to 0 - 255 and colour with our lut -stripe = ((stripe + 1) * 128).maplut(lut) +stripe = stripe.maplut(gradient(dark_brown, white)) stripe.write_to_file ARGV[0] ```