(split-string substr "$"))))
(split-string string -))))
-(defun sixel-tag-bits (n tag bit-count)
- "Create a list of length BIT-COUNT with the elements corresponding to the
-true bits of N set to TAG."
- (if (= bit-count 0)
- nil
- (cons (if (= (% n 2) 1)
- tag
- nil)
- (sixel-tag-bits (/ n 2) tag (1- bit-count)))))
+(defun sixel-tag-bits (sixel n tag)
+ "Set bits of SIXEL corresponding to N with to the value TAG."
+ (dotimes (i 6)
+ (if (= (% n 2) 1)
+ (aset sixel i tag))
+ (setq n (/ n 2))))
-(defun sixel-make-sixel-from-char (char tag)
- "Retrieve sequence of bits to be set."
- (sixel-tag-bits (- char 63) tag 6))
-
-(defun sixel-union (sixel1 sixel2)
- "Returns a union of the two sixels, SIXEL1 and SIXEL2.
-When both sixels specify a tag for the same pixel, the tag
-from SIXEL2 wins."
- (seq-mapn (lambda (tag1 tag2)
- (or tag2 tag1))
- sixel1 sixel2))
+(defun sixel-tag-sixel-in-row (row-variable index char tag)
+ "Tag the bits of the sixel at INDEX in the list identified by
+the variable ROW-VARIABLE corresponding to input character CHAR
+with TAG."
+ (while (not (< index (length (symbol-value row-variable))))
+ (add-to-list row-variable (make-vector 6 nil)))
+ (let ((sixel (elt (symbol-value row-variable) index)))
+ (sixel-tag-bits sixel (- char 63) tag)))
(defun sixel-process-row (string)
(let ((idx-in 0)
(setq idx-in (match-end 0))))
((string-match "^#\\([0-9]+\\)" trunc-string)
(let ((tag (intern (match-string 1 trunc-string))))
- (setq current-colour tag)
+ (setq sixel-current-colour tag)
(setq idx-in (match-end 0))))
+ ((string-match "^$" trunc-string)
+ (setq idx-out 0)
+ (setq idx-in (match-end 0 trunc-string)))
((string-match "^!\\([0-9]+\\)\\([?-~]\\)" trunc-string)
(let ((repeat-count (string-to-number (match-string 1 trunc-string)))
(char (elt (match-string 2 trunc-string) 0)))
(dotimes (i repeat-count)
- (unless (< idx-out (length result))
- (add-to-list result (make-vector 6 nil)))
- (let ((sixel (elt result idx-out))))))))))))
-
+ (sixel-tag-sixel-in-row 'result idx-out char sixel-current-colour)
+ (setq idx-out (+1 idx-out)))))
+ ((string-match "^\\([?-~]\\)" trunc-string)
+ (let ((char (elt (match-string 1 trunc-string) 0)))
+ (sixel-tag-sixel-in-row 'result idx-out char sixel-current-colour))
+ (setq idx-out (+1 idx-out))))))))
-
(sixel-get-rows test-string)
(defun sixel-to-xpm (string)