hello i need a java program that creates the badha bing fractal (not by GUI but
ID: 3545953 • Letter: H
Question
hello i need a java program that creates the badha bing fractal (not by GUI but by recursion) , which is basically a sequare that in its each vertex anathor sequare half size of the original which shuold look like this AND I NEED A SCREEN SHOOT FROM THE OUTBUT:
Explanation / Answer
g2.draw(new Rectangle2D.Double(x, y, rectwidth, rectheight)); after drawing the square using above class we recursively call a function draw_square_corner(x,y,side); now in this function we will draw four rectangles and recursively call draw_square_corner() for all this four square. example: void draw_square_corner(x,y,side) { if(x>=0 && y>=0) { g2.draw(new Rectangle2D.Double(x-side/2, y-side/2, side/2, side/2)); g2.draw(new Rectangle2D.Double(x+side, y-side/2, side/2, side/2)); g2.draw(new Rectangle2D.Double(x-side/2, y+side, side/2, side/2)); g2.draw(new Rectangle2D.Double(x+side, y+side, side/2, side/2)); //now giving recursive call to the function with the parameter of abovve squares draw_square_corner(x+side, y-side/2, side/2); draw_square_corner(x-side/2, y-side/2, side/2); draw_square_corner(x+side, y+side, side/2); draw_square_corner(x-side/2, y+side, side/2); } } this will work.As I am not a java man so cant give you exact code.But the logic will work for sure.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.