diff --git a/docs/changelog.org b/docs/changelog.org index c4a7f51..266734b 100644 --- a/docs/changelog.org +++ b/docs/changelog.org @@ -1,4 +1,13 @@ * CALM +** 1.3.0 +- upgrade SBCL to 2.4.7 +- add macos-14 (arm64) support +- fix: weird Quicklisp + Windows + SBCL bug + https://groups.google.com/g/quicklisp/c/wrULkRePVE4/m/DZHc0qVhAQAJ +- fix: weird Windows + plain old CMD bug + https://github.com/VitoVan/calm/issues/179 +- ci: add macos-14 binary release +- ci: remove macos-11 binary release ** 1.2.0 - add documents: - hacking_JA.md @eltociear diff --git a/docs/hacking.html b/docs/hacking.html index e16cc6a..6afa596 100644 --- a/docs/hacking.html +++ b/docs/hacking.html @@ -774,13 +774,13 @@
https://github.com/VitoVan/calm/fork
-https://github.com/VitoVan/calm#-installation
-# cd to your downloaded CALM binary directory
# e.g. on macOS:
cd /Applications/Calm.app/Contents/MacOS
@@ -797,7 +797,7 @@
Now you can modify, push and create pull requests!
-Personally, I would clone the repository somewhere else and make some symbol links into the directory of the downloaded binary, such as:
cd /Applications/Calm.app/Contents/MacOS
@@ -809,7 +809,7 @@
This won't cover all the source code, but normally it's enough.
-Preparation
@@ -918,7 +918,7 @@https://github.com/VitoVan/calm/fork
-https://github.com/VitoVan/calm#-installation
-# ダウンロードした CALM バイナリのディレクトリに cd する
# 例 macOS の場合:
cd /Applications/Calm.app/Contents/MacOS
@@ -797,7 +797,7 @@ # hard を origin/main にリセット
git reset --hard origin/main
これで、修正、プッシュ、プルリクエストの作成ができるようになりましたた!
-個人的には、リポジトリをどこか別の場所にクローンし、ダウンロードしたバイナリのディレクトリにシンボルリンクを作成します、それは次のものなどがあります:
cd /Applications/Calm.app/Contents/MacOS
@@ -809,7 +809,7 @@
これですべてのソースコードをカバーできるわけではないが、通常はこれで十分です。
-準備
@@ -918,7 +918,7 @@You have donwloaded it, right?
Now let's set up the environment for the ease of use.
もうダウンロード済みですよね?
では、使いやすい環境を整えてみましょう。
Canvas Aided Lisp Magic: Create canvas-based applications with Lisp and distribute them on Linux, macOS, Windows, and the web.
English | 日本語
-Find whatever directory, and create a file: canvas.lisp
-(defparameter *color-list* '((0.83 0.82 0.84) (0.89 0.12 0.17) (0.94 0.87 0.47) (0 0.35 0.59)))
+(defparameter *color-list* '((0.83 0.82 0.84) (0.89 0.12 0.17) (0.94 0.87 0.47) (0 0.35 0.59)))
(defun draw ()
- (c:set-operator :darken)
+ (c:set-operator :darken)
(dotimes (i 7)
- (c:arc (+ 72 (* (- (/ *calm-window-width* 5) 44) i)) 73 50 0 (* 2 pi))
- (apply #'c:set-source-rgb (nth (if (>= i 4) (- i 4) i) *color-list*))
- (c:fill-path)))
+ (c:arc (+ 72 (* (- (/ *calm-window-width* 5) 44) i)) 73 50 0 (* 2 pi))
+ (apply #'c:set-source-rgb (nth (if (>= i 4) (- i 4) i) *color-list*))
+ (c:fill-path)))
Launch your terminal, cd to that directory, and enter the command:
calm
Source files and binaries for the above examples are here and here.
+Source files and binaries for the above examples are here and here.
For more applications made with CALM, please check Made with CALM.
-For macOS and Windows users, you need to be smarter than Windows SmartScreen or able to tame macOS to use CALM. In case anything went wrong, here is an Installation Guide.
-Supported platforms are currently limited by Github Actions runner images.
If your platforms are not supported, feel free to Run from Source.
-Launch your terminal, cd to the directory where the file canvas.lisp exists, enter the command:
calm publish
This command will generate different packages on different platforms:
@@ -846,19 +846,19 @@The binary detection was done by where makensis
and where winget
.
calm publish-web
This command could compile your Lisp code into web pages that could be served on the internet.
For more, please refer to the Command Reference.
-From CALM 1.0.0, the version number will follow Semantic Versioning Specification. This means you can use CALM calmly without worrying about me being crazy. Because whenever I'm going to be crazy, I will let you know before anything got changed and bump the major version if anything could surprise you.
Keep CALM and have fun.
-calm
You should run this command inside your project directory, where the file canvas.lisp should exist.
This command will load canvas.lisp and show a window according to the instructions of the function draw
or draw-forever
. The file canvas.lisp is just a regular Lisp source file, you do whatever you like in it.
For CALM-related functions and parameters, please refer to the API Reference.
-calm hello
This command will create a sample application with the default directory structure. You should create a project directory first, such as:
mkdir my-cool-app
cd my-cool-app
@@ -872,7 +872,7 @@ calm publish
+
.
-This command will generate:
If you have provided the corresponding environment variable, the option will not be asked. You could also set these environment variables while using the command calm publish
, the options will be picked up.
calm publish-web
This command will generate a web directory containing all the necessary materials for you to serve it on the internet. The common usage could be like this:
cd my-cool-app
calm publish-web
Then open http://127.0.0.1:8000/calm.html in your browser.
Note: The files inside fonts and assets directories will NOT be packed by default, please check the REBUILD_WASM_P option below.
-calm publish-web-with-options
This command works like calm publish-with-options
except it's for calm publish-web
.
Since JSCL is the backbone of CALM on the web, any change of JSCL will be considered as a change of CALM itself. The code base of JSCL used by each version of CALM is fixed, it won't change unless you update CALM. Please feel safe to use it.
-CALM is intended to be a thin layer above SDL2, Cairo, and some other things. So the number of APIs provided by CALM is intended to be as small as possible.
-canvas.lisp
-This is the entry file for a CALM application. Typically, it should contain a function called draw
.
draw
-This is the entry function for a CALM application, it will be called once the application started. You are supposed to call some canvas drawing functions to be shown, such as:
-(defun draw ()
- (c:set-source-rgb 1 0 0)
- (c:arc 200 73 50 0 (* 2 pi))
- (c:fill-path))
(defun draw ()
+ (c:set-source-rgb 1 0 0)
+ (c:arc 200 73 50 0 (* 2 pi))
+ (c:fill-path))
This function will be called passively. That is to say, this function won't be called again after the first call, unless any event has been triggered by the user, such as mouse motion, key down, key up, mouse button down, etc.
If you want to continually refresh the canvas without user interaction, you should use draw-forever
.
Note: Functions like c:arc
are third-party APIs exposed by CALM. Please refer to Drawing on Canvas for more info.
draw-forever
-This function also serves as the entry point for a CALM application, similar to the draw
function. It is important to avoid defining both draw
and draw-forever
as doing so would have severe consequences, comparable to killing John Wick's dog.
This function will be called every *calm-delay*
milliseconds, regardless of user interaction.
*calm-delay*
-This variable controls how many milliseconds CALM should wait before refreshing the canvas.
Default: 42
This variable only works on the desktop platform, for the web platform, please check *calm-fps*
.
*calm-redraw*
-This variable controls if the canvas will be refreshed from now on.
Normally, you don't need to touch this variable. But if you are using draw-forever
and you want to manually control the process of refreshing, it could be useful. Such as:
(defparameter *game-started* nil)
+(defparameter *game-started* nil)
(defun on-keyup (key)
- (when (c:keq key :SCANCODE-SPACE)
- (setf *game-started* (not *game-started*))))
+ (when (c:keq key :SCANCODE-SPACE)
+ (setf *game-started* (not *game-started*))))
(defun draw-forever ()
- (format t "drawing canvas...~%")
- (c:set-source-rgb (/ 12 255) (/ 55 255) (/ 132 255))
- (c:paint)
- (c:set-source-rgb 1 1 1)
- (c:move-to 70 90)
- (c:select-font-family "Arial" :normal :normal)
- (c:set-font-size 60)
- (c:show-text (format nil "Press SPACE: ~A" (write-to-string (mod (c:get-ticks) 9))))
- (setf *calm-redraw* *game-started*))
+ (format t "drawing canvas...~%")
+ (c:set-source-rgb (/ 12 255) (/ 55 255) (/ 132 255))
+ (c:paint)
+ (c:set-source-rgb 1 1 1)
+ (c:move-to 70 90)
+ (c:select-font-family "Arial" :normal :normal)
+ (c:set-font-size 60)
+ (c:show-text (format nil "Press SPACE: ~A" (write-to-string (mod (c:get-ticks) 9))))
+ (setf *calm-redraw* *game-started*))
Note: this variable will be set to T
whenever a user event was triggered.
*calm-fps*
-This variable controls how many milliseconds CALM should wait before refreshing the canvas. Setting 0 will use the browser’s requestAnimationFrame
mechanism to refresh the canvas.
Default: 42
This variable only works on the web, for the desktop platform, please check *calm-delay*
.
Drawing in CALM could be achieved via Cairo.
To know more about how to draw anything, please read Cairo Tutorial and Cairo API, most of the code could be modified to work in CALM.
For example:
@@ -1044,47 +1044,47 @@is equivalent to
-(c:set-line-width 0.1)
-(c:set-source-rgb 0 0 0)
-(c:rectangle 0.25 0.25 0.5 0.5)
-(c:stroke)
(c:set-line-width 0.1)
+(c:set-source-rgb 0 0 0)
+(c:rectangle 0.25 0.25 0.5 0.5)
+(c:stroke)
All the symbols exported by cl-cairo2 should be accessible through c:
prefix, such as: c:arc
. On the web, the accessible symbols are limited by cairo.lisp.
Since Cairo is the cardinal drawing facility of CALM, any change of Cairo-related symbols will be considered as a change of CALM itself. Please feel safe to use them.
-c:rrectangle
-Draw a rounded rectangle.
-(defun draw ()
- (c:set-source-rgb 0 0 1)
- (c:rrectangle 20 20 100 100 :radius 8) ;; <---- here
- (c:fill-path))
c:show-png
-(defun draw ()
+ (c:set-source-rgb 0 0 1)
+ (c:rrectangle 20 20 100 100 :radius 8) ;; <---- here
+ (c:fill-path))
Show a png file.
-(defun draw ()
- (c:show-png "assets/calm.png" 20 20 100 100))
(defun draw ()
+ (c:show-png "assets/calm.png" 20 20 100 100))
This function will stretch the png if needed.
-c:select-font-family
-This function will select a font to be used in c:show-text
.
(c:select-font-family "Open Sans" :normal :normal)
(c:select-font-family "Open Sans" :normal :normal)
It takes three arguments: family
, slant
and weight
. For detailed example, please check c:show-text
.
To use a custom font without installing it, just put it inside the fonts directory, relative to the file canvas.lisp.
-c:show-text
-This function will show simple text.
-(defun draw ()
- (c:move-to 30 100)
- (c:set-font-size 84)
- (c:select-font-family "Open Sans" :italic :bold)
- (c:show-text "DON'T PANIC"))
c:show-markup
-(defun draw ()
+ (c:move-to 30 100)
+ (c:set-font-size 84)
+ (c:select-font-family "Open Sans" :italic :bold)
+ (c:show-text "DON'T PANIC"))
This function will show Pango Markup.
-(defun draw ()
- (c:move-to 20 10)
- (c:set-font-size 84)
- (c:show-markup "This is <span fgcolor='#245791' weight='bold' face='Open Sans'>SICK</span>"))
(defun draw ()
+ (c:move-to 20 10)
+ (c:set-font-size 84)
+ (c:show-markup "This is <span fgcolor='#245791' weight='bold' face='Open Sans'>SICK</span>"))
Note that the coordinate system between c:show-markup
and c:show-text
are slightly different, so you may need to adjust the position a little if you switch between c:show-markup
and c:show-text
.
This function is not exposed to the web due to the following reasons:
c:play-wav
-Play a wav file.
If c:play-wav
were called before, and the previous wav file was still playing, the sound will be merged together.
(c:play-wav "assets/ouch.ogg" :loops 0 :channel -1)
(c:play-wav "assets/ouch.ogg" :loops 0 :channel -1)
Set :loops
to -1 means "infinitely" (~65000 times)
Set :channel
to -1 means play on the first free channel
The maximum number of files playing at the same time is limited to the variable *calm-audio-numchans*
.
*calm-audio-numchans*
-The maximum number of wav files being played at the same time.
Default: 8
-c:volume-wav
-Set the volume of c:play-wav
.
(c:volume-wav 128 :channel -1)
(c:volume-wav 128 :channel -1)
The value should be between 0 (silence) and 128.
Set :channel
to -1 means all channels.
c:halt-wav
-Stop playing a channel or all of them.
-(c:halt-wav :channel -1)
(c:halt-wav :channel -1)
Set :channel
to -1 means all channels.
c:play-music
-Play a music file, it can play MP3, Ogg, and WAV.
Other types of files might also work, but they are not guaranteed by CALM.
-(c:play-music "assets/bgm.ogg" :loops 0)
(c:play-music "assets/bgm.ogg" :loops 0)
If c:play-music
were called before, and the previous music was still playing, it will be stopped and the latest music will start playing.
c:volume-music
-Set the volume of c:play-music
.
(c:volume-music 128)
(c:volume-music 128)
The value should be between 0 (silence) and 128.
-c:halt-music
-Stop playing music.
-c:play-audio
-Play an audio file, this function is only available on the web since it utilizes the HTMLAudioElement.
-(c:play-audio "assets/meow.ogg" :loop-audio-p nil :volume 1)
(c:play-audio "assets/meow.ogg" :loop-audio-p nil :volume 1)
:volume
should be between 0 and 1.
c:halt-audio
-Stop playing one specific audio file or all of them.
-(c:halt-audio "assets/purr.ogg")
(c:halt-audio "assets/purr.ogg")
If call it without any arguments, it stops all the playing audio.
-*calm-state-mouse-x*
-*calm-state-mouse-y*
-*calm-state-mouse-up*
-*calm-state-mouse-down*
-*calm-state-mouse-just-clicked*
-*calm-state-finger-x*
-*calm-state-finger-y*
-*calm-state-finger-just-tapped*
-The above variables hold the state of the mouse and finger (touch device, like the mobile web browser), they are read-only. The consequence of (setf *calm-state-mouse-x* 20)
is equivalent to drinking bleach.
c:get-ticks
-This is just SDL_GetTicks.
-These callbacks are functions that you should define. If you defined any of them, they will be called when the corresponding event was triggered.
-on-keydown
-on-keyup
-You know what these callbacks do, what you don't know is their should-be arguments. Please check c:keq
for a detailed example.
c:keq
-This function compares the first argument with an infinite number of SDL2 Scancodes, if any of them matched, it will return T
.
(defun on-keyup (key) ;; keyup handler for evil vimers
- (cond
- ((c:keq key :scancode-left :scancode-h)
- (format t "move left~%"))
- ((c:keq key :scancode-right :scancode-l)
- (format t "move right~%"))
- ((c:keq key :scancode-up :scancode-k)
- (format t "move up~%"))
- ((c:keq key :scancode-down :scancode-j)
- (format t "move down~%"))
- (t (format t "I don't know what to do~%"))))
(defun on-keyup (key) ;; keyup handler for evil vimers
+ (cond
+ ((c:keq key :scancode-left :scancode-h)
+ (format t "move left~%"))
+ ((c:keq key :scancode-right :scancode-l)
+ (format t "move right~%"))
+ ((c:keq key :scancode-up :scancode-k)
+ (format t "move up~%"))
+ ((c:keq key :scancode-down :scancode-j)
+ (format t "move down~%"))
+ (t (format t "I don't know what to do~%"))))
SDL2 Scancode: https://wiki.libsdl.org/SDL2/SDL_Scancode
-on-mousewheel
-(defun on-mousewheel (x y direction)
+
+(defun on-mousewheel (x y direction)
;; your code here
)
-on-mousemotion
-
- Callback (defun internal-on-mousemotion (&key x y)
+
+(defun internal-on-mousemotion (&key x y)
;; your code here
)
-on-mousebuttonup
-
- Callback on-mousebuttondown
-
- Callback (defun on-mousebuttonup (&key button x y clicks)
+
+
+(defun on-mousebuttonup (&key button x y clicks)
;; your code here
)
-(defun on-mousebuttondown (&key button x y clicks)
+(defun on-mousebuttondown (&key button x y clicks)
;; your code here
)
-on-fingermotion
-
- Callback (defun on-fingermotion (&key x y dx dy pressure finger-id)
+
+(defun on-fingermotion (&key x y dx dy pressure finger-id)
;; your code here
)
-on-fingerup
-
- Callback on-fingerdown
-
- Callback (defun on-fingerup (&key x y dx dy pressure finger-id)
+
+
+(defun on-fingerup (&key x y dx dy pressure finger-id)
;; your code here
)
-(defun on-fingerdown (&key x y dx dy pressure finger-id)
+(defun on-fingerdown (&key x y dx dy pressure finger-id)
;; your code here
)
-on-windowresized
-
- Callback (defun on-windowresized (width height)
+
+(defun on-windowresized (width height)
;; your code here
)
-on-windowenter
-
- Callback on-windowleave
-
+ Callback
+
These two callbacks do not take any arguments, for example:
-(defun on-windowenter ()
+(defun on-windowenter ()
;; your code here
)
-
- Window Related*calm-window*
-
+ Variable
+
This variable is readonly, it holds the created instance of SDL_Window.
With this variable, one could utilize all kinds of SDL2 window related functions, such as:
-;; get window position
-(sdl2:get-window-position *calm-window*)
+;; get window position
+(sdl2:get-window-position *calm-window*)
;; set window always on top
-(sdl2-ffi.functions:sdl-set-window-always-on-top
- *calm-window*
- sdl2-ffi:+true+)
-*calm-window-x*
-
- Variable *calm-window-y*
-
+( Variable sdl2-ffi.functions:sdl-set-window-always-on-top
+ *calm-window*
+ sdl2-ffi:+true+)
+
+
The initial position (x, y) of your CALM application window.
Default: :centered
-*calm-window-flags*
-
+ Variable
A list of SDL_WindowFlags.
You could set this value like: (setf *calm-window-flags* '(:shown :allow-highdpi :resizable))
Default: '(:shown :allow-highdpi)
-*calm-window-width*
-
- Variable *calm-window-height*
-
- Variable *calm-window-title*
-
+ Variable
+
+
You know what these variables do.
If you don't, give me 5 bucks and think harder.
-
+ Tutorials
Ok ok, I will write this, I will write this, just wait a second.
You could check these useful links while waiting:
@@ -1301,7 +1301,7 @@
+ License
The source code is released under GPL-2.0-only.
diff --git a/index_ja.html b/index_ja.html
index 107b349..9c31730 100644
--- a/index_ja.html
+++ b/index_ja.html
@@ -774,38 +774,38 @@
- ソース
- C A L M
-
-
+
+
Canvas Aided Lisp Magic: Lisp でキャンバスベースのアプリケーションを作成し、Linux、macOS、Windows、Web 上で配布できます。
English | 日本語
-
+ Hello, World!
任意のディレクトリを探し、ファイルを作成する: canvas.lisp
-(defparameter *color-list* '((0.83 0.82 0.84) (0.89 0.12 0.17) (0.94 0.87 0.47) (0 0.35 0.59)))
+(defparameter *color-list* '((0.83 0.82 0.84) (0.89 0.12 0.17) (0.94 0.87 0.47) (0 0.35 0.59)))
(defun draw ()
- (c:set-operator :darken)
+ (c:set-operator :darken)
(dotimes (i 7)
- (c:arc (+ 72 (* (- (/ *calm-window-width* 5) 44) i)) 73 50 0 (* 2 pi))
- (apply #'c:set-source-rgb (nth (if (>= i 4) (- i 4) i) *color-list*))
- (c:fill-path)))
+ (c:arc (+ 72 (* (- (/ *calm-window-width* 5) 44) i)) 73 50 0 (* 2 pi))
+ (apply #'c:set-source-rgb (nth (if (>= i 4) (- i 4) i) *color-list*))
+ (c:fill-path)))
ターミナルを起動し、そのディレクトリに cd してコマンドを入力する:
calm
-
+ 例
-
+
CALM で作られた他のアプリケーションについては、Made with CALM をご覧ください。
- インストール
-
-
+ ビルド済みバイナリ
+
macOS と Windows ユーザーの場合、CALM を使うには Windows SmartScreen よりもスマートであるか、macOS を飼いならす事ができる必要があります。万が一何かあったときのために、ここにインストールガイドがあります。
-
+ ソースからの実行
現在、サポートされているプラットフォームは GitHub Actions runner images によって制限されています。
もしあなたのプラットフォームがサポートされていない場合は、ソースから実行を使ってください。
- 配布
+
-
ターミナルを起動し、canvas.lisp ファイルが存在するディレクトリに cd し、次のコマンドを入力する:
calm publish
このコマンドは、プラットフォームによって異なるパッケージを生成する:
@@ -846,19 +846,19 @@
がなければ、これで winget もインストールされます。
バイナリ検出は where makensis
と where winget
によって行われています。
-
+ Web へ
calm publish-web
このコマンドを実行すると、Lisp コードをコンパイルして Web ページを作成することができます。
詳しくはコマンドリファレンスを参照してください。
-
+ CALM - リファレンス
CALM 1.0.0 から、バージョン番号は Semantic Versioning Specification に従います。これは、私がおかしくなることを心配することなく、落ち着いて CALM を使えることを意味します。というのも、私がおかしくなりそうなときはいつでも、何かが変更される前にお知らせしますし、何か驚かせるようなことがあったらメジャーバージョンを上げます。
Keep CALM and have fun.
-
- コマンドリファレンスcalm
+
+
このコマンドはプロジェクトのディレクトリ内で実行する必要があり、canvas.lisp というファイルが存在するはずです。
このコマンドは canvas.lisp をロードし、関数 draw
または draw-forever
の指示に従ってウィンドウを表示します。canvas.lisp は普通の Lisp ソースファイルなので、好きなように記述してください。
CALM 関連の関数やパラメータについては、API リファレンスを参照してください。
-calm hello
+
このコマンドは、デフォルトのディレクトリ構造でサンプルアプリケーションを作成します。最初にプロジェクトディレクトリを作成する必要があります:
mkdir my-cool-app
cd my-cool-app
@@ -872,7 +872,7 @@ calm publish
+
を参照してください。
-このコマンドは以下を生成します:
- Linux AppImage
@@ -881,7 +881,7 @@
@@ -944,7 +944,7 @@
対応する環境変数を設定した場合、オプションは聞かれません。また、calm publish
コマンドを使っているときにこれらの環境変数を設定することもできます。
-calm publish-web
+
このコマンドは、インターネット上で提供するために必要なすべての素材を含む web ディレクトリを生成します。一般的な使い方は次のようになります:
cd my-cool-app
calm publish-web
@@ -963,7 +963,7 @@
次にブラウザで http://127.0.0.1:8000/calm.html を開きます。
注: デフォルトでは fonts と assets ディレクトリ内のファイルはパック されません 。以下の REBUILD_WASM_P オプションを確認してください。
-calm publish-web-with-options
+
このコマンドは calm publish-web
用であることを除けば、calm publish-with-options
のように動作します。
@@ -985,58 +985,58 @@
JSCL は CALM の Web 上でのバックボーンですので、JSCL の変更は CALM 自体の変更とみなされます。CALM の各バージョンで使用されている JSCL のコードベースは固定されていますので、CALM をアップデートしない限り変更されることはありません。安心してお使いください。
-
+ API リファレンス
CALM は、SDL2 や Cairo、その他のものの上の薄いレイヤーになることを意図しています。なので、CALM が提供する API の数はできるだけ少なくなるように意図しています。
-
- 基礎canvas.lisp
-
+ ファイル
+
これは CALM アプリケーションのエントリーファイルです。通常、draw
という関数が含まれています。
-draw
-
+ 関数
これは CALM アプリケーションのエントリー関数で、アプリケーションが起動すると呼び出されます。表示されるキャンバスの描画関数を呼び出すことになっています:
-(defun draw ()
- (c:set-source-rgb 1 0 0)
- (c:arc 200 73 50 0 (* 2 pi))
- (c:fill-path))
+(defun draw ()
+ (c:set-source-rgb 1 0 0)
+ (c:arc 200 73 50 0 (* 2 pi))
+ (c:fill-path))
この関数は受動的に呼び出されます。つまり、マウスの動き、キーのダウン、キーのアップ、マウスボタンのダウンなど、ユーザーによって何らかのイベントがトリガーされない限り、この関数は最初の呼び出しの後、再び呼び出されることはありません。
ユーザーの操作なしにキャンバスを更新し続けたい場合は、draw-forever
を使うべきです。
注: c:arc
のような関数は CALM が公開しているサードパーティの API です。詳しくはキャンバスに描画を参照してください。
-draw-forever
-
+ 関数
この関数は draw
関数と同様に、CALM アプリケーションのエントリーポイントとしても機能します。draw
と draw-forever
の両方を定義することは、John Wick の犬を殺してしまうような深刻な結果をもたらすので、避けることが重要です。
この関数はユーザーの操作に関係なく、*calm-delay*
ミリ秒ごとに呼び出されます。
-*calm-delay*
-
+ 変数
この変数は、CALM がキャンバスをリフレッシュする前に何ミリ秒待つかをコントロールします
デフォルト: 42
この変数はデスクトッププラットフォームでのみ機能します。ウェブプラットフォームでは *calm-fps*
をチェックしてください。
-*calm-redraw*
-
+ 変数
この変数はこの後のキャンバスをリフレッシュするかどうかを制御します。
通常はこの変数に触れる必要はありません。しかし、draw-forever
を使用していて、リフレッシュのプロセスを手動でコントロールしたい場合、この変数は役に立ちます。例えば:
-(defparameter *game-started* nil)
+(defparameter *game-started* nil)
(defun on-keyup (key)
- (when (c:keq key :SCANCODE-SPACE)
- (setf *game-started* (not *game-started*))))
+ (when (c:keq key :SCANCODE-SPACE)
+ (setf *game-started* (not *game-started*))))
(defun draw-forever ()
- (format t "drawing canvas...~%")
- (c:set-source-rgb (/ 12 255) (/ 55 255) (/ 132 255))
- (c:paint)
- (c:set-source-rgb 1 1 1)
- (c:move-to 70 90)
- (c:select-font-family "Arial" :normal :normal)
- (c:set-font-size 60)
- (c:show-text (format nil "Press SPACE: ~A" (write-to-string (mod (c:get-ticks) 9))))
- (setf *calm-redraw* *game-started*))
+ (format t "drawing canvas...~%")
+ (c:set-source-rgb (/ 12 255) (/ 55 255) (/ 132 255))
+ (c:paint)
+ (c:set-source-rgb 1 1 1)
+ (c:move-to 70 90)
+ (c:select-font-family "Arial" :normal :normal)
+ (c:set-font-size 60)
+ (c:show-text (format nil "Press SPACE: ~A" (write-to-string (mod (c:get-ticks) 9))))
+ (setf *calm-redraw* *game-started*))
注: この変数は、ユーザーイベントがトリガーされるたびに T
に設定されます。
-*calm-fps*
-
+ 変数
この変数は CALM がキャンバスを更新する前に何ミリ秒待つかを制御します。0 を設定すると、ブラウザの requestAnimationFrame
メカニズムを使用してキャンバスを更新します。
デフォルト: 42
この変数はウェブ上でのみ動作します。デスクトッププラットフォームでは *calm-delay*
をチェックしてください。
-
+ キャンバスに描画
CALM での描画は、Cairo を使って実現できます。
どのように描画するかについては、Cairo チュートリアルと Cairo API を読んでください。
たとえば:
@@ -1045,47 +1045,47 @@
は以下と同じです
-(c:set-line-width 0.1)
-(c:set-source-rgb 0 0 0)
-(c:rectangle 0.25 0.25 0.5 0.5)
-(c:stroke)
+(c:set-line-width 0.1)
+(c:set-source-rgb 0 0 0)
+(c:rectangle 0.25 0.25 0.5 0.5)
+(c:stroke)
cl-cairo2 によってエクスポートされる シンボルはすべて、c:
のような接頭辞でアクセスできるようにすべきです、例えば: c:arc
。ウェブ上では、アクセス可能なシンボルは cairo.lisp によって制限されています。
Cairo は CALM の主要な描画機能ですので、Cairo 関連のシンボルの変更は CALM 自体の変更とみなされます。安心してお使いください。
-c:rrectangle
-
+ 関数
丸みのある長方形を描きます。
-(defun draw ()
- (c:set-source-rgb 0 0 1)
- (c:rrectangle 20 20 100 100 :radius 8) ;; <---- ここ
- (c:fill-path))
-c:show-png
-
+ 関数 (defun draw ()
+ (c:set-source-rgb 0 0 1)
+ (c:rrectangle 20 20 100 100 :radius 8) ;; <---- ここ
+ (c:fill-path))
+
png ファイルを表示します。
-(defun draw ()
- (c:show-png "assets/calm.png" 20 20 100 100))
+(defun draw ()
+ (c:show-png "assets/calm.png" 20 20 100 100))
この関数は必要に応じて png を引き伸ばします。
-
- テキストのレンダリングc:select-font-family
-
+ 関数
+
この関数はc:show-text
で使用するフォントを選択します。
-(c:select-font-family "Open Sans" :normal :normal)
+(c:select-font-family "Open Sans" :normal :normal)
次の 3 つの引数を取ります: family
、slant
、weight
です。詳細な例については、c:show-text
を参照して下さい。
カスタムフォントをインストールせずに使用するには、canvas.lispファイルからの相対パスで、fontsディレクトリに置くだけです。
-c:show-text
-
+ 関数
この関数は単純なテキストを表示します。
-(defun draw ()
- (c:move-to 30 100)
- (c:set-font-size 84)
- (c:select-font-family "Open Sans" :italic :bold)
- (c:show-text "DON'T PANIC"))
-c:show-markup
-
+ 関数 (defun draw ()
+ (c:move-to 30 100)
+ (c:set-font-size 84)
+ (c:select-font-family "Open Sans" :italic :bold)
+ (c:show-text "DON'T PANIC"))
+
この関数は Pango Markup を表示します。
-(defun draw ()
- (c:move-to 20 10)
- (c:set-font-size 84)
- (c:show-markup "This is <span fgcolor='#245791' weight='bold' face='Open Sans'>SICK</span>"))
+(defun draw ()
+ (c:move-to 20 10)
+ (c:set-font-size 84)
+ (c:show-markup "This is <span fgcolor='#245791' weight='bold' face='Open Sans'>SICK</span>"))
c:show-markup
と c:show-text
では座標系が若干異なるので、c:show-markup
と c:show-text
を切り替える場合には少し位置を調整する必要があるかもしれないです。
この関数は以下の理由によりウェブには公開されていません:
@@ -1094,177 +1094,177 @@ c:play-wav
-
+ 関数
+
サウンドの再生
-wavファイルを再生します。
もし c:play-wav
が以前に呼ばれ、前の wav ファイルがまだ再生されていた場合、その音はマージされます。
-(c:play-wav "assets/ouch.ogg" :loops 0 :channel -1)
+(c:play-wav "assets/ouch.ogg" :loops 0 :channel -1)
:loops
を -1 に設定すると、"無限に" (~65000 回)再生します
:channel
を -1 に設定すると、最初に空いているチャンネルで再生します
同時に再生できるファイルの最大数は *calm-audio-numchans*
変数に制限されます。
-*calm-audio-numchans*
-
+ 変数
同時に再生される wav ファイルの最大数です。
デフォルト: 8
-c:volume-wav
-
+ 関数
c:play-wav
の音量を設定します。
-(c:volume-wav 128 :channel -1)
+(c:volume-wav 128 :channel -1)
値は 0 (無音)から 128 の間でなければなりません。
:channel
を -1 に設定すると、すべてのチャンネルを意味します。
-c:halt-wav
-
+ 関数
あるチャンネル、あるいはすべてのチャンネルを停止します。
-(c:halt-wav :channel -1)
+(c:halt-wav :channel -1)
:channel
を -1 に設定すると、すべてのチャンネルを意味します。
-c:play-music
-
+ 関数
MP3、Ogg、WAV の音楽ファイルを再生します。
他のタイプのファイルでも動作するかもしれませんが、CALM が保証するものではありません。
-(c:play-music "assets/bgm.ogg" :loops 0)
+(c:play-music "assets/bgm.ogg" :loops 0)
もし c:play-music
が以前に呼ばれ、前の音楽がまだ再生されていた場合、それは停止され、最新の音楽が再生され始めます。
-c:volume-music
-
+ 関数
c:play-music
の音量を設定します。
-(c:volume-music 128)
+(c:volume-music 128)
値は 0 (無音)から 128 の間でなければなりません。
-c:halt-music
-
+ 関数
音楽の再生を停止します。
-c:play-audio
-
+ 関数
音声ファイルを再生します。この機能は HTMLAudioElement を利用するため、ウェブ上でのみ利用可能です。
-(c:play-audio "assets/meow.ogg" :loop-audio-p nil :volume 1)
+(c:play-audio "assets/meow.ogg" :loop-audio-p nil :volume 1)
:volume
は 0 から 1 の間でなければなりません。
-c:halt-audio
-
+ 関数
特定のオーディオファイルまたはすべてのオーディオファイルの再生を停止します。
-(c:halt-audio "assets/purr.ogg")
+(c:halt-audio "assets/purr.ogg")
引数なしで呼び出すと、再生中のすべてのオーディオを停止します。
-
- 内部の状態*calm-state-mouse-x*
-
- 変数 *calm-state-mouse-y*
-
- 変数 *calm-state-mouse-up*
-
- 変数 *calm-state-mouse-down*
-
- 変数 *calm-state-mouse-just-clicked*
-
- 変数 *calm-state-finger-x*
-
- 変数 *calm-state-finger-y*
-
- 変数 *calm-state-finger-just-tapped*
-
+ 変数
+
+
+
+
+
+
+
+
上記の変数はマウスと指(モバイルウェブブラウザのようなタッチデバイス)の状態を保持し、読み取り専用です。(setf *calm-state-mouse-x* 20)
の結果は漂白剤を飲むことと同じです。
-c:get-ticks
-
+ 関数
これは単なる SDL_GetTicks です。
-
+ イベントのコールバック
これらのコールバックは、あなたが定義すべき関数です。定義しておけば、対応するイベントがトリガーされたときに呼び出されます。
-on-keydown
-
- コールバック on-keyup
-
+ コールバック
+
あなたはこれらのコールバックが何をするのか知っているが、知らないのは、その本来あるべき引数でしょう。詳しい例については c:keq
を確認して下さい。
-c:keq
-
+ 関数
この関数は、最初の引数を無限の SDL2 スキャンコードと比較し、マッチするものがあれば T
を返します。
-(defun on-keyup (key) ;; 悪い vimer のためのキーアップハンドラー
- (cond
- ((c:keq key :scancode-left :scancode-h)
- (format t "move left~%"))
- ((c:keq key :scancode-right :scancode-l)
- (format t "move right~%"))
- ((c:keq key :scancode-up :scancode-k)
- (format t "move up~%"))
- ((c:keq key :scancode-down :scancode-j)
- (format t "move down~%"))
- (t (format t "I don't know what to do~%"))))
+(defun on-keyup (key) ;; 悪い vimer のためのキーアップハンドラー
+ (cond
+ ((c:keq key :scancode-left :scancode-h)
+ (format t "move left~%"))
+ ((c:keq key :scancode-right :scancode-l)
+ (format t "move right~%"))
+ ((c:keq key :scancode-up :scancode-k)
+ (format t "move up~%"))
+ ((c:keq key :scancode-down :scancode-j)
+ (format t "move down~%"))
+ (t (format t "I don't know what to do~%"))))
SDL2 スキャンコード: https://wiki.libsdl.org/SDL2/SDL_Scancode
-on-mousewheel
-
- コールバック (defun on-mousewheel (x y direction)
+
+(defun on-mousewheel (x y direction)
;; コードをここに
)
-on-mousemotion
-
- コールバック (defun internal-on-mousemotion (&key x y)
+
+(defun internal-on-mousemotion (&key x y)
;; コードをここに
)
-on-mousebuttonup
-
- コールバック on-mousebuttondown
-
- コールバック (defun on-mousebuttonup (&key button x y clicks)
+
+
+(defun on-mousebuttonup (&key button x y clicks)
;; コードをここに
)
-(defun on-mousebuttondown (&key button x y clicks)
+(defun on-mousebuttondown (&key button x y clicks)
;; コードをここに
)
-on-fingermotion
-
- コールバック (defun on-fingermotion (&key x y dx dy pressure finger-id)
+
+(defun on-fingermotion (&key x y dx dy pressure finger-id)
;; コードをここに
)
-on-fingerup
-
- コールバック on-fingerdown
-
- コールバック (defun on-fingerup (&key x y dx dy pressure finger-id)
+
+
+(defun on-fingerup (&key x y dx dy pressure finger-id)
;; コードをここに
)
-(defun on-fingerdown (&key x y dx dy pressure finger-id)
+(defun on-fingerdown (&key x y dx dy pressure finger-id)
;; コードをここに
)
-on-windowresized
-
- コールバック (defun on-windowresized (width height)
+
+(defun on-windowresized (width height)
;; コードをここに
)
-on-windowenter
-
- コールバック on-windowleave
-
+ コールバック
+
これら 2 つのコールバックは引数を取りません:
-(defun on-windowenter ()
+(defun on-windowenter ()
;; コードをここに
)
-
- ウィンドウ関連*calm-window*
-
+ 変数
+
この変数は読み取り専用で、作成された SDL_Window のインスタンスを保持します。
この変数を使用すると、次のような SDL2 ウィンドウ関連のあらゆる関数を使用できます:
-;; ウィンドウの位置を取得
-(sdl2:get-window-position *calm-window*)
+;; ウィンドウの位置を取得
+(sdl2:get-window-position *calm-window*)
;; ウィンドウを常に上に表示
-(sdl2-ffi.functions:sdl-set-window-always-on-top
- *calm-window*
- sdl2-ffi:+true+)
-*calm-window-x*
-
- 変数 *calm-window-y*
-
+( 変数 sdl2-ffi.functions:sdl-set-window-always-on-top
+ *calm-window*
+ sdl2-ffi:+true+)
+
+
CALM アプリケーションのウィンドウの初期位置(x、y)。
デフォルト: :centered
-*calm-window-flags*
-
+ 変数
SDL_WindowFlags のリスト。
この値は次のように設定できます: (setf *calm-window-flags* '(:shown :allow-highdpi :resizable))
デフォルト: '(:shown :allow-highdpi)
-*calm-window-width*
-
- 変数 *calm-window-height*
-
- 変数 *calm-window-title*
-
+ 変数
+
+
あなたはこれらの変数が何をするか知っているはずです。
そうでないなら、5 ドルを私に渡して、そしてもっとよく考えて下さい。
-
+ チュートリアル
OKOK、これを書くよ、これを書くよ、ちょっと待ってて。
待っている間、以下の便利なリンクをチェックできますよ:
@@ -1302,7 +1302,7 @@
+ ライセンス
ソースコードは GPL-2.0-only でリリースされています。