ahsangahothi commited on
Commit
ae747e2
·
verified ·
1 Parent(s): b2ead61

Update requirements.txt

Browse files
Files changed (1) hide show
  1. requirements.txt +2 -55
requirements.txt CHANGED
@@ -1,55 +1,2 @@
1
- import streamlit as st
2
- import matplotlib.pyplot as plt
3
- import io
4
-
5
- def convert_to_meters(value, unit):
6
- conversion_factors = {
7
- "m": 1,
8
- "ft": 0.3048,
9
- "cm": 0.01,
10
- "in": 0.0254
11
- }
12
- return value * conversion_factors[unit]
13
-
14
- def draw_floor_plan(length, width, unit):
15
- fig, ax = plt.subplots(figsize=(8, 8))
16
- ax.plot([0, length, length, 0, 0], [0, 0, width, width, 0], marker='o', color='blue')
17
- ax.set_xlim(-1, length + 1)
18
- ax.set_ylim(-1, width + 1)
19
- ax.set_aspect('equal', adjustable='box')
20
- ax.set_title(f"Floor Plan ({unit})")
21
- ax.set_xlabel(f"Length ({unit})")
22
- ax.set_ylabel(f"Width ({unit})")
23
- return fig
24
-
25
- st.title("Floor Plan Generator")
26
-
27
- st.write("Enter the dimensions of the floor plan and select the unit of measurement.")
28
-
29
- # Input fields
30
- length = st.number_input("Enter the length:", min_value=0.0, format="%.2f")
31
- width = st.number_input("Enter the width:", min_value=0.0, format="%.2f")
32
- unit = st.selectbox("Select the unit:", ["m", "ft", "cm", "in"], index=1)
33
-
34
- if st.button("Generate Floor Plan"):
35
- if length > 0 and width > 0:
36
- length_converted = convert_to_meters(length, unit) if unit != "m" else length
37
- width_converted = convert_to_meters(width, unit) if unit != "m" else width
38
- st.success(f"Dimensions: Length = {length:.2f} {unit}, Width = {width:.2f} {unit}")
39
- fig = draw_floor_plan(length, width, unit)
40
-
41
- # Show the plot
42
- st.pyplot(fig)
43
-
44
- # Add a download button
45
- buf = io.BytesIO()
46
- fig.savefig(buf, format="png")
47
- buf.seek(0)
48
- st.download_button(
49
- label="Download Floor Plan",
50
- data=buf,
51
- file_name="floor_plan.png",
52
- mime="image/png"
53
- )
54
- else:
55
- st.error("Please enter positive values for length and width.")
 
1
+ streamlit
2
+ matplotlib