Help with drawing

So, I was making a script to draw a rounded rectangle, but when you put Hight and width to 0 and smoothness to 30 it shows a circle insead.

Here the code:

//% block="draw rounded rectangle at $img|x: $x|y: $y|width: $width|height: $height|smoothness: $smooth| color: $c"
    //% c.shadow="colorindexpicker"
    //% inlineInputMode=inline
    //% subcategory="Image"
    //% img.defl=picture
    //% img.shadow=variables_get
    export function RoundedRectangle(img: Image, x: number, y: number, width: number, height: number, smooth: number, c: number) {
        for (let index = 0; index <= 360; index++) {
            img.fillRect(x + Math.sin(index) * smooth, y + Math.cos(index) * smooth, width, height, c)
        }
        img.fillRect(x, y, width, height, c)
    }

If you use blocks then drawing is a LOT easier

Yes, when you’re drawing a sprite, but I think drawing a rounded rectangle (what @Cybercube is trying to draw) is easier in Java?

1 Like