-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.html
102 lines (94 loc) · 3.58 KB
/
ui.html
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
<!DOCTYPE html>
<html>
<head>
<title>Design2Mc</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: #f0f0f0;
}
pre {
background-color: #2d2d2d;
color: #ffffff;
padding: 15px;
border-radius: 8px;
overflow-x: auto;
font-family: 'Courier New', Courier, monospace;
position: relative;
}
button.copy-button {
position: absolute;
top: 10px;
right: 10px;
background-color: #4caf50;
color: #ffffff;
border: none;
padding: 5px 10px;
border-radius: 5px;
cursor: pointer;
font-size: 12px;
}
button.copy-button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<pre id="code-block">
<button class="copy-button" onclick="copyCode()">Copy</button>
</pre>
<p1>1.21 Helper Methods</p1>
<pre id="method-block">
public static void drawRoundedRect(DrawContext context, double fromX, double fromY, double toX, double toY, double rad, Color c) {
MatrixStack matrices = context.getMatrices();
int color = c.getRGB();
Matrix4f matrix = matrices.peek().getPositionMatrix();
float f = (float) (color >> 24 & 255) / 255.0F;
float g = (float) (color >> 16 & 255) / 255.0F;
float h = (float) (color >> 8 & 255) / 255.0F;
float k = (float) (color & 255) / 255.0F;
RenderSystem.enableBlend();
RenderSystem.setShader(GameRenderer::getPositionColorProgram);
renderRoundedQuadInternal(matrix, g, h, k, f, fromX, fromY, toX, toY, rad, 20);
RenderSystem.disableBlend();
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
}
public static void renderRoundedQuadInternal(Matrix4f matrix, float cr, float cg, float cb, float ca, double fromX, double fromY, double toX, double toY, double rad, double samples) {
// field_27381 = TRIANGLE_FAN
BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.field_27381, VertexFormats.POSITION_COLOR);
double toX1 = toX - rad;
double toY1 = toY - rad;
double fromX1 = fromX + rad;
double fromY1 = fromY + rad;
double[][] map = new double[][]{new double[]{toX1, toY1}, new double[]{toX1, fromY1}, new double[]{fromX1, fromY1}, new double[]{fromX1, toY1}};
for (int i = 0; i < 4; i++) {
double[] current = map[i];
for (double r = i * 90d; r < (360 / 4d + i * 90d); r += (90 / samples)) {
float rad1 = (float) Math.toRadians(r);
float sin = (float) (Math.sin(rad1) * rad);
float cos = (float) (Math.cos(rad1) * rad);
bufferBuilder.vertex(matrix, (float) current[0] + sin, (float) current[1] + cos, 0.0F).color(cr, cg, cb, ca);
}
}
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
}
</pre>
<script>
function copyCode() {
const codeBlock = document.getElementById('code-block');
const code = codeBlock.textContent;
navigator.clipboard.writeText(code).then(() => {
alert('Code copied to clipboard!');
});
}
onmessage = (event) => {
const { type, codeLines } = event.data.pluginMessage;
if (type === 'display-code') {
const codeBlock = document.getElementById('code-block');
codeBlock.textContent = codeLines.join('\n');
}
};
</script>
</body>
</html>