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

Drawing LaTeX Improvements #224

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Conversation

TheCedarPrince
Copy link
Member

PR Checklist

If you are contributing to Javis.jl, please make sure you are able to check off each item on this list:

  • Did I update CHANGELOG.md with whatever changes/features I added with this PR?
  • Did I make sure to only change the part of the file where I introduced a new change/feature?
  • Did I cover all corner cases to be close to 100% test coverage (if applicable)?
  • Did I properly add Javis dependencies to the Project.toml + set an upper bound of the dependency (if applicable)?
  • Did I properly add test dependencies to the test directory (if applicable)?
  • Did I check relevant tutorials that may be affected by changes in this PR?
  • Did I clearly articulate why this PR was made the way it was and how it was made?

Link to relevant issue(s)
#161

How did you address these issues with this PR? What methods did you use?

The draw LaTeX PR was good (#206 ) but I noticed that the drawing animation seems to "swoop" into the frame. This is a result of using the circle object to cover up/uncover the LaTeX being animated. I propose to add additional shapes (such as rectangles) to modify this behavior.

@TheCedarPrince
Copy link
Member Author

@Wikunia, I noticed that there seems to be a strange behavior in my code in providing a rectangular glide. Here is my code:

function animate_latex(text, pos::Point, t, action)
    svg = get_latex_svg(text)
    action == :stroke && (action = :fill)
    if t >= 1
        translate(pos)
        pathsvg(svg)
        do_action(action)
        translate(-pos)
        return
    end

    pathsvg(svg)
    polygon = pathtopoly()
    w, h = polywh(polygon)

    translate(pos)
    pathsvg(svg)
    do_action(:clip)
    rect(O, t * w, h, :fill)
    translate(-pos)
end

And here is the output:
latex

Somehow, the h "height" return from polywh does not completely cover the LaTeX. Any thoughts as to why this is? Is this a bug in polywh?

@Wikunia
Copy link
Member

Wikunia commented Oct 11, 2020

It gives you the width and height but not the starting point. You assume the starting point is the origin but this seems to be wrong in this case. You should be able to see it when drawing the rectangle in red and on top the latex.

@TheCedarPrince
Copy link
Member Author

Hey @Wikunia I tested this again and, though I changed the presumed point, I still have the same problem. Here is what the output of my modified code is now:

function animate_latex(text, pos::Point, t, action)
    svg = get_latex_svg(text)
    action == :stroke && (action = :fill)
    if t >= 1
        translate(pos)
        pathsvg(svg)
        do_action(action)
        translate(-pos)
        return
    end 
    
    pathsvg(svg)
    polygon = pathtopoly()
    w, h = polywh(polygon)
    sethue("red")
    rect(pos, t * w, h, :fill)
    pathsvg(svg)
    do_action(:clip)
    translate(-pos)
end

and output:

latex

It's almost like the LaTeX is being shifted somehow... Thoughts?

@Wikunia
Copy link
Member

Wikunia commented Oct 12, 2020

I can't see anything to be honest. Why don't you draw the latex on top of the rectangle to see where it is exactly and why it doesn't match.

@Wikunia
Copy link
Member

Wikunia commented Nov 11, 2020

Will you continue trying to tackle this @TheCedarPrince ?

@TheCedarPrince
Copy link
Member Author

Yes @Wikunia - it is on my radar to be worked on in v0.3.x. So, should be one of the first ones I tackle.

@TheCedarPrince TheCedarPrince mentioned this pull request Nov 12, 2020
@Wikunia Wikunia changed the base branch from master to main February 25, 2022 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants