Giter Site home page Giter Site logo

barkpixels / grab Goto Github PK

View Code? Open in Web Editor NEW

This project forked from transmedia-gx/grab

0.0 0.0 0.0 1.52 MB

Processing library for exporting sketch window as JPG or PDF via keyboard or mouse input

Home Page: http://transmedia.graphics/

License: Other

Java 37.64% CSS 47.01% HTML 15.35%

grab's Introduction

Grab Processing Library

Processing library for exporting a JPG or PDF of the current state of the sketch window via input from keyboard or mouse.

Setup

Add these 3 lines at the top of your Processing Sketch. By default, exporting will be done by typing on your keyboard. Type the p key to export a PDF, or type the j key to export a JPG.

import processing.pdf.*;
import grab.*;
Grab grab = new Grab(this);

Keyboard vs Mouse Mode

You can choose between keyboard or mouse mode by passing an argument to the constructor.

Keyboard mode (p for PDF, j for JPG)

Grab grab = new Grab(this); // Keyboard is the default
Grab grab = new Grab(this, Mode.KEYBOARD); // You can explicitly pass Mode.KEYBOARD too

Mouse mode (left click for PDF, right click for JPG)

Grab grab = new Grab(this, Mode.MOUSE); // Pass Mode.MOUSE to use the mouse mode

Keyboard Mode Example

Available under File > Examples then Contributed Libraries > Grab > Grab_01_KeyboardMode

// Tell Processing to use the PDF and Grab library
import processing.pdf.*;
import grab.*;

// Activate the Grab library
// Hit p key for exporting PDF, and j for jpg
Grab grab = new Grab(this);



// Basic setup() and draw() with mouse interaction
void setup() {
  size(500, 500);
  pixelDensity(displayDensity());
}

void draw() {
  background(0);
  fill(255);
  circle(mouseX, mouseY, 50);
}

Mouse Mode Example

Available under File > Examples then Contributed Libraries > Grab > Grab_02_MouseMode

// Tell Processing to use the PDF and Grab library
import processing.pdf.*;
import grab.*;

// Activate the Grab library with mouse mode
// Left click: PDF, right click: JPG
Grab grab = new Grab(this, Mode.MOUSE);



// Basic setup() and draw() with keyboard interaction
char letterToDraw = 'a';

void setup() {
  size(500, 500);
  pixelDensity(displayDensity());
}

void draw() {
  background(0);
  fill(255);
  textSize(400);
  textAlign(CENTER);
  text(letterToDraw, width/2, height - 120);
}

void keyPressed() {
  letterToDraw = key;
}

grab's People

Contributors

roytatum avatar takaiwai 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.