@rian8337/osu-strain-graph-generator 4.0.0-beta.102 → 4.0.0-beta.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +375 -0
- package/dist/index.d.cts +45 -0
- package/dist/index.d.mts +45 -0
- package/dist/index.mjs +375 -0
- package/package.json +29 -13
- package/dist/index.js +0 -452
- package/typings/index.d.ts +0 -49
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
let _rian8337_osu_base = require("@rian8337/osu-base");
|
|
2
|
+
let canvas = require("canvas");
|
|
3
|
+
// src/Chart.ts
|
|
4
|
+
/**
|
|
5
|
+
* Utility to draw a graph with only node-canvas.
|
|
6
|
+
*
|
|
7
|
+
* Used for creating strain graph of beatmaps.
|
|
8
|
+
*/
|
|
9
|
+
var Chart = class {
|
|
10
|
+
/**
|
|
11
|
+
* The canvas instance of this chart.
|
|
12
|
+
*/
|
|
13
|
+
canvas;
|
|
14
|
+
/**
|
|
15
|
+
* The 2D rendering surface for the drawing surface of this chart.
|
|
16
|
+
*/
|
|
17
|
+
context;
|
|
18
|
+
graphWidth;
|
|
19
|
+
graphHeight;
|
|
20
|
+
minX;
|
|
21
|
+
minY;
|
|
22
|
+
maxX;
|
|
23
|
+
maxY;
|
|
24
|
+
unitsPerTickX;
|
|
25
|
+
unitsPerTickY;
|
|
26
|
+
background;
|
|
27
|
+
xLabel;
|
|
28
|
+
yLabel;
|
|
29
|
+
xValueType;
|
|
30
|
+
yValueType;
|
|
31
|
+
pointRadius;
|
|
32
|
+
padding = 10;
|
|
33
|
+
tickSize = 10;
|
|
34
|
+
axisColor = "#424242";
|
|
35
|
+
font = "12pt Calibri";
|
|
36
|
+
axisLabelFont = "bold 11pt Calibri";
|
|
37
|
+
fontHeight = 12;
|
|
38
|
+
baseLabelOffset = 15;
|
|
39
|
+
rangeX;
|
|
40
|
+
rangeY;
|
|
41
|
+
numXTicks;
|
|
42
|
+
numYTicks;
|
|
43
|
+
x;
|
|
44
|
+
y;
|
|
45
|
+
width;
|
|
46
|
+
height;
|
|
47
|
+
scaleX;
|
|
48
|
+
scaleY;
|
|
49
|
+
/**
|
|
50
|
+
* @param values Initializer options for the graph.
|
|
51
|
+
*/
|
|
52
|
+
constructor(values) {
|
|
53
|
+
this.graphWidth = values.graphWidth;
|
|
54
|
+
this.graphHeight = values.graphHeight;
|
|
55
|
+
this.canvas = (0, canvas.createCanvas)(this.graphWidth, this.graphHeight);
|
|
56
|
+
this.context = this.canvas.getContext("2d");
|
|
57
|
+
this.minX = values.minX;
|
|
58
|
+
this.minY = values.minY;
|
|
59
|
+
this.maxX = values.maxX;
|
|
60
|
+
this.maxY = values.maxY;
|
|
61
|
+
this.unitsPerTickX = values.unitsPerTickX;
|
|
62
|
+
this.unitsPerTickY = values.unitsPerTickY;
|
|
63
|
+
this.background = values.background;
|
|
64
|
+
this.xLabel = values.xLabel;
|
|
65
|
+
this.yLabel = values.yLabel;
|
|
66
|
+
this.xValueType = values.xValueType;
|
|
67
|
+
this.yValueType = values.yValueType;
|
|
68
|
+
this.pointRadius = Math.max(0, values.pointRadius ?? 1);
|
|
69
|
+
this.rangeX = this.maxX - this.minX;
|
|
70
|
+
this.rangeY = this.maxY - this.minY;
|
|
71
|
+
this.numXTicks = Math.round(this.rangeX / this.unitsPerTickX);
|
|
72
|
+
this.numYTicks = Math.round(this.rangeY / this.unitsPerTickY);
|
|
73
|
+
this.x = this.getLongestValueWidth() + this.padding * 2;
|
|
74
|
+
this.y = this.padding * 2;
|
|
75
|
+
this.width = this.canvas.width - this.x - this.padding * 2;
|
|
76
|
+
this.height = this.canvas.height - this.y - this.padding - this.fontHeight;
|
|
77
|
+
this.scaleX = (this.width - (this.xLabel ? this.baseLabelOffset : 0)) / this.rangeX;
|
|
78
|
+
this.scaleY = (this.height - (this.yLabel ? this.baseLabelOffset : 0)) / this.rangeY;
|
|
79
|
+
this.setBackground();
|
|
80
|
+
if (this.xLabel !== void 0) this.drawXAxis();
|
|
81
|
+
if (this.yLabel !== void 0) this.drawYAxis();
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Draws a line graph with specified data, color, and line width.
|
|
85
|
+
*
|
|
86
|
+
* @param data The data to make the graph.
|
|
87
|
+
* @param color The color of the line.
|
|
88
|
+
* @param width The width of the line.
|
|
89
|
+
*/
|
|
90
|
+
drawLine(data, color, width) {
|
|
91
|
+
const c = this.context;
|
|
92
|
+
c.save();
|
|
93
|
+
this.transformContext();
|
|
94
|
+
c.lineWidth = width;
|
|
95
|
+
c.strokeStyle = c.fillStyle = color;
|
|
96
|
+
c.beginPath();
|
|
97
|
+
c.moveTo(data[0].x * this.scaleX, data[0].y * this.scaleY);
|
|
98
|
+
for (const point of data) {
|
|
99
|
+
c.lineTo(point.x * this.scaleX, point.y * this.scaleY);
|
|
100
|
+
c.stroke();
|
|
101
|
+
c.closePath();
|
|
102
|
+
if (this.pointRadius) {
|
|
103
|
+
c.beginPath();
|
|
104
|
+
c.arc(point.x * this.scaleX, point.y * this.scaleY, this.pointRadius, 0, 2 * Math.PI, false);
|
|
105
|
+
c.fill();
|
|
106
|
+
c.closePath();
|
|
107
|
+
}
|
|
108
|
+
c.beginPath();
|
|
109
|
+
c.moveTo(point.x * this.scaleX, point.y * this.scaleY);
|
|
110
|
+
}
|
|
111
|
+
c.restore();
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Draws an area graph with specified data and color.
|
|
115
|
+
*
|
|
116
|
+
* @param data The data to make the graph.
|
|
117
|
+
* @param color The color of the area.
|
|
118
|
+
*/
|
|
119
|
+
drawArea(data, color) {
|
|
120
|
+
const c = this.context;
|
|
121
|
+
c.save();
|
|
122
|
+
this.transformContext();
|
|
123
|
+
c.strokeStyle = c.fillStyle = color;
|
|
124
|
+
c.beginPath();
|
|
125
|
+
data.forEach((d) => {
|
|
126
|
+
c.lineTo(d.x * this.scaleX, d.y * this.scaleY);
|
|
127
|
+
});
|
|
128
|
+
c.stroke();
|
|
129
|
+
c.lineTo(data.at(-1).x * this.scaleX, 0);
|
|
130
|
+
c.lineTo(0, 0);
|
|
131
|
+
c.fill();
|
|
132
|
+
c.restore();
|
|
133
|
+
if (color !== this.axisColor) {
|
|
134
|
+
if (this.xLabel !== void 0) this.drawXAxis();
|
|
135
|
+
if (this.yLabel !== void 0) this.drawYAxis();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Returns a Buffer that represents the graph.
|
|
140
|
+
*/
|
|
141
|
+
getBuffer() {
|
|
142
|
+
return this.canvas.toBuffer();
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Draws the X axis of the graph.
|
|
146
|
+
*/
|
|
147
|
+
drawXAxis() {
|
|
148
|
+
const c = this.context;
|
|
149
|
+
const labelOffset = this.xLabel ? this.baseLabelOffset : 0;
|
|
150
|
+
const yLabelOffset = this.yLabel ? this.baseLabelOffset : 0;
|
|
151
|
+
c.save();
|
|
152
|
+
if (this.xLabel) {
|
|
153
|
+
c.textAlign = "center";
|
|
154
|
+
c.font = this.axisLabelFont;
|
|
155
|
+
c.fillText(this.xLabel, this.x + this.width / 2, this.y + this.height + labelOffset);
|
|
156
|
+
c.restore();
|
|
157
|
+
}
|
|
158
|
+
c.beginPath();
|
|
159
|
+
c.moveTo(this.x + yLabelOffset, this.y + this.height - labelOffset);
|
|
160
|
+
c.lineTo(this.x + this.width, this.y + this.height - labelOffset);
|
|
161
|
+
c.strokeStyle = this.axisColor;
|
|
162
|
+
c.lineWidth = 2;
|
|
163
|
+
c.stroke();
|
|
164
|
+
for (let n = 0; n <= this.numXTicks; ++n) {
|
|
165
|
+
c.beginPath();
|
|
166
|
+
c.moveTo(n * (this.width - yLabelOffset) / this.numXTicks + this.x + yLabelOffset, this.y + this.height - labelOffset);
|
|
167
|
+
c.lineTo(n * (this.width - yLabelOffset) / this.numXTicks + this.x + yLabelOffset, this.y + this.height - labelOffset - this.tickSize);
|
|
168
|
+
c.stroke();
|
|
169
|
+
}
|
|
170
|
+
c.font = this.font;
|
|
171
|
+
c.fillStyle = "black";
|
|
172
|
+
c.textAlign = "center";
|
|
173
|
+
c.textBaseline = "middle";
|
|
174
|
+
if (this.xLabel !== void 0) for (let n = 0; n <= this.numXTicks; ++n) {
|
|
175
|
+
const label = Math.round(n * this.maxX / this.numXTicks);
|
|
176
|
+
let stringLabel = label.toString();
|
|
177
|
+
switch (this.xValueType) {
|
|
178
|
+
case "time": stringLabel = this.timeString(label);
|
|
179
|
+
}
|
|
180
|
+
c.save();
|
|
181
|
+
c.translate(n * (this.width - yLabelOffset) / this.numXTicks + this.x + yLabelOffset, this.y + this.height + this.padding - labelOffset);
|
|
182
|
+
c.fillText(stringLabel, 0, 0);
|
|
183
|
+
c.restore();
|
|
184
|
+
}
|
|
185
|
+
c.restore();
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Draws the Y axis of the graph.
|
|
189
|
+
*
|
|
190
|
+
* @param drawLabel Whether or not to draw the axis label.
|
|
191
|
+
*/
|
|
192
|
+
drawYAxis() {
|
|
193
|
+
const c = this.context;
|
|
194
|
+
const labelOffset = this.yLabel ? this.baseLabelOffset : 0;
|
|
195
|
+
const xLabelOffset = this.xLabel ? this.baseLabelOffset : 0;
|
|
196
|
+
c.save();
|
|
197
|
+
if (this.yLabel) {
|
|
198
|
+
c.textAlign = "center";
|
|
199
|
+
c.font = this.axisLabelFont;
|
|
200
|
+
c.translate(0, this.graphHeight);
|
|
201
|
+
c.rotate(-Math.PI / 2);
|
|
202
|
+
c.fillText(this.yLabel, this.y + xLabelOffset + this.height / 2, this.x - labelOffset * 2.5);
|
|
203
|
+
c.restore();
|
|
204
|
+
}
|
|
205
|
+
c.beginPath();
|
|
206
|
+
c.moveTo(this.x + labelOffset, this.y);
|
|
207
|
+
c.lineTo(this.x + labelOffset, this.y + this.height - xLabelOffset);
|
|
208
|
+
c.strokeStyle = this.axisColor;
|
|
209
|
+
c.lineWidth = 2;
|
|
210
|
+
c.stroke();
|
|
211
|
+
c.restore();
|
|
212
|
+
if (this.yLabel !== void 0) for (let n = 0; n < this.numYTicks; ++n) {
|
|
213
|
+
c.beginPath();
|
|
214
|
+
c.moveTo(this.x + labelOffset, n * (this.height - xLabelOffset) / this.numYTicks + this.y);
|
|
215
|
+
c.lineTo(this.x + labelOffset + this.tickSize, n * (this.height - xLabelOffset) / this.numYTicks + this.y);
|
|
216
|
+
c.stroke();
|
|
217
|
+
}
|
|
218
|
+
c.font = this.font;
|
|
219
|
+
c.fillStyle = "black";
|
|
220
|
+
c.textAlign = "right";
|
|
221
|
+
c.textBaseline = "middle";
|
|
222
|
+
for (let n = 0; n < this.numYTicks; ++n) {
|
|
223
|
+
const value = Math.round(this.maxY - n * this.maxY / this.numYTicks);
|
|
224
|
+
c.save();
|
|
225
|
+
c.translate(this.x + labelOffset - this.padding, n * (this.height - xLabelOffset) / this.numYTicks + this.y);
|
|
226
|
+
c.fillText(value.toString(), 0, 0);
|
|
227
|
+
c.restore();
|
|
228
|
+
}
|
|
229
|
+
c.restore();
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Transforms the context and move it to the center of the graph.
|
|
233
|
+
*/
|
|
234
|
+
transformContext() {
|
|
235
|
+
const c = this.context;
|
|
236
|
+
c.translate(this.x + (this.yLabel ? this.baseLabelOffset : 0), this.y + this.height - (this.xLabel ? this.baseLabelOffset : 0));
|
|
237
|
+
c.scale(1, -1);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Gets the longest width from each label text in Y axis.
|
|
241
|
+
*/
|
|
242
|
+
getLongestValueWidth() {
|
|
243
|
+
if (this.yLabel === void 0) return 0;
|
|
244
|
+
this.context.font = this.font;
|
|
245
|
+
let longestValueWidth = 0;
|
|
246
|
+
for (let n = 0; n < this.numYTicks; ++n) {
|
|
247
|
+
const value = this.maxY - n * this.unitsPerTickY;
|
|
248
|
+
let stringValue = value.toString();
|
|
249
|
+
switch (this.yValueType) {
|
|
250
|
+
case "time": stringValue = this.timeString(value);
|
|
251
|
+
}
|
|
252
|
+
longestValueWidth = Math.max(longestValueWidth, this.context.measureText(stringValue).width);
|
|
253
|
+
}
|
|
254
|
+
return longestValueWidth;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Sets the background of the graph.
|
|
258
|
+
*/
|
|
259
|
+
setBackground() {
|
|
260
|
+
if (!this.background) {
|
|
261
|
+
this.context.globalAlpha = .7;
|
|
262
|
+
this.context.fillStyle = "#ffffff";
|
|
263
|
+
this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);
|
|
264
|
+
this.context.fillStyle = "#000000";
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
this.context.globalAlpha = 1;
|
|
268
|
+
this.context.drawImage(this.background, 0, 0, this.canvas.width, this.canvas.height);
|
|
269
|
+
this.context.globalAlpha = .8;
|
|
270
|
+
this.context.fillStyle = "#bbbbbb";
|
|
271
|
+
this.context.fillRect(0, 0, 900, 250);
|
|
272
|
+
this.context.globalAlpha = 1;
|
|
273
|
+
this.context.fillStyle = "#000000";
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Time string parsing function for axis labels.
|
|
277
|
+
*/
|
|
278
|
+
timeString(seconds) {
|
|
279
|
+
seconds = Math.trunc(seconds);
|
|
280
|
+
const days = Math.floor(seconds / 86400);
|
|
281
|
+
seconds -= days * 86400;
|
|
282
|
+
const hours = Math.floor(seconds / 3600);
|
|
283
|
+
seconds -= hours * 3600;
|
|
284
|
+
const minutes = Math.floor(seconds / 60);
|
|
285
|
+
seconds -= minutes * 60;
|
|
286
|
+
const final = [minutes.toString(), seconds.toString().padStart(2, "0")];
|
|
287
|
+
if (hours > 0) final.unshift(hours.toString());
|
|
288
|
+
if (days > 0) final.unshift(days.toString());
|
|
289
|
+
return final.join(":");
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
// src/index.ts
|
|
293
|
+
/**
|
|
294
|
+
* Creates a sampler function that retrieves the value of the most recent peak at or before a given time.
|
|
295
|
+
*
|
|
296
|
+
* Peaks of different skills can represent sections of different (and possibly variable) lengths, or even
|
|
297
|
+
* one peak per hitobject, so they cannot be assumed to share a common, fixed-width time grid. This walks
|
|
298
|
+
* a single chronologically sorted `peaks` array forward as `time` increases, treating each peak as holding
|
|
299
|
+
* its value until the next peak takes over.
|
|
300
|
+
*
|
|
301
|
+
* @param peaks The peaks to sample from, in chronological order.
|
|
302
|
+
*/
|
|
303
|
+
function createSampler(peaks) {
|
|
304
|
+
let index = -1;
|
|
305
|
+
let value = 0;
|
|
306
|
+
return (time) => {
|
|
307
|
+
while (index + 1 < peaks.length && peaks[index + 1].time <= time) {
|
|
308
|
+
++index;
|
|
309
|
+
value = peaks[index].value;
|
|
310
|
+
}
|
|
311
|
+
return value;
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Generates the strain chart of a beatmap and returns the chart as a buffer.
|
|
316
|
+
*
|
|
317
|
+
* @param beatmap The beatmap to generate the strain graph for.
|
|
318
|
+
* @param strainPeaks The strain peaks of the beatmap.
|
|
319
|
+
* @param clockRate The clock rate of the beatmap.
|
|
320
|
+
* @param options The options for the canvas.
|
|
321
|
+
*/
|
|
322
|
+
async function src_default(beatmap, strainPeaks, clockRate, options) {
|
|
323
|
+
const sectionLength = 400;
|
|
324
|
+
const hasFlashlight = strainPeaks.flashlight.length > 0;
|
|
325
|
+
const timestamps = /* @__PURE__ */ new Set();
|
|
326
|
+
for (const peak of strainPeaks.aimWithSliders) timestamps.add(peak.time);
|
|
327
|
+
for (const peak of strainPeaks.speed) timestamps.add(peak.time);
|
|
328
|
+
for (const peak of strainPeaks.flashlight) timestamps.add(peak.time);
|
|
329
|
+
const sortedTimestamps = [...timestamps].sort((a, b) => a - b);
|
|
330
|
+
const firstObjectStartTime = beatmap.hitObjects.objects[0].startTime / clockRate;
|
|
331
|
+
const sampleAim = createSampler(strainPeaks.aimWithSliders);
|
|
332
|
+
const sampleSpeed = createSampler(strainPeaks.speed);
|
|
333
|
+
const sampleFlashlight = createSampler(strainPeaks.flashlight);
|
|
334
|
+
const strainInformations = new Array(sortedTimestamps.length + 1);
|
|
335
|
+
strainInformations[0] = {
|
|
336
|
+
strain: 0,
|
|
337
|
+
time: (firstObjectStartTime - sectionLength) / 1e3
|
|
338
|
+
};
|
|
339
|
+
for (let i = 0; i < sortedTimestamps.length; ++i) {
|
|
340
|
+
const time = sortedTimestamps[i];
|
|
341
|
+
const aimStrain = sampleAim(time);
|
|
342
|
+
const speedStrain = sampleSpeed(time);
|
|
343
|
+
const flashlightStrain = sampleFlashlight(time);
|
|
344
|
+
strainInformations[i + 1] = {
|
|
345
|
+
time: time / 1e3,
|
|
346
|
+
strain: hasFlashlight ? (aimStrain + speedStrain + flashlightStrain) / 3 : (aimStrain + speedStrain) / 2
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
const maxTime = strainInformations.at(-1)?.time ?? beatmap.hitObjects.objects.at(-1).endTime / 1e3 / clockRate;
|
|
350
|
+
const maxStrain = Math.max(_rian8337_osu_base.MathUtils.max(strainInformations.map((v) => v.strain)), 1);
|
|
351
|
+
const maxXUnits = 10;
|
|
352
|
+
const maxYUnits = 10;
|
|
353
|
+
const unitsPerTickX = Math.ceil(maxTime / maxXUnits / 10) * 10;
|
|
354
|
+
const unitsPerTickY = maxStrain / maxYUnits / 20;
|
|
355
|
+
const chart = new Chart({
|
|
356
|
+
graphWidth: options?.width ?? 600,
|
|
357
|
+
graphHeight: options?.height ?? 150,
|
|
358
|
+
minX: 0,
|
|
359
|
+
minY: 0,
|
|
360
|
+
maxX: Math.ceil(maxTime / unitsPerTickX) * unitsPerTickX,
|
|
361
|
+
maxY: options?.drawStrainAxis ? Math.ceil(maxStrain / Math.ceil(unitsPerTickY) / 20) * Math.ceil(unitsPerTickY) * 20 : maxStrain,
|
|
362
|
+
unitsPerTickX,
|
|
363
|
+
unitsPerTickY: options?.drawStrainAxis ? Math.ceil(unitsPerTickY) * 20 : unitsPerTickY,
|
|
364
|
+
background: options?.beatmapsetID !== void 0 ? await (0, canvas.loadImage)(`https://assets.ppy.sh/beatmaps/${options.beatmapsetID.toString()}/covers/cover.jpg`).catch(() => void 0) : void 0,
|
|
365
|
+
xLabel: options?.showTimeLabel ? "Time" : "",
|
|
366
|
+
yLabel: options?.drawStrainAxis ? options.showStrainLabel ? "Strain" : "" : void 0,
|
|
367
|
+
pointRadius: 0,
|
|
368
|
+
xValueType: "time"
|
|
369
|
+
});
|
|
370
|
+
chart.drawArea(strainInformations.map((v) => new _rian8337_osu_base.Vector2(v.time, v.strain)), options?.color ?? "#000000");
|
|
371
|
+
return chart.getBuffer();
|
|
372
|
+
}
|
|
373
|
+
module.exports = src_default;
|
|
374
|
+
|
|
375
|
+
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Beatmap } from "@rian8337/osu-base";
|
|
2
|
+
import { StrainPeaks } from "@rian8337/osu-difficulty-calculator";
|
|
3
|
+
import { StrainPeaks as StrainPeaks$1 } from "@rian8337/osu-rebalance-difficulty-calculator";
|
|
4
|
+
/**
|
|
5
|
+
* Options for initializing the canvas.
|
|
6
|
+
*/
|
|
7
|
+
export interface CanvasOptions {
|
|
8
|
+
/**
|
|
9
|
+
* The beatmapset ID to get background image from. If omitted, the background will be plain white.
|
|
10
|
+
*/
|
|
11
|
+
readonly beatmapsetID?: number;
|
|
12
|
+
/**
|
|
13
|
+
* The width of the canvas. Defaults to 600.
|
|
14
|
+
*/
|
|
15
|
+
readonly width?: number;
|
|
16
|
+
/**
|
|
17
|
+
* The height of the canvas. Defaults to 150.
|
|
18
|
+
*/
|
|
19
|
+
readonly height?: number;
|
|
20
|
+
/**
|
|
21
|
+
* The color of the graph. Defaults to black.
|
|
22
|
+
*/
|
|
23
|
+
readonly color?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Whether to show the time label. Defaults to `false`.
|
|
26
|
+
*/
|
|
27
|
+
readonly showTimeLabel?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Whether to show the strain axis. Defaults to `false`.
|
|
30
|
+
*/
|
|
31
|
+
readonly drawStrainAxis?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Whether to show the strain label. Only active when `drawStrainAxis` is set to `true`. Defaults to `false`.
|
|
34
|
+
*/
|
|
35
|
+
readonly showStrainLabel?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generates the strain chart of a beatmap and returns the chart as a buffer.
|
|
39
|
+
*
|
|
40
|
+
* @param beatmap The beatmap to generate the strain graph for.
|
|
41
|
+
* @param strainPeaks The strain peaks of the beatmap.
|
|
42
|
+
* @param clockRate The clock rate of the beatmap.
|
|
43
|
+
* @param options The options for the canvas.
|
|
44
|
+
*/
|
|
45
|
+
export default function export_default(beatmap: Beatmap, strainPeaks: StrainPeaks | StrainPeaks$1, clockRate: number, options?: CanvasOptions): Promise<Buffer>;
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Beatmap } from "@rian8337/osu-base";
|
|
2
|
+
import { StrainPeaks } from "@rian8337/osu-difficulty-calculator";
|
|
3
|
+
import { StrainPeaks as StrainPeaks$1 } from "@rian8337/osu-rebalance-difficulty-calculator";
|
|
4
|
+
/**
|
|
5
|
+
* Options for initializing the canvas.
|
|
6
|
+
*/
|
|
7
|
+
export interface CanvasOptions {
|
|
8
|
+
/**
|
|
9
|
+
* The beatmapset ID to get background image from. If omitted, the background will be plain white.
|
|
10
|
+
*/
|
|
11
|
+
readonly beatmapsetID?: number;
|
|
12
|
+
/**
|
|
13
|
+
* The width of the canvas. Defaults to 600.
|
|
14
|
+
*/
|
|
15
|
+
readonly width?: number;
|
|
16
|
+
/**
|
|
17
|
+
* The height of the canvas. Defaults to 150.
|
|
18
|
+
*/
|
|
19
|
+
readonly height?: number;
|
|
20
|
+
/**
|
|
21
|
+
* The color of the graph. Defaults to black.
|
|
22
|
+
*/
|
|
23
|
+
readonly color?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Whether to show the time label. Defaults to `false`.
|
|
26
|
+
*/
|
|
27
|
+
readonly showTimeLabel?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Whether to show the strain axis. Defaults to `false`.
|
|
30
|
+
*/
|
|
31
|
+
readonly drawStrainAxis?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Whether to show the strain label. Only active when `drawStrainAxis` is set to `true`. Defaults to `false`.
|
|
34
|
+
*/
|
|
35
|
+
readonly showStrainLabel?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generates the strain chart of a beatmap and returns the chart as a buffer.
|
|
39
|
+
*
|
|
40
|
+
* @param beatmap The beatmap to generate the strain graph for.
|
|
41
|
+
* @param strainPeaks The strain peaks of the beatmap.
|
|
42
|
+
* @param clockRate The clock rate of the beatmap.
|
|
43
|
+
* @param options The options for the canvas.
|
|
44
|
+
*/
|
|
45
|
+
export default function export_default(beatmap: Beatmap, strainPeaks: StrainPeaks | StrainPeaks$1, clockRate: number, options?: CanvasOptions): Promise<Buffer>;
|