-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
180 lines (167 loc) · 5.77 KB
/
test.html
File metadata and controls
180 lines (167 loc) · 5.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PIE Extension Test - Pixi.js Demo</title>
<style>
body {
margin: 0;
padding: 20px;
font-family: Arial, sans-serif;
background: #2c3e50;
}
#info {
color: white;
background: rgba(0, 0, 0, 0.7);
padding: 15px;
border-radius: 5px;
margin-bottom: 10px;
max-width: 800px;
}
#info h2 {
margin-top: 0;
}
#info code {
background: rgba(255, 255, 255, 0.1);
padding: 2px 6px;
border-radius: 3px;
}
#info ul {
margin: 10px 0;
}
#info li {
margin: 5px 0;
}
canvas {
border: 2px solid #34495e;
display: block;
background: white;
}
</style>
</head>
<body>
<div id="info">
<h2>🍰 PIE Extension Test Page</h2>
<p>This page contains a simple Pixi.js application. Use the PIE extension to edit the objects:</p>
<ul>
<li><code>E</code> + mouse - Scale object (hold Shift for uniform scaling)</li>
<li><code>W</code> + mouse - Move object</li>
<li><code>Q</code> + mouse - Rotate object</li>
<li><code>V</code> - Toggle visibility</li>
<li><code>F</code> - Select next item</li>
<li><code>D</code> - Select previous item</li>
<li><code>Space</code> - Log active item (Shift+Space for all items)</li>
</ul>
<p><strong>🔧 Pixi DevTools Integration:</strong> Select any object in <a href="https://pixijs.io/devtools/" target="_blank" style="color: #3498db;">Pixi DevTools</a> (available as <code>$pixi</code> in console) and PIE will automatically switch to editing it!</p>
<p><strong>Note:</strong> Make sure the PIE extension is loaded in Chrome!</p>
</div>
<script src="https://cdn.jsdelivr.net/npm/pixi.js@7.x/dist/pixi.min.js"></script>
<script>
// Create the Pixi application
const app = new PIXI.Application({
width: 800,
height: 600,
backgroundColor: 0xecf0f1,
antialias: true
});
document.body.appendChild(app.view);
// Make PIXI globally accessible for PIE extension
window.$pixi = app.stage;
// Hooks for Pixi DevTools
window.__PIXI_APP__ = app;
window.__PIXI_STAGE__ = app.stage;
window.PIXI = PIXI;
// Enable devtools
if (window.__PIXI_DEVTOOLS__) {
window.__PIXI_DEVTOOLS__ = {
app
};
}
// Dispatch custom event for devtools detection
window.dispatchEvent(new CustomEvent('__PIXI_APP_INIT__', { detail: { app } }));
// Create a red circle
const circle = new PIXI.Graphics();
circle.beginFill(0xe74c3c);
circle.drawCircle(0, 0, 50);
circle.endFill();
circle.x = 150;
circle.y = 150;
circle.interactive = true;
app.stage.addChild(circle);
// Create a blue rectangle
const rectangle = new PIXI.Graphics();
rectangle.beginFill(0x3498db);
rectangle.drawRect(0, 0, 100, 80);
rectangle.endFill();
rectangle.x = 350;
rectangle.y = 200;
rectangle.interactive = true;
app.stage.addChild(rectangle);
// Create a green star
const star = new PIXI.Graphics();
star.beginFill(0x2ecc71);
const points = 5;
const outerRadius = 60;
const innerRadius = 30;
star.moveTo(0, -outerRadius);
for (let i = 0; i < points * 2; i++) {
const radius = i % 2 === 0 ? outerRadius : innerRadius;
const angle = (Math.PI / points) * i - Math.PI / 2;
star.lineTo(Math.cos(angle) * radius, Math.sin(angle) * radius);
}
star.endFill();
star.x = 600;
star.y = 150;
star.interactive = true;
app.stage.addChild(star);
// Create text
const text = new PIXI.Text('Hello PIE!', {
fontFamily: 'Arial',
fontSize: 48,
fill: 0x9b59b6,
fontWeight: 'bold'
});
text.x = 250;
text.y = 400;
text.anchor.set(0.5);
text.interactive = true;
app.stage.addChild(text);
// Create a sprite with a simple texture
const sprite = new PIXI.Graphics();
sprite.beginFill(0xf39c12);
sprite.drawPolygon([
0, -40,
40, 0,
0, 40,
-40, 0
]);
sprite.endFill();
sprite.x = 150;
sprite.y = 450;
sprite.interactive = true;
app.stage.addChild(sprite);
// Register all objects with PIE extension
// Wait a bit for the extension to load
setTimeout(() => {
if (window.___PIE___) {
window.___PIE___.ADD(circle);
window.___PIE___.ADD(rectangle);
window.___PIE___.ADD(star);
window.___PIE___.ADD(text);
window.___PIE___.ADD(sprite);
console.log('✓ PIE Extension detected! All objects registered.');
console.log('✓ Use F/D keys to cycle through objects.');
} else {
console.warn('⚠ PIE Extension not detected. Make sure it is loaded in Chrome!');
}
}, 1000);
// Add simple animation
app.ticker.add(() => {
// Gentle rotation animation
circle.rotation += 0.01;
star.rotation -= 0.01;
});
</script>
</body>
</html>