Git Product home page Git Product logo

maptasticjs's Introduction

maptastic

Javascript/CSS projection mapping utility. Put your internets on things!

maptastic animation

Usage:

When you include maptastic.min.js in your page, a new class named Maptastic is defined. The first step is to instantiate Maptastic, which can be done a couple of different ways depending on your needs. For most simple cases, this only requires a single line of code.

SHOW ME THE DEMO

<html>
<head>
	<style>
		#so-simple {
			width: 300px;
			height: 300px;
			background: green;
		}
	</style>
</head>
<body>

	<div id="so-simple">This is pretty simple.</div>

	<script src="maptastic.min.js"></script>
	<script>
		Maptastic("so-simple");
	</script>

</body>
</html>

Controls

Since the idea is to have a projector aimed all crazy-like, the controls are all keyboard and mouse based since any UI would either get in the way, or would be impossible to see in most cases anyway.

SHIFT + Space Toggle edit mode

While In Edit Mode

click or drag select and move quads/corner points

SHIFT + drag move selcted quad/corner point with 10x precision

ALT + drag rotate and scale selected quad

SHIFT + ALT + drag rotate and scale selected quad with 10x precision.

Arrow keys move selected quad/corner point

SHIFT + Arrow keys move selected quad/corner point by 10 pixels

ALT + Arrow keys rotate and scale selected quad

's' Solo or unsolo the selected quad (hides all others). This helps to adjust quads when corner points are very close together.

'c' Toggle mouse cursor crosshairs

'b' Toggle display bounds/metrics

'r' Rotate selected layer 90 degrees clockwise

'h' Flip selected layer horizontally

'v' Flip selected layer vertically

How about that code?

Constructor:

The constructor can be used in two different ways depending on how you would like to integrate with Maptastic.

Option 1 - Simple Setup

Specify a list of HTML elements, element IDs, or a mix of both. These elements will all be set up as Maptastic layers and will be configurable in edit mode.

var element2 = document.getElementById("element-id2");

Maptastic("element-id1", element2, ...);

Option 2 - Advanced Configuration

For more advanced useage, specify a configuration object. Available configuration properties are defined below.

var configObject = {
	autoSave: false,
	autoLoad: false,
	onchange: myChangeHandler,
	layers: ["element-id1", "element-id2"]
};
var maptastic = Maptastic(configObject);
Configuration options

layers Array, default empty. Identical to Option 1 above, an array of IDs or HTML elements to be used as Maptastic layers.

onchange function, default null. A function to be invoked whenever the layer layout is changed (if you want to implement your own save/load functionality).

crosshairs boolean, default false. Set the default crosshairs setting for edit mode, this can be toggled at run time with the c key.

labels boolean, default true. When in edit mode, show the element ID as an overlay.

autoSave boolean, default true. Control the automatic saving of layer positions into local storage.

autoLoad boolean, default true. Control the automatic loading of layer positions from local storage.

Methods

In most cases, simply instantiating Maptastic with an element or two should be fine. However, if you are doing something more complicated, the Maptastic instance exposes several methods for controlling things at run time.

getLayout

Returns an array of layer descriptor objects that represent the current mapping configuration. This can be helpful if you want to save the configuration to a remote database or something.

setLayout( layoutData )

Sets the current mapping layout. The schema must match that returned from getLayout and is as follows:

[
  {
    'id': 'some-element-id',
	'sourcePoints': [
      [x1, y1],
      [x2, y2],
      [x3, y3],
      [x4, y4]
    ],
    'targetPoints': [
      [x1, y1],
      [x2, y2],
      [x3, y3],
      [x4, y4]
    ]
  },
  ...
]

addLayer( target, coordinates )

Add a new HTML element to be mapped.

target required. HTML Element or a string representing an element ID.

coordinates optional. An array of four two-dimensional arrays specifying the corner points. This is the same structure as the targetPoints array used in getLayout and setLayout

setConfigEnabled( enabled )

Sets the current Configuration Mode state.

enabled boolean, required.

maptasticjs's People

Contributors

benpurdy avatar floriansegginger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

maptasticjs's Issues

NPM

Hey! I see a package.json, are you planning on publishing this?

Alt+mouse is for window manager

Im using linux mint and when using example alt+mouse moves chrome window instead of controllers. May you provide alternative combination?

Example for onchange function

Hello

You make an incredible work with maptastic.js. It's very simple to use, lightweight...

Does someone know how to use onchange function in Configuration options ?

Is it possible to submit an example in the example directory ?

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.