-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
JImage
Implementation for J-Objects
#399
base: main
Are you sure you want to change the base?
Changes from 1 commit
8f62037
f1e0822
e1f5cd8
de8f54f
7ffc1ba
e908f6d
da0184c
1ac4713
c891118
27620ba
80957f1
6017adc
10c9686
68a452a
36bbcbd
5811f1a
2debc17
545268c
80ca14e
92f36ca
6e91da7
2c18b27
d6331a2
51dde2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
function _JImage(pos, img, centering, shapeargs, shape, scaleargs) | ||
if shape != false | ||
if !isnothing(shape) | ||
shape(shapeargs...) | ||
end | ||
scale(scaleargs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would really like to have automatic scaling by checking the size of the shape and that of the image. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, following on from my question (#399 (comment)) not all graphic construction functions are similar in having an action keyword. We'd have to compile a list and see which ones could be updated... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you interested in standardizing the functions though such that all have an option which provide using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we can make a list of possible functions as an issue at Luxor.jl. It might be easy or not, not too sure how many are affected... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since this spawned off another issue, shall we resolve this comment @Wikunia and @cormullion ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided to close this conversation as I do not think automatic scaling is feasible as all shapes can define a bounding box differently within Luxor. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can find a BoundingBox for a lot of "shapes" using eg @draw begin
circle(O, 100, :stroke)
circle(O, 100, :path)
bbox = BoundingBox(pathtopoly()[1])
box(bbox, :stroke)
end If you can convert a shape to a polygon, then you can get a bounding box that way. Are there any other shapes in Luxor that you'd like BoundingBox to work on? |
||
placeimage(img, pos, centered = centering) | ||
TheCedarPrince marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return pos | ||
end | ||
|
||
JImage(pos::Point, img, centering = true; shapeargs = (), shape = false, scaleargs = 1) = | ||
""" | ||
JImage(pos::Point, img, centering = true; shapeargs = (), shape = nothing, scaleargs = 1) | ||
|
||
Place a given image at a given location as a `Javis` object. | ||
Images can be cropped to different shapes and scaled to different sizes while being placed. | ||
TheCedarPrince marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Returns the position of the image location. | ||
""" | ||
JImage(pos::Point, img, centering = true; shapeargs = (), shape = nothing, scaleargs = 1) = | ||
( | ||
args...; | ||
pos = pos, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor thing:
I think we should mention(in the docstring) that
shape
should be a valid Luxor shape(a luxor function).eg: rect, box, poly etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"valid Luxor shape" I'm not aware of this concept. :) Do you mean a built-in Luxor function - eg one that constructs paths, or one that generates points for polygons...? (Not trying to be awkward, just I get worried in case I'm not providing the tools you folks need for your cool constructions!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah! We need shape to be a valid luxor function. Since a user may interpret it as entering a full shape name eg: rectangle instead of
rect
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We mean any kind of function either their own or more likely a Luxor drawing function. Mostly those which provide the clipping action (so yeah a drawing function 😂)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, yes. Perhaps any function that has an
action
parameter/keyword...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing I want to mention is that
shape
should by typed toMethod
.eg: If there's a variable
circle = Object(...)
, and user passes circle as an argument, it will throw theObjects of type Javis.Object are not callable
error and maybe use a try catch block to give out a better error message?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea - error handling is something we need to reckon with @Sov-trotter . I agree with your thoughts and will see what I can do.