コード例 #1
0
def RGB_component_from_name(name: str = ''):
    '''Get a named RGB color (or random color) from fitz predefined colors, e.g. 'red' -> (1.0,0.0,0.0).'''
    # get color index
    if name and name.upper() in getColorList():
        pos = getColorList().index(name.upper())
    else:
        pos = random.randint(0, len(getColorList()) - 1)

    c = getColorInfoList()[pos]
    return (c[1] / 255.0, c[2] / 255.0, c[3] / 255.0)
コード例 #2
0
ファイル: colordbHSV.py プロジェクト: zzang2004/PyMuPDF
    else:
        hue = 60. * (((r - g) / delta) + 4)

    H = str(int(round(hue))).zfill(3)

    if cmax == 0:
        sat = 0
    else:
        sat = delta / cmax
    S = str(int(round(sat * 100))).zfill(3)

    return H + S + V


# create color list sorted down by hue, value, saturation
mylist = sorted(getColorInfoList(), reverse=True, key=lambda x: sortkey(x))

w = 800  # page width
h = 600  # page height
rw = 80  # width of color rect
rh = 60  # height of color rect

num_colors = len(mylist)  # number of color triples
black = getColor("black")  # text color
white = getColor("white")  # text color
fsize = 8  # fontsize
lheight = fsize * 1.2  # line height
idx = 0  # index in color database
doc = fitz.open()  # empty PDF
while idx < num_colors:
    doc.insertPage(-1, width=w, height=h)  # new empty page
コード例 #3
0
ファイル: colordbHSV.py プロジェクト: ResearchDLP/PyMuPDF
        hue = 60. * (((b - r)/delta) + 2)
    else:
        hue = 60. * (((r - g)/delta) + 4)
        
    H = str(int(round(hue))).zfill(3)
    
    if cmax == 0:
        sat = 0
    else:
        sat = delta / cmax
    S = str(int(round(sat  * 100))).zfill(3)

    return H + S + V

# create color list sorted down by hue, value, saturation
mylist = sorted(getColorInfoList(), reverse = True, key=lambda x: sortkey(x))

w = 800            # page width
h = 600            # page height
rw = 80            # width of color rect
rh = 60            # height of color rect

num_colors = len(mylist)     # number of color triples
black = getColor("black")    # text color
white = getColor("white")    # text color
fsize = 8                    # fontsize
lheight = fsize *1.2         # line height
idx = 0                      # index in color database
doc = fitz.open()            # empty PDF
while idx < num_colors:
    doc.insertPage(-1, width = w, height = h)    # new empty page