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

Intelligent copy/paste image #109

Open
acbart opened this issue Nov 25, 2020 · 1 comment
Open

Intelligent copy/paste image #109

acbart opened this issue Nov 25, 2020 · 1 comment

Comments

@acbart
Copy link
Contributor

acbart commented Nov 25, 2020

When someone copy/pastes an image into the BlockPy editor, you can set up hooks with BlockMirror to convert the image into a URL (potentially uploading it to a remote server along the way), and then returning some Python code to inject (that will be rendered as an image by BlockMirror in its respective editors).

The code that should be injected could vary in a few different ways, depending on what framework you are using. Both PIL and Pygame are popular choices for image manipulation, and we probably will ultimately create our own library that sits on one or both of them.

I think BlockPy could do a little witchcraft to check what packages are currently "loaded" (imported) in a user's code in order to provide a best guess about what they want. For example, if import pygame is found in the AST, then we can probably assume they want it to be a pygame image.

Ultimately, I'd like the following user experience:

  1. User pastes an image into the editor
  2. The image gets stored in the images associated with that submission
  3. A filename is produced for that image relative to the current folder.
  4. The following code gets injected (intelligently reusing any viable existing import)
import pygame
# ...
dog = pygame.image.load('images/dog.png')
  1. The editor knows to render the pygame.image.load("valid filename") call as an image

The user could then go into the Images tab to edit/replace/move the image.

@thomaswp
Copy link

This would also be nice on the instructor's side in the assignment editor :D

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

No branches or pull requests

2 participants