Last active
February 20, 2020 12:23
-
-
Save nakamura001/83e2f1c07c50657a6d20c434d2d987f6 to your computer and use it in GitHub Desktop.
グラデーション画像を作成
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# coding: utf-8 | |
from PIL import Image | |
from PIL import ImageDraw | |
screenW = 640 | |
screenH = 50 | |
img = Image.new('RGBA', (screenW, screenH), (255,255,255,0)) | |
draw = ImageDraw.Draw(img) | |
draw.rectangle(((0, 0), (img.size[0]-1, img.size[1]-1)), outline='red') | |
maxX = screenW-2 | |
for v in range(maxX): | |
g = int(v/(maxX-1)*255) | |
print(g) | |
x = v + 1 | |
draw.line((x, 1, x, screenH-2), fill=(g, g, g)) | |
img.save("test.png"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment