i’m more of a backend web developer and this is for a friend of mine but i have this issue with turtle where her code wont run and i keep getting syntax errors saying certain things aren’t defined. Heres the code Answer If you use import turtle then you have to use turtle.penup(), turtle.setpositi…
Tag: graphics
obtaining a single plot of two contour lines matplotlib
I am making a program that interpolates the points of some level curves, but when it comes to graphing, I am obtaining two individual graphs of the two level curves and not a single graph. I would like to get this output: Answer You need to declare plt.figure() only once, outside of the for loop. Inside the f…
How to show data by day in a Plotly chart
I have a dataframe with the number of people vaccinated per day and I’m trying to put this data in a daily bar chart of Plotly, but it aggregates the data every about 13 days. I don’t want the aggregated view this way, I need it to show the bars per day. Below is a part of the dataframe and
Black and white color addition
When red is mixed with green, I get yellow as expected. But when white is mixed with black, I should get normally grey but I get white. Shouldn’t I get grey? Here is the code: Answer I think what @Cris Luengo said (“If you want to get gray, average the white and black pixels together”) is va…
How to make a shape a button in Tkinter
Is there a way to make a shape a button in a tkinter canvas? Or, to put it simply, is there a way to figure out if the user clicked the rectangle drawn above? Answer I don’t know how to see if someone clicks the rectangle but you could have the color change if a cursor hovers over it… I’m
Need help implementing flood-fill algorithm
So I’m trying to create a flood fill algorithm and I keep getting a recursion error with this. The algorithm seems to have infinite recursion and I cannot pinpoint why. I have looked all over the internet and I cannot find a solution as it seems like my program is correct according to most sources. Ther…
Ray and square/rectangle intersection in 3D
Hei. Are making a game and are looking for a ray intersection onto a square or a rectangle only in 3D space. Have search the web and found many solutions but nothing i can understand have a line and line segment intersection script in 2D but i cant figure out have to make it 3D. It is not important from
Finding points on a rectangle at a given angle
I’m trying to draw a gradient in a rectangle object, with a given angle (Theta), where the ends of the gradient are touching the perimeter of the rectangle. I thought that using tangent would work, but I’m having trouble getting the kinks out. Is there an easy algorithm that I am just missing? End…
How to read the RGB value of a given pixel in Python?
If I open an image with open(“image.jpg”), how can I get the RGB values of a pixel assuming I have the coordinates of the pixel? Then, how can I do the reverse of this? Starting with a blank graphic, ‘write’ a pixel with a certain RGB value? I would prefer if I didn’t have to dow…