From b29e68caa5b7b69dae696dfdb9c6d59d8d775c0f Mon Sep 17 00:00:00 2001 From: Vito Van Date: Wed, 7 Aug 2024 11:12:52 +0800 Subject: [PATCH] Deploy docs for 1.3.0 to gh-pages 1723000372 --- docs/changelog.org | 9 + docs/hacking.html | 16 +- docs/hacking_ja.html | 16 +- docs/installation.html | 4 +- docs/installation_ja.html | 4 +- index.html | 412 +++++++++++++++++++------------------- index_ja.html | 412 +++++++++++++++++++------------------- 7 files changed, 441 insertions(+), 432 deletions(-) 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 @@
  • Source
  • -

    Hacking CALM

    -

    With Pre-built Binaries

    -

    Step 1: Fork CALM

    +

    Hacking CALM

    +

    With Pre-built Binaries

    +

    Step 1: Fork CALM

    https://github.com/VitoVan/calm/fork

    -

    Step 2: Install CALM binary

    +

    Step 2: Install CALM binary

    https://github.com/VitoVan/calm#-installation

    -

    Step 3: Init Git Repository

    +

    Step 3: Init Git Repository

    # cd to your downloaded CALM binary directory
     # e.g. on macOS:
     cd /Applications/Calm.app/Contents/MacOS
    @@ -797,7 +797,7 @@ 

    My Personal Favour

    +

    My Personal Favour

    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 @@ 

    Run From Source

    +

    Run From Source

    1. Preparation

      @@ -918,7 +918,7 @@

      Building CALM

      +

      Building CALM

      Currently CALM was built on github actions, you can find the workflow here.

      If you have interests to build CALM and encountered any problem, please let me know.

      I would be so glad to help.

      diff --git a/docs/hacking_ja.html b/docs/hacking_ja.html index 030b632..4253188 100644 --- a/docs/hacking_ja.html +++ b/docs/hacking_ja.html @@ -774,13 +774,13 @@
    2. ソース
    -

    CALM をハックする

    -

    ビルド済みバイナリを使用

    -

    ステップ 1: CALM をフォークする

    +

    CALM をハックする

    +

    ビルド済みバイナリを使用

    +

    ステップ 1: CALM をフォークする

    https://github.com/VitoVan/calm/fork

    -

    ステップ 2: CALM バイナリのインストール

    +

    ステップ 2: CALM バイナリのインストール

    https://github.com/VitoVan/calm#-installation

    -

    ステップ 3: Git リポジトリの初期化

    +

    ステップ 3: Git リポジトリの初期化

    # ダウンロードした 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 @@ 

    ソースからの実行

    +

    ソースからの実行

    1. 準備

      @@ -918,7 +918,7 @@

      CALM のビルド

      +

      CALM のビルド

      現在、CALM は GitHub actions でビルドされています。ワークフローはこちらにあります。

      もし CALM のビルドに興味があり、何か問題が発生したら、私にお知らせください。

      喜んでお手伝いします。

      diff --git a/docs/installation.html b/docs/installation.html index af98643..7e9ffa1 100644 --- a/docs/installation.html +++ b/docs/installation.html @@ -774,8 +774,8 @@
    2. Source
    -

    CALM Installation

    -

    Setting Up CALM

    +

    CALM Installation

    +

    Setting Up CALM

    You have donwloaded it, right?

    Now let's set up the environment for the ease of use.

      diff --git a/docs/installation_ja.html b/docs/installation_ja.html index 8d06fcd..c54e994 100644 --- a/docs/installation_ja.html +++ b/docs/installation_ja.html @@ -774,8 +774,8 @@
    • ソース
    -

    CALM インストール

    -

    CALM の設定

    +

    CALM インストール

    +

    CALM の設定

    もうダウンロード済みですよね?

    では、使いやすい環境を整えてみましょう。

      diff --git a/index.html b/index.html index a6c5398..669b684 100644 --- a/index.html +++ b/index.html @@ -774,38 +774,38 @@
    • Source
    -

    -Calm C A L M

    -

    CI GitHub all releases Discord

    +

    +Calm C A L M

    +

    Canvas Aided Lisp Magic: Create canvas-based applications with Lisp and distribute them on Linux, macOS, Windows, and the web.

    English | 日本語

    -

    Hello, World!

    +

    Hello, World!

    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

    Hello World

    -

    Examples

    +

    Examples

    - Fan - Mondrian - Meditator + Fan + Mondrian + Meditator

    -

    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.

    -

    -Calm Installer Installation

    -

    Pre-built Binary

    +

    +Calm Installer Installation

    +

    Pre-built Binary

    1. Download

      -

      Linux Download macOS Ventura Download Windows Download macOS Monterey Download macOS Big Sur Download

      +

    2. Extract

      @@ -816,11 +816,11 @@

    Windows SmartScreen or able to tame macOS to use CALM. In case anything went wrong, here is an Installation Guide.

    -

    Run from Source

    +

    Run from Source

    Supported platforms are currently limited by Github Actions runner images.

    If your platforms are not supported, feel free to Run from Source.

    -

    -Calm Application Distribution

    +

    +Calm Application Distribution

    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 @@

    winget under your PATH, this will also install winget for you.

    The binary detection was done by where makensis and where winget.

    -

    To the Web

    +

    To the Web

    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.

    -

    CALM - References

    +

    CALM - References

    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.

    -

    Command Reference

    -

    calm

    +

    Command Reference

    +

    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

    +

    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

    +

    calm publish

    This command will generate:

    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

    +

    calm publish-web-with-options

    This command works like calm publish-with-options except it's for calm publish-web.

    @@ -984,58 +984,58 @@

    API Reference

    +

    API Reference

    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.

    -

    Fundamentals

    -
    File canvas.lisp -
    +

    Fundamentals

    +
    File canvas.lisp +

    This is the entry file for a CALM application. Typically, it should contain a function called draw.

    -
    Function draw -
    +
    Function 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.

    -
    Function draw-forever -
    +
    Function 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.

    -
    Variable *calm-delay* -
    +
    Variable *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*.

    -
    Variable *calm-redraw* -
    +
    Variable *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.

    -
    Variable *calm-fps* -
    +
    Variable *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 on Canvas

    +

    Drawing on Canvas

    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 @@

    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.

    -
    Function c:rrectangle -
    +
    Function 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))
    -
    Function c:show-png -
    +
    (defun draw ()
    +  (c:set-source-rgb 0 0 1)
    +  (c:rrectangle 20 20 100 100 :radius 8) ;; <---- here
    +  (c:fill-path))
    +
    Function c:show-png +

    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.

    -

    Rendering Text

    -
    Function c:select-font-family -
    +

    Rendering Text

    +
    Function 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.

    -
    Function c:show-text -
    +
    Function 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"))
    -
    Function 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"))
    +
    Function c:show-markup +

    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:

      @@ -1093,177 +1093,177 @@
      Playing Sound
      -
      Function c:play-wav -
      +

      Playing Sound

      +
      Function 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*.

      -
      Variable *calm-audio-numchans* -
      +
      Variable *calm-audio-numchans* +

      The maximum number of wav files being played at the same time.

      Default: 8

      -
      Function c:volume-wav -
      +
      Function 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.

      -
      Function c:halt-wav -
      +
      Function 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.

      -
      Function c:play-music -
      +
      Function 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.

      -
      Function c:volume-music -
      +
      Function 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.

      -
      Function c:halt-music -
      +
      Function c:halt-music +

      Stop playing music.

      -
      Function c:play-audio -
      +
      Function 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.

      -
      Function c:halt-audio -
      +
      Function 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.

      -

      Internal States

      -
      Variable *calm-state-mouse-x* -
      -
      Variable *calm-state-mouse-y* -
      -
      Variable *calm-state-mouse-up* -
      -
      Variable *calm-state-mouse-down* -
      -
      Variable *calm-state-mouse-just-clicked* -
      -
      Variable *calm-state-finger-x* -
      -
      Variable *calm-state-finger-y* -
      -
      Variable *calm-state-finger-just-tapped* -
      +

      Internal States

      +
      Variable *calm-state-mouse-x* +
      +
      Variable *calm-state-mouse-y* +
      +
      Variable *calm-state-mouse-up* +
      +
      Variable *calm-state-mouse-down* +
      +
      Variable *calm-state-mouse-just-clicked* +
      +
      Variable *calm-state-finger-x* +
      +
      Variable *calm-state-finger-y* +
      +
      Variable *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.

      -
      Function c:get-ticks -
      +
      Function c:get-ticks +

      This is just SDL_GetTicks.

      -

      Event Callbacks

      +

      Event Callbacks

      These callbacks are functions that you should define. If you defined any of them, they will be called when the corresponding event was triggered.

      -
      Callback on-keydown -
      -
      Callback on-keyup -
      +
      Callback on-keydown +
      +
      Callback 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.

      -
      Function c:keq -
      +
      Function 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

      -
      Callback on-mousewheel -
      -
      (defun on-mousewheel (x y direction)
      +
      Callback on-mousewheel +
      +
      (defun on-mousewheel (x y direction)
         ;; your code here
         )
      -
      Callback on-mousemotion -
      -
      (defun internal-on-mousemotion (&key x y)
      +
      Callback on-mousemotion +
      +
      (defun internal-on-mousemotion (&key x y)
         ;; your code here
         )
      -
      Callback on-mousebuttonup -
      -
      Callback on-mousebuttondown -
      -
      (defun on-mousebuttonup (&key button x y clicks)
      +
      Callback on-mousebuttonup +
      +
      Callback on-mousebuttondown +
      +
      (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
         )
      -
      Callback on-fingermotion -
      -
      (defun on-fingermotion (&key x  y dx dy pressure finger-id)
      +
      Callback on-fingermotion +
      +
      (defun on-fingermotion (&key x  y dx dy pressure finger-id)
         ;; your code here
         )
      -
      Callback on-fingerup -
      -
      Callback on-fingerdown -
      -
      (defun on-fingerup (&key x  y dx dy pressure finger-id)
      +
      Callback on-fingerup +
      +
      Callback on-fingerdown +
      +
      (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
         )
      -
      Callback on-windowresized -
      -
      (defun on-windowresized (width height)
      +
      Callback on-windowresized +
      +
      (defun on-windowresized (width height)
         ;; your code here
         )
      -
      Callback on-windowenter -
      -
      Callback on-windowleave -
      +
      Callback on-windowenter +
      +
      Callback on-windowleave +

      These two callbacks do not take any arguments, for example:

      -
      (defun on-windowenter ()
      +
      (defun on-windowenter ()
         ;; your code here
         )
      -

      Window Related

      -
      Variable *calm-window* -
      +

      Window Related

      +
      Variable *calm-window* +

      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+)
      -
      Variable *calm-window-x* -
      -
      Variable *calm-window-y* -
      +(sdl2-ffi.functions:sdl-set-window-always-on-top + *calm-window* + sdl2-ffi:+true+)
      +
      Variable *calm-window-x* +
      +
      Variable *calm-window-y* +

      The initial position (x, y) of your CALM application window.

      Default: :centered

      -
      Variable *calm-window-flags* -
      +
      Variable *calm-window-flags* +

      A list of SDL_WindowFlags.

      You could set this value like: (setf *calm-window-flags* '(:shown :allow-highdpi :resizable))

      Default: '(:shown :allow-highdpi)

      -
      Variable *calm-window-width* -
      -
      Variable *calm-window-height* -
      -
      Variable *calm-window-title* -
      +
      Variable *calm-window-width* +
      +
      Variable *calm-window-height* +
      +
      Variable *calm-window-title* +

      You know what these variables do.

      If you don't, give me 5 bucks and think harder.

      -

      Tutorials

      +

      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

        +

        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 @@
    1. ソース
    2. -

      -Calm C A L M

      -

      CI GitHub all releases Discord

      +

      +Calm C A L M

      +

      Canvas Aided Lisp Magic: Lisp でキャンバスベースのアプリケーションを作成し、Linux、macOS、Windows、Web 上で配布できます。

      English | 日本語

      -

      Hello, World!

      +

      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

      Hello World

      -

      +

      - Fan - Mondrian - Meditator + Fan + Mondrian + Meditator

      -

      上記の例のソースファイルとバイナリはこちらこちらです。

      +

      上記の例のソースファイルとバイナリはこちらこちらです。

      CALM で作られた他のアプリケーションについては、Made with CALM をご覧ください。

      -

      -Calm Installer インストール

      -

      ビルド済みバイナリ

      +

      +Calm Installer インストール

      +

      ビルド済みバイナリ

      1. ダウンロード

        -

        Linux Download macOS Ventura Download Windows Download macOS Monterey Download macOS Big Sur Download

        +

      2. 解凍

        @@ -816,11 +816,11 @@

      Windows SmartScreen よりもスマートであるか、macOS を飼いならす事ができる必要があります。万が一何かあったときのために、ここにインストールガイドがあります。

      -

      ソースからの実行

      +

      ソースからの実行

      現在、サポートされているプラットフォームは GitHub Actions runner images によって制限されています。

      もしあなたのプラットフォームがサポートされていない場合は、ソースから実行を使ってください。

      -

      -Calm Application 配布

      +

      +Calm Application 配布

      ターミナルを起動し、canvas.lisp ファイルが存在するディレクトリに cd し、次のコマンドを入力する:

      calm publish

      このコマンドは、プラットフォームによって異なるパッケージを生成する:

      @@ -846,19 +846,19 @@

      がなければ、これで winget もインストールされます。

      バイナリ検出は where makensiswhere winget によって行われています。

      -

      Web へ

      +

      Web へ

      calm publish-web

      このコマンドを実行すると、Lisp コードをコンパイルして Web ページを作成することができます。

      詳しくはコマンドリファレンスを参照してください。

      -

      CALM - リファレンス

      +

      CALM - リファレンス

      CALM 1.0.0 から、バージョン番号は Semantic Versioning Specification に従います。これは、私がおかしくなることを心配することなく、落ち着いて CALM を使えることを意味します。というのも、私がおかしくなりそうなときはいつでも、何かが変更される前にお知らせしますし、何か驚かせるようなことがあったらメジャーバージョンを上げます。

      Keep CALM and have fun.

      -

      コマンドリファレンス

      -

      calm

      +

      コマンドリファレンス

      +

      calm

      このコマンドはプロジェクトのディレクトリ内で実行する必要があり、canvas.lisp というファイルが存在するはずです。

      このコマンドは canvas.lisp をロードし、関数 draw または draw-forever の指示に従ってウィンドウを表示します。canvas.lisp は普通の Lisp ソースファイルなので、好きなように記述してください。

      CALM 関連の関数やパラメータについては、API リファレンスを参照してください。

      -

      calm hello

      +

      calm hello

      このコマンドは、デフォルトのディレクトリ構造でサンプルアプリケーションを作成します。最初にプロジェクトディレクトリを作成する必要があります:

      mkdir my-cool-app
       cd my-cool-app
      @@ -872,7 +872,7 @@ 

      を参照してください。

      -

      calm publish

      +

      calm publish

      このコマンドは以下を生成します:

      http://127.0.0.1:8000/calm.html を開きます。

      注: デフォルトでは fontsassets ディレクトリ内のファイルはパック されません 。以下の REBUILD_WASM_P オプションを確認してください。

      -

      calm publish-web-with-options

      +

      calm publish-web-with-options

      このコマンドは calm publish-web 用であることを除けば、calm publish-with-options のように動作します。

      @@ -985,58 +985,58 @@

      API リファレンス

      +

      API リファレンス

      CALM は、SDL2Cairo、その他のものの上の薄いレイヤーになることを意図しています。なので、CALM が提供する API の数はできるだけ少なくなるように意図しています。

      -

      基礎

      -
      ファイル canvas.lisp -
      +

      基礎

      +
      ファイル canvas.lisp +

      これは CALM アプリケーションのエントリーファイルです。通常、draw という関数が含まれています。

      -
      関数 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-forever +

      この関数は draw 関数と同様に、CALM アプリケーションのエントリーポイントとしても機能します。drawdraw-forever の両方を定義することは、John Wick の犬を殺してしまうような深刻な結果をもたらすので、避けることが重要です。

      この関数はユーザーの操作に関係なく、*calm-delay* ミリ秒ごとに呼び出されます。

      -
      変数 *calm-delay* -
      +
      変数 *calm-delay* +

      この変数は、CALM がキャンバスをリフレッシュする前に何ミリ秒待つかをコントロールします

      デフォルト: 42

      この変数はデスクトッププラットフォームでのみ機能します。ウェブプラットフォームでは *calm-fps* をチェックしてください。

      -
      変数 *calm-redraw* -
      +
      変数 *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-fps* +

      この変数は CALM がキャンバスを更新する前に何ミリ秒待つかを制御します。0 を設定すると、ブラウザの requestAnimationFrame メカニズムを使用してキャンバスを更新します。

      デフォルト: 42

      この変数はウェブ上でのみ動作します。デスクトッププラットフォームでは *calm-delay* をチェックしてください。

      -

      キャンバスに描画

      +

      キャンバスに描画

      CALM での描画は、Cairo を使って実現できます。

      どのように描画するかについては、Cairo チュートリアルCairo API を読んでください。

      たとえば:

      @@ -1045,47 +1045,47 @@

      cl-cairo2 によってエクスポートされる シンボルはすべて、c: のような接頭辞でアクセスできるようにすべきです、例えば: c:arc 。ウェブ上では、アクセス可能なシンボルは cairo.lisp によって制限されています。

      Cairo は CALM の主要な描画機能ですので、Cairo 関連のシンボルの変更は CALM 自体の変更とみなされます。安心してお使いください。

      -
      関数 c:rrectangle -
      +
      関数 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))
      +
      関数 c:show-png +

      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:select-font-family +

      この関数はc:show-textで使用するフォントを選択します。

      -
      (c:select-font-family "Open Sans" :normal :normal)
      +
      (c:select-font-family "Open Sans" :normal :normal)

      次の 3 つの引数を取ります: familyslantweight です。詳細な例については、c:show-text を参照して下さい。

      カスタムフォントをインストールせずに使用するには、canvas.lispファイルからの相対パスで、fontsディレクトリに置くだけです。

      -
      関数 c:show-text -
      +
      関数 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"))
      +
      関数 c:show-markup +

      この関数は 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-markupc:show-text では座標系が若干異なるので、c:show-markupc:show-text を切り替える場合には少し位置を調整する必要があるかもしれないです。

      この関数は以下の理由によりウェブには公開されていません:

        @@ -1094,177 +1094,177 @@
        サウンドの再生
        -
        関数 c:play-wav -
        +

        サウンドの再生

        +
        関数 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* -
        +
        変数 *calm-audio-numchans* +

        同時に再生される wav ファイルの最大数です。

        デフォルト: 8

        -
        関数 c:volume-wav -
        +
        関数 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 +

        あるチャンネル、あるいはすべてのチャンネルを停止します。

        -
        (c:halt-wav :channel -1)
        +
        (c:halt-wav :channel -1)

        :channel を -1 に設定すると、すべてのチャンネルを意味します。

        -
        関数 c:play-music -
        +
        関数 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:volume-music +

        c:play-music の音量を設定します。

        -
        (c:volume-music 128)
        +
        (c:volume-music 128)

        値は 0 (無音)から 128 の間でなければなりません。

        -
        関数 c:halt-music -
        +
        関数 c:halt-music +

        音楽の再生を停止します。

        -
        関数 c:play-audio -
        +
        関数 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 +

        特定のオーディオファイルまたはすべてのオーディオファイルの再生を停止します。

        -
        (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* -
        +

        内部の状態

        +
        変数 *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 -
        +
        関数 c:get-ticks +

        これは単なる SDL_GetTicks です。

        -

        イベントのコールバック

        +

        イベントのコールバック

        これらのコールバックは、あなたが定義すべき関数です。定義しておけば、対応するイベントがトリガーされたときに呼び出されます。

        -
        コールバック on-keydown -
        -
        コールバック on-keyup -
        +
        コールバック on-keydown +
        +
        コールバック on-keyup +

        あなたはこれらのコールバックが何をするのか知っているが、知らないのは、その本来あるべき引数でしょう。詳しい例については c:keq を確認して下さい。

        -
        関数 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)
        +
        コールバック on-mousewheel +
        +
        (defun on-mousewheel (x y direction)
           ;; コードをここに
           )
        -
        コールバック on-mousemotion -
        -
        (defun internal-on-mousemotion (&key x y)
        +
        コールバック on-mousemotion +
        +
        (defun internal-on-mousemotion (&key x y)
           ;; コードをここに
           )
        -
        コールバック on-mousebuttonup -
        -
        コールバック on-mousebuttondown -
        -
        (defun on-mousebuttonup (&key button x y clicks)
        +
        コールバック on-mousebuttonup +
        +
        コールバック on-mousebuttondown +
        +
        (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)
        +
        コールバック on-fingermotion +
        +
        (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)
        +
        コールバック on-fingerup +
        +
        コールバック on-fingerdown +
        +
        (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)
        +
        コールバック on-windowresized +
        +
        (defun on-windowresized (width height)
           ;; コードをここに
           )
        -
        コールバック on-windowenter -
        -
        コールバック on-windowleave -
        +
        コールバック on-windowenter +
        +
        コールバック on-windowleave +

        これら 2 つのコールバックは引数を取りません:

        -
        (defun on-windowenter ()
        +
        (defun on-windowenter ()
           ;; コードをここに
           )
        -

        ウィンドウ関連

        -
        変数 *calm-window* -
        +

        ウィンドウ関連

        +
        変数 *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-window-x* +
        +
        変数 *calm-window-y* +

        CALM アプリケーションのウィンドウの初期位置(x、y)。

        デフォルト: :centered

        -
        変数 *calm-window-flags* -
        +
        変数 *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* -
        +
        変数 *calm-window-width* +
        +
        変数 *calm-window-height* +
        +
        変数 *calm-window-title* +

        あなたはこれらの変数が何をするか知っているはずです。

        そうでないなら、5 ドルを私に渡して、そしてもっとよく考えて下さい。

        -

        チュートリアル

        +

        チュートリアル

        OKOK、これを書くよ、これを書くよ、ちょっと待ってて。

        待っている間、以下の便利なリンクをチェックできますよ:

          @@ -1302,7 +1302,7 @@

          ライセンス

          +

          ライセンス

          ソースコードは GPL-2.0-only でリリースされています。