Permalink
Browse files

Initial up

  • Loading branch information...
Shinmera committed Jun 5, 2014
0 parents commit e395ab3b8ce749e4b64ad8eacccff42c613d8de8
Showing with 699 additions and 0 deletions.
  1. +16 −0 brush.lisp
  2. +81 −0 canvas.lisp
  3. +33 −0 curves/curve.lisp
  4. +278 −0 curves/spline.lisp
  5. +32 −0 gui/brush-widget.lisp
  6. +57 −0 gui/canvas-widget.lisp
  7. +42 −0 gui/color-widget.lisp
  8. +9 −0 gui/layer-widget.lisp
  9. +31 −0 gui/main-window.lisp
  10. +10 −0 package.lisp
  11. +34 −0 parasol.asd
  12. +22 −0 parasol.lisp
  13. +40 −0 stroke.lisp
  14. +14 −0 toolkit.lisp
@@ -0,0 +1,16 @@
#|
This file is a part of Parasol
(c) 2014 TymoonNET/NexT http://tymoon.eu (shinmera@tymoon.eu)
Author: Nicolas Hafner <shinmera@tymoon.eu>
|#
(in-package #:parasol)
(named-readtables:in-readtable :qt)
(defvar *current-brush* NIL)
(defclass brush ()
((%color :initarg :color :initform (#_new QColor 0 0 0) :accessor color)
(%base-size :initarg :base-size :initform 5 :accessor base-size)))
(setf *current-brush* (make-instance 'brush))
@@ -0,0 +1,81 @@
#|
This file is a part of Parasol
(c) 2014 TymoonNET/NexT http://tymoon.eu (shinmera@tymoon.eu)
Author: Nicolas Hafner <shinmera@tymoon.eu>
|#
(in-package #:parasol)
(named-readtables:in-readtable :qt)
(defclass canvas ()
(;; Properties
(%width :initform 500 :initarg :width :accessor width)
(%height :initform 500 :initarg :height :accessor height)
(%background :initform (#_new QColor 255 255 255) :initarg :background :accessor background)
;; Qt instances
(%brush :initform (#_new QBrush) :accessor brush)
(%pen :initform (#_new QPen) :accessor pen)
(%pixmap :initform NIL :accessor pixmap)
(%painter :initform NIL :accessor painter)
;;
(%stroke :initform NIL :accessor stroke)))
(defmethod initialize-instance :after ((canvas canvas) &key)
(#_setColor (brush canvas) (#_new QColor 0 0 0))
(#_setColor (pen canvas) (#_new QColor 0 0 0))
(#_setStyle (brush canvas) (#_Qt::SolidPattern))
(#_setWidthF (pen canvas) 1)
(#_setCapStyle (pen canvas) (#_Qt::RoundCap))
(#_setJoinStyle (pen canvas) (#_Qt::RoundJoin))
(resize-canvas canvas (width canvas) (height canvas)))
(defgeneric resize-canvas (canvas width height &optional (x-offset 0) (y-offset 0))
(:method ((canvas canvas) width height &optional (x-offset 0) (y-offset 0))
(let ((pixmap (#_new QPixmap width height)))
(#_fill pixmap (background canvas))
(when (pixmap canvas)
(#_end (painter canvas))
(let ((painter (#_new QPainter pixmap)))
(#_drawPixmap painter x-offset y-offset (pixmap canvas))
(#_end painter)))
(let ((painter (#_new QPainter pixmap)))
(#_setRenderHint painter (#_QPainter::Antialiasing))
(#_setRenderHint painter (#_QPainter::HighQualityAntialiasing))
(#_setPen painter (pen canvas))
(#_setBrush painter (brush canvas))
(setf (pixmap canvas) pixmap
(painter canvas) painter
(width canvas) width
(height canvas) height)))
canvas))
(defgeneric scale-canvas (canvas width height)
(:method ((canvas canvas) width height)
(let ((pixmap (#_scaled (pixmap canvas) width height (#_Qt::IgnoreAspectRatio) (#_Qt::SmoothTransformation))))
(let ((painter (#_new QPainter pixmap)))
(#_setRenderHint painter (#_QPainter::Antialiasing))
(#_setRenderHint painter (#_QPainter::HighQualityAntialiasing))
(#_setPen painter (pen canvas))
(#_setBrush painter (brush canvas))
(setf (pixmap canvas) pixmap
(painter canvas) painter
(width canvas) width
(height canvas) height)))))
(defgeneric save-canvas (canvas path format)
(:method ((canvas canvas) (path pathname) format)
(#_save (pixmap canvas) (uiop:native-namestring path) format 100)
path))
(defgeneric start-stroke (canvas x y x-tilt y-tilt pressure)
(:method ((canvas canvas) x y x-tilt y-tilt pressure)
(setf (stroke canvas) (make-instance 'stroke))
(record-point canvas x y x-tilt y-tilt pressure)
canvas))
(defmethod record-point ((canvas canvas) x y x-tilt y-tilt pressure)
(record-point (stroke canvas) x y x-tilt y-tilt pressure)
(draw-incremental (stroke canvas) (painter canvas))
canvas)
@@ -0,0 +1,33 @@
#|
This file is a part of Parasol
(c) 2014 TymoonNET/NexT http://tymoon.eu (shinmera@tymoon.eu)
Author: Nicolas Hafner <shinmera@tymoon.eu>
|#
(in-package #:org.tymoonnext.parasol)
(defclass curve ()
()
(:documentation ""))
(defgeneric record-point (curve x y x-tilt y-tilt pressure)
(:documentation "Records a new point."))
(defgeneric make-curve (curve-type)
(:documentation "Creates a new, empty curve of type CURVE-TYPE."))
(defgeneric point-count (curve)
(:documentation "Returns the number of points the curve wants to draw.
This is not equal to the points recorded in the curve, but rather to the
number of points the curve uses when interpolated."))
(defgeneric point-data (curve pos)
(:documentation "Returns a list of point-data at position POS.
POS must be of the following size: 0<=POS<POINT-COUNT
The returned list looks like this: (X Y X-TILT Y-TILT PRESSURE)"))
(defgeneric map-points (curve function &key from to)
(:documentation "Maps the interpolated points of CURVE to FUNCTION.
The function must accept five arguments: X Y X-TILT Y-TILT PRESSURE
FROM and TO must be of the following size: 0<=FROM<TO<=POINT-COUNT
FROM defaults to 0 and TO to POINT-COUNT"))
Oops, something went wrong.

0 comments on commit e395ab3

Please sign in to comment.