File size: 3,264 Bytes
af70590
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# app.py
import streamlit as st
import math
import matplotlib.pyplot as plt

# Page Configuration
st.set_page_config(
    page_title="🧱 Brick Masonry Estimator",
    page_icon="πŸ—οΈ",
    layout="centered"
)

# Custom CSS for Styling
st.markdown("""
    <style>
        .title {
            text-align: center;
            font-size: 2.5em;
            font-weight: bold;
            color: #FF5733;
        }
        .subtitle {
            text-align: center;
            font-size: 1.2em;
            color: #555;
        }
        .result {
            text-align: center;
            font-size: 1.3em;
            font-weight: bold;
            color: #2196F3;
            margin-top: 20px;
        }
        .footer {
            text-align: center;
            margin-top: 50px;
            font-size: 0.9em;
            color: #777;
        }
        .icon {
            text-align: center;
            font-size: 4em;
            color: #FF9800;
        }
    </style>
""", unsafe_allow_html=True)

# Header with Icon
st.markdown("<div class='icon'>πŸ—οΈ</div>", unsafe_allow_html=True)
st.markdown("<h1 class='title'>🧱 Brick Masonry Estimator</h1>", unsafe_allow_html=True)
st.markdown("<p class='subtitle'>Calculate bricks and mortar required for a wall</p>", unsafe_allow_html=True)

# User Inputs
st.subheader("πŸ“ Wall Dimensions")
wall_length = st.number_input("πŸ“ Wall Length (m):", min_value=0.1, value=5.0)
wall_height = st.number_input("πŸ“ Wall Height (m):", min_value=0.1, value=3.0)
wall_thickness = st.number_input("🧱 Wall Thickness (m):", min_value=0.05, value=0.1)

st.subheader("🧱 Brick Dimensions")
brick_length = st.number_input("πŸ“ Brick Length (m):", min_value=0.05, value=0.2)
brick_height = st.number_input("πŸ“ Brick Height (m):", min_value=0.05, value=0.1)
brick_width = st.number_input("🧱 Brick Width (m):", min_value=0.05, value=0.1)

mortar_thickness = st.number_input("βš’οΈ Mortar Thickness (m):", min_value=0.005, value=0.01)

# Calculation Button
if st.button("πŸ”„ Calculate Bricks and Mortar"):
    # Calculate Wall Volume
    wall_volume = wall_length * wall_height * wall_thickness
    
    # Calculate Brick Volume (Including Mortar)
    brick_volume = (brick_length + mortar_thickness) * (brick_height + mortar_thickness) * (brick_width + mortar_thickness)
    
    # Calculate Number of Bricks
    num_bricks = wall_volume / brick_volume
    
    # Calculate Mortar Volume
    mortar_volume = wall_volume - (num_bricks * (brick_length * brick_height * brick_width))
    
    st.markdown(f"<p class='result'>🧱 Total Number of Bricks: {math.ceil(num_bricks)} bricks</p>", unsafe_allow_html=True)
    st.markdown(f"<p class='result'>βš’οΈ Total Mortar Volume: {mortar_volume:.2f} mΒ³</p>", unsafe_allow_html=True)
    
    # Visualization
    st.subheader("πŸ“Š Wall Dimension Visualization")
    fig, ax = plt.subplots(figsize=(6, 4))
    ax.barh(["Wall Volume", "Brick Volume", "Mortar Volume"], [wall_volume, brick_volume * num_bricks, mortar_volume], color=['skyblue', 'orange', 'green'])
    ax.set_xlabel("Volume (mΒ³)")
    ax.set_title("Volume Breakdown")
    st.pyplot(fig)

# Footer
st.markdown("<p class='footer'>πŸ’» <b>Developed by ChatGPT</b></p>", unsafe_allow_html=True)