morepretty

This commit is contained in:
Ryan Oldenburg 2021-05-31 20:41:03 -05:00
parent 3b6474b565
commit 7ea0a37013
7 changed files with 42 additions and 36 deletions

View file

@ -108,16 +108,26 @@ proc main() =
# Figure out the right size of the window we want. # Figure out the right size of the window we want.
var rect: lean.RECT var rect: lean.RECT
rect.left = 0 rect.left = 0
rect.top = 0 rect.top = 0
rect.right = w rect.right = w
rect.bottom = h rect.bottom = h
AdjustWindowRectEx(cast[LPRECT](rect.addr), WS_OVERLAPPEDWINDOW, 0, 0) AdjustWindowRectEx(cast[LPRECT](rect.addr), WS_OVERLAPPEDWINDOW, 0, 0)
# Open the window. # Open the window.
hwnd = CreateWindow(appName, "Win32/Pixie", WS_OVERLAPPEDWINDOW, hwnd = CreateWindow(
CW_USEDEFAULT, CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, appName,
0, 0, hInstance, nil) "Win32/Pixie",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
rect.right - rect.left,
rect.bottom - rect.top,
0,
0,
hInstance,
nil
)
ShowWindow(hwnd, SW_SHOW) ShowWindow(hwnd, SW_SHOW)
UpdateWindow(hwnd) UpdateWindow(hwnd)

View file

@ -1,4 +1,4 @@
import pixie, wNim/[wApp, wFrame, wPaintDC, wImage] import pixie, wFrame, wImage], wNim/[wApp, wPaintDC
let let
w = 256 w = 256

View file

@ -1,10 +1,6 @@
import opengl, pixie, pixie/context import opengl, pixie, pixie/context, staticglfw except Image
export pixie export pixie, staticglfw except Image
import staticglfw except Image
export staticglfw except Image
var var
dpi: float32 = 1.0 dpi: float32 = 1.0

View file

@ -18,8 +18,8 @@ type
lineHeight*: float32 ## The line height in pixels or AutoLineHeight for the font's default line height. lineHeight*: float32 ## The line height in pixels or AutoLineHeight for the font's default line height.
paint*: Paint paint*: Paint
textCase*: TextCase textCase*: TextCase
underline*: bool ## Apply an underline. underline*: bool ## Apply an underline.
strikethrough*: bool ## Apply a strikethrough. strikethrough*: bool ## Apply a strikethrough.
noKerningAdjustments*: bool ## Optionally disable kerning pair adjustments noKerningAdjustments*: bool ## Optionally disable kerning pair adjustments
Span* = ref object Span* = ref object
@ -27,11 +27,11 @@ type
font*: Font font*: Font
Arrangement* = ref object Arrangement* = ref object
lines*: seq[(int, int)] ## The (start, stop) of the lines of text. lines*: seq[(int, int)] ## The (start, stop) of the lines of text.
spans*: seq[(int, int)] ## The (start, stop) of the spans in the text. spans*: seq[(int, int)] ## The (start, stop) of the spans in the text.
fonts*: seq[Font] ## The font for each span. fonts*: seq[Font] ## The font for each span.
runes*: seq[Rune] ## The runes of the text. runes*: seq[Rune] ## The runes of the text.
positions*: seq[Vec2] ## The positions of the glyphs for each rune. positions*: seq[Vec2] ## The positions of the glyphs for each rune.
selectionRects*: seq[Rect] ## The selection rects for each glyph. selectionRects*: seq[Rect] ## The selection rects for each glyph.
HAlignMode* = enum HAlignMode* = enum

View file

@ -1,4 +1,4 @@
import pixie, random, os import os, pixie, random
when not defined(pixieLeakCheck): when not defined(pixieLeakCheck):
quit("Requires -d:pixieLeakCheck") quit("Requires -d:pixieLeakCheck")

View file

@ -1,4 +1,4 @@
import pixie, random, pixie/fileformats/svg import pixie, pixie/fileformats/svg, random
when not defined(pixieLeakCheck): when not defined(pixieLeakCheck):
quit("Requires -d:pixieLeakCheck") quit("Requires -d:pixieLeakCheck")
@ -8,7 +8,7 @@ randomize()
let data = readFile("tests/images/svg/Ghostscript_Tiger.svg") let data = readFile("tests/images/svg/Ghostscript_Tiger.svg")
for i in 0 ..< 100_000: for i in 0 ..< 100_000:
var image = decodeSvg(data, rand(300 .. 1800), rand(30 .. 1800)) var image = decodeSvg(data, rand(300 .. 1800), rand(30 .. 1800))
# image.writeFile("tests/fuzz_leaks3.png") # image.writeFile("tests/fuzz_leaks3.png")
# break # break

View file

@ -499,20 +499,20 @@ block:
var y = 15.float32 var y = 15.float32
proc drawDashedLine(pattern: seq[float32]) = proc drawDashedLine(pattern: seq[float32]) =
ctx.beginPath(); ctx.beginPath()
ctx.setLineDash(pattern); ctx.setLineDash(pattern)
ctx.moveTo(0, y); ctx.moveTo(0, y)
ctx.lineTo(300, y); ctx.lineTo(300, y)
ctx.stroke(); ctx.stroke()
y += 20; y += 20
drawDashedLine(@[]); drawDashedLine(@[])
drawDashedLine(@[1.float32, 1]); drawDashedLine(@[1.float32, 1])
drawDashedLine(@[10.float32, 10]); drawDashedLine(@[10.float32, 10])
drawDashedLine(@[20.float32, 5]); drawDashedLine(@[20.float32, 5])
drawDashedLine(@[15.float32, 3, 3, 3]); drawDashedLine(@[15.float32, 3, 3, 3])
drawDashedLine(@[20.float32, 3, 3, 3, 3, 3, 3, 3]); drawDashedLine(@[20.float32, 3, 3, 3, 3, 3, 3, 3])
drawDashedLine(@[12.float32, 3, 3]); drawDashedLine(@[12.float32, 3, 3])
image.writeFile("tests/images/context/setLineDash_1.png") image.writeFile("tests/images/context/setLineDash_1.png")