├── README.md ├── package.json ├── raphael.free_transform.js └── screenshot.png /README.md: -------------------------------------------------------------------------------- 1 | Raphaël.FreeTransform 2 | ==================== 3 | 4 | Free transform tool for [Raphaël 2.0](http://raphaeljs.com/) elements and sets with many options. Supports snap-to-grid dragging, scaling and rotating with a specified interval and range. 5 | 6 |  7 | 8 | *Licensed under the [MIT license](http://www.opensource.org/licenses/mit-license.php).* 9 | 10 |  Donate Bitcoin: 1PgSBQXVBpVHxZKmQpaJDULyPwqw9ieVcT - *Thanks!* 11 | 12 | Demo 13 | ---- 14 | 15 | https://alias.io/raphael/free_transform/ 16 | 17 | Examples 18 | -------- 19 | 20 | ```html 21 | 22 | 23 | 24 |
25 | 26 | 58 | ``` 59 | 60 | Options 61 | ------- 62 | 63 | #### `animate: true | { delay: num, easing: string } | false` 64 | 65 | Animate transformations. Works best in combination with `apply()` (see the functions section below). 66 | 67 | Default: `{ delay: 700, easing: 'linear' }` 68 | 69 | 70 | #### `attrs: { fill: hex, stroke: hex }` 71 | 72 | Sets the attributes of the handles. 73 | 74 | Default: `{ fill: '#fff', stroke: '#000' }` 75 | 76 | 77 | #### `customCorners: { size: num, distance: num, corners: [ { action: string: image: string }, ... ] } | false 78 | 79 | Specify custom images and events for corner handles. 80 | 81 | The corners array should contain 4 objects, one for each corner starting top left going clockwise. 82 | 83 | Valid actions: `drag`, `rotate`, `scale` or a custom string. Actions are emitted as events in the callback. 84 | 85 | Default: `false` 86 | 87 | 88 | #### `boundary: { x: int, y: int, width: int, height: int } | false` 89 | 90 | Limits the drag area of the handles. 91 | 92 | Default: dimensions of the paper 93 | 94 | 95 | #### `distance: num` 96 | 97 | Sets the distance of the handles from the center of the element (`num` times radius). 98 | 99 | Default: `1.3` 100 | 101 | 102 | #### `drag: true | [ 'center', 'self' ] | false` 103 | 104 | Enables/disables dragging. 105 | 106 | Default: `[ 'center', 'self' ]` 107 | 108 | 109 | #### `draw: [ 'bbox', 'circle' ]` 110 | 111 | Additional elements to draw. 112 | 113 | Default: `false` 114 | 115 | 116 | #### `keepRatio: true | [ 'axisX', 'axisY', 'bboxCorners', 'bboxSides' ] | false` 117 | 118 | Scale axes together or individually. 119 | 120 | Default: `false` 121 | 122 | 123 | #### `range: { rotate: [ num, num ], scale: [ num, num ] }` 124 | 125 | Limit the range of transformation. 126 | 127 | Default: `{ rotate: [ -180, 180 ], scale: [ 0, 99999 ] }` 128 | 129 | 130 | #### `rotate: true | [ 'axisX', 'axisY', 'self' ]|false` 131 | 132 | Enables/disables rotating. 133 | 134 | Default: `[ 'axisX', 'axisY' ]` 135 | 136 | 137 | #### `scale: true | [ 'axisX', 'axisY', 'bboxCorners', 'bboxSides' ] | false` 138 | 139 | Enables/disables scaling. 140 | 141 | Default: `[ 'axisX', 'axisY', 'bboxCorners', 'bboxSides' ]` 142 | 143 | 144 | #### `snap: { rotate: num, scale: num, drag: num }`: 145 | 146 | Snap transformations to num degrees (rotate) or pixels (scale, drag). 147 | 148 | Default: `{ rotate: 0, scale: 0, drag: 0 }` 149 | 150 | 151 | #### `snapDist: { rotate: num, scale: num, drag: num }` 152 | 153 | Snap distance in degrees (rotate) or pixels (scale, drag). 154 | 155 | Default: `{ rotate: 0, scale: 0, drag: 7 }` 156 | 157 | 158 | #### `size: num | { axes: num, bboxCorners: num, bboxSides: num, center: num }` 159 | 160 | Sets the radius of the handles in pixels. 161 | 162 | Default: `5` 163 | 164 | 165 | Callback 166 | -------- 167 | 168 | A callback function can be specified to capture changes and events. 169 | 170 | 171 | Functions 172 | --------- 173 | 174 | #### `apply()` 175 | 176 | Programmatically apply transformations (see the example above). 177 | 178 | 179 | #### `hideHandles( opts )` 180 | 181 | Removes handles but keeps values set by the plugin in memory. By 182 | default removes all drag events from the elements. If you'd like to 183 | keep then while the handles are hidden, pass ``{undrag: false}`` to 184 | hideHandles(). 185 | 186 | 187 | #### `showHandles()` 188 | 189 | Shows handles hidden with `hideHandles()`. 190 | 191 | 192 | #### `setOpts( object, function )` 193 | 194 | Update options and callback. 195 | 196 | 197 | #### `unplug()` 198 | 199 | Removes handles and deletes all values set by the plugin. 200 | 201 | 202 | #### `updateHandles()` 203 | 204 | Updates handles to reflect the element's transformations. 205 | 206 | 207 | Raphaël.FreeTransform and Raphaël.JSON 208 | -------------------------------------- 209 | 210 | Instructions on how to use Raphaël.FreeTransform in combination with 211 | Raphaël.JSON can be found 212 | [here](https://github.com/ElbertF/Raphael.JSON#raphaëljson-and-raphaëlfreetransform). 213 | 214 | 215 | Sponsors 216 | -------- 217 | 218 | Some of the work done for this plugin was paid for by [Signs.com](http://www.signs.com/) and [Merchbro.com](http://www.merchbro.com/). 219 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Raphael.FreeTransform", 3 | "version": "1.0.0", 4 | "main": "raphael.free_transform.js", 5 | "repository": "git@github.com:AliasIO/Raphael.FreeTransform.git", 6 | "author": "Elbert Alias