iwmlib/lib/pixi/blurfilter.html

51 lines
1.8 KiB
HTML
Raw Normal View History

2019-03-21 09:57:27 +01:00
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>PIXI BlurFilter</title>
2019-05-22 16:03:19 +02:00
<link rel="stylesheet" href=".././3rdparty/highlight/styles/default.css">
2019-03-21 09:57:27 +01:00
<link rel="stylesheet" href="../../css/doctest.css">
2019-05-22 16:03:19 +02:00
<script src=".././3rdparty/highlight/highlight.pack.js"></script>
<script src="../../dist/iwmlib.3rdparty.js"></script>
2019-03-21 09:57:27 +01:00
2019-05-22 16:03:19 +02:00
<script src="../../dist/iwmlib.js"></script>
<script src="../../dist/iwmlib.pixi.js"></script>
2019-03-21 09:57:27 +01:00
</head>
<body onload="Doctest.run()">
<h1>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()
// Load a video and add it to the scene
const videoSprite = new PIXI.Sprite(PIXI.Texture.fromVideo("assets/blurfilter.mp4"))
videoSprite.width = app.size.width
videoSprite.height = app.size.height
app.scene.addChild(videoSprite)
// 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>