Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkPerlinNoiseShader.h
Go to the documentation of this file.
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
13#include "include/core/SkShader.h" // IWYU pragma: keep
15
16struct 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*/
30namespace 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 */
45SK_API sk_sp<SkShader> MakeFractalNoise(SkScalar baseFrequencyX, SkScalar baseFrequencyY,
46 int numOctaves, SkScalar seed,
47 const SkISize* tileSize = nullptr);
48SK_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
#define SK_API
Definition SkAPI.h:35
float SkScalar
Definition extension.cpp:12
SK_API sk_sp< SkShader > MakeTurbulence(SkScalar baseFrequencyX, SkScalar baseFrequencyY, int numOctaves, SkScalar seed, const SkISize *tileSize=nullptr)
SK_API sk_sp< SkShader > MakeFractalNoise(SkScalar baseFrequencyX, SkScalar baseFrequencyY, int numOctaves, SkScalar seed, const SkISize *tileSize=nullptr)