From e5cccb63d1f6902188e668211e79af042cb60184 Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Sun, 18 Jul 2021 16:59:50 -0500 Subject: [PATCH] morepretty --- examples/realtime_sdl.nim | 6 +-- experiments/svg_cairo.nim | 3 +- src/pixie/paths.nim | 2 +- tests/test_contexts.nim | 4 +- tests/test_paths.nim | 86 +++++++++++++++++++-------------------- 5 files changed, 49 insertions(+), 52 deletions(-) diff --git a/examples/realtime_sdl.nim b/examples/realtime_sdl.nim index 09a86d8..c88a959 100644 --- a/examples/realtime_sdl.nim +++ b/examples/realtime_sdl.nim @@ -2,7 +2,6 @@ import math, pixie, sdl2, sdl2/gfx - const rmask = uint32 0x000000ff gmask = uint32 0x0000ff00 @@ -23,7 +22,6 @@ var mainTexture: TexturePtr evt = sdl2.defaultEvent - proc display() = ## Called every frame by main while loop @@ -52,7 +50,8 @@ proc display() = inc frameCount var dataPtr = ctx.image.data[0].addr - mainSurface = createRGBSurfaceFrom(dataPtr, cint w, cint h, cint 32, cint 4*w, rmask, gmask, bmask, amask) + mainSurface = createRGBSurfaceFrom(dataPtr, cint w, cint h, cint 32, cint 4*w, + rmask, gmask, bmask, amask) mainTexture = render.createTextureFromSurface(mainSurface) destroy(mainSurface) @@ -62,7 +61,6 @@ proc display() = render.present() - discard sdl2.init(INIT_EVERYTHING) window = createWindow("SDL/Pixie", 100, 100, cint w, cint h, SDL_WINDOW_SHOWN) render = createRenderer(window, -1, 0) diff --git a/experiments/svg_cairo.nim b/experiments/svg_cairo.nim index 7183e01..70c5b31 100644 --- a/experiments/svg_cairo.nim +++ b/experiments/svg_cairo.nim @@ -1,7 +1,6 @@ ## Load and Save SVG files. -import cairo, chroma, pixie/common, pixie/images, strutils, vmath, - xmlparser, xmltree +import cairo, chroma, pixie/common, pixie/images, strutils, vmath, xmlparser, xmltree include pixie/paths diff --git a/src/pixie/paths.nim b/src/pixie/paths.nim index 790b0a7..e9d7d30 100644 --- a/src/pixie/paths.nim +++ b/src/pixie/paths.nim @@ -1,4 +1,4 @@ -import blends, bumpy, chroma, common, images, masks, paints, internal, strutils, vmath +import blends, bumpy, chroma, common, images, internal, masks, paints, strutils, vmath when defined(amd64) and not defined(pixieNoSimd): import nimsimd/sse2 diff --git a/tests/test_contexts.nim b/tests/test_contexts.nim index f66e597..79ab2b7 100644 --- a/tests/test_contexts.nim +++ b/tests/test_contexts.nim @@ -592,7 +592,7 @@ block: image = newImage(300, 227) ctx = newContext(image) rhino = readImage("tests/images/rhino.png") - ctx.drawImage(rhino, 33, 71, 104, 124, 21, 20, 87, 104); + ctx.drawImage(rhino, 33, 71, 104, 124, 21, 20, 87, 104) image.writeFile("tests/images/context/draw_image_rhino.png") block: @@ -600,7 +600,7 @@ block: image = newImage(300, 227) ctx = newContext(image) rhino = readImage("tests/images/rhino.png") - ctx.drawImage(rhino, rect(33, 71, 104, 124), rect(21, 20, 87, 104)); + ctx.drawImage(rhino, rect(33, 71, 104, 124), rect(21, 20, 87, 104)) image.writeFile("tests/images/context/draw_image_rhino2.png") block: diff --git a/tests/test_paths.nim b/tests/test_paths.nim index fe98c3b..c59995a 100644 --- a/tests/test_paths.nim +++ b/tests/test_paths.nim @@ -445,20 +445,20 @@ block: # Draw shapes for i in 0 .. 3: for j in 0 .. 2: - ctx.beginPath(); - let x = 25f + j.float32 * 50f; # x coordinate - let y = 25f + i.float32 * 50f; # y coordinate - let radius = 20f; # Arc radius - let startAngle = 0f; # Starting point on circle - let endAngle = PI + (PI * j.float32) / 2; # End point on circle - let counterclockwise = i mod 2 == 1; # Draw counterclockwise + ctx.beginPath() + let x = 25f + j.float32 * 50f # x coordinate + let y = 25f + i.float32 * 50f # y coordinate + let radius = 20f # Arc radius + let startAngle = 0f # Starting point on circle + let endAngle = PI + (PI * j.float32) / 2 # End point on circle + let counterclockwise = i mod 2 == 1 # Draw counterclockwise - ctx.arc(x, y, radius, startAngle, endAngle, counterclockwise); + ctx.arc(x, y, radius, startAngle, endAngle, counterclockwise) if i > 1: - ctx.fill(); + ctx.fill() else: - ctx.stroke(); + ctx.stroke() surface.writeFile("tests/images/paths/arc.png") @@ -469,14 +469,14 @@ block: surface.fill(rgba(255, 255, 255, 255)) let - p0 = vec2(230, 20 ) - p1 = vec2(90, 130) - p2 = vec2(20, 20 ) + p0 = vec2(230, 20) + p1 = vec2(90, 130) + p2 = vec2(20, 20) - ctx.beginPath(); - ctx.moveTo(p0.x, p0.y); - ctx.arcTo(p1.x, p1.y, p2.x, p2.y, 50); - ctx.lineTo(p2.x, p2.y); + ctx.beginPath() + ctx.moveTo(p0.x, p0.y) + ctx.arcTo(p1.x, p1.y, p2.x, p2.y, 50) + ctx.lineTo(p2.x, p2.y) ctx.stroke() surface.writeFile("tests/images/paths/arcTo1.png") @@ -487,33 +487,33 @@ block: ctx = newContext(surface) surface.fill(rgba(255, 255, 255, 255)) # Tangential lines - ctx.beginPath(); - ctx.strokeStyle = "gray"; - ctx.moveTo(200, 20); - ctx.lineTo(200, 130); - ctx.lineTo(50, 20); - ctx.stroke(); + ctx.beginPath() + ctx.strokeStyle = "gray" + ctx.moveTo(200, 20) + ctx.lineTo(200, 130) + ctx.lineTo(50, 20) + ctx.stroke() # Arc - ctx.beginPath(); - ctx.strokeStyle = "black"; - ctx.lineWidth = 5; - ctx.moveTo(200, 20); - ctx.arcTo(200,130, 50,20, 40); - ctx.stroke(); + ctx.beginPath() + ctx.strokeStyle = "black" + ctx.lineWidth = 5 + ctx.moveTo(200, 20) + ctx.arcTo(200, 130, 50, 20, 40) + ctx.stroke() # Start point - ctx.beginPath(); - ctx.fillStyle = "blue"; - ctx.arc(200, 20, 5, 0, 2 * PI); - ctx.fill(); + ctx.beginPath() + ctx.fillStyle = "blue" + ctx.arc(200, 20, 5, 0, 2 * PI) + ctx.fill() # Control points - ctx.beginPath(); - ctx.fillStyle = "red"; - ctx.arc(200, 130, 5, 0, 2 * PI); # Control point one - ctx.arc(50, 20, 5, 0, 2 * PI); # Control point two - ctx.fill(); + ctx.beginPath() + ctx.fillStyle = "red" + ctx.arc(200, 130, 5, 0, 2 * PI) # Control point one + ctx.arc(50, 20, 5, 0, 2 * PI) # Control point two + ctx.fill() surface.writeFile("tests/images/paths/arcTo2.png") @@ -523,11 +523,11 @@ block: ctx = newContext(surface) surface.fill(rgba(255, 255, 255, 255)) - ctx.beginPath(); - ctx.moveTo(180, 90); - ctx.arcTo(180,130, 110,130, 130); - ctx.lineTo(110, 130); - ctx.stroke(); + ctx.beginPath() + ctx.moveTo(180, 90) + ctx.arcTo(180, 130, 110, 130, 130) + ctx.lineTo(110, 130) + ctx.stroke() surface.writeFile("tests/images/paths/arcTo3.png")