math - Python PIL to draw a circle-segment of sunshine -


I have a problem for which I want to draw a circle / object in a fixed position in an image, and then I I want to attract the rays coming out of the image - with each beam being separated from 1 degree. The rays will be applied only to 145 degree segments, however - it is not making a full circle. I am using Python PIL (on which I am a newbie) to complete that task - although I am not strict on language requirements. Def drawSunshine (im): draw = ImageDraw.Draw (im) x, y = im.size draw.ellipse ((370,200, 400,230), fill = 'red', outline = ' Black ') draw.line ((370,205,390,218), fill =' black ', width = 3) I was thinking that I could resume on every pixel around the circle. (Score: 3, Informative) And then I could change the color of that pixel.

Edit I understood this approach because I had a black and Adam-white PNG file for this image if the current pixel was white, then I could see another pixel line Had to pull, if the current pixel is black: I consider it an obstacle and end the line at that point.

However, the main question:

  • How do I recycle an image around an object in an arbitrary condition, such as the area around the object Is there a circle or a circle segment?
  • And, how can I ensure that every "ray" I am painting per pixel is different from 1 degree?
  • Edit Can these "rays" be blocked by black pixels?
  • Here's a small function that you can adjust; Import image, math import sin, cos, pi width, height = 400, 400 wah = (135, 206, 235) im = Image.new ("Draws an image" from "RGBA") . (Width, height), skyblue) #Down Sun Draw = Image Draw. Draw (IM) DRF draws (draw, center, radius, ray = false, startangle = 0, Finnish = 360, Reangel = 10, Reggae = 10, Releagrahi = 1000, Ray Collar = "Yellow", Ray Autline = "Orange" ): X1, x2 = center [0] - radius, center [0] + radius y1, y2 = center [1] - radius, center [1] + radius ray: range for range (start, engl , Reangel + Regep): Raid = (Restart + Reengel) * PI / 180 Ristart * = PI / 180 Corner 1 = Center [0] + Ray Lane * (Restart), center [1] + reenganement * sin (restart) corner 2 = center [0] + ray length * cos (reindeer), center [1] + relegant * sin (reindeer) print [center, corner 1, Corner 2] Draw (Polyethylene), polygon ((center, corner 1, corner 2), fill = "yellow", outline = "orange"). Draw to lipase ((x1, y1, x2, y2), fill = "yellow", outline = "Orange") Draw.sun (Draw, (100, 100), 40, Re = true, startAngle = 0, finishAngle = 145, Regegal = 3, Reggae = 5) im.save ("example.png") < / Code>

    image details enter here Do


Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -