IwoHerka
How to draw transparency using :egd?
I cannot get drawing transparency to work. How can I make :egd to set alpha properly?
image = :egd.create(100, 100)
# Use any color with alpha = 0
:egd.filledRectangle(image, {0, 0}, {99, 99}, :egd.color({25, 123, 0, 0}))
:egd.render(image, :png)
# or :egd.render(image, :png, [render_engine: :alpha])
:edg.save(image, "image.png")
The above produces solid-color image, instead a transparent one. Am I doing something wrong?
Thanks!
First Post!
kip
ex_cldr Core Team
Wow, the :egd documentation is not very expansive!
The only thing I can think of is to assert on the function. It’s a strange module in that it mutates too! Perhaps try this and see if you get any exceptions?
image = :egd.create(100, 100)
# Use any color with alpha = 0
:ok = :egd.filledRectangle(image, {0, 0}, {99, 99}, :egd.color({25, 123, 0, 0}))
:edg.save(image, "image.png")
Edit:
Hmmm since you get a solid color image I guess the filledRectangle/4 call is working as expected.
0
Last Post!
IwoHerka
I get an exception, but because not calling render first makes image invalid type for save. render returns Binary::binary() which save excepts. Before call to render, image is of type Image::egd_image().
0
Popular in Questions
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
In templates/appointment/index.html.eex:
<%= for appointment <- @appointments do %>
<tr>
<td><%= appoi...
New
If I have a post route which an argument:
post /my_post_route/:my_param1, MyController.my_post_handler
How would get the post params ...
New
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
Other popular topics
Phoenix 1.4.0 released
Phoenix 1.4 is out! This release ships with exciting new features, most notably
with HTTP2 support, improved deve...
New
Hi All,
I set a environment variables in dev.exs , like below code.
when i start server, how can i set the ${enable} value?
thanks.
d...
New
Hello!
tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability.
After spen...
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar.
I p...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









