iwmlib/lib/pixi/blurfilter.html

52 lines
2.2 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html>
2019-03-21 09:57:27 +01:00
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
2019-03-21 09:57:27 +01:00
<title>PIXI BlurFilter</title>
2019-03-21 09:57:27 +01:00
<link rel="stylesheet" href=".././3rdparty/highlight/styles/default.css" />
<link rel="stylesheet" href="../../css/doctest.css" />
2019-03-21 09:57:27 +01:00
<script src=".././3rdparty/highlight/highlight.pack.js"></script>
<script src="../../dist/iwmlib.3rdparty.js"></script>
2019-03-21 09:57:27 +01:00
<script src="../../dist/iwmlib.js"></script>
<script src="../../dist/iwmlib.pixi.js"></script>
</head>
<body onload="Doctest.run()">
<h1><a href="../index.html">lib.</a><a href="index.html">pixi.</a>BlurFilter</h1>
<p>
The BlurFilter class creates a blur filter on the renderer. In contrast to the PIXI BlurFilter, you can
specify a range (defined as a PIXI.Rectangle) on which the filter should be applied.
</p>
<h2>Example with Image</h2>
<p>Let's look at an example of creating a new blur filter near the bottom:</p>
<canvas id="canvas" class="interactive"></canvas>
<p>What you should see: A sniffing hedgehog and three blurred areas (with different strengths of blur).</p>
<script class="doctest">
// Create the app
const app = new PIXIApp({
view: canvas,
width: 480,
height: 270,
transparent: false
})
.setup()
.run()
2019-03-21 09:57:27 +01:00
// Load a video and add it to the scene
const videoSprite = new PIXI.Sprite(PIXI.Texture.from('assets/blurfilter.mp4'))
videoSprite.width = app.size.width
videoSprite.height = app.size.height
app.scene.addChild(videoSprite)
2019-03-21 09:57:27 +01:00
// Create three filters and assign them to the scene
const blurFilter1 = new BlurFilter(new PIXI.Rectangle(40, 40, 120, 80))
const blurFilter2 = new BlurFilter(new PIXI.Circle(240, 140, 60), 150)
const blurFilter3 = new BlurFilter(new PIXI.Rectangle(380, 40, 100, 100), 20)
app.scene.filters = [blurFilter1, blurFilter2, blurFilter3]
</script>
</body>
</html>