Categories
Generative Art Projects

minara – selection buffer code

The code that creates the selection buffer. This will act like a translucent drag or ghost drag rather than direct manipulation. Direct manipulation would be slow as we’d have to update the translation in the main buffer and render the whole thing each time. A minara written by a large team of programmers could split the buffer into layers of dragging and non dragging buffers then re-unite them after the drag (the main buffer must always be coherent for other tools or for saving). But currently it’s just me so we do it this way.

(define (highlight-selection win)
(let ((highlight-buffer (ensure-window-buffer win "_highlight")))
(set-buffer-variable! highlight-buffer "x" 0.0)
(set-buffer-variable! highlight-buffer "y" 0.0)
(insert-buffer-text-undoable
highlight-buffer
"(translate (buffer-variable (current-buffer) \"x\") (buffer-variable (current-buffer) \"x\")")
(insert-buffer-text-undoable
highlight-buffer
"(set-colour 1.0 0.0 0.0 0.0)\n(set! old-set-colour set-colour)\n(set! set-colour (lambda (a b c d) #f)\n")
(copy-selection-ranges-to-buffer (main-buffer win) highlight-buffer)
(insert-buffer-text-undoable
highlight-buffer
"(set! set-colour old-set-colour)\n")))

Technorati Tags: