0%

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from PIL import Image, ImageFont, ImageDraw
import os


def fun(img, factor=1):
img = img.convert('RGBA')
img_blender = Image.new('RGBA', img.size, (0, 0, 0, 0))
img = Image.blend(img_blender, img, factor)
img = img.resize((700, 700))
return img


rootdir = 'logo'
savedir = 'save'
lists = os.listdir(rootdir)
for i in range(0, len(lists)):
path = os.path.join(rootdir, lists[i])
im = Image.open('logo.jpg')
im1 = Image.open(path)
im1 = fun(im1)
xy = im1.size
im.paste(im1, (960-xy[0]/2, 400-xy[1]/2), mask=im1)
draw = ImageDraw.Draw(im)
textsize = 24
font = ImageFont.truetype("C:\Windows\Fonts\Arial.ttf", textsize)
length = draw.textsize(lists[i].split('.')[0], font)
while True:
font = ImageFont.truetype("C:\Windows\Fonts\Arial.ttf", textsize)
length = draw.textsize(lists[i].split('.')[0], font)
if (length[0] <= 1536) and (textsize <= 96):
textsize += 1
else:
textsize -= 1
font = ImageFont.truetype("C:\Windows\Fonts\Arial.ttf", textsize)
length = draw.textsize(lists[i].split('.')[0], font)
break
draw.text((960-length[0]/2, 860-length[1]/2), lists[i].split('.')[0], (255, 255, 255), font=font)
im.save(os.path.join(savedir, lists[i]), 'jpeg')
print(i)

Description

The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter ‘e’. He was a member of the Oulipo group. A quote from the book:

Tout avait Pair normal, mais tout s’affirmait faux. Tout avait Fair normal, d’abord, puis surgissait l’inhumain, l’affolant. Il aurait voulu savoir où s’articulait l’association qui l’unissait au roman : stir son tapis, assaillant à tout instant son imagination, l’intuition d’un tabou, la vision d’un mal obscur, d’un quoi vacant, d’un non-dit : la vision, l’avision d’un oubli commandant tout, où s’abolissait la raison : tout avait l’air normal mais…

Perec would probably have scored high (or rather, low) in the following contest. People are asked to write a perhaps even meaningful text on some subject with as few occurrences of a given “word” as possible. Our task is to provide the jury with a program that counts these occurrences, in order to obtain a ranking of the competitors. These competitors often write very long texts with nonsense meaning; a sequence of 500,000 consecutive ‘T’s is not unusual. And they never use spaces.

So we want to quickly find out how often a word, i.e., a given string, occurs in a text. More formally: given the alphabet {‘A’, ‘B’, ‘C’, …, ‘Z’} and two finite strings over that alphabet, a word W and a text T, count the number of occurrences of W in T. All the consecutive characters of W must exactly match consecutive characters of T. Occurrences may overlap.

阅读全文 »

在此处打开命令窗口(管理员)

cmd

1
2
3
4
5
6
7
8
9
10
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
@="@shell32.dll,-8506"
"NoWorkingDirectory"=""
"ShowBasedOnVelocityId"=dword:00639bc8
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""
阅读全文 »

Description

一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢?

阅读全文 »