Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to draw squircle python

from PIL.ImageDraw import ImageDraw


def rounded_rectangle(self: ImageDraw, xy, corner_radius, fill=None, outline=None):
    upper_left_point = xy[0]
    bottom_right_point = xy[1]
    self.rectangle(
        [
            (upper_left_point[0], upper_left_point[1] + corner_radius),
            (bottom_right_point[0], bottom_right_point[1] - corner_radius)
        ],
        fill=fill,
        outline=outline
    )
    self.rectangle(
        [
            (upper_left_point[0] + corner_radius, upper_left_point[1]),
            (bottom_right_point[0] - corner_radius, bottom_right_point[1])
        ],
        fill=fill,
        outline=outline
    )
    self.pieslice([upper_left_point, (upper_left_point[0] + corner_radius * 2, upper_left_point[1] + corner_radius * 2)],
        180,
        270,
        fill=fill,
        outline=outline
    )
    self.pieslice([(bottom_right_point[0] - corner_radius * 2, bottom_right_point[1] - corner_radius * 2), bottom_right_point],
        0,
        90,
        fill=fill,
        outline=outline
    )
    self.pieslice([(upper_left_point[0], bottom_right_point[1] - corner_radius * 2), (upper_left_point[0] + corner_radius * 2, bottom_right_point[1])],
        90,
        180,
        fill=fill,
        outline=outline
    )
    self.pieslice([(bottom_right_point[0] - corner_radius * 2, upper_left_point[1]), (bottom_right_point[0], upper_left_point[1] + corner_radius * 2)],
        270,
        360,
        fill=fill,
        outline=outline
    )


ImageDraw.rounded_rectangle = rounded_rectangle
Comment

PREVIOUS NEXT
Code Example
Python :: python or in if statement 
Python :: accessing element from csv file in python 
Python :: studygyaan python everywhere - host on heroku 
Python :: python print list in dictionary 
Python :: shutil cut poython 
Python :: tkinter titre fenetre 
Python :: evaluate value of polynomial in python code 
Python :: adding attributes and metadata to a dataset using xarray 
Python :: apply numba to itertools import product 
Python :: python tuples number Multiplication 
Python :: why am i not able to import wtf flask 
Python :: python faculty of 0 is 1 faculty of 1 is 1 
Python :: reportlab drawimage issues with png transparency background 
Python :: username__icontains in django 
Python :: autoencoder for classification keras 
Python :: F-Strings decilamal places 
Python :: python creare una list comprehension 
Python :: top automotive blogs 
Python :: 5.4.7 categories python 
Python :: how to upgrade python from 2.7 to 2.9 on ubuntu 14.04 
Python :: how to acces textedit fields pyqt 
Python :: api csv python 
Python :: access host database django docker 
Python :: I want only the span of finditer in re python 
Python :: discord.File(fp=image_binary,filename=name) discord py 
Python :: django user refistration 
Python :: create matrice 2d whit 3colum panda 
Python :: matplotlib 3.4.1 und csv 
Python :: save changes flask sqlalchemy 
Python :: can we pickle pyspark dataframe using python 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =