Git Product home page Git Product logo

pixelhouse's People

Contributors

dwhit avatar shannonturner avatar thoppe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pixelhouse's Issues

Continuous animations

Multiple people expressed interest in creating animations that do not have a fixed time schedule, but rather run with a generator. I envision an Artist generator that takes input continuously and keeps rendering until broken by the user. cc @ehaengel

Overlaying non-transparent, same-size-as-Canvas images makes them fully transparent

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:

town_default

And a working transparent image for reference:

wilds_default

Normal World:

screen1

Bugged world (nevermind the purple guys they're fine. Just notice there's no door sprites):

world_1560191136

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:

null_actor

Works fine:

null_npc

There's probably some issue with how opencv handles transparency. I know that alphas can be infuriating. Thank you.

transform_length off by a factor of two

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()

bad

Mention in the Readme that you need to install libraqm for proper kerning of text

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.

Bad Kerning:
no_kern

Proper Kerning:
proper_kerning

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)

Allow installation with other OpenCV distributions

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.

Overlay a partially-transparent Canvas on-top of another Canvas

I'm trying to composite these two images:

https://imgur.com/a/0RaH9zq

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.

Escape animations without ctrl-C

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.