PHP Imagearc () Function

| |
Syntax:
bool imagearc ($image, $cx, $cy, $width, $height, $start, $end, $color) 
Parameters:This function takes eight parameters as above and described below:
  • $image:returned by one of the create functions images such as imagecreatetruecolor(). Used to create the size of the image.
  • $cx:is used to set the x-coordinate of the center.
  • $cy:is used to setting the y-coordinate of the center.
  • $width:the width of the arc.
  • $height:the height of the arc.
  • $start:is used to set the angle of the start of the arc in degrees.
  • $end:is used to set the angle of the end of the arc in degrees. 0 ¬∞ is at the three o’clock position and the arc is drawn clockwise.
  • $color:sets the color of the image. Color identifier generated by the imagecolorallocate() function.
Return value:This function returns true on success or false on error.The programs below illustrate the imagearc() functionin PHP.Program 1:
// Create image or blank image size . $image_size = imagecreatetruecolor (500, 300);
// Set the background color of the image. $bg = imagecolorallocate ( $image_size , 0, 103, 0);
// Fill the background with the selected color above. imagefill ( $image_size , 0, 0, $bg );
// Set the image colors $white_color = imagecolorallocate ( $image_size , 255, 255, 255); $red_color = imagecolorallocate ( $image_size , 255, 0, 0); $green_color = imagecolorallocate ( $image_size , 0, 255, 0); $blue_color = imagecolorallocate ( $image_size , 0, 0, 255);
// Draw a circle imagearc ( $image_size , 200, 150, 200, 200, 0, 360, $white_color ); imagearc ( $image_size , 200, 150, 150, 150, 25, 155, $red_color ); imagearc ( $image_size , 260, 110, 50, 50, 0, 360, $green_color ); imagearc ( $image_size , 140, 110, 50, 50, 0, 360, $blue_color );
// Output image to browser header ( "Content-type: image / png" ); imagepng ( $image_size );
// Free memory imagedestroy ( $image_size );
?>
Output: Program 2:
// Create the size of the image or blank image. $image_size = imagecreatetruecolor (500, 300);
// Set the background color of the image. $bg = imagecolorallocate ( $image_size , 0, 102, 0);
// Fill the background with the selected color above. imagefill ( $image_size , 0, 0, $bg );
// Set the image colors $white_color = imagecolorallocate ( $image_size , 255, 255, 255); $red_color = imagecolorallocate ( $image_size , 255, 0, 0); $black_color = imagecolorallocate ( $image_size , 0, 0, 0);
// Draw an image of a circular arc imagearc ( $image_size , 200, 150, 200, 200, 0, 360, $white_color ); imagearc ( $image_size , 200, 150, 150, 150, 0, 360, $red_color ); imagearc ( $image_size , 200, 150, 50, 50, 0, 360, $black_color );
// Output image to browser header ( "Content-type: image / png" ); imagepng ( $image_size );
// Free memory imagedestroy ( $image_size );
?>
Output: Related Articles:
  • PHP | Imagepolygon() Function
  • PHP | Imagefilledellipse() Function
  • PHP | Imagefilledpolygon() function
Link: http://php.net/manual/en/function.imagearc.php

PHP Imagearc () Function __del__: Questions

How can I make a time delay in Python?

5 answers

I would like to know how to put a time delay in a Python script.

2973

Answer #1

import time
time.sleep(5)   # Delays for 5 seconds. You can also use a float value.

Here is another example where something is run approximately once a minute:

import time
while True:
    print("This prints once a minute.")
    time.sleep(60) # Delay for 1 minute (60 seconds).

2973

Answer #2

You can use the sleep() function in the time module. It can take a float argument for sub-second resolution.

from time import sleep
sleep(0.1) # Time in seconds

How to delete a file or folder in Python?

5 answers

How do I delete a file or folder in Python?

2639

Answer #1


Path objects from the Python 3.4+ pathlib module also expose these instance methods:

PHP Imagearc () Function circle: Questions

How to do a scatter plot with empty circles in Python?

2 answers

In Python, with Matplotlib, how can a scatter plot with empty circles be plotted? The goal is to draw empty circles around some of the colored disks already plotted by scatter(), so as to highlight them, ideally without having to redraw the colored circles.

I tried facecolors=None, to no avail.

204

Answer #1

From the documentation for scatter:

Optional kwargs control the Collection properties; in particular:

    edgecolors:
        The string ‘none’ to plot faces with no outlines
    facecolors:
        The string ‘none’ to plot unfilled outlines

Try the following:

import matplotlib.pyplot as plt 
import numpy as np 

x = np.random.randn(60) 
y = np.random.randn(60)

plt.scatter(x, y, s=80, facecolors="none", edgecolors="r")
plt.show()

example image

Note: For other types of plots see this post on the use of markeredgecolor and markerfacecolor.

plot a circle with pyplot

2 answers

surprisingly I didn"t find a straight-forward description on how to draw a circle with matplotlib.pyplot (please no pylab) taking as input center (x,y) and radius r. I tried some variants of this:

import matplotlib.pyplot as plt
circle=plt.Circle((0,0),2)
# here must be something like circle.plot() or not?
plt.show()

... but still didn"t get it working.

199

Answer #1

You need to add it to an axes. A Circle is a subclass of an Patch, and an axes has an add_patch method. (You can also use add_artist but it"s not recommended.)

Here"s an example of doing this:

import matplotlib.pyplot as plt

circle1 = plt.Circle((0, 0), 0.2, color="r")
circle2 = plt.Circle((0.5, 0.5), 0.2, color="blue")
circle3 = plt.Circle((1, 1), 0.2, color="g", clip_on=False)

fig, ax = plt.subplots() # note we must use plt.subplots, not plt.subplot
# (or if you have an existing figure)
# fig = plt.gcf()
# ax = fig.gca()

ax.add_patch(circle1)
ax.add_patch(circle2)
ax.add_patch(circle3)

fig.savefig("plotcircles.png")

This results in the following figure:

The first circle is at the origin, but by default clip_on is True, so the circle is clipped when ever it extends beyond the axes. The third (green) circle shows what happens when you don"t clip the Artist. It extends beyond the axes (but not beyond the figure, ie the figure size is not automatically adjusted to plot all of your artists).

The units for x, y and radius correspond to data units by default. In this case, I didn"t plot anything on my axes (fig.gca() returns the current axes), and since the limits have never been set, they defaults to an x and y range from 0 to 1.

Here"s a continuation of the example, showing how units matter:

circle1 = plt.Circle((0, 0), 2, color="r")
# now make a circle with no fill, which is good for hi-lighting key results
circle2 = plt.Circle((5, 5), 0.5, color="b", fill=False)
circle3 = plt.Circle((10, 10), 2, color="g", clip_on=False)
    
ax = plt.gca()
ax.cla() # clear things for fresh plot

# change default range so that new circles will work
ax.set_xlim((0, 10))
ax.set_ylim((0, 10))
# some data
ax.plot(range(11), "o", color="black")
# key data point that we are encircling
ax.plot((5), (5), "o", color="y")
    
ax.add_patch(circle1)
ax.add_patch(circle2)
ax.add_patch(circle3)
fig.savefig("plotcircles2.png")

which results in:

You can see how I set the fill of the 2nd circle to False, which is useful for encircling key results (like my yellow data point).

Shop

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method