[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 158/255: beginning to translate svg images into elisp
From: |
Eric Schulte |
Subject: |
[elpa] 158/255: beginning to translate svg images into elisp |
Date: |
Sun, 16 Mar 2014 01:02:39 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit f4e92f7cc3a71ae4e129a328df1555603ca36f1e
Author: Eric Schulte <address@hidden>
Date: Tue Jun 5 00:36:27 2012 -0600
beginning to translate svg images into elisp
---
NOTES | 8 +++-
go-board-faces.el | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 100 insertions(+), 2 deletions(-)
diff --git a/NOTES b/NOTES
index 467eef0..99cbc1c 100644
--- a/NOTES
+++ b/NOTES
@@ -1,9 +1,13 @@
# -*- mode:org -*-
* better looking board
-could try to make wider characters or could just use images
+See [[info:elisp#Image%20Descriptors][info:elisp#Image Descriptors]], can just
use the text svg data
+directly, no need for files. Also look at
[[info:elisp#Pointer%20Shape][info:elisp#Pointer Shape]]
+for controlling the shape of the map.
-For images look at these images (go with wikipedia svg images).
+: '(image :type 'svg :data )
+
+** For images look at these images (go with wikipedia svg images).
- http://en.wikipedia.org/wiki/File:Go_b.svg
- http://en.wikipedia.org/wiki/File:Go_w.svg
- or at ruby go http://rubygo.rubyforge.org/
diff --git a/go-board-faces.el b/go-board-faces.el
index dc2ba7d..e7e2e76 100644
--- a/go-board-faces.el
+++ b/go-board-faces.el
@@ -74,4 +74,98 @@
'((t (:background "#cd9c67" :foreground "white")))
"white piece on white territory")
+
+;;; Images
+(defvar go-board-image-overlays nil
+ "List of overlays carrying the images of points on a GO board.")
+
+(defun go-board-svg-trans (list)
+ (concat (format "<%s%s" (caar list) (if (cdar list) " " ""))
+ (mapconcat (lambda (pair) (format "%s=\"%s\"" (car pair) (cdr pair)))
+ (cdar list) " ")
+ (if (cdr list)
+ (concat ">"
+ (mapconcat #'go-board-svg-trans (cdr list) " ")
+ (format "</%s>" (caar list)))
+ "/>")))
+
+(defmacro go-board-wrap (body)
+ (declare (indent 0))
+ `(concat "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ (go-board-svg-trans ',body)))
+
+(defvar go-board-image-black
+ `(image
+ :type svg :ascent center :data
+ ,(go-board-wrap
+ ((svg (xmlns . "http://www.w3.org/2000/svg")
+ (xmlns:xlink . "http://www.w3.org/1999/xlink")
+ (width . 25) (height . 25) (version . 1.0))
+ ((defs)
+ ((radialGradient (id . "$rg") (cx . ".3") (cy . ".3") (r . ".8"))
+ ((stop (offset . 0) (stop-color . "#777")))
+ ((stop (offset . 0.3) (stop-color . "#222")))
+ ((stop (offset . 1) (stop-color . "#000")))))
+ ((rect (width . 25) (height . 25) (fill . "#dcb35c")))
+ ((circle (cx . 12.5) (cy . 12.5) (r . 6.125) (fill . "url(#$rg)")))))))
+
+(defvar go-board-image-white
+ `(image
+ :type svg :ascent center :data
+ ,(concat
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<svg xmlns=\"http://www.w3.org/2000/svg\" "
+ "xmlns:xlink=\"http://www.w3.org/1999/xlink\" "
+ "width=\"25\" height=\"25\" version=\"1.0\">"
+ "<defs><radialGradient id=\"$rg\" cx=\".47\" cy=\".49\" r=\".48\">"
+ " <stop offset=\".7\" stop-color=\"#FFF\"/>"
+ " <stop offset=\".9\" stop-color=\"#DDD\"/>"
+ " <stop offset=\"1\" stop-color=\"#777\"/>"
+ "</radialGradient></defs>"
+ "<rect width=\"25\" height=\"25\" fill=\"#dcb35c\"/>"
+ "<circle cx=\"12.5\" cy=\"12.5\" r=\"6.125\" fill=\"url(#$rg)\"/>"
+ "</svg>")))
+
+(defvar go-board-image-back
+ `(image
+ :type svg :ascent center :data
+ ,(concat
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<svg xmlns=\"http://www.w3.org/2000/svg\" "
+ "width=\"25\" height=\"25\">"
+ "<rect width=\"25\" height=\"25\" fill=\"#DCB35C\"/>"
+ "<path stroke=\"#000\" stroke-width=\"1\" "
+ "d=\"M0,12.5H25M12.5,0V25\"/>"
+ "</svg>")))
+
+(defvar go-board-image-hoshi
+ `(image
+ :type svg :ascent center :data
+ ,(concat
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<svg xmlns=\"http://www.w3.org/2000/svg\" "
+ "width=\"25\" height=\"25\">"
+ "<rect width=\"25\" height=\"25\" fill=\"#DCB35C\"/>"
+ "<path stroke=\"#000\" stroke-width=\"1\" "
+ "d=\"M0,12.5H25M12.5,0V25\"/>"
+ "<circle cx=\"12.5\" cy=\"12.5\" r=\"2.5\"/>"
+ "</svg>")))
+
+(defvar go-board-image-left
+ `(image
+ :type svg :ascent center :data
+ ,(concat
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<svg xmlns=\"http://www.w3.org/2000/svg\" "
+ "width=\"25\" height=\"25\">"
+ "<rect width=\"25\" height=\"25\" fill=\"#DCB35C\"/>"
+ "<path stroke=\"#000\" stroke-width=\"1\" "
+ "d=\"M12,12.5H25M12.5,0V25\"/>"
+ "</svg>")))
+
+(defun go-board-image (point image)
+ (let ((ov (make-overlay point (1+ point))))
+ (overlay-put ov 'display image)
+ (push ov go-board-image-overlays)))
+
(provide 'go-board-faces)
- [elpa] 143/255: pass move through board to *back-end*, (continued)
- [elpa] 143/255: pass move through board to *back-end*, Eric Schulte, 2014/03/15
- [elpa] 144/255: tests require igs, Eric Schulte, 2014/03/15
- [elpa] 146/255: print igs kibitz strings, Eric Schulte, 2014/03/15
- [elpa] 141/255: beginning of infrastructure for player names & info, Eric Schulte, 2014/03/15
- [elpa] 145/255: periodically ping IGS server to prevent disconnect, Eric Schulte, 2014/03/15
- [elpa] 147/255: igs implements the go back-end API, Eric Schulte, 2014/03/15
- [elpa] 148/255: improved the setf method for aget, Eric Schulte, 2014/03/15
- [elpa] 150/255: more lenient regexp for matching game listing, Eric Schulte, 2014/03/15
- [elpa] 152/255: Revert "improved the setf method for aget", Eric Schulte, 2014/03/15
- [elpa] 154/255: don't quit main back-end when quitting a board, Eric Schulte, 2014/03/15
- [elpa] 158/255: beginning to translate svg images into elisp,
Eric Schulte <=
- [elpa] 149/255: push all buffer-local variables into an igs object, Eric Schulte, 2014/03/15
- [elpa] 162/255: painting a nice svg board, but more to do, Eric Schulte, 2014/03/15
- [elpa] 159/255: translated all svg stone images into elisp, Eric Schulte, 2014/03/15
- [elpa] 164/255: prompt before quitting, Eric Schulte, 2014/03/15
- [elpa] 153/255: safety measure when observing igs games, Eric Schulte, 2014/03/15
- [elpa] 163/255: sorted out different types of backgrounds, Eric Schulte, 2014/03/15
- [elpa] 168/255: adding option to play a sound during moves, Eric Schulte, 2014/03/15
- [elpa] 155/255: less permissive igs move regular expression, Eric Schulte, 2014/03/15
- [elpa] 166/255: board images working with backgrounds, Eric Schulte, 2014/03/15
- [elpa] 173/255: start gnugo process when object is created, Eric Schulte, 2014/03/15