How to get the flipped coordinates in a rectangle (python) [closed] - python

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 days ago.
Improve this question
I am a novice. I don't know how to write the following code:
I have a rectangular box. There is a point in the box. How to get the new coordinates for the point after turning the image horizontally.
How to get the new position of the point after a horizontal flip
Their position has changed from (100, 150) to (100, 50)
Thank you.

Related

How to find empty space on a page for inserting an image of fixed size (200x200) [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 days ago.
This post was edited and submitted for review 5 days ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I want to create a Python script which adds an image to pages of a PDF without overlapping existing text or images.
I tried the following libraries: PyPDF2, PIL (Image, ImageDraw), PyMuPDF.
I tried going pixel by pixel and check if it is white and after that add the image but it takes too long.
Then I tried with PIL checking the average color in the pdf if it is white but it dose not work...
I want to get the coordinate of the empty/white space where I can add the stamp.
Any idea how it can be done?

cv2.fitline() usage and exmaple [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 days ago.
Improve this question
So I have centre points from of contours stored in a points array.I am having trouble understanding how to use a fitline() function. can someone give an example?
points=\[\]
for i in contours:
if cv2.contourArea(i)\>200:
M = cv2.moments(i)
if M\['m00'\] != 0:
cx = int(M\['m10'\]/M\['m00'\])
cy = int(M\['m01'\]/M\['m00'\])
points.append((cx,cy))
points= np.array(points)
points = points.astype(np.float32)

How do I make shapes/objects in pygame? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I wan't to know how I can make objects in pygame. For example a Rectangle. How do I draw it? And I know/heard that you need different names for different shapes for example rect for rectangle. Can you tell me wich names I should use for other shapes? For example a triangle or a circle, etc.
I really hope this question is fitting to StackOverflow and not a waste of time for you! :)
You can draw rectangle in pygame using this code line -
DISPLAY=pygame.display.set_mode((500,400),0,32)
pygame.draw.rect(DISPLAY,BLUE,(200,150,100,50))
The above code, creates a rectangle Blue in color.
Now, Let's say in future you want to make a rectangle smaller or larger, in that case, you can just remove this rectangle and redraw it using the above command.
Similarly, to draw circle , you can use something like this:-
pygame.draw.circle(DISPLAY, BLUE, (150, 50), 15, 1)
Hope this helps!

Python: How to check whether a Circle has equal radius along all 360 degrees [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Using Python, I want to check whether a circle has an equal radius along all 360 degrees. Actually, I have segmented a circular shape from an image and then want to check whether it has a same-sized and equal radius along all the 360 degrees or not.
Can someone kindly help and tell how to do that?
In Python, OpenCV is a strong choice for an imaging library. You'd want to fit a contour to the circle and use moments to check the properties. You can fit an ellipse and see how close the major and minor axis of the ellipse match.
See this tutorial/docs for details.
Also, this question should help.

Python (pygame), spawning at random time [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I am trying to make my first game in pygame and I run into some problems.
I don't know how to spawn my enemies at random times. When I do it in my while loop they show all at once.
Every game loop add a chance to create an enemy. For example:
import random
# Main game loop
while True:
if random.randrange(0, 100) < 1: # 1% chance every frame
# Create a fly with specified properties
Fly(random.randrange(xmin, xmax), random.randrange(ymin, ymax), width, height, img_src)

Categories