You can't just "Plot a pixel on the screen"
StevenSiew opened this issue · comments
Here is a simple assignment. Plot a pixel to an image.
- Image size 640(width) by 480(height)
- on position Cartesian coordinate (0,479)
- plot a pixel with color RGB (123,147,250)
Easy right??? Wrong! On Luxor this is HARD.
you need to do this
struct CanvasConfig
width::Int64
height::Int64
end
lit_apixel = zeros(ARGB32, 1, 1)
lit_apixel[1, 1] = colorant"red"
widthheight = (640,480)
Drawing(widthheight..., "MyImage.png")
canvasconfig = CanvasConfig(widthheight...)
function lit_plot_a_pixel_imagecoor_noncenter(canvasconfig,x,y,apixel)
local p = Point(x,y)
placeimage(apixel, p)
end
function lit_color_apixel(color_p)
lit_apixel[1, 1] = color_p
end
coor = lit_convert_xy_cartesiancoor_to_imagecoor(canvasconfig,0,479)
lit_color_apixel(RGB(123,147,250))
lit_plot_a_pixel_imagecoor_noncenter(canvasconfig,coor.x,coor.y,lit_apixel)
Your mission Jim, if you choose to accept this, is to write Luxor function to do this using only one Function. As always, should you or any of your IM Force be caught or killed, the Secretary will disavow any knowledge of your actions. This tape will self-destruct in ten seconds. Good luck, Jim.
Luxor is designed to draw vector graphics. Pixel operations are best done in Images.jl.
Can't you just create a function in Luxor to plot a pixel with RGB value (r,g,b) to a pixel at image coordinate X,Y???
You can access the RGBA array directly (as described at length in the documentation ) but there’s no access to pixels via the Cairo API, other than by drawing small rectangles.