@Override public void renderImage( @Nonnull final Graphics g, final int x, final int y, final int w, final int h, final int srcX, final int srcY, final int srcW, final int srcH, @Nonnull final Color color, final float scale, final int centerX, final int centerY) { final int scaledWidth = Math.round(w * scale); final int scaledHeight = Math.round(h * scale); final int fixedX = x + Math.round((w - scaledWidth) * ((float) centerX / (float) w)); final int fixedY = y + Math.round((h - scaledHeight) * ((float) centerY / (float) h)); if (isOnMapArea()) { final int offsetX = (FastMath.sqrt(FastMath.sqr(currentDeltaX) / 2) * -FastMath.sign(currentDeltaX)) + (FastMath.sqrt(FastMath.sqr(currentDeltaY) / 2) * -FastMath.sign(currentDeltaY)); final int offsetY = (FastMath.sqrt(FastMath.sqr(currentDeltaX) / 2) * FastMath.sign(currentDeltaX)) + (FastMath.sqrt(FastMath.sqr(currentDeltaY) / 2) * -FastMath.sign(currentDeltaY)); final Color renderColor; if (available) { renderColor = POINTER_COLOR; } else { renderColor = color; } g.drawTexture( pointSprite.getFrame(0), fixedX - offsetX, fixedY - offsetY, scaledWidth, scaledHeight, srcX, srcY, srcW, srcH, centerX - fixedX, centerY - fixedY, 0.f, renderColor); } }
/** * This functions returns if this pointer is on the mini map right now or outside of it. * * @return {@code true} in case the pointer is on the map */ private boolean isOnMapArea() { return FastMath.sqrt(FastMath.sqr(currentDeltaX) + FastMath.sqr(currentDeltaY)) < 71; }