-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
[GSoC'21] Layers Feature #343
Conversation
Thanks for the update @Sov-trotter |
So not all actions are supported, but we can support the ones defined here https://juliagraphics.github.io/Luxor.jl/dev/images/#Transforming-images I am planning to do rotation and opacity abit later? They are easy to implement. |
Oh because each layer is kinda it's own drawing, right? |
Can we keep the As reference of your test script: https://gist.github.com/Sov-trotter/f8b8a7a188c4d0782e48fb2f32a9b48e#file-test_layers-jl-L95 |
Yeah sure. Also I think that this is the right time to start talking about the syntax. @TheCedarPrince I would like to hear your opinion too. L1 = @layer(frame, width, length) begin
.......
........
end But this will be quite difficult to parse and generalize. A simpler macro syntax can be L1 = @layer 1:70 500 500 Point(10, 20) begin
object1 = .....
act!(object1...)
...
...
end They are almost similar except for the comma separators and braces. Also I have introduced a new flag viz. Updated the test script https://gist.github.com/Sov-trotter/f8b8a7a188c4d0782e48fb2f32a9b48e |
Interesting process with the macro. I like that way. We just always need to make sure that both things work such that we can move objects later into a layer which might sometimes be better for readability. |
Yeah. Sure. I'll start with the tests once @TheCedarPrince gives his views on the macro syntax. I think trying to recreate the video using layers will put the feature to a good test!
orange_ball = Object(1:70, (args...)->object(O, "orange"), Point(100,0))
act!(orange_ball, Action(anim_rotate_around(2π, 0.0, layer1)))
|
One thing that I'm not sure about: |
No it actually scales the layer down. Also the objects no longer exist and all the layer based actions are applied to the image matrix of the layer.
Yeah they will be |
Codecov Report
@@ Coverage Diff @@
## master #343 +/- ##
==========================================
+ Coverage 95.58% 95.98% +0.39%
==========================================
Files 23 27 +4
Lines 1201 1369 +168
==========================================
+ Hits 1148 1314 +166
- Misses 53 55 +2
Continue to review full report at Codecov.
|
include all tests
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.
Just a quick review for now. Will try to find some time to really test it out. Sorry I'm a bit slow these days.
Make sure to add something to the changelog for this PR @Sov-trotter |
It seems like |
Oh so the assumption is normally more that we want to rotate the layer around a point while the layer itself should not rotate. |
Yeah. |
Current code for the chess board: using Colors
using Javis
function ground(args...)
background("white") # canvas background
sethue("black") # pen color
end
function ground_chess_board(args...)
background("black") # canvas background
sethue("white") # pen color
end
function chess_square(i,j,square_size, light, dark)
translate(-4*square_size, -4*square_size)
translate((i-1)*square_size, (j-1)*square_size)
if (i+j) % 2 == 1
sethue(dark)
else
sethue(light)
end
rect(O, square_size, square_size, :fill)
end
myvideo = Video(1000, 1000)
Background(1:300, ground)
default_light = RGB(1.0, 1.0, 1.0)
default_dark = RGB(2/256, 144/256, 53/256)
new_light = RGB(0.8, 0.8, 0.8)
new_dark = RGB(204/256, 136/256, 0.0)
chess_board = @JLayer 1:300 500 500 O begin
Background(1:300, ground_chess_board)
square_size = 60
squares = [Object(1:300, (args...; light=default_light, dark=default_dark) -> chess_square(i,j,square_size, light, dark)) for i=1:8, j=1:8]
for col in squares
act!(col, Action(20:80, change(:light, default_light => new_light)))
act!(col, Action(20:80, change(:dark, default_dark => new_dark)))
act!(col, Action(240:300, change(:light, new_light => default_light)))
act!(col, Action(240:300, change(:dark, new_dark => default_dark)))
end
end
act!(chess_board, Action(20:80, anim_rotate(1.0*π)))
act!(chess_board, Action(100:120, anim_translate(Point(-100, -100))))
act!(chess_board, Action(130:190, anim_rotate(-1.0*π)))
act!(chess_board, Action(200:220, anim_translate(Point(-100, -100), O)))
act!(chess_board, Action(240:300, anim_rotate(1.0*π)))
render(myvideo; pathname = "chess_board.gif") |
I think it makes sense to release this as v0.6 also due to the fact that we need a newer version of Luxor.jl for this
This reverts commit 5a5add4.
This should be good to go now @TheCedarPrince @Wikunia |
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.
Oh forgot to publish my review. Sorry. Otherwise looks very solid
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.
@Sov-trotter and @Wikunia - this is ready for merging.
Just address @Wikunia 's last two points and we can merge. |
I can't understand what happened here? Any ideas @Wikunia |
I think you understood it 😉 You don't want to return from inside of the |
Thanks a lot for your wonderful work @Sov-trotter |
PR Checklist
If you are contributing to
Javis.jl
, please make sure you are able to check off each item on this list:CHANGELOG.md
with whatever changes/features I added with this PR?Project.toml
+ set an upper bound of the dependency (if applicable)?test
directory (if applicable)?Link to relevant issue(s)
Closes #75
How did you address these issues with this PR? What methods did you use?
So this is a new approach towards having layers in Javis. Thanks to the ideas of @TheCedarPrince we have something that focuses on Actions rather than objects.
We realised that treating a layer as an object had certain limitations. So why not treat each layer as a drawing. This way we can apply actions on the objects in the layer and also apply actions to the layer(which is a Drawing).
One drawback of this is that since a layer is no longer an object, the actions are applied to it as a whole(ie. to the matrix of the layer's drawing). But its much better than having the layer as an object(as explored here #341 ).
So rendering is now a three step process:
test script
TODO'S :