Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sethue() and setcolor() to accept Nothing arguement #273

Closed
StevenSiew opened this issue Oct 2, 2023 · 2 comments
Closed

Update sethue() and setcolor() to accept Nothing arguement #273

StevenSiew opened this issue Oct 2, 2023 · 2 comments

Comments

@StevenSiew
Copy link

StevenSiew commented Oct 2, 2023

Please update sethue() amd setcolor() to accept Nothing arguement to return the current values of color and alpha

function sethue(::Nothing)
    (cr, r, g, b, a) = _get_current_cr_color()
    return current_color
end
function setcolor(::Nothing)
    (cr, r, g, b, a) = _get_current_cr_color()
    return current_color_and_alpha
end

and make two new functions

gethue() = sethue(nothing)

getcolor() = setcolor(nothing)

you can also add this

sethue() = sethue(nothing)

setcolor() = setcolor(nothing)
@cormullion
Copy link
Member

cormullion commented Oct 2, 2023

Hi! It's a reasonable idea. There's already a getcolor() function, a gethue() function would be easy to add.

In general there's an inconsistency in the APl: the interface style of set...(nothing) to do the equivalent get...() is sometimes available and sometimes not. For example, there's a getline() to match setline(), but a setstrokescale(nothing) rather than a getstrokescale(). There's no setantialias(nothing) or setlinecap(nothing). And sometimes there aren't available hooks to get the information that you can set (getopacity()). So I think the interface will continue to be inconsistent even with these additions ... :)

@cormullion
Copy link
Member

Luxor v3.9:

julia-1.10> Drawing()
 Luxor drawing: (type = :png, width = 800.0, height = 800.0, location = luxor-drawing.png)

julia-1.10> sethue()
RGB{Float64}(0.0,0.0,0.0)

julia-1.10> getcolor()
RGBA{Float64}(0.0,0.0,0.0,1.0)

julia-1.10> setcolor()
RGBA{Float64}(0.0,0.0,0.0,1.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants