GithubHelp home page GithubHelp logo

fluffycatware / kittycoin-id-parser Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 12.81 MB

Official KittyCoin Generator

Home Page: https://fluffycatware.github.io/kittycoin-id-parser/

Python 34.04% HTML 65.96%
ethereum palette-swap ppm-image smart-contract-tools

kittycoin-id-parser's Introduction

KittyCoin Parser

Official KittyCoin Generation Library for the KittyCoin Club Ethereum Smart Contract.

Python

About

This library exports a single function kittycoinparser which takes a 5 byte hex kittyCoinId and returns a 2D array of hex color value strings, or null for transparency.

You can view a demo of this library running here: https://fluffycatware.github.io/kittycoin-id-parser/

Setup

The PPM definitions for the types of images output can be found in kittycoinparser.js under the var designs field. You can use the image2ppm python util that is also in this project. Check the README for more inforamtion on how to generate lists of PPM strings.

Web Example

<!DOCTYPE HTML>
<html>
<head>
    <style>
        body {
            margin: 0px;
            padding: 0px;
            }
    </style>
</head>
    <body>
        <canvas id="canvas"></canvas>
        <script src="kittycoinparser.js"></script>
        <script>

            generateKittyCoinImage("0x00f9e605e3", 2)

            function generateKittyCoinImage(catId, size){
                size = size || 10;
                var data = kittycoinparser(catId);
                var canvas = document.getElementById("canvas");
                canvas.width = size * data.length;
                canvas.height = size * data[1].length;
                var ctx = canvas.getContext("2d");

                for(var i = 0; i < data.length; i++){
                    for(var j = 0; j < data[i].length; j++){
                        var color = data[i][j];
                        if(color){
                        ctx.fillStyle = color;
                        ctx.fillRect(i * size, j * size, size, size);
                        }
                    }
                }
                return canvas.toDataURL();
            }
        </script>
    </body>
</html> 

Here's a couple example of different random IDs:

0x00f9e605e3

Attribution

This library was based heavily on the work done by ponderware

kittycoin-id-parser's People

Contributors

t04glovern avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.