Convert Figma logo to code with AI

Platane logosnk

🟩⬜ Generates a snake game from a github user contributions graph and output a screen capture as animated svg or gif

4,179
1,016
4,179
1

Top Related Projects

Browser extension for rendering an isometric pixel art version of your GitHub contribution graph.

:octocat: Generate an image of all your Github contributions

Tool for visualizing GitHub profiles

:octocat: A tool that generates a repository which being pushed into your GitHub account creates a nice contributions calendar.

Quick Overview

Platane/snk is a GitHub repository that generates a snake game animation for your GitHub contribution graph. It creates a customizable SVG animation of a snake eating your contributions, which can be used to add a fun and dynamic element to your GitHub profile README.

Pros

  • Adds a unique, eye-catching element to GitHub profiles
  • Highly customizable with various options for colors, snake behavior, and grid size
  • Automatically updates to reflect recent contributions
  • Easy to integrate into GitHub profile READMEs

Cons

  • May be considered gimmicky or unprofessional for some users or in certain contexts
  • Requires GitHub Actions to run, which might not be suitable for all users
  • Limited practical utility beyond visual appeal
  • Can potentially slow down the loading of GitHub profile pages

Getting Started

To add the snake animation to your GitHub profile:

  1. Fork the Platane/snk repository
  2. Create a new workflow file in your profile repository:
name: generate animation

on:
  schedule:
    - cron: "0 */24 * * *" # runs every 24 hours
  workflow_dispatch:

