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

hoc2023: AI modal #652

Merged
merged 5 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,11 @@ module.exports = class DanceAPI {
changePropEachBy: (group, property, val) => {
return nativeAPI.changePropEachBy(group, property, val);
},
ai: value => {
nativeAPI.ai(value);
ai: params => {
nativeAPI.ai(params);
},
aiText: value => {
nativeAPI.aiText(value);
},
};
}
Expand Down
25 changes: 20 additions & 5 deletions src/p5.dance.js
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,25 @@ module.exports = class DanceParty {
}

// Called when executing the AI block.
async ai(value) {
ai(params) {
console.log('handle AI:', params);
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you intend to leave this print statements here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I have found them useful for development, for now. We can probably remove when we get closer to done.


if (params) {
if (params.backgroundEffect && params.backgroundColor) {
this.setBackgroundEffect(
params.backgroundEffect,
params.backgroundColor
);
}

if (params.foregroundEffect) {
this.setForegroundEffect(params.foregroundEffect);
}
}
}

// Called when executing the free-text AI block.
async aiText(value) {
console.log('AI:', value);

// Call the main repo's doAI function which will transform this
Expand All @@ -1129,10 +1147,7 @@ module.exports = class DanceParty {
const params = JSON.parse(response);
console.log('handle AI:', params);

this.setBackgroundEffect(
params.backgroundEffect,
params.backgroundColor
);
this.setBackgroundEffect(params.backgroundEffect, params.backgroundColor);

this.setForegroundEffect(params.foregroundEffect);

Expand Down
Loading