• Stars
    star
    104
  • Rank 330,604 (Top 7 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created about 6 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Use any of the of the 50 million Quick, Draw! doodles in your web-based project with one line of markup

logos for Quick, Draw! and the Polymer Project and Google Cloud

Quick, Draw! Polymer Component & API

Embed Quick, Draw! drawings into your project using a web component, as easily as:

<quick-draw category="apple" key="API_KEY"></quick-draw>

This component is built using Polymer3 and is coupled with an API layer for accessing individual drawing data from the open sourced data set. The drawings are drawn out to a canvas element, and provides you with options to customize it for your own web project. Here's a demo of how it can be used in different ways.

Background

In October 2016 we released Quick, Draw!, a game to test your ability to doodle and have a neural net guess what you're drawing. You can help teach it by adding your drawings to the world’s largest doodling data set, shared publicly to help with machine learning research.

Since the release, we've collected over 1 billion drawings across 345 categories. We've released the data in the form of very large ndjson files of moderated doodles. Now we are releasing a data API, a Polymer web component, and an option to self-host the 50 million files.

Run example

With npm installed, in the root of this repo:

npm install
npm start

When this works, you'll see this simple demo of the component:

demo image

Usage

Install as an NPM dependency to your project:

npm install --save quickdraw-component

Import it:

import 'quickdraw-component/quickdraw-component.js';

You need to make sure that your app is using a tool like Webpack or Rollup to transpile and bundle the component into your app.

The most basic usage of the component's properties is to include a static, random drawing of a category with an API Key:

<quick-draw category="apple" key="AIzaSyC0U3yLy_m6u7aOMi9YJL2w1vWG4oI5mj0"></quick-draw>

A list of all the available categories is here.

Getting a demo API Key

It is highly encouraged for any large project to not use the demo endpoint as a dependency - see Self-Hosting below. In order to get an API key for the demo endpoint, you need to:

  1. Join the Quick Draw API Google Group.

  2. In your project on Google Cloud Platform, go to APIs & Services > Library and search for "Quick, Draw! API"

  3. Click into Quick, Draw! Data API and press "Enable"

  4. If you haven't created an API Key yet for your project, go into APIs & Services > Credentials and create one. This is what you'll use in the key property of: <quick-draw key="YOUR_API_KEY"></quick-draw>

Options

Name Description Type Default Options / Examples
category *required One of the available categories String null <quick-draw category="apple"></quick-draw>
key *required API Key from Google Cloud Platform String null <quick-draw key="AIzaSyC0U3yLy_m6u7aOMi9YJL2w1vWG4oI5mj0"></quick-draw>
host The host of your API String https://quickdrawfiles.appspot.com <quick-draw host="https://quickdrawfiles.appspot.com"></quick-draw>
index The drawing id within a category (random unless specified) Number -1 <quick-draw category="apple" index="3927"></quick-draw>
animate Animate the drawing in the same time frame it was originally drawn Boolean false <quick-draw category="apple" animate></quick-draw>
time Sets the total time for the animation, preserving time proportions for each path (in milliseconds) Number null <quick-draw category="apple" time="1500" animate></quick-draw>
paused When set to true, the component will only load the image data but not draw it. Listen for the data loaded event drawingData and then call drawImage() to control it manually Number null <quick-draw category="apple" paused animate></quick-draw>
strokeColor A hex value for the stroke color String #000000 <quick-draw category="apple" strokeColor="#4285f4"></quick-draw>
strokeWidth The width/thickness of the stroke Number 4 <quick-draw category="apple" strokeWidth="1"></quick-draw>
width The px width of the drawing. If provided, the drawing will scale proportionally to fit the space. String 'auto' <quick-draw category="apple" width="125"></quick-draw>
height The px height of the drawing. If provided, the drawing will scale proportionally to fit the space. String 'auto' <quick-draw category="apple" height="125"></quick-draw>
debug For testing purposes, will log output Boolean false <quick-draw category="apple" debug></quick-draw>

Events

You can listen for the following custom events from the component:

Name Description Return
drawingData When drawing data is received {detail: {index, category, data}}
drawingComplete When drawing is completed {detail: {index, category, data}}

An example of how to access the element to listen for events:

function ready() {
	var el = document.querySelector('quick-draw');
	el.addEventListener('drawingData', function(){
	  console.log('Drawing data loaded...');
	});
	el.addEventListener('drawingComplete', function(){
	  console.log('Drawing complete!');
	});
}
	
document.addEventListener("DOMContentLoaded", ready);

Methods

You can manually call the following methods on your element:

fetchImageData(category, index)

This method will load image data, where "category" is one of these available categories like "cat", or "apple", and index is the number of the drawing. If index isn't passed, then it will load in a random image. To find out exactly how many indices are available for a given category, use the /{category}/count API call below.

drawImage()

This method will simply draw the image out on the canvas with its current properties. This is especially useful when using the paused property (when you want to control exactly when it's drawn out).

API / Middleware

This component has a server-side dependency, which can be reached from this endpoint:

https://quickdrawfiles.appspot.com/drawing/{category}?id={id}&key={key}&isAnimated={isAnimated}&format={format}

Name Description Type Default
category *required One of the available categories String null
id *required ID (number) or "random" String null
key *required API Key (see above for instructions) String null
isAnimated Will return raw time-based data if true, otherwise simplified data Boolean false
format JSON or canvas drawing String "json"

You can also retrieve the total count of drawings within a category using:

https://quickdrawfiles.appspot.com/drawing/{category}/count?key={key}

Self-Hosting

It's highly encouraged that you self-host for larger, more serious projects as the quota limits are subject to change with this one (and it's not guaranteed to be supported / maintained forever). View the README.md in the API directory to learn more about how to self-host the files and the API.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

The component & API fall under the Apache 2.0 license.

More Repositories

1

anypixel

A web-friendly way for anyone to build unusual displays
C
6,437
star
2

quickdraw-dataset

Documentation on how to access and use the Quick, Draw! Dataset.
6,092
star
3

teachable-machine-v1

Explore how machine learning works, live in the browser. No coding required.
JavaScript
3,848
star
4

coder

A simple way to make web stuff on Raspberry Pi
JavaScript
2,425
star
5

open-nsynth-super

Open NSynth Super is an experimental physical interface for the NSynth algorithm
C++
2,419
star
6

chrome-music-lab

A collection of experiments for exploring how music works, all built with the Web Audio API.
JavaScript
2,127
star
7

aiexperiments-ai-duet

A piano that responds to you.
JavaScript
1,634
star
8

teachablemachine-community

Example code snippets and machine learning code for Teachable Machine
TypeScript
1,488
star
9

paper-signals

Build your own voice controlled object.
C++
743
star
10

aiexperiments-drum-machine

Thousands of everyday sounds, organized using machine learning.
JavaScript
736
star
11

Sprayscape

Sprayscape is a perfectly imperfect VR-ish camera. It is an open source Android app released on the Android Experiments platform.
Objective-C
568
star
12

teachable-machine-boilerplate

Boilerplate code for Teachable Machine
JavaScript
504
star
13

aiexperiments-giorgio-cam

Take a picture to make music with the computer.
JavaScript
481
star
14

aiexperiments-bird-sounds

Thousands of bird sounds visualized using machine learning.
JavaScript
474
star
15

ar-drawing-java

A simple AR drawing experiment build in Java using ARCore.
Java
415
star
16

inside-music

Inside Music lets you step inside of a song, seeing its individual pieces to give you a closer look at how music is made.
JavaScript
384
star
17

meter

Meter is a data-driven wallpaper that displays your battery, wireless signal and notifications
Java
362
star
18

digital-wellbeing-experiments-toolkit

Code components for starting your own Digital Wellbeing experiments
Kotlin
341
star
19

giantemoji

JavaScript
313
star
20

creatability-components

Web components for making creative tools more accessible.
TypeScript
287
star
21

morse-learn

A fun little web app to help you learn Morse code on Gboard.
JavaScript
284
star
22

alto

Explore the basics of machine learning by building your own teachable object at home.
Python
278
star
23

aiexperiments-sound-maker

Make unusual new sounds with machine learning.
JavaScript
255
star
24

justaline-android

The first cross-platform collaborative AR app (for doodling)
Java
252
star
25

shadercam

Simple OpenGL Shaders with the camera2 apis in Android 5.0+
Java
240
star
26

posenet-sketchbook

PoseNet Sketchbook is a collection of open source, interactive web experiments designed to allude to the artistic possibilities of using PoseNet (running on tensorflow.js) to create a relationship between movement and machine.
JavaScript
207
star
27

arexperiments-portal-painter

Doodle new worlds onto your own, with Google ARCore.
C#
198
star
28

beat-blender

Blend beats using machine learning to create music in a fun new way.
JavaScript
190
star
29

coder-projects

Fun projects and sneakily educational things that can all be made with Coder and Rasberry Pi.
CSS
188
star
30

landmarker

Orientation, GPS, and Places enabled Android Experiment
Java
180
star
31

webvr-musicalforest

Join users from around the world in a musical forest. A WebVR Experiment.
JavaScript
164
star
32

balloon-pop

A multiplayer geospatial experience
C#
163
star
33

melody-mixer

A fun way to explore music using machine learning.
JavaScript
153
star
34

lipswap

Replace sections of a photo with your own recorded video.
Java
142
star
35

norman-ar

Decorate your world with AR animations.
C++
136
star
36

justaline-ios

The first cross-platform collaborative AR app (for doodling)
Swift
120
star
37

creatability-seeing-music

Experience music visually.
JavaScript
101
star
38

semi-conductor

Semi-Conductor allows you to conduct a virtual orchestra using only your web browser & webcam.
JavaScript
100
star
39

tunnelvision

Distort your surroundings through a collection of transformative filters
Java
93
star
40

lines-of-play

Design domino art creations that interact with the real world using the ARCore Depth API.
C#
89
star
41

project-oasis

A voice controlled terrarium that recreates outside weather inside a box
JavaScript
89
star
42

access-mars

JavaScript
82
star
43

tiny-motion-trainer

Train and test machine learning models for your Arduino Nano 33 BLE Sense in the browser.
JavaScript
79
star
44

mystery-animal

A new spin on the classic 20-questions game.
JavaScript
79
star
45

mix-lab

MixLab is an experiment that makes it easier for anyone to create music, using simple voice commands.
TypeScript
71
star
46

sounds-in-space

An interactive audio experience, where the virtual sounds you hear change depending on your physical location.
C#
71
star
47

tf4micro-motion-kit

Arduino Sketch and a Web Bluetooth API for loading models and running inference on the Nano Sense 33 BLE device.
C++
66
star
48

obvi

A Polymer 3+ webcomponent / button for doing speech recognition
JavaScript
57
star
49

finger-user-interface

Control connected devices with the wave of a finger.
C
54
star
50

xyfi

Xyfi: BYO pointing device at a physical installation
JavaScript
48
star
51

morse-speak-demo

Text-to-Speech (TTS) demo web app that converts written text into spoken words via Morse code
JavaScript
44
star
52

aog-canvas-quiz

Canvas Quiz is a starter kit for developers to make custom, voice-enabled question-answer games for the Google Assistant.
JavaScript
40
star
53

air-snare

Play drums in the air.
Svelte
40
star
54

webvr-speaktogo

Explore the world with your voice.
JavaScript
34
star
55

norman-sketch-player

Embed Norman animated sketches on the web
JavaScript
29
star
56

pattern-radio

Code for patternradio.withgoogle.com
JavaScript
27
star
57

things-with-firebase-at-io2017

The Android Things projects used in the Experiments Tent at Google I/O 2017
Java
22
star
58

astrowand

Draw shapes in the sky to form constellations with TensorFlow and a microcontroller.
JavaScript
19
star
59

visual-alarm-clock

Get up in the morning by striking a pose to stop your alarm from ringing.
C++
10
star
60

dat.fire

JavaScript
6
star
61

gemini-demos

TypeScript
2
star
62

.allstar

2
star
63

.github

1
star