jobs:
  generate:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    
    steps:
      - uses: Platane/snk@v2
        with:
          github_user_name: ${{ github.repository_owner }}
          outputs: |
            dist/github-contribution-grid-snake.svg
            dist/github-contribution-grid-snake-dark.svg?palette=github-dark
      - uses: crazy-max/ghaction-github-pages@v3.1.0
        with:
          target_branch: output
          build_dir: dist
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  1. Add the following to your profile README.md:
![GitHub Snake Light](https://github.com/{username}/{username}/blob/output/github-contribution-grid-snake.svg#gh-light-mode-only)
![GitHub Snake Dark](https://github.com/{username}/{username}/blob/output/github-contribution-grid-snake-dark.svg#gh-dark-mode-only)

Replace {username} with your GitHub username. The snake animation will now appear on your profile and update automatically.

Competitor Comparisons

Browser extension for rendering an isometric pixel art version of your GitHub contribution graph.

Pros of isometric-contributions

  • Provides a unique 3D isometric view of GitHub contributions
  • Offers customization options for colors and tile height
  • Lightweight and easy to integrate into GitHub profiles

Cons of isometric-contributions

  • Limited to visualizing only GitHub contributions
  • Less dynamic and interactive compared to snk
  • Hasn't been updated recently, potentially lacking newer GitHub features

Code Comparison

isometric-contributions:

var ContributionsGraph = function(options) {
  this.data = options.data;
  this.colorScheme = options.colorScheme || defaultColorScheme;
  this.setCanvasSize();
};

snk:

export const generateSnakeAnimation = async (
  cells: Cells,
  options: Options = {}
): Promise<SnakeAnimation> => {
  const snake = createSnake(cells);
  return { snake, cells };
};

Summary

isometric-contributions offers a visually appealing 3D representation of GitHub contributions, while snk provides a more interactive and dynamic snake game-style visualization. isometric-contributions is simpler and focuses solely on contributions, whereas snk offers a broader range of customization and interactivity. The code comparison shows that isometric-contributions uses JavaScript and focuses on graph rendering, while snk utilizes TypeScript and emphasizes animation generation.

:octocat: Generate an image of all your Github contributions

Pros of github-contributions-chart

  • Generates a high-resolution image of the contributions chart
  • Supports custom color schemes and themes
  • Can be easily integrated into other applications or websites

Cons of github-contributions-chart

  • Limited to static image generation
  • Doesn't offer interactive or animated visualizations
  • Requires server-side processing for image generation

Code Comparison

snk:

const cells = frame.map((_, i) => ({
  x: i % width,
  y: Math.floor(i / width),
  color: colors[frame[i]],
}));

github-contributions-chart:

const chartData = data.map(day => ({
  date: day.date,
  count: day.count,
  color: getColor(day.count, colors)
}));

Both projects use similar approaches to map contribution data to visual elements, but snk focuses on creating animated SVGs, while github-contributions-chart generates static images.

Tool for visualizing GitHub profiles

Pros of profile-summary-for-github

  • Provides a comprehensive overview of a user's GitHub activity
  • Offers visual representations of data through charts and graphs
  • Includes language statistics and repository information

Cons of profile-summary-for-github

  • Requires server-side setup and hosting
  • Less customizable for individual user preferences
  • May have limitations on API rate limits for high-traffic instances

Code Comparison

profile-summary-for-github (Java):

public static List<Repository> getRepositories(String user) throws IOException {
    String repos = fetch("https://api.github.com/users/" + user + "/repos");
    return Arrays.asList(gson.fromJson(repos, Repository[].class));
}

snk (JavaScript):

export const drawSnake = (
  snake: Snake,
  { x, y }: Point,
  cellSize: number,
  ctx: CanvasRenderingContext2D
) => {
  ctx.fillStyle = colors.snake;
  for (const { x: dx, y: dy } of snake)
    ctx.fillRect(x + dx * cellSize, y + dy * cellSize, cellSize, cellSize);
};

The code snippets demonstrate different functionalities: profile-summary-for-github focuses on fetching GitHub data, while snk is concerned with drawing a snake animation. profile-summary-for-github uses Java and interacts with the GitHub API, whereas snk utilizes JavaScript for canvas-based animations.

:octocat: A tool that generates a repository which being pushed into your GitHub account creates a nice contributions calendar.

Pros of github-contributions

  • Simpler implementation, focusing solely on fetching and displaying GitHub contribution data
  • Provides a JavaScript API for easy integration into other projects
  • Lightweight and has fewer dependencies

Cons of github-contributions

  • Less visually appealing output compared to snk's animated SVG
  • Limited customization options for the generated contribution graph
  • Lacks the gamification aspect and interactivity of snk

Code Comparison

snk (Python):

def generate_snake(grid):
    snake = [(0, 0)]
    for _ in range(len(grid) * len(grid[0]) - 1):
        head = snake[-1]
        next_pos = get_next_position(grid, head, snake)
        snake.append(next_pos)
    return snake

github-contributions (JavaScript):

GitHubCalendar(".calendar", "your-username", {
  responsive: true,
  tooltips: true,
  global_stats: true,
  summary_text: "Summary of contributions"
});

While snk focuses on generating an animated snake path through the contribution grid, github-contributions provides a more straightforward approach to displaying the contribution data. snk offers a more engaging and visually appealing result, while github-contributions is simpler to implement and integrate into existing projects.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

snk

GitHub Workflow Status GitHub release GitHub marketplace type definitions code style

Generates a snake game from a github user contributions graph

github contribution grid snake animation

Pull a github user's contribution graph. Make it a snake Game, generate a snake path where the cells get eaten in an orderly fashion.

Generate a gif or svg image.

Available as github action. It can automatically generate a new image each day. Which makes for great github profile readme

Usage

github action

- uses: Platane/snk@v3
  with:
    # github user name to read the contribution graph from (**required**)
    # using action context var `github.repository_owner` or specified user
    github_user_name: ${{ github.repository_owner }}

    # list of files to generate.
    # one file per line. Each output can be customized with options as query string.
    #
    #  supported options:
    #  - palette:     A preset of color, one of [github, github-dark, github-light]
    #  - color_snake: Color of the snake
    #  - color_dots:  Coma separated list of dots color.
    #                 The first one is 0 contribution, then it goes from the low contribution to the highest.
    #                 Exactly 5 colors are expected.
    outputs: |
      dist/github-snake.svg
      dist/github-snake-dark.svg?palette=github-dark
      dist/ocean.gif?color_snake=orange&color_dots=#bfd6f6,#8dbdff,#64a1f4,#4b91f1,#3c7dd9

example with cron job

If you are only interested in generating a svg, consider using this faster action: uses: Platane/snk/svg-only@v3

dark mode

For dark mode support on github, use this special syntax in your readme.

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="github-snake-dark.svg" />
  <source media="(prefers-color-scheme: light)" srcset="github-snake.svg" />
  <img alt="github-snake" src="github-snake.svg" />
</picture>

interactive demo

platane.github.io/snk

local

npm install

npm run dev:demo

Implementation

solver algorithm

NPM DownloadsLast 30 Days