Skip to content

Commit

Permalink
copy marquee art to clipboard as flat img
Browse files Browse the repository at this point in the history
for copying to external editors
  • Loading branch information
audionerd committed Oct 29, 2018
1 parent d4ff3f6 commit 6ac0309
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
19 changes: 17 additions & 2 deletions src/js/window/storyboarder-sketch-pane.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const paper = require('paper')

const EventEmitter = require('events').EventEmitter

const { ipcRenderer, remote } = require('electron')
const { ipcRenderer, remote, nativeImage } = require('electron')

const fs = require('fs')
const path = require('path')
Expand Down Expand Up @@ -305,9 +305,24 @@ class StoryboarderSketchPane extends EventEmitter {
copyToClipboard () {
if (this.strategy instanceof MarqueeStrategy && this.strategy.marqueePath) {
this.sketchPane.selectedArea.set(this.strategy.marqueePath)

let spritesByLayerId = this.sketchPane.selectedArea.copy(this.visibleLayersIndices)

// flattened image of marquee selected art
let sprite = this.sketchPane.selectedArea.asSprite(this.visibleLayersIndices, false)
let pixels = this.sketchPane.app.renderer.plugins.extract.pixels(sprite)
SketchPaneUtil.arrayPostDivide(pixels)
let image = nativeImage.createFromDataURL(
SketchPaneUtil.pixelsToCanvas(
pixels,
sprite.width,
sprite.height
).toDataURL())

this.strategy.copyToClipboard(
this.strategy.marqueePath,
this.sketchPane.selectedArea.copy(this.visibleLayersIndices)
image,
spritesByLayerId
)
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/js/window/storyboarder-sketch-pane/marquee-strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ class MarqueeStrategy {
return this.context.sketchPane.layers.findByName(name)
}

copyToClipboard (marqueePath, spritesByLayerId) {
// flattened image of marquee art
let image

copyToClipboard (marqueePath, image, spritesByLayerId) {
// marquee data, including path and bounds
let marquee = {
path: JSON.parse(marqueePath.exportJSON()),
Expand Down

0 comments on commit 6ac0309

Please sign in to comment.