align to pixel grid when rendering
This commit is contained in:
parent
b986ce77a7
commit
89f92a0412
1 changed files with 5 additions and 1 deletions
|
@ -2,6 +2,7 @@ package showimage
|
|||
|
||||
import "core:os"
|
||||
import "core:fmt"
|
||||
import "core:math"
|
||||
import "core:strings"
|
||||
import rl "vendor:raylib"
|
||||
|
||||
|
@ -51,7 +52,10 @@ main :: proc() {
|
|||
rl.BeginDrawing()
|
||||
rl.ClearBackground({50, 50, 50, 255})
|
||||
if tex != nil {
|
||||
rl.DrawTextureEx(tex^, offset, 0, zoom, rl.WHITE)
|
||||
factor := max(1, zoom)
|
||||
scaled := offset / factor
|
||||
aligned_offset : [2]f32 = {math.floor(scaled.x), math.floor(scaled.y)} * factor
|
||||
rl.DrawTextureEx(tex^, aligned_offset, 0, zoom, rl.WHITE)
|
||||
}
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue