iwmlib/lib/pixi/scatter-resolution-2.html

139 lines
5.4 KiB
HTML
Raw Normal View History

2022-05-04 15:18:11 +02:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PIXI Scatter Resolution Doctest</title>
<link rel="stylesheet" href="../3rdparty/highlight/styles/default.css" />
<link rel="stylesheet" href="../../css/doctest.css" />
2022-05-04 15:18:11 +02:00
<script src="../../dist/iwmlib.3rdparty.js"></script>
<script src="../../dist/iwmlib.js"></script>
<script src="../../dist/iwmlib.pixi.js"></script>
</head>
<body>
<h1><a href="../index.html">lib.</a><a href="index.html">pixi.</a>Scatter Resolution</h1>
2022-05-05 12:29:27 +02:00
<canvas id="canvas" />
2022-05-04 15:18:11 +02:00
<script>
2022-05-05 12:29:27 +02:00
const app = new PIXIApp({
view: canvas,
roundPixels: true,
resolution: 2
})
.setup()
.run()
app.loadSprites(
[
'../examples/front__1_dpi75.png',
'../examples/front__1_dpi150.png',
'../examples/front__1_dpi300.png',
'../examples/front__1_dpi600.png',
'../examples/front__1_dpi1200.png'
],
(sprites) => {
2022-05-05 12:29:27 +02:00
app.scatterContainerFront = new ScatterContainer(app.renderer, { app })
app.scatterContainerBack = new ScatterContainer(app.renderer, { app })
app.scene.addChild(app.scatterContainerBack)
app.scene.addChild(app.scatterContainerFront)
2022-05-04 15:18:11 +02:00
let startScale = 0.5
2022-05-05 12:29:27 +02:00
// sprite1
//--------------------
let sprite1 = sprites.get('../examples/front__1_dpi75.png')
2022-05-04 15:18:11 +02:00
sprite1.interactive = true
2022-05-05 12:29:27 +02:00
let scatter1 = new DisplayObjectScatter(sprite1, app.renderer, {
2022-05-04 15:18:11 +02:00
x: 20,
y: 20,
startScale,
minScale: 0.01,
maxScale: 5.0
})
2022-05-05 12:29:27 +02:00
app.scatterContainerBack.addChild(sprite1)
2022-05-04 15:18:11 +02:00
2022-05-05 12:29:27 +02:00
// sprite2
//--------------------
let sprite2 = sprites.get('../examples/front__1_dpi150.png')
2022-05-04 15:18:11 +02:00
sprite2.interactive = true
2022-05-05 12:29:27 +02:00
let scatter2 = new DisplayObjectScatter(sprite2, app.renderer, {
2022-05-04 15:18:11 +02:00
x: 320,
y: 20,
startScale: 0.5 * startScale,
minScale: 0.01,
maxScale: 5.0
})
2022-05-05 12:29:27 +02:00
app.scatterContainerFront.addChild(sprite2)
2022-05-04 15:18:11 +02:00
2022-05-05 12:29:27 +02:00
// sprite3
//--------------------
let sprite3 = sprites.get('../examples/front__1_dpi300.png')
2022-05-04 15:18:11 +02:00
sprite3.interactive = true
2022-05-05 12:29:27 +02:00
let scatter3 = new DisplayObjectScatter(sprite3, app.renderer, {
2022-05-04 15:18:11 +02:00
x: 620,
y: 20,
startScale: 0.25 * startScale,
minScale: 0.01,
maxScale: 5.0
})
2022-05-05 12:29:27 +02:00
app.scatterContainerBack.addChild(sprite3)
2022-05-04 15:18:11 +02:00
2022-05-05 12:29:27 +02:00
// sprite4
//--------------------
let sprite4 = sprites.get('../examples/front__1_dpi600.png')
2022-05-04 15:18:11 +02:00
sprite4.interactive = true
2022-05-05 12:29:27 +02:00
let scatter4 = new DisplayObjectScatter(sprite4, app.renderer, {
2022-05-04 15:18:11 +02:00
x: 920,
y: 20,
startScale: 0.125 * startScale,
minScale: 0.01,
maxScale: 5.0
})
2022-05-05 12:29:27 +02:00
app.scatterContainerFront.addChild(sprite4)
2022-05-04 15:18:11 +02:00
2022-05-05 12:29:27 +02:00
// sprite5
//--------------------
let sprite5 = sprites.get('../examples/front__1_dpi1200.png')
2022-05-04 15:18:11 +02:00
sprite5.interactive = true
2022-05-05 12:29:27 +02:00
let scatter5 = new DisplayObjectScatter(sprite5, app.renderer, {
2022-05-04 15:18:11 +02:00
x: 1220,
y: 20,
startScale: 0.0625 * startScale,
minScale: 0.01,
maxScale: 5.0
})
2022-05-05 12:29:27 +02:00
app.scatterContainerFront.addChild(sprite5)
2022-05-04 15:18:11 +02:00
2022-05-05 12:29:27 +02:00
// renderTexture
//--------------------
sprites.forEach((value) => {
2022-05-05 12:29:27 +02:00
const matrix = new PIXI.Matrix()
matrix.translate(-value.x, -value.y)
const texture = PIXI.RenderTexture.create({
width: value.width,
height: value.height,
resolution: 2
})
2022-05-05 12:29:27 +02:00
app.renderer.render(value, texture, true, matrix)
const sprite = new PIXI.Sprite(texture)
sprite.interactive = true
new DisplayObjectScatter(sprite, app.renderer, {
x: value.x,
y: 400,
minScale: 0.01,
maxScale: 5.0
})
app.scatterContainerFront.addChild(sprite)
})
},
{ resolutionDependent: false }
)
2022-05-04 15:18:11 +02:00
</script>
</body>
</html>