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

JImage Implementation for J-Objects #399

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8f62037
Exported the JImage function from the JImage shorthand
TheCedarPrince Aug 14, 2021
f1e0822
Possible implementation of adding an image easily to JObjects
TheCedarPrince Aug 14, 2021
e1f5cd8
Made argument names less confusing
TheCedarPrince Aug 14, 2021
de8f54f
Merge branch 'master' into tcp-image-jobjects
TheCedarPrince Sep 28, 2021
7ffc1ba
Added scaling capabilities
TheCedarPrince Sep 28, 2021
e908f6d
Added docstring, changed default for shape
TheCedarPrince Oct 5, 2021
da0184c
In process of adding tests for JImage
TheCedarPrince Oct 5, 2021
1ac4713
Merge branch 'master' into tcp-image-jobjects
TheCedarPrince Dec 29, 2021
c891118
Added type signature from Cairo
TheCedarPrince Dec 30, 2021
27620ba
Reference image for JImage
TheCedarPrince Dec 30, 2021
80957f1
Fixed docstrings
TheCedarPrince Dec 30, 2021
6017adc
Revised using dispatch image
TheCedarPrince Dec 30, 2021
10c9686
Merge branch 'master' into tcp-image-jobjects
TheCedarPrince Jan 5, 2022
68a452a
Added TODO for scaling logic
TheCedarPrince Jan 5, 2022
36bbcbd
Temporary disabling of tests
TheCedarPrince Jan 5, 2022
5811f1a
Added TODO for tests, fixed test cases, and fixed references
TheCedarPrince Jan 5, 2022
2debc17
Added individual tests; working on scaling
TheCedarPrince Jan 10, 2022
545268c
Begin adding autoscaling support for JImage
TheCedarPrince Jan 10, 2022
80ca14e
Added image support dispatch for JBox
TheCedarPrince Jan 16, 2022
92f36ca
Added image support dispatch for JPoly
TheCedarPrince Jan 16, 2022
6e91da7
Added image support dispatch for JStar
TheCedarPrince Jan 16, 2022
2c18b27
Added image support dispatch for JRect
TheCedarPrince Jan 17, 2022
d6331a2
Added image support dispatch for JCircle
TheCedarPrince Jan 17, 2022
51dde2c
Added image support dispatch for JEllipse
TheCedarPrince Jan 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Javis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ include("shorthands/JEllipse.jl")
include("shorthands/JStar.jl")
include("shorthands/JPoly.jl")
include("shorthands/JShape.jl")
include("shorthands/JImage.jl")

export render, latex
export Video, Object, Background, Action, RFrames, GFrames
Expand All @@ -696,7 +697,7 @@ export act!
export anim_translate, anim_rotate, anim_rotate_around, anim_scale

export @Frames, prev_start, prev_end, startof, endof
export JBox, JCircle, JEllipse, JLine, JPoly, JRect, JStar, @JShape
export JBox, JCircle, JEllipse, JImage, JLine, JPoly, JRect, JStar, @JShape

# custom override of luxor extensions
export setline, setopacity, fontsize, get_fontsize, scale, text
Expand Down
17 changes: 17 additions & 0 deletions src/shorthands/JImage.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function _JImage(pos, img, centering, shapeargs, shape)
if shape != false
shape(shapeargs...)
Copy link
Member

@Sov-trotter Sov-trotter Aug 15, 2021

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.

Copy link
Contributor

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!)

Copy link
Member

@Sov-trotter Sov-trotter Aug 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean a built-in Luxor function - eg one that constructs paths

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.

Copy link
Member

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 😂)

Copy link
Contributor

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...

Copy link
Member

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 to Method.
eg: If there's a variable circle = Object(...), and user passes circle as an argument, it will throw the Objects of type Javis.Object are not callable error and maybe use a try catch block to give out a better error message?

Copy link
Member Author

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.

end
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) =
(
args...;
pos = pos,
img = img,
centering = centering,
shapeargs = shapeargs,
shape = shape,
) -> _JImage(pos, img, centering, shapeargs, shape)