ahsangahothi commited on
Commit
ddead5d
·
verified ·
1 Parent(s): 1ff6ac9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -17
app.py CHANGED
@@ -10,7 +10,7 @@ def fig_to_bytes(fig):
10
  img_bytes.seek(0)
11
  return img_bytes.read()
12
 
13
- # Function to draw the house floor plan with random room placement
14
  def draw_house(length, width, unit):
15
  fig, ax = plt.subplots(figsize=(8, 8))
16
 
@@ -21,13 +21,11 @@ def draw_house(length, width, unit):
21
  ax.plot([length, length], [0, width], color="black", lw=2) # Right side
22
 
23
  # Randomly place rooms within the plot
24
- # Defining rooms within the plot
25
-
26
  # Bedroom (Randomly positioned)
27
  x1 = random.randint(0, length//2)
28
  y1 = random.randint(width//2, width)
29
  room_length1 = random.randint(10, 20)
30
- room_width1 = random.randint(5, 10)
31
  ax.plot([x1, x1 + room_length1], [y1, y1], color="blue", lw=2)
32
  ax.plot([x1 + room_length1, x1 + room_length1], [y1, y1 - room_width1], color="blue", lw=2)
33
  ax.plot([x1 + room_length1, x1], [y1 - room_width1, y1 - room_width1], color="blue", lw=2)
@@ -114,16 +112,4 @@ st.title("Random House Layout Drawing App")
114
 
115
  # User input for plot dimensions and units
116
  length = st.number_input("Enter the Length of the Plot", min_value=1, max_value=1000, value=50)
117
- width = st.number_input("Enter the Width of the Plot", min_value=1, max_value=1000, value=30)
118
-
119
- # Dropdown menu for unit selection
120
- unit = st.selectbox("Select Unit", ["ft", "m", "cm"])
121
-
122
- # Draw the house layout when inputs are provided
123
- if length and width:
124
- fig = draw_house(length, width, unit)
125
-
126
- # Display the plot
127
- st.pyplot(fig)
128
-
129
- # Option to download
 
10
  img_bytes.seek(0)
11
  return img_bytes.read()
12
 
13
+ # Function to draw the house floor plan with detailed layout and random room placement
14
  def draw_house(length, width, unit):
15
  fig, ax = plt.subplots(figsize=(8, 8))
16
 
 
21
  ax.plot([length, length], [0, width], color="black", lw=2) # Right side
22
 
23
  # Randomly place rooms within the plot
 
 
24
  # Bedroom (Randomly positioned)
25
  x1 = random.randint(0, length//2)
26
  y1 = random.randint(width//2, width)
27
  room_length1 = random.randint(10, 20)
28
+ room_width1 = random.randint(6, 12)
29
  ax.plot([x1, x1 + room_length1], [y1, y1], color="blue", lw=2)
30
  ax.plot([x1 + room_length1, x1 + room_length1], [y1, y1 - room_width1], color="blue", lw=2)
31
  ax.plot([x1 + room_length1, x1], [y1 - room_width1, y1 - room_width1], color="blue", lw=2)
 
112
 
113
  # User input for plot dimensions and units
114
  length = st.number_input("Enter the Length of the Plot", min_value=1, max_value=1000, value=50)
115
+ width = st.number_input("Enter the Width of