JuliaGraphics / Luxor.jl

Simple drawings using vector graphics; Cairo "for tourists!"
http://juliagraphics.github.io/Luxor.jl/
Other
588 stars 71 forks source link

A 1x1 box is semi-transparent #298

Closed flexagoon closed 7 months ago

flexagoon commented 7 months ago

It seems like the easiest way to paint a single pixel with Luxor.jl is like this:

box(p, 1, 1, :fill)

However, for some reason, this makes the box semi-transparent.

Example:

@draw begin
    background("blue")
    sethue("white")
    for x in -150:150
        for y in -150:150
            p = Point(x, y)
            box(p, 1, 1, :fill)
        end
    end
end

Expected result:

image

Actual result:

image

cormullion commented 7 months ago

Hi! I believe antiasliasing is on by default. So try:

setantialias(1)

which switches it off.

See here for more.

flexagoon commented 7 months ago

@cormullion that does fix the issue, thank you!

By the way, is there a better way of painting individual pixels? The only two methods I managed to find is either drawing a 1x1 box or manually creating a pixel matrix before initializing the drawing. The first one is much easier, but as it turns out it requires disabling antialiasing.

cormullion commented 7 months ago

If you're going to be addressing pixels a lot, then you should probably be using Images.jl rather than Luxor.jl ... The only benefit of Luxor's "imagematrix" feature is being able to combine both simple pixel-addressing (where an image is merely a Julia array) with vector graphics and text ... The conflicting coordinate systems are mildly irritating though 😀

flexagoon commented 7 months ago

Unfortunately I need both per-pixel drawing and vector shapes, so I can't really use Images.jl