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
import { createHash } from "crypto"; | |
import { createServer, IncomingMessage } from "http"; | |
import { Duplex } from "stream"; | |
type WsFn = (val: string | Uint8Array) => void; | |
// Create this object whenever a websocket connection has been established | |
type WebSocket = { | |
write: WsFn; | |
addListener: (listener: WsFn) => void; |
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
""" | |
Draws the text <text> on the ImageDraw <image_draw> in the box (specified as a 4-ple of [x,y,width,height]) | |
with the font <font> and the allignments as given. Passes other arguments to the ImageDraw.text function | |
(for example, fill is a good one to use here). | |
Can be used to center text horizontally and vertically, as well as right-align and bottom-allign (although it defaults to | |
left- and top-allignment). Nothing is done to prevent overflow, but the y and height values from the box will be used for vertical | |
allignment | |
Example usage: |