Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * this method will split rectangle horizentally
- */
- public void split_Horizentally(Graphics g,int start,int end,int width,int height)
- {
- Random R = new Random();
- int Height_Split_Point = getRandomPoint(R);
- int left_width = Height_Split_Point * width;
- int right_width = width - left_width;
- g.setColor(c);
- g.fillRect(start,end,left_width,height);
- g.fillRect(start + left_width,end,right_width,height);
- recursionRect(g,start,end,left_width,height);
- recursionRect(g,start + left_width,end,right_width,height);
- }
- /**
- * this method will split rectangle vertically
- */
- public void split_Vertically(Graphics g,int start,int end,int width,int height)
- {
- Random R = new Random();
- int Width_Split_Point = getRandomPoint(R);
- int top_height = Width_Split_Point * height;
- int bottom_height = height - top_height;
- g.setColor(c);
- g.fillRect(start,end,width,top_height);
- g.fillRect(start,end + top_height,width,bottom_height);
- recursionRect(g,start,end,width,top_height);
- recursionRect(g,start,end + top_height,width,bottom_height);
- }
- /**
- * this method will draw rectangles recursively
- */
- public void recursionRect(Graphics g,int start,int end,int width,int height)
- {
- Random R = new Random();
- int Height_Split_Point = R.nextInt((MINIMUM_REGION_LENGTH - ((3/2)*width)) + (int)((3/2)*width));
- int Width_Split_Point = R.nextInt((MINIMUM_REGION_LENGTH - ((3/2)*height)) + (int)((3/2)*height));
- if(width>WIDTH/2 && height>HEIGHT/2)
- {
- splitBoth(g,start,end,width,height);
- }
- else if(width>WIDTH/2)
- {
- split_Vertically(g,start,end,width,height);
- // it shows error ^ here.
- }
- else if(height>HEIGHT/2)
- {
- split_Horizentally(g,start,end,width,height);
- }
- else if(Height_Split_Point <width )
- {
- split_Vertically(g,start,end,width,height);
- }
- else if(Width_Split_Point<height)
- {
- split_Horizentally(g,start,end,width,height);
- }
- else
- {
- g.fillRect(start,end,width,height);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement