Creating a drawing using dimensions results in expected plotting behavior in the VS code plot pane:
using Luxor, Dates
dt=now()
d=Drawing(400, 400, "useDimensions_" * Dates.format(dt, dateformat"yyyymmdd\THHMMSS") * ".png")
background("cyan")
origin()
juliacircles()
finish()
preview()
However, specifying a matrix when creating the drawing results in plots being directed to my default PNG app, Paint. Furthermore, two instances of Paint are produced
using Luxor, Images, Dates
A = zeros(ARGB32, 400, 400)
dt=now()
d=Drawing(A, "useMatrix_" * Dates.format(dt, dateformat"yyyymmdd\THHMMSS") * ".png")
background("orange")
origin()
juliacircles()
finish()
preview()
Yes. Do you need an explanation, or… ?
@cormullion This adventure started with me just trying to get the color of a pixel as in something like ‘getPixel(300,200)’. In any case, I found the matrix example. So, while it would be nice to understand why the matrix example uses the external app to display the PNG file and/or 'Why two?", I would really like to know if there is a simple way to get pixel values, or a way to access the underlying matrix if using the “Drawing(400, 400, …)” call.
@cormullion I tried the second example in the Luxor Playing with Pixels while “paying attention” and noticed that the plot (which does appear in the VS Code plot pane) is generated by adding the matrix variable A at the end. So, I added the ‘A’ at the end of my code and I guess I can live with not understanding what is happening with my original. Thanks for your input.
using Luxor, Images, Dates
A = zeros(ARGB32, 400, 400)
dt=now()
d=Drawing(A, "useMatrix_" * Dates.format(dt, dateformat"yyyymmdd\THHMMSS") * ".png")
background("orange")
origin()
juliacircles()
finish()
preview()
**A**
When you create a drawing out of an array, the surface type (d.surfacetype
) is set to :image
, so it will be displayed (by preview()
) in an external application, rather than in the plot pane. But if Images.jl also installed and active, image arrays can be displayed in the plot pane.
One of the things to be aware of - if you mix arrays and drawing canvases - is that the addresses of pixels won’t correspond directly with the coordinates of vector graphics. It’s easy to get confused…
If you create a drawing directly rather than from an array, you won’t have access to the internal ‘drawing array’ later. It’s possible that something could be changed in the source code, but it’s probably out of scope for this “simple drawing package”.
@cormullion Thank you very much for that! That explanation has clarified a number of things. I think things will be going a lot smoother for me now.