# 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(""" """, unsafe_allow_html=True) # Header with Icon st.markdown("
🏗️
", unsafe_allow_html=True) st.markdown("

🧱 Brick Masonry Estimator

", unsafe_allow_html=True) st.markdown("

Calculate bricks and mortar required for a wall

", 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"

🧱 Total Number of Bricks: {math.ceil(num_bricks)} bricks

", unsafe_allow_html=True) st.markdown(f"

⚒️ Total Mortar Volume: {mortar_volume:.2f} m³

", 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("", unsafe_allow_html=True)