Spaces:
Sleeping
Sleeping
jk
commited on
Commit
•
439a4dc
1
Parent(s):
28efeac
Add stroke
Browse files- assets/Tram-25-4-stroke.bmp +0 -0
- output.bmp +0 -0
- simulator.py +16 -4
assets/Tram-25-4-stroke.bmp
ADDED
output.bmp
CHANGED
simulator.py
CHANGED
@@ -31,13 +31,25 @@ def set_pixel(x, y, c):
|
|
31 |
def get_new_coordinates(coordinates):
|
32 |
x, y = coordinates
|
33 |
# if x=0 then new_x= 2, if index=1 then new_x= 7, if index=2 then new_x= 12, if index=3 then new_x= 2, if index=4 then new_x= 7, if index=5 then new_x= 12
|
34 |
-
new_x = x *
|
35 |
-
new_y = y *
|
36 |
return new_x, new_y
|
37 |
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
def draw_new_pixel(coordinates, color):
|
40 |
x, y = coordinates
|
|
|
41 |
new_image.putpixel(coordinates, color)
|
42 |
new_image.putpixel((x + 1, y), color)
|
43 |
new_image.putpixel((x + 2, y), color)
|
@@ -58,8 +70,8 @@ def draw_new_pixel(coordinates, color):
|
|
58 |
print(list_of_pixels)
|
59 |
|
60 |
# Calculate new Canvas size
|
61 |
-
new_width = width *
|
62 |
-
new_height = height *
|
63 |
|
64 |
# Create new image
|
65 |
new_image = Image.new("RGB", (new_width, new_height))
|
|
|
31 |
def get_new_coordinates(coordinates):
|
32 |
x, y = coordinates
|
33 |
# if x=0 then new_x= 2, if index=1 then new_x= 7, if index=2 then new_x= 12, if index=3 then new_x= 2, if index=4 then new_x= 7, if index=5 then new_x= 12
|
34 |
+
new_x = x * 6 + 2
|
35 |
+
new_y = y * 6 + 2
|
36 |
return new_x, new_y
|
37 |
|
38 |
|
39 |
+
# Increase RGB value by 50 but not (0, 0, 0) values
|
40 |
+
def increase_rgb_value(color):
|
41 |
+
r, g, b = color
|
42 |
+
if r == 0 and g == 0 and b == 0:
|
43 |
+
return r, g, b
|
44 |
+
r += 50
|
45 |
+
g += 50
|
46 |
+
b += 50
|
47 |
+
return r, g, b
|
48 |
+
|
49 |
+
|
50 |
def draw_new_pixel(coordinates, color):
|
51 |
x, y = coordinates
|
52 |
+
color = increase_rgb_value(color)
|
53 |
new_image.putpixel(coordinates, color)
|
54 |
new_image.putpixel((x + 1, y), color)
|
55 |
new_image.putpixel((x + 2, y), color)
|
|
|
70 |
print(list_of_pixels)
|
71 |
|
72 |
# Calculate new Canvas size
|
73 |
+
new_width = width * 6
|
74 |
+
new_height = height * 6
|
75 |
|
76 |
# Create new image
|
77 |
new_image = Image.new("RGB", (new_width, new_height))
|