implemented share sketch

This commit is contained in:
ojack
2022-02-11 16:56:16 +01:00
parent 9482b5005d
commit cfe1f9ed76
3 changed files with 50 additions and 14 deletions

View File

@@ -26033,11 +26033,6 @@ module.exports = function store (state, emitter) {
// @todo create gallery store
console.warn('gallery callback not let implemented')
})
emitter.on('shuffle sketches', function (count) {
})
emitter.on('editor:randomize', function(evt) {
const editor = state.editor.editor
@@ -26079,8 +26074,19 @@ module.exports = function store (state, emitter) {
repl.eval(block)
})
emitter.on('gallery:shareSketch', function (editor) {
console.log('waiting to share', state.editor.editor.getValue())
emitter.on('gallery:shareSketch', function () {
let editor = state.editor.editor
const code = editor.getValue()
repl.eval(editor.getValue(), (code, error) => {
// console.log('evaluated', code, error)
if(!error){
showConfirmation( (name) => {
sketches.shareSketch(code, state.hydra.hydra, name)
}, () => {} )
} else {
console.warn(error)
}
})
})
emitter.on('gallery:showExample', () => {
@@ -26115,6 +26121,16 @@ module.exports = function store (state, emitter) {
})
}
function showConfirmation(successCallback, terminateCallback) {
var c = prompt("Pressing OK will share this sketch to \nhttps://twitter.com/hydra_patterns.\n\nInclude your name or twitter handle (optional):")
// console.log('confirm value', c)
if (c !== null) {
successCallback(c)
} else {
terminateCallback()
}
}
},{"./gallery.js":134,"./views/editor/repl.js":143}],136:[function(require,module,exports){
const html = require('choo/html')
const Component = require('choo/component')
@@ -26172,11 +26188,13 @@ module.exports = class Hydra extends Component {
constructor (id, state, emit) {
super(id)
this.local = state.components[id] = {}
state.hydra = this
}
load (element) {
const hydra = new HydraSynth({ detectAudio: true, canvas: element.querySelector("canvas")})
console.log(hydra)
this.hydra = hydra
osc().out()
}