awacke1 commited on
Commit
5955b9e
·
1 Parent(s): d77c3c1

Create backup-app.py

Browse files
Files changed (1) hide show
  1. backup-app.py +41 -0
backup-app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import svgwrite
3
+
4
+ # Define the card suits and values
5
+ suits = ["clubs", "diamonds", "hearts", "spades"]
6
+ values = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]
7
+
8
+ # Define the size of the cards
9
+ CARD_WIDTH = 75
10
+ CARD_HEIGHT = 100
11
+
12
+ # Define the size of the SVG canvas
13
+ CANVAS_WIDTH = CARD_WIDTH * 13
14
+ CANVAS_HEIGHT = CARD_HEIGHT * 4
15
+
16
+ # Create a new SVG drawing
17
+ dwg = svgwrite.Drawing(size=(f"{CANVAS_WIDTH}px", f"{CANVAS_HEIGHT}px"))
18
+
19
+ # Draw each card in the SVG canvas
20
+ for suit_idx, suit in enumerate(suits):
21
+ for value_idx, value in enumerate(values):
22
+ # Calculate the position of the card on the canvas
23
+ x = CARD_WIDTH * value_idx
24
+ y = CARD_HEIGHT * suit_idx
25
+
26
+ # Draw the card border
27
+ dwg.add(dwg.rect((x, y), (CARD_WIDTH, CARD_HEIGHT), rx=10, ry=10, fill="white", stroke="black", stroke_width=2))
28
+
29
+ # Draw the card suit symbol
30
+ symbol = svgwrite.text.Text(suit.upper(), insert=(x + 5, y + 15), fill="black", font_size="16px", font_weight="bold")
31
+ dwg.add(symbol)
32
+
33
+ # Draw the card value
34
+ value = svgwrite.text.Text(value, insert=(x + 5, y + CARD_HEIGHT - 10), fill="black", font_size="16px", font_weight="bold")
35
+ dwg.add(value)
36
+
37
+ # Convert the SVG drawing to a string
38
+ svg_string = dwg.tostring()
39
+
40
+ # Display the SVG canvas in the Streamlit app
41
+ st.write(f'<svg viewBox="0 0 {CANVAS_WIDTH} {CANVAS_HEIGHT}">{svg_string}</svg>', unsafe_allow_html=True)