File tree Expand file tree Collapse file tree 3 files changed +41
-3
lines changed
Expand file tree Collapse file tree 3 files changed +41
-3
lines changed Original file line number Diff line number Diff line change 339339
340340** .hide()** - hide instance
341341
342+
342343** .save()** - call save (same save as on buttons bar). Can be used if save button is hidden (` hiddenTools: ['save'] ` )
343344
345+ ** .doScale({ width, height, scale })** - scale the image and resize area.
346+
347+ Scale to match the width and scale height proportinally (e.g. 50x32 will become 100->64):
348+
349+ ```
350+ .doScale({width: 100})
351+ ```
352+
353+ Scale to fill width and height (e.g. 50x32 will become 11->15):
354+
355+ ```
356+ .doScale({width: 11, height: 15})
357+ ```
358+
359+ Scale x2 (e.g. 11x12 will become 22->24):
360+
361+ ```
362+ .doScale({ scale: 2 })
363+ ```
364+
365+
366+
344367Example:
345368
346369``` js
Original file line number Diff line number Diff line change @@ -1210,6 +1210,24 @@ class PainterroProc {
12101210 return this ;
12111211 }
12121212
1213+ doScale ( { width, height, scale} ) {
1214+ if ( scale ) {
1215+ if ( width || height ) {
1216+ throw new Error ( `You can't pass width or height and scale at the same time` )
1217+ }
1218+ this . resizer . newW = Math . round ( this . size . w * scale ) ;
1219+ this . resizer . newH = Math . round ( this . size . h * scale ) ;
1220+
1221+ } else {
1222+ if ( scale ) {
1223+ throw new Error ( `You can't pass width or height and scale at the same time` )
1224+ }
1225+ this . resizer . newW = width || Math . round ( this . size . w * ( height / this . size . h ) ) ;
1226+ this . resizer . newH = height || Math . round ( this . size . h * ( width / this . size . w ) ) ;
1227+ }
1228+ this . resizer . scaleButton . onclick ( ) ;
1229+ }
1230+
12131231 openFile ( f ) {
12141232 if ( ! f ) {
12151233 return ;
Original file line number Diff line number Diff line change @@ -219,12 +219,9 @@ ${Math.round(pxData[i][j][3] / s)})`;
219219 }
220220
221221 handleKeyDown ( evt ) {
222- console . log ( 1 )
223222 if ( this . main . inserter . handleKeyDown ( evt ) ) {
224223 return true ;
225224 }
226- console . log ( 2 )
227-
228225 if ( this . shown && this . imagePlaced ) {
229226 if ( evt . keyCode === KEYS . enter ) {
230227 this . finishPlacing ( ) ;
You can’t perform that action at this time.
0 commit comments