1 ;;; xpm-ops.el --- drawing operations -*- lexical-binding: t -*-
3 ;; Copyright (C) 2014 Free Software Foundation, Inc.
5 ;; This program is free software; you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, either version 3 of the License, or
8 ;; (at your option) any later version.
10 ;; This program is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; GNU General Public License for more details.
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
26 (defun xpm-flood-fill (px x y)
27 (xpm--w/gg (cpp origin y-mult) (xpm--gate)
28 (let ((q (queue-create))
31 ((pos (x y) (+ origin (* cpp x) (* y-mult y)))
32 (cur () (let ((p (point)))
33 (buffer-substring-no-properties
35 (oldp () (string= bye (cur)))
37 (let* ((x (car coord))
39 (p (goto-char (pos x y)))
44 do (backward-char cpp)
46 finally do (cl-incf beg))
51 finally do (cl-decf end))
53 (setq bye (let ((p (pos x y)))
54 (buffer-substring-no-properties
56 (queue-enqueue q (cons x y))
57 (cl-loop until (queue-empty q)
58 do (let* ((coord (queue-dequeue q))
61 (xpm-put-points px ext y)
62 ;; todo: expansion and queuing of y-1 and y+1
65 ;;; xpm-ops.el ends here