# Transparent background with Luxor.jl

**URL:** <https://discourse.julialang.org/t/transparent-background-with-luxor-jl/114437>\
**Category:** General Usage\
**Tags:** luxor\
**Created:** [May 18, 2024, 5:17pm UTC](https://discourse.julialang.org/t/transparent-background-with-luxor-jl/114437 "2024-05-18T17:17:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fatteneder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fatteneder/32/33991_2.png) [@fatteneder](https://discourse.julialang.org/u/fatteneder)\
**Post date:** [May 18, 2024, 5:17pm UTC](https://discourse.julialang.org/t/transparent-background-with-luxor-jl/114437/1 "2024-05-18T17:17:09Z")

</div>

Hi.

Does somebody know how I can generate a `.png` file with a transparent background?

The [docs](https://juliagraphics.github.io/Luxor.jl/stable/reference/api/#Luxor.background-Tuple%7BColorTypes.Colorant%7D) here say that it should suffice to put `background(0,0,0,0)`.

Using the MWE from [Simple examples · Luxor](https://juliagraphics.github.io/Luxor.jl/stable/example/examples/)

```julia
using Luxor
@png begin
   background(0,0,0,0)
   setopacity(0.85)
   steps = 20
   gap = 2
   for (n, θ) in enumerate(range(0, step=2π/steps, length=steps))
       sethue([Luxor.julia_green,
           Luxor.julia_red,
           Luxor.julia_purple,
           Luxor.julia_blue][mod1(n, 4)])
       sector(Point(0, 0), 50, 250 + 2n, θ, θ + 2π/steps - deg2rad(gap), action = :fill)
   end
end

```

I only ever get a white background (my image viewer is set to show a checker pattern instead)

 ![image](https://global.discourse-cdn.com/julialang/original/3X/d/a/da0b70bbed254ac1d2d2b5c986d3dbe2237182b5.png)

What am I doing wrong here?

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [May 18, 2024, 5:22pm UTC](https://discourse.julialang.org/t/transparent-background-with-luxor-jl/114437/2 "2024-05-18T17:22:53Z")

</div>

You’re using the “quick” macros, which set the foreground and background to “sensible” defaults. Use the `Drawing()` constructor directly.

---

<div class="post-metadata">

**Author:** ![fatteneder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fatteneder/32/33991_2.png) [@fatteneder](https://discourse.julialang.org/u/fatteneder)\
**Post date:** [May 18, 2024, 5:26pm UTC](https://discourse.julialang.org/t/transparent-background-with-luxor-jl/114437/3 "2024-05-18T17:26:05Z")

</div>

That was it!  
Thanks a lot for the amazing package and the quick tech support 🙂

For completeness:

```julia
using Luxor

Drawing()
origin()

background(0,0,0,0)
setopacity(0.85)
steps = 20
gap = 2
for (n, θ) in enumerate(range(0, step=2π/steps, length=steps))
    sethue([Luxor.julia_green,
        Luxor.julia_red,
        Luxor.julia_purple,
        Luxor.julia_blue][mod1(n, 4)])
    sector(Point(0, 0), 50, 250 + 2n, θ, θ + 2π/steps - deg2rad(gap), action = :fill)
end

finish()
preview()

```
