This site requires JavaScript, please enable it in your browser!
Greenfoot back
DavranbekRozmetov
DavranbekRozmetov wrote ...

2018/4/11

How can I set a border-radius to a rectangle

DavranbekRozmetov DavranbekRozmetov

2018/4/11

#
Hey guys, I am new to Greenfoot. I am working in one game the same as 2048. The problem is I don't want the boxes to have sharp edges and I couldn't find the way to set round edges to the rectangles.
1
2
3
4
5
6
7
8
9
10
11
12
13
// create the text image
        int fontsize = 28; // change as desired
        Color fontColor = Color.WHITE; // change as desired
        Color bgColor = new Color(255, 255, 255, 1); // transparent background
        GreenfootImage txtImg = new GreenfootImage(text, fontsize, fontColor, bgColor);
        // create the base image
        GreenfootImage img = new GreenfootImage(62, 62);
        bgColor = Color.BLUE; // change as desired
        img.setColor(bgColor);
        img.fill();
        // draw text image on base image
        img.drawImage(txtImg, 20, 5);
        setImage(img);
this is my code Thanks in advance!
danpost danpost

2018/4/11

#
It would be a long process, but possible. You would create a small image (maybe 40x 49) with a circle on it and then draw onto 4 10x10 mages the 4 quadrants of the circle. Then you can draw the quarter circles onto your tile image at the corners and draw lines between them -- making a rounded border for your image.
DavranbekRozmetov DavranbekRozmetov

2018/4/11

#
Thank you, seems like I will be wasting time on it if I keep being stubborn about making the game pure code since the time for project is very limited. Thank you again
danpost danpost

2018/4/11

#
danpost wrote...
(maybe 40x 49)
should read "40x40".
You need to login to post a reply.