-
Notifications
You must be signed in to change notification settings - Fork 22
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
Aaron Plocharczyk created Turtle Exercise blog post #48
Conversation
This includes the trinket itself as well as a reflection.
|
||
I started out making a photoshop icon, and I was going to draw some background designs around it. Then I realized while drawing the box shape for the Photoshop icon that I could just draw a bunch of boxes to make a big grid across the screen. I could then fill in the boxes of that grid to display some retro pixel art, like a Mario character or something. Then I thought, why stop there? Actual pictures are nothing but a ton of pixels, so if I could extract color values from a real image, I could fill in the grid with those color values and have something that looks like a real image. I found a PHP function that extracts color values from images, and I just used nested for loops in PHP to write python code to draw a grid with those color values. My code is included for your viewing. It takes forever to draw, so I've included a link below with a preview image of the final result. | ||
|
||
http://bytecrank.com/filebox/316d4df8eae0e148ef1237ead8118e03c7188b3aba829f9aaa42d1e53998c02856a84036913cccd69da3a6505bbf124efac43684a45fde319ab5866e114c0687/clients/inls560/ss.png |
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.
You can (and should) embed images like these into posts with this syntax:
![Image alt text](url)
|
||
<iframe src="https://trinket.io/embed/python/18013b1bd3" width="100%" height="600" frameborder="0" marginwidth="0" marginheight="0" allowfullscreen></iframe> | ||
|
||
I started out making a photoshop icon, and I was going to draw some background designs around it. Then I realized while drawing the box shape for the Photoshop icon that I could just draw a bunch of boxes to make a big grid across the screen. I could then fill in the boxes of that grid to display some retro pixel art, like a Mario character or something. Then I thought, why stop there? Actual pictures are nothing but a ton of pixels, so if I could extract color values from a real image, I could fill in the grid with those color values and have something that looks like a real image. I found a PHP function that extracts color values from images, and I just used nested for loops in PHP to write python code to draw a grid with those color values. My code is included for your viewing. It takes forever to draw, so I've included a link below with a preview image of the final result. |
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.
Creative thought!
Revisiting this with what we're learning about loops, you'll be able to make a much more flexible program. You could still use a PHP utility to make a text-based description of the image, but use a loop to go through the colors and build an image in turtle.
Perhaps this post would be inspiring: http://www.101computing.net/pixel-art-in-python/
In that post, users hand-code pixel art. If you generated the text-based representation of the image required by the code examples above, you could then print any image in a pixelated style.
I like the persistence and creativity here. Bringing in things you know from other programming language is good, of course, but one thing this hack lacks is much of your 'hand' in the code. The Photoshop logo would've let you use far more of Turtle's capability and you'd have written far more actual Python.
That said, this gets high marks for creativity, precision, and persistence.
I'm going to merge this but you need a .md file extension on your post. Please fix this in its own or a future PR. |
This includes the trinket itself as well as a reflection.