-
-
Notifications
You must be signed in to change notification settings - Fork 50
Description
Is your feature request related to a problem? Please explain.
After some fun experiments today, I realized that we do not have a way to easily add images to J-Objects!
Describe the solution you'd like
Here is the syntax I created for a function call:
JCircle(dog_positions[i], 27; img = readpng("tiny_doggo.png"))
Then, here is what I changed in base Javis to the JCircle
function:
JCircle(
center::Point,
radius::Real;
color = "black",
linewidth = 1,
action = :stroke,
img = nothing,
) =
(
args...;
center = center,
radius = radius,
color = color,
linewidth = linewidth,
action = action,
img = img,
) -> _JCircle(center, radius, color, linewidth, action, img)
and here is the internal method:
function _JCircle(center, radius, color, linewidth, action, img)
sethue(color)
setline(linewidth)
if !isnothing(img)
circle(center, radius, :stroke)
circle(center, radius, :clip)
placeimage(img, center, centered = true)
else
circle(center, radius, action)
end
return center
end
Describe alternatives you've considered
I considered writing an external function outside of Javis to do this, but it felt like too much work for such a small new feature addition. Then, I thought about creating a new base Javis function. That didn't make much sense as it is not much different from the base JCircle
J-Object implementation. So, I added it to the base Javis JCircle
definition.
What do you think @Wikunia and @Sov-trotter ? I tested out the above changes and none of the tests we had in place failed using this new functionality.