Skip to content

Commit

Permalink
Merge pull request #16 from Master-Bw3/render-dots-near-mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
enjarai authored Jul 8, 2024
2 parents 807637f + 3f5a9a2 commit 7a6c0b5
Showing 1 changed file with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,11 @@ protected void drawGlyph(MatrixStack matrices, VertexConsumerProvider vertexCons

private void drawSide(MatrixStack matrices, VertexConsumerProvider vertexConsumers, SpellPart parent, float x, float y, float size, Function<Float, Float> alphaGetter, Fragment glyph) {
var alpha = alphaGetter.apply(size);
var patternSize = size / PATTERN_TO_PART_RATIO;
var pixelSize = patternSize / PART_PIXEL_RADIUS;

if (glyph instanceof PatternGlyph pattern) {
var patternSize = size / PATTERN_TO_PART_RATIO;
var pixelSize = patternSize / PART_PIXEL_RADIUS;


var isDrawing = inEditor && drawingPartGetter.get() == parent;
var drawingPattern = inEditor ? drawingPatternGetter.get() : null;
Expand Down Expand Up @@ -215,6 +216,35 @@ private void drawSide(MatrixStack matrices, VertexConsumerProvider vertexConsume
);

matrices.pop();

if (inEditor && inUI) {
for (int i = 0; i < 9; i++) {
var pos = getPatternDotPosition(x, y, i, patternSize);

float dotScale;

if (isInsideHitbox(pos, pixelSize, mouseX, mouseY) && isCircleClickable(size)) {
dotScale = 1.6f;
} else {
if (isCircleClickable(size)) {
var mouseDistance = new Vector2f((float) (mouseX - pos.x), (float) (mouseY - pos.y)).length();
dotScale = Math.clamp(patternSize / (mouseDistance * 2) - 0.2f, 0, 1);
} else {
// Skip the dot if its too small to click
continue;
}
}

var dotSize = pixelSize * dotScale;

drawFlatPolygon(matrices, vertexConsumers, c -> {
c.accept(pos.x - dotSize, pos.y - dotSize);
c.accept(pos.x - dotSize, pos.y + dotSize);
c.accept(pos.x + dotSize, pos.y + dotSize);
c.accept(pos.x + dotSize, pos.y - dotSize);
}, 0, 1, 1, 1, 0.25f);
}
}
}
}

Expand Down

0 comments on commit 7a6c0b5

Please sign in to comment.