Debian Codegraph @

include/effects/SkPerlinNoiseShader.h

raw
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkPerlinNoiseShader_DEFINED
9 #define SkPerlinNoiseShader_DEFINED
10
11 #include "include/core/SkRefCnt.h"
12 #include "include/core/SkScalar.h"
13 #include "include/core/SkShader.h" // IWYU pragma: keep
14 #include "include/private/base/SkAPI.h"
15
16 struct SkISize;
17
18 /** \class SkPerlinNoiseShader
19
20 SkPerlinNoiseShader creates an image using the Perlin turbulence function.
21
22 It can produce tileable noise if asked to stitch tiles and provided a tile size.
23 In order to fill a large area with repeating noise, set the stitchTiles flag to
24 true, and render exactly a single tile of noise. Without this flag, the result
25 will contain visible seams between tiles.
26
27 The algorithm used is described here :
28 http://www.w3.org/TR/SVG/filters.html#feTurbulenceElement
29 */
30 namespace SkShaders {
31 /**
32 * This will construct Perlin noise of the given type (Fractal Noise or Turbulence).
33 *
34 * Both base frequencies (X and Y) have a usual range of (0..1) and must be non-negative.
35 *
36 * The number of octaves provided should be fairly small, with a limit of 255 enforced.
37 * Each octave doubles the frequency, so 10 octaves would produce noise from
38 * baseFrequency * 1, * 2, * 4, ..., * 512, which quickly yields insignificantly small
39 * periods and resembles regular unstructured noise rather than Perlin noise.
40 *
41 * If tileSize isn't NULL or an empty size, the tileSize parameter will be used to modify
42 * the frequencies so that the noise will be tileable for the given tile size. If tileSize
43 * is NULL or an empty size, the frequencies will be used as is without modification.
44 */
45 SK_API sk_sp<SkShader> MakeFractalNoise(SkScalar baseFrequencyX, SkScalar baseFrequencyY,
46 int numOctaves, SkScalar seed,
47 const SkISize* tileSize = nullptr);
48 SK_API sk_sp<SkShader> MakeTurbulence(SkScalar baseFrequencyX, SkScalar baseFrequencyY,
49 int numOctaves, SkScalar seed,
50 const SkISize* tileSize = nullptr);
51 } // namespace SkShaders
52
53 #endif