File:Line pixel subpixel aa.gif
Line_pixel_subpixel_aa.gif (384 × 128 pixels, file size: 95 KB, MIME type: image/gif, looped, 64 frames, 3.2 s)
Captions
Summary
[edit]DescriptionLine pixel subpixel aa.gif |
English: This is a simple animation, created with Python, that compares side-by-side pixel precision vs subpixel precision vs anti-aliasing in line rasterization. |
Date | |
Source | Own work |
Author | Drummyfish |
Source code InfoField | # Simple animation showing pixel vs subpixel accuracy.
# by Miloslav Ciz, released under CC0 1.0
from PIL import Image
import math
SCALE = 8
FRAMES = 64
RESOLUTION = (48,16)
img = Image.new("RGB",(RESOLUTION[0] * SCALE,RESOLUTION[1] * SCALE),"white")
pixels = img.load()
def setPixel(x, y, c):
for b in range(SCALE):
for a in range(SCALE):
pixels[x * SCALE + a,y * SCALE + b] = (c,c,c)
def drawLine(p0, p1, aa):
slope = (p1[1] - p0[1]) / float(p1[0] - p0[0])
for i in range(int(p1[0] - p0[0] + 1)):
x = int(p0[0] + i) if aa else round(p0[0] + i)
y = p0[1] + i * slope
c = int(255 * (y % 1)) if aa else 0
y = int(y) if aa else round(y)
setPixel(x,y,c)
if aa:
setPixel(x,y + 1,255 - c)
for f in range(FRAMES):
img.paste((255,255,255),(0,0,img.size[0],img.size[1]))
t = f / float(FRAMES) * math.pi * 2
x0 = 0
x1 = 15
y0 = 8 + math.sin(t) * 5
y1 = 7 + math.cos(t) * 3
drawLine((x0,round(y0)),(x1,round(y1)),False)
drawLine((x0 + RESOLUTION[0] / 3,y0),(x1 + RESOLUTION[0] / 3,y1),False)
drawLine((x0 + 2 * RESOLUTION[0] / 3,y0),(x1 + 2 * RESOLUTION[0] / 3,y1),True)
for i in range(RESOLUTION[1] * SCALE):
pixels[int(RESOLUTION[0] * SCALE / 3),i] = (0,0,0)
pixels[int(2 * RESOLUTION[0] * SCALE / 3),i] = (0,0,0)
img.save("out" + str(f).zfill(2) + ".png")
|
Licensing
[edit]This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication. | |
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse |
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 13:20, 3 February 2023 | 384 × 128 (95 KB) | Drummyfish (talk | contribs) | Fix rounding | |
12:59, 3 February 2023 | 384 × 128 (95 KB) | Drummyfish (talk | contribs) | Uploaded own work with UploadWizard |
You cannot overwrite this file.
File usage on Commons
The following 2 pages use this file:
File usage on other wikis
The following other wikis use this file:
- Usage on en.wikipedia.org
- Usage on www.wikidata.org
Metadata
This file contains additional information such as Exif metadata which may have been added by the digital camera, scanner, or software program used to create or digitize it. If the file has been modified from its original state, some details such as the timestamp may not fully reflect those of the original file. The timestamp is only as accurate as the clock in the camera, and it may be completely wrong.
GIF file comment | by drummyfish, released under CC0 1.0 |
---|