mirror of
https://gitlab.com/eql/lqml.git
synced 2025-12-06 02:30:38 -08:00
first working desktop version
This commit is contained in:
parent
0e6ff84388
commit
42e8912912
30 changed files with 2561 additions and 3 deletions
BIN
examples/9999/doc/9999.jpg
Normal file
BIN
examples/9999/doc/9999.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
3
examples/9999/doc/readme.txt
Normal file
3
examples/9999/doc/readme.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
simple canvas example: draw in JS, calculate in Lisp
|
||||
|
||||
see also: https://en.wikipedia.org/wiki/Cistercian_numerals
|
||||
48
examples/9999/lisp/main.lisp
Normal file
48
examples/9999/lisp/main.lisp
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
(in-package :qml-user)
|
||||
|
||||
(defvar *number* 0)
|
||||
|
||||
;;; QML items
|
||||
|
||||
(defvar *canvas* "canvas")
|
||||
(defvar *input* "input")
|
||||
|
||||
(defun draw-line (x1 y1 x2 y2)
|
||||
(qjs |drawLine| *canvas*
|
||||
x1 y1 x2 y2))
|
||||
|
||||
(defun draw-number (number)
|
||||
(setf *number* number)
|
||||
(q! |requestPaint| *canvas*))
|
||||
|
||||
(defun paint ()
|
||||
(draw-line 0 -150 0 150)
|
||||
(let ((dy -50)
|
||||
(dig 1))
|
||||
(labels ((line (x1 y1 x2 y2)
|
||||
(when (find dig '(2 4))
|
||||
(setf x1 (- x1)
|
||||
x2 (- x2)))
|
||||
(when (>= dig 3)
|
||||
(setf y1 (- y1)
|
||||
y2 (- y2)
|
||||
dy 50))
|
||||
(draw-line (* 100 x1) (+ dy (* 100 y1))
|
||||
(* 100 x2) (+ dy (* 100 y2))))
|
||||
(draw (n)
|
||||
(case n
|
||||
(1 (line 0 -1 1 -1))
|
||||
(2 (line 0 0 1 0))
|
||||
(3 (line 0 -1 1 0))
|
||||
(4 (line 0 0 1 -1))
|
||||
(5 (draw 1) (draw 4))
|
||||
(6 (line 1 -1 1 0))
|
||||
(7 (draw 1) (draw 6))
|
||||
(8 (draw 2) (draw 6))
|
||||
(9 (draw 1) (draw 8)))))
|
||||
(let ((num *number*))
|
||||
(x:while (plusp num)
|
||||
(draw (mod num 10))
|
||||
(setf num (floor (/ num 10)))
|
||||
(incf dig))))))
|
||||
|
||||
49
examples/9999/qml/main.qml
Normal file
49
examples/9999/qml/main.qml
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import Lisp
|
||||
|
||||
Rectangle {
|
||||
width: 220
|
||||
height: 320 + input.height
|
||||
color: "lavender"
|
||||
|
||||
Canvas {
|
||||
id: canvas
|
||||
objectName: "canvas"
|
||||
width: 220
|
||||
height: 320
|
||||
|
||||
property var painter
|
||||
|
||||
function drawLine(x1, y1, x2, y2) {
|
||||
painter.moveTo(x1, y1)
|
||||
painter.lineTo(x2, y2)
|
||||
}
|
||||
|
||||
onPaint: {
|
||||
var ctx = getContext("2d")
|
||||
painter = ctx
|
||||
ctx.reset()
|
||||
ctx.strokeStyle = "blue"
|
||||
ctx.lineWidth = 10
|
||||
ctx.lineCap = "round"
|
||||
ctx.translate(110, 160)
|
||||
|
||||
Lisp.call("qml-user:paint")
|
||||
|
||||
ctx.stroke()
|
||||
}
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: input
|
||||
objectName: "input"
|
||||
width: parent.width
|
||||
anchors.bottom: parent.bottom
|
||||
horizontalAlignment: Qt.AlignHCenter
|
||||
text: "0000"
|
||||
inputMask: "9999"
|
||||
|
||||
onTextChanged: Lisp.call("qml-user:draw-number", Number(text))
|
||||
}
|
||||
}
|
||||
14
examples/9999/run.lisp
Normal file
14
examples/9999/run.lisp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
(in-package :qml-user)
|
||||
|
||||
(load "lisp/main")
|
||||
|
||||
(qset *quick-view*
|
||||
|x| 75
|
||||
|y| 75)
|
||||
|
||||
;;; for Slime after copying 'qml-start-swank.lisp' from LQML sources
|
||||
;;; to your Slime directory, which is assumed to be '~/slime/'
|
||||
|
||||
(when (find "-slime" (ext:command-args) :test 'string=)
|
||||
(load "~/slime/qml-start-swank")) ; for 'slime-connect' from Emacs
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue