Hello everyone, hope you all are fit and fine.
==>Soon, I'm going to make a black and white image of 'Stylish Star Allu Arjun'. So, don't forget to subscribe my YouTube channel 'Coder of Paradise'.
Watch Full Tutorial of " How to find coordinates and draw image with coordinates in python":
Source Code:
#I made brave browser's 'lion' in python using turtle.
#if you like it, then hit subscribe button
import turtle as tu
class brave():
def __init__(self):
self.red = [(193, 154), (194, 153), (199, 152), (208, 152), (238, 152), (242, 147), (244, 141), (272, 113), (273, 110),(277, 108), (430, 108), (460, 137), (460, 142), (470, 151), (514, 152), (523, 156), (559, 192), (560, 203), (557, 205), (556, 210), (552, 213), (551, 223), (549, 225), (548, 228), (552, 229), (552, 239), (556, 241), (556, 251), (560, 254), (562, 259), (565, 271), (558, 286), (556, 304), (551, 314), (549, 330), (541, 348), (535, 378), (519, 438), (516, 454), (512, 467), (507, 479), (503, 487), (499, 494), (496, 502), (476, 519), (466, 528), (459, 530), (455, 535), (448, 538), (443, 542), (440, 547), (431, 551), (426, 554), (418, 557), (415, 561), (407, 567), (402, 570), (394, 574), (390, 578), (383, 581), (378, 587), (366, 592), (362, 595), (346,595), (338, 592), (329, 588), (325, 583), (318, 580), (313, 576), (306, 572), (302, 567), (293, 564), (290, 559), (281, 555), (271, 547), (256, 540), (245, 530), (238, 524), (233, 520), (230, 519), (212, 503), (205, 490), (202, 478), (197, 470), (192, 455), (189, 438), (186, 426), (149, 288), (145, 271), (145, 261), (147, 259), (150, 249), (152, 246), (152, 237), (157, 234), (156, 217), (153, 215), (151, 205), (147, 203), (148, 192), (168, 174), (185, 158), (192, 156), (194, 154), (192, 156), (193, 154), (194, 155), (193, 155), (193, 155), (193, 155)]
self.white1 = [(197, 277), (196, 263), (196, 267), (196, 272), (198, 258), (203, 252), (212, 238), (226, 218), (237, 204),(246, 191), (250, 190), (257, 191), (260, 192), (270, 193), (279, 195), (293, 197), (314, 196), (328, 192), (340, 188), (366, 187), (379, 191), (391, 194), (430, 194), (451, 190), (459, 190), (479, 216), (497, 242), (509, 259), (510, 262), (511, 276), (507, 282), (458, 334), (453, 338), (452, 341), (451, 344), (449, 347), (448, 351), (451, 356), (452, 362), (457, 375), (459, 382), (457, 388), (454, 395), (451, 400), (448, 405), (442, 413), (435, 415), (422, 416), (405, 410), (389, 401), (371, 385), (365, 380), (381, 393), (361, 371), (371, 362), (398, 343), (409, 337), (414, 327), (411, 315), (408, 308), (405, 304), (402, 299), (398, 291), (394,283), (394, 273), (401, 267), (419, 259), (438, 252), (456, 245), (465, 239), (462, 237), (459, 235), (455, 233), (450, 233), (441, 233), (432, 233), (422, 233), (412, 234), (404, 236), (395, 239), (383, 242), (379, 244), (376, 247), (376, 250), (376, 256), (377, 275), (382, 295), (384, 312), (386, 326), (381, 331), (365, 335), (338, 335), (330, 329), (322, 327), (323, 315), (325, 299), (330, 277), (332, 264), (334, 252), (331, 247), (328, 244), (320, 241), (312, 239), (295, 234), (279, 234), (258, 235), (250, 236), (244, 238), (249, 244), (258, 248), (268, 251), (285, 257), (299, 261), (309, 268), (315, 275), (315, 281), (312, 289), (307, 296),(301, 305), (299, 313), (297, 319), (295, 326), (298, 331), (302, 337), (309, 341), (317, 347), (330, 357), (340, 361), (346, 368), (348, 375), (345, 377), (336, 387), (322, 399), (317, 403), (302, 412), (294, 415), (287, 419), (279, 419), (272, 418), (270, 415), (266, 413), (262, 409), (259, 405), (256, 401), (255, 397), (252, 393), (251, 388), (250, 380), (252, 373), (253, 367), (255, 363), (257, 356), (257, 347), (254, 340), (233, 318), (221, 306), (215, 299), (208, 291), (204, 288), (199, 283), (198, 280), (205, 245), (217, 228), (230, 211), (242, 196), (302, 197)]
self.white2 = [(348, 413), (357, 414), (361, 416), (371, 417), (377, 420), (401, 434), (409, 437), (412, 439), (415, 441),(416, 446), (410, 450), (370, 482), (361, 489), (357, 493), (348, 493), (341, 487), (334, 481), (319, 468), (311, 463), (304, 455), (299, 451), (291, 445), (291, 441), (299, 437), (308, 431), (318, 427), (328, 421), (337, 418), (344, 416), (353, 414)]
self.pen = tu.Turtle()
self.pen.hideturtle()
self.pen.speed(0)
self.x_offset = 300
self.y_offset = 300
def go(self, x, y):
self.pen.penup()
self.pen.goto(x-self.x_offset,(y*-1)+self.y_offset)
self.pen.pendown()
#pencolor
def paint(self,coord,co=(0,0,0)):
self.pen.color(co)
t_x,t_y = coord[0]
self.go(t_x,t_y)
self.pen.fillcolor(co)
self.pen.begin_fill()
t = 0
for i in coord[1:]:
print(i)
x,y = i
if t:
self.go(x,y)
t = 0
self.pen.begin_fill()
continue
if x == -1 and y == -1:
t = 1
self.pen.end_fill()
continue
else:
self.pen.goto(x-self.x_offset,(y*-1)+self.y_offset)
self.pen.end_fill()
#for draw
def draw_fn(self,coord,mode = 1,co = (0,0,0),thickness = 1):
co = (co[0]/255,co[1]/255,co[2]/255)
self.pen.color(co)
if mode:
self.pen.width(thickness)
t_x,t_y = coord[0]
self.go(t_x,t_y)
t = 0
for i in coord[1:]:
print(i)
x,y = i
if t:
self.go(x,y)
t = 0
continue
if x == -1 and y == -1:
t = 1
continue
else:
self.pen.goto(x-self.x_offset,(y*-1)+self.y_offset)
else:
self.paint(coord=coord,co = co)
#what and how to draw
def draw(self,retain=True):
self.draw_fn(self.red,co = (250,0,0),mode = 0)
self.draw_fn(self.white1,co = (255,255,255),mode = 0)
self.draw_fn(self.white2,mode = 0,co = (255,255,255))
if retain:
tu.done()
pen = brave()
pen.draw()
##Click here for codes of " How to find coordinates of any image?"
Thank you, all.
Comments
Post a Comment