@Override public void onDraw(Canvas canvas) { if (fillTexture != null) { int size = TeraMath.floorToInt(canvas.size().x * getValue()); int barWidth = fillTexture.getWidth(); int offset = 0; if (time != null && animate) { offset = (int) ((time.getRealTimeInMs() / 10) % barWidth); } int drawnWidth = 0; // Draw Offset if (offset != 0) { int drawWidth = Math.min(size, offset); canvas.drawTextureRaw(fillTexture, Rect2i.createFromMinAndSize(0, 0, drawWidth, canvas.size().y), ScaleMode.STRETCH, barWidth - offset, 0, drawWidth, canvas.size().y); drawnWidth += drawWidth; } // Draw Remainder while (drawnWidth < size) { int drawWidth = Math.min(size - drawnWidth, barWidth); canvas.drawTextureRaw(fillTexture, Rect2i.createFromMinAndSize(drawnWidth, 0, drawWidth, canvas.size().y), ScaleMode.STRETCH, 0, 0, drawWidth, canvas.size().y); drawnWidth += drawWidth; } } }
break; case SPLIT: canvas.drawTextureRaw(icon, Rect2i.createFromMinAndSize(offset, new Vector2i(iconSize.x / 2, iconSize.y)), ScaleMode.STRETCH, 0f, 0f, (float) (iconSize.x / 2) / iconSize.x, 1.0f);