Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Project Work
Manage
Activity
Members
Labels
Plan
Issues
5
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fabian Del Villar
Project Work
Commits
4b424e4e
Commit
4b424e4e
authored
1 year ago
by
Fabian
Browse files
Options
Downloads
Patches
Plain Diff
Create test2-2.py
parent
693d07ce
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test2-2.py
+26
-0
26 additions, 0 deletions
test2-2.py
with
26 additions
and
0 deletions
test2-2.py
0 → 100644
+
26
−
0
View file @
4b424e4e
def
create_rectangle
():
# Prompt for the coordinates of two points
x1
=
float
(
input
(
"
Enter the x-coordinate of the first point:
"
))
y1
=
float
(
input
(
"
Enter the y-coordinate of the first point:
"
))
x2
=
float
(
input
(
"
Enter the x-coordinate of the second point:
"
))
y2
=
float
(
input
(
"
Enter the y-coordinate of the second point:
"
))
# Calculate the rectangle's coordinates
x_min
=
min
(
x1
,
x2
)
y_min
=
min
(
y1
,
y2
)
width
=
abs
(
x2
-
x1
)
height
=
abs
(
y2
-
y1
)
# Create the SVG code for the rectangle
svg_code
=
f
'
<svg xmlns=
"
http://www.w3.org/2000/svg
"
width=
"
{
width
}
"
height=
"
{
height
}
"
>
'
svg_code
+=
f
'
<rect x=
"
{
x_min
}
"
y=
"
{
y_min
}
"
width=
"
{
width
}
"
height=
"
{
height
}
"
fill=
"
none
"
stroke=
"
red
"
stroke-width=
"
0.05
"
/>
'
svg_code
+=
'
</svg>
'
# Write the SVG code to a file
with
open
(
'
rectangle.svg
'
,
'
w
'
)
as
file
:
file
.
write
(
svg_code
)
print
(
"
Rectangle SVG file
'
rectangle.svg
'
has been generated.
"
)
# Call the function to create the rectangle
create_rectangle
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment