A bathroom scale in SVG! That's a fun one. Here's a simple, yet detailed representation of a bathroom scale in SVG. I'll guide you through the code and explain the different parts.
bathroom-scale.svg
<?xml version="1.0" encoding="UTF-8"?>
<svg width="300" height="400" viewBox="0 0 300 400" xmlns="http://www.w3.org/2000/svg">
<!-- Scale platform -->
<rect x="50" y="250" width="200" height="20" rx="5" fill="#C0C0C0" stroke="#666" stroke-width="2" />
<rect x="55" y="270" width="190" height="80" rx="5" fill="#F7F7F7" stroke="#666" stroke-width="2" />
<!-- Scale body -->
<rect x="70" y="150" width="160" height="100" rx="10" fill="#E5E5E5" stroke="#666" stroke-width="2" />
<path d="M 70,150 L 60,170 L 240,170 L 230,150 Z" fill="#E5E5E5" stroke="#666" stroke-width="2" />
<!-- Display screen -->
<rect x="90" y="80" width="120" height="60" rx="10" fill="#000" stroke="#666" stroke-width="2" />
<text x="150" y="120" font-size="36" font-family="Arial" text-anchor="middle" fill="#0F0">188.5</text>
<text x="150" y="160" font-size="18" font-family="Arial" text-anchor="middle" fill="#FFF">kg</text>
<!-- Buttons -->
<circle cx="110" cy="220" r="15" fill="#E5E5E5" stroke="#666" stroke-width="2" />
<text x="110" y="225" font-size="18" font-family="Arial" text-anchor="middle" fill="#666">kg/lb</text>
<circle cx="190" cy="220" r="15" fill="#E5E5E5" stroke="#666" stroke-width="2" />
<text x="190" y="225" font-size="18" font-family="Arial" text-anchor="middle" fill="#666">Tare</text>
<!-- Feet -->
<ellipse cx="100" cy="370" rx="15" ry="10" fill="#C0C0C0" stroke="#666" stroke-width="2" />
<ellipse cx="200" cy="370" rx="15" ry="10" fill="#C0C0C0" stroke="#666" stroke-width="2" />
<!-- Highlights -->
<path d="M 70,150 L 80,140 L 220,140 L 230,150 Z" fill="#FFF" opacity="0.2" />
<rect x="55" y="270" width="190" height="10" fill="#FFF" opacity="0.2" />
</svg>
Let me break down the components:
- Scale platform: Two
rect elements create the step platform. The top one is gray (#C0C0C0), and the bottom one is light gray (#F7F7F7) with a slight rounded corner (rx="5").
- Scale body: A
rect with rounded corners (rx="10") forms the main body, and a path element creates the slanted front panel.
- Display screen: A black
rect (#000) with a green text (#0F0) displays the weight (188.5 kg in this example). A smaller white text (#FFF) shows the unit (kg).
- Buttons: Two
circle elements with light gray fill (#E5E5E5) and gray stroke (#666) represent the unit switch (kg/lb) and Tare buttons. The text labels are centered within each circle.
- Feet: Two
ellipse elements create the scale's feet, with a gray fill (#C0C0C0) and gray stroke (#666).
- Highlights: Two elements add some subtle highlights to the design:
- A white
path (#FFF) with 20% opacity (opacity="0.2") creates a shiny effect on the scale's front panel.
- A white
rect with 20% opacity adds a highlight to the top edge of the platform.
You can adjust the width and height attributes of the svg element to resize the scale. The viewBox attribute ensures the scale remains proportional when resized.
Tips and Variations
- To change the weight value, simply update the text content of the
text element with the font-size="36" attribute.
- Experiment with different colors, gradients, or textures to give your scale a unique look.
- Add more details, like a battery compartment or a sensor grid on the platform.
- Animate the weight display by changing the text value over time using JavaScript and
<animate> elements or CSS transitions.
- Create an interactive scale by adding JavaScript event listeners to the buttons and updating the display accordingly.
Now, go ahead and weigh yourself (virtually, of course!) by opening this SVG file in your favorite browser or image viewer.
Happy coding!