Formating fixes.
This commit is contained in:
parent
7a1a2850c2
commit
f67b940f2d
2 changed files with 12 additions and 9 deletions
|
@ -592,14 +592,17 @@ proc strokePolygon*(ctx: Context, pos: Vec2, size: float32, sides: int) =
|
|||
|
||||
proc drawImage*(ctx: Context, image: Image, dx, dy, dWidth, dHeight: float32) =
|
||||
## Draws a source image onto the destination image.
|
||||
var path: Path
|
||||
var imageMat = ctx.mat * translate(vec2(dx, dy)) * scale(vec2(
|
||||
dWidth / image.width.float32,
|
||||
dHeight / image.height.float32
|
||||
))
|
||||
var
|
||||
imageMat = ctx.mat * translate(vec2(dx, dy)) * scale(vec2(
|
||||
dWidth / image.width.float32,
|
||||
dHeight / image.height.float32
|
||||
))
|
||||
saveStyle = ctx.fillStyle
|
||||
ctx.fillStyle = Paint(kind: pkImage, image: image, imageMat: imageMat)
|
||||
var path: Path
|
||||
path.rect(rect(dx, dy, dWidth, dHeight))
|
||||
ctx.fill(path)
|
||||
ctx.fillStyle = saveStyle
|
||||
|
||||
proc drawImage*(ctx: Context, image: Image, dx, dy: float32) =
|
||||
## Draws a source image onto the destination image.
|
||||
|
|
|
@ -553,7 +553,7 @@ block:
|
|||
let
|
||||
image = newImage(100, 100)
|
||||
ctx = newContext(image)
|
||||
var testImage = readImage("tests/images/pip1.png")
|
||||
testImage = readImage("tests/images/pip1.png")
|
||||
ctx.drawImage(testImage, 0, 0)
|
||||
ctx.drawImage(testImage, 30, 30)
|
||||
image.writeFile("tests/images/context/draw_image.png")
|
||||
|
@ -562,7 +562,7 @@ block:
|
|||
let
|
||||
image = newImage(100, 100)
|
||||
ctx = newContext(image)
|
||||
var testImage = readImage("tests/images/pip1.png")
|
||||
testImage = readImage("tests/images/pip1.png")
|
||||
ctx.translate(30, 30)
|
||||
ctx.drawImage(testImage, -30, -30)
|
||||
ctx.drawImage(testImage, 0, 0)
|
||||
|
@ -572,7 +572,7 @@ block:
|
|||
let
|
||||
image = newImage(100, 100)
|
||||
ctx = newContext(image)
|
||||
var testImage = readImage("tests/images/pip1.png")
|
||||
testImage = readImage("tests/images/pip1.png")
|
||||
ctx.scale(2, 2)
|
||||
ctx.drawImage(testImage, 0, 0)
|
||||
ctx.scale(0.25, 0.25)
|
||||
|
@ -583,7 +583,7 @@ block:
|
|||
let
|
||||
image = newImage(100, 100)
|
||||
ctx = newContext(image)
|
||||
var testImage = readImage("tests/images/pip1.png")
|
||||
testImage = readImage("tests/images/pip1.png")
|
||||
ctx.drawImage(testImage, 30, 30, 20, 20)
|
||||
image.writeFile("tests/images/context/draw_image_self_scaled.png")
|
||||
|
||||
|
|
Loading…
Reference in a new issue