Improved rounded rectangles
This commit is contained in:
@@ -32,7 +32,9 @@ public interface RenderScope {
|
||||
default void drawRoundedRectangle(int x, int y, int width, int height, int radius, int color) {
|
||||
if (color == 0)
|
||||
return;
|
||||
radius = Math.min(radius, Math.min(width, height));
|
||||
|
||||
radius = Math.min(radius, width / 2);
|
||||
radius = Math.min(radius, height / 2);
|
||||
|
||||
String svg = String.format(
|
||||
"<svg xmlns='http://www.w3.org/2000/svg' width='%d' height='%d'>" +
|
||||
@@ -45,8 +47,9 @@ public interface RenderScope {
|
||||
InputStream svgStream = new ByteArrayInputStream(svg.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
drawTexture(SvgTexture.getSvg(svgStream,
|
||||
IdentifierRef.ofSaturn("textures/gui/tmp_rect/rounded_" + width + "_" + height + "_" + radius),
|
||||
width * 3, height * 3), x, y, 0, 0, width, height, color);
|
||||
IdentifierRef.ofSaturn(
|
||||
"textures/gui/tmp_rect/rounded_" + width + "_" + height + "_" + radius),
|
||||
width * 4, height * 4), x, y, 0, 0, width, height, color);
|
||||
}
|
||||
|
||||
void drawBorder(int x, int y, int width, int height, int color);
|
||||
|
||||
@@ -17,9 +17,9 @@ public class Toggle extends Element {
|
||||
|
||||
@Override
|
||||
public void render(RenderScope renderScope, ElementContext ctx) {
|
||||
renderScope.drawRoundedRectangle(0, 0, width, height, height,
|
||||
renderScope.drawRoundedRectangle(0, 0, 60, 30, Theme.WIDGET_RADIUS.value,
|
||||
Theme.withAlpha(0.5f, prop.value ? Theme.ACCENT.value : Theme.PRIMARY.value));
|
||||
renderScope.drawRoundedRectangle(prop.value ? 30 : 0, 0, 30, 30, 30,
|
||||
renderScope.drawRoundedRectangle(prop.value ? 30 : 0, 0, 30, 30, Theme.WIDGET_RADIUS.value,
|
||||
prop.value ? Theme.ACCENT.value : Theme.PRIMARY.value);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user