GithubHelp home page GithubHelp logo

hama / snaptag Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jusleg/snaptag

0.0 1.0 0.0 962 KB

Make your own custom snapcode

Home Page: https://snapcodes.herokuapp.com/

License: MIT License

JavaScript 80.65% PHP 12.51% HTML 3.79% CSS 3.05%

snaptag's Introduction

Snaptag

gif

Make your own custom snapcode

Live demo

How it works

  1. Query the Snapchat API to get snapcode
  2. Send snapcode to PHP script to add necessary tags
  3. Select the colors using jscolor picker
  4. Render the SVG as a canvas
  5. Convert the canvas to PNG
  6. Download the PNG
  7. showcase your cool snapcode ๐Ÿ˜„

API

I made a simple php script that inserts id tag in the svg to be able to modify it via css or using javascript.

<?php
    header('Access-Control-Allow-Origin: *');
    $username = $_GET["username"];
    $size = $_GET["size"];
    if(strlen($username)>0){
            //snapchat api call
            $url = "https://feelinsonice-hrd.appspot.com/web/deeplink/snapcode?username=".$username."&type=SVG&size=".$size;
            $file = file_get_contents($url, false, $context);
            $pos =strpos($file,"svg");
            $file = substr($file, 0, $pos+3)." id=\"tag\"".substr($file, $pos+4);
            $pos =strpos($file,"path d");
            $file = substr($file, 0, $pos+4)." id=\"border\" ".substr($file, $pos+5);
            $pos =strpos($file,"path d");
            $file = substr($file, 0, $pos+4)." id=\"back\" ".substr($file, $pos+5);
            $pos =strpos($file,"path d");
            $file = substr($file, 0, $pos+4)." id=\"ghost\" ".substr($file, $pos+5);
            echo $file;
    }
?>

You can try my script at https://snapcodes.herokuapp.com/snapcode.php

Modifications

I am using the PHP script because it inserts the necessary id and class tags to do DOM manipulations. Parts of the snapcode can be modified using the id below

Name id or class
Snapcode #tag
Ghost .ghost
Code .back
Frame .border

guidelines

To read about scan guidelines, you can read Snapchat's Snapcode Scan Guidelines

Gif background (Beta)

You can put a gif instead of an image. You can fiddle around with the code on this codepen

Limitations

The only limitation of this project at the moment is that Snapcodes cannot be downloaded from an iOS device. This is due to the canvas rendering used to convert from SVG to PNG. This is not a problem on Android devices or desktop. I will try to use a php script to convert the SVG to PNG if the user is on iOS.

People currently using snaptag

Future improvements

  • iOS download
  • Ability to insert a picture inside the ghost
  • custom sizes
  • animated snapcodes (like the one pictured above)

Credits

snaptag's People

Contributors

jusleg avatar

Watchers

fang qiang 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.