-
Notifications
You must be signed in to change notification settings - Fork 24
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
Feature: Implement p5 workflow #902
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…to snapshot, and handle onleave
mohdsayed
approved these changes
Dec 25, 2024
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.
Looks great ❤️, just few comments to address.
mohdsayed
approved these changes
Dec 26, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds the logic of creating a new workflow for p5 by introducing a framework over p5.
This PR is the first batch of work, more PRs containing code are coming.
Relevant Technical Choices
This PR contains four classes,
Main
, 'Figure,
Group, and
Animator` (subject to name change in the future).Main
Classp5
library and is set up with the required callbacks.init
method is called to initialize thep5
, withsetup
,draw
, and other event handler methods.The setup
function initializes the canvas and other required variables.draw
function is called in a loop to draw the animation, where two queues are used for rendering, and each rendered object is stored in a snapshot if the throw value is false/unset.stepsQueue
contains the components' objects to be rendered with delay, taking the first object from the queue and rendering it in the next delayed frame.groupStepsQueue
andanimatorStepsQueue
respectively.groupStepsQueue
contains the components' objects to be rendered as a group in the next delayed frame. (Eg. Box and Text together)stepsQueue
is a Group, thegroupStepsQueue
is used to render the group components, and the same number of objects are removed from thestepsQueue
.animatorStepsQueue
contains the components' objects to be rendered as an animation in the next frame. (Eg. Rendering box and then text in the next delayed frame)stepsQueue
is an Animator, theanimatorStepsQueue
is used to render the animator components(can be Figure or Group) and the same number of objects are removed from thestepsQueue
andgroupStepsQueue
respectively.instantQueue
contains the components' objects to be rendered instantly in the next frame.groupInstantQueue
andanimatorInstantQueue
respectively.groupInstantQueue
contains the components' objects to be rendered as a group in the next frame. (Eg. Box and Text together)instantQueue
is a Group, thegroupInstantQueue
is used to render the group components, and the same number of objects are removed from theinstantQueue
.animatorInstantQueue
contains the components' objects to be rendered as an animation in the next frame. (Eg. Rendering box and then text in the next frame)instantQueue
is an Animator, theanimatorInstantQueue
is used to render the animator components(can be Figure or Group) and the same number of objects are removed from theinstantQueue
andgroupInstantQueue
respectively.snapshot
variable is used to store the rendered components till now.Snapshot
can be used to render the components instantly, without any delay whenever redrawing is required.groupSnapshot
andanimatorSnapshot
respectively.reDrawAll
function is used to redraw all the components instantly. It is called on the snapshot and each stored object is pushed to theinstant queue
for rendering.onHover
function is used to check if the mouse is hovering over any figure or group.onHover
function is called on that figure or group.onLeave
function is called.onMousePressed
function is used to check if the mouse is pressed over any figure or group.onMousePressed
function is called on that figure or group.addFigure
function is used to add a figure to the (stepsQueue
||instantQueue
) based on the instant param of the callback.addGroup
function is used to add a group to the (stepsQueue
||instantQueue
) and (groupStepsQueue
||groupInstantQueue
) based on the instant param of the callback.addAnimator
function is used to add an animator to the (stepsQueue
||instantQueue
) and (groupStepsQueue
||groupInstantQueue
) and (animatorStepsQueue
||animatorInstantQueue
) based on instant param of the callback.Figure
ClassFigure
class contains the properties and methods which are common to all the figures, likex
,y
,stroke
,fill
,onClick
,onHover
,onLeave
, etc.Figure
object when created is initialized with a unique ID.Figure
object can be a part of a group or an animator, with gid and aid set respectively.draw
,onHover
,onLeave
, andonClick
are present in theFigure
class, which are implemented in the child classes, eg.Box
,Text
, etc.Group
ClassGroup
object when created is initialized with a unique ID and the figures are set with the gid of the group.draw
method is implemented in theGroup
class, which is used to render the group of figures at once.onHover
,onLeave
, andonClick
methods are implemented in theGroup
class, which are used to call the respective methods of the figures in the group altogether.Animator
ClassAnimator
object when created is initialized with a unique ID and the figures or groups are set with the aid of the animator.The
draw
method is implemented in theAnimator
class, which is used to take the current index of the figures or groups to be rendered render them, and increment the index for the next frame.Testing Instructions
Additional Information:
Screenshot/Screencast
Checklist
This code is covered by unit tests to verify that it works as intended.The QA of this PR is done by a member of the QA team (to be checked by QA).Fixes #857