Skip to content

Rotated TiledImagePaint causes misplaced pixels and IndexDefect. #597

Description

@nico-robert

Rotated a TiledImagePaint causes an IndexDefect in debug mode. In release mode, some pixels appear in the wrong places.

import std/math
import pixie

let tile = newImage(4, 4)
tile.fill(rgba(255, 255, 255, 255))

for x in 0 ..< tile.width:
  tile[x, 0] = rgba(35, 115, 210, 255)

let paint = newPaint(TiledImagePaint)
paint.image = tile
paint.imageMat = rotate(-7.0.float32 * PI.float32 / 180.0.float32)

let image = newImage(256, 160)
image.fill(paint)
image.writeFile("result.png")
Image

On the Nim forum, janAkali suggested the following workaround in images.nim file, which fixes the issue in my tests:

x0y0 = image.unsafe[x0.euclMod(image.width), y0.euclMod(image.height)]
x1y0 = image.unsafe[x1.euclMod(image.width), y0.euclMod(image.height)]
x0y1 = image.unsafe[x0.euclMod(image.width), y1.euclMod(image.height)]
x1y1 = image.unsafe[x1.euclMod(image.width), y1.euclMod(image.height)]

However, I would prefer not not to have to modify Pixie’s source code locally, which is why I am reporting the issue here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions