mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Render point grid as background 🌐
This commit is contained in:
parent
833166c3bf
commit
e40b57498d
@ -2,6 +2,7 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import math
|
import math
|
||||||
|
import numpy
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
|
|
||||||
|
|
||||||
@ -102,6 +103,13 @@ class BoxRenderer:
|
|||||||
self.draw = ImageDraw.Draw(self.img)
|
self.draw = ImageDraw.Draw(self.img)
|
||||||
self.cursor = (0, 0)
|
self.cursor = (0, 0)
|
||||||
|
|
||||||
|
pixels = numpy.array(self.img)
|
||||||
|
for i in range(0, int(height)):
|
||||||
|
for j in range(0 if i % 2 == 0 else 1, int(width), 2):
|
||||||
|
pixels[4*i:4*(i+1), 4*j:4*(j+1)] = (200, 200, 200, 255)
|
||||||
|
|
||||||
|
self.img = Image.fromarray(pixels)
|
||||||
|
|
||||||
self.colors = [
|
self.colors = [
|
||||||
(176, 264, 158),
|
(176, 264, 158),
|
||||||
(274, 173, 207),
|
(274, 173, 207),
|
||||||
@ -167,7 +175,7 @@ class BoxRenderer:
|
|||||||
|
|
||||||
|
|
||||||
def pix(points):
|
def pix(points):
|
||||||
return int(2 * points)
|
return int(4 * points)
|
||||||
|
|
||||||
def overlap(a, b):
|
def overlap(a, b):
|
||||||
return (a[0] < b[2] and b[0] < a[2]) and (a[1] < b[3] and b[1] < a[3])
|
return (a[0] < b[2] and b[0] < a[2]) and (a[1] < b[3] and b[1] < a[3])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user