thoppe / pixelhouse Goto Github PK
View Code? Open in Web Editor NEWA minimalist drawing library for making beautiful animations in python
A minimalist drawing library for making beautiful animations in python
https://dev.to/agathacco/how-to-create-pure-css-illustrations-and-animate-them---part-1-1j1k
Useful as a tutorial for beginners!
cf.
https://github.com/mxgmn/WaveFunctionCollapse
https://github.com/ikarth/wfc_python
These will probably need to be recoded by hand.
This issue bounces off of #38
I'm trying to overlay an image the same size as the Canvas
object, using the method
with canvas.layer() as layer:
layer += image.canvas
This works for images that are the same size as the original/base Canvas
(16x16), but they're transparent around the edges. When I try and overlay a fully-colored 16x16 image, it returns transparent. This issues was avoided using the black_to_transparent
function you wrote for me last time. I'm not sure why.
def black_to_transparent(canvas: ph.Canvas) -> ph.Canvas:
black_pixels = np.all(canvas.img == [0, 0, 0, 0], axis=-1)
transparent_canvas = canvas.copy()
transparent_canvas[~black_pixels, 3] = 255 # Change alpha to 255
return transparent_canvas
But since you said you've fixed it, I changed it to this:
def black_to_transparent(canvas: ph.Canvas) -> ph.Canvas:
return canvas
This only causes the full image to go away; it works for everything else.
Here's the full image in question:
And a working transparent image for reference:
Normal World:
Bugged world (nevermind the purple guys they're fine. Just notice there's no door sprites):
Also, the regular black_to_transparent
method causes this following sprite to have a white background. I compared it to a working transparent sprite, which still worked fine:
Doesn't work:
Works fine:
There's probably some issue with how opencv
handles transparency. I know that alphas can be infuriating. Thank you.
The code below produces this image (the red and blue circles should be at 2 and 1 respectively)
import pixelhouse as ph
C = ph.Canvas(1000, 500, extent=4)
r = 2
C += ph.circle(0,0,r=r/20,color='w',thickness=0.0001)
C += ph.circle(0,0,r=2,thickness=0.00001,color='r')
C += ph.circle(0,0,r=1,thickness=0.00001,color='b')
for k in range(-4, 5):
if k==0: continue
C += ph.circle(k,0,r=r/20,color='w')
C.show()
I was messing around with some of the examples and I couldn't figure out why my name wasn't kerned properly, until I dug around enough and found out that Pillow requires a package called libraqm to be installed to use the kerning specified by the ttf and otf files. Once I installed it, the weird kerning between the A and V in my name was fixed, as seen below.
Relevant package: https://github.com/HOST-Oman/libraqm
If you wanted, you could even add an argument to the pixelhouse text class to turn kerning (or any TTF/OTF font feature on or off)
I am a student in the School of Film and I am very interested in this project. I want to get the model and data and study it by myself. Do you have it and can you share with me
https://github.com/rsomani95/shot-type-classifier
I want to get the data set and model of this project. Do you have it? I saw the link that the author of the project has cancelled
Thank you very much and look forward to your reply
I'm in an odd use-case where I'm working with Python 3.7 on a Raspberry Pi. As 3.7 isn't officially available, I had to just through some hoops to get it running. I also compiled OpenCV from source. However, I see that pixelhouse
uses the prebuilt binaries from opencv-python
. Normally, python can install pre-built opencv-python
wheels from https://www.piwheels.org/, but these are only for the officially supported versions (2.7 and 3.5).
From what I've read, all the different wrappers from Python to OpenCV use the same namespace, cv2
. This means that (ideally) shouldn't be any changes to the code, only setup.py
and requirements.txt
perhaps. I'm just not sure how setuptools
would handle an "optional" requirement. However, I'm not sure how to setup pixelhouse
without this change.
Thanks.
I'm trying to composite these two images:
Ideally, the Tree should appear on top of the Grass tile. Following the examples, I made this short piece of code to test this idea:
from pixelhouse import Canvas
spr = Canvas().load(r"C:\Users\SawyerPC\PycharmProjects\Discordia\Discordia\Interface\Rendering\Sprites\Terrain\grass_center.png")
spr.show()
with spr.layer() as layer:
c = Canvas().load(r"C:\Users\SawyerPC\PycharmProjects\Discordia\Discordia\Interface\Rendering\Sprites\Structures\wilds_default.png") # Tree Sprite
c.show()
layer += c
spr.show()
I've tried manually calling Canvas().combine()
with mode
equal to blend
, add
, and subtract
, all of which don't seem to change the final Canvas
object at all. Is there an easy way to superimpose one Canvas
on top of another? Thank you.
from reddit
Very cool library! Thanks for putting it out there. I teach kids coding and this would interest a few of them. We've used Scratch and Processing a bit. I've played with Pygame and other game frameworks too, but there's usually too much boilerplate for beginners.
One thing I'd love, because I find it's a useful sandbox for beginners, is a way to run this library from a REPL - i.e. draw a canvas, throw a few primitives up, change their attributes. Not sure if that's possible for this library. I did try to run it from the Python prompt but found that I had to Cmd-Q the Python window to close it - which also quit my Python prompt too. Again, probably not a use case you are shooting for here - but anyways....
I'd also love a way to bring interactivity into it - i.e. move things via key presses, mouse movements etc... Once, again - this might be outside the scope.
At the very least, it should be easy to capture a key press and escape from an animation without ctrl-c/q.
After installing from pip, the logo example fails as the fonts folder does not exist in the site-packages/pixelhouse folder.
Background should be the canvas background
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.