From 677eb07b00f13708b0f94517feb1b2a5ab66d61a Mon Sep 17 00:00:00 2001 From: David Thompson Date: Fri, 27 May 2016 22:21:45 -0400 Subject: render: Add 9-patch implementation. * sly/render/nine-patch: New file. * Makefile.am (SOURCES): Add it. * examples/images/dialog.png: New file. * examples/nine-patch.scm: New file. --- examples/images/dialog.png | Bin 0 -> 409 bytes examples/nine-patch.scm | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 examples/images/dialog.png create mode 100644 examples/nine-patch.scm (limited to 'examples') diff --git a/examples/images/dialog.png b/examples/images/dialog.png new file mode 100644 index 0000000..9277ff1 Binary files /dev/null and b/examples/images/dialog.png differ diff --git a/examples/nine-patch.scm b/examples/nine-patch.scm new file mode 100644 index 0000000..9f77de6 --- /dev/null +++ b/examples/nine-patch.scm @@ -0,0 +1,41 @@ +;;; Sly +;;; Copyright (C) 2016 David Thompson +;;; +;;; This program is free software: you can redistribute it and/or +;;; modify it under the terms of the GNU General Public License as +;;; published by the Free Software Foundation, either version 3 of the +;;; License, or (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see +;;; . + +(use-modules (sly) + (sly render nine-patch)) + +(load "common.scm") + +(define-signal dialog + (on-start + (render-nine-patch #:texture (load-texture "images/dialog.png") + #:width 512 + #:height 256 + #:margin 8) + render-nothing)) + +(define-signal scene + (signal-let ((dialog dialog)) + (with-camera (2d-camera #:area (make-rect 0 0 640 480)) + (move (vector2 320 240) dialog)))) + +(with-window (make-window #:title "9-patch") + (run-game-loop scene)) + +;;; Local Variables: +;;; compile-command: "../pre-inst-env guile nine-patch.scm" +;;; End: -- cgit v1.2.3