Grid Sample 0.1.0

このプログラムは画面上に方眼線を描画します。 これから色々作画しようと思っているのでその土台になる予定です。

実行結果

Small Basic オンラインで実行したスクリーンショットを以下に示します。 方眼線の間隔は 10 ピクセルです。方眼線はブラウザのサイズいっぱいに表示されます。 画面半分は TextWindow として使うこともあるので、実際に描画できそうなのは幅 600 ピクセル、高さ 400 ピクセルくらいでしょう。

ソース

GridSample.txt

Small Basic オンラインのために書いたものですが、Small Basic デスクトップや IE + Silverlight の環境でも実行できるようにしました。水色の行について以下で解説します。

' Grid Sample
' Version 0.1.0
' Copyright © 2020 Nonki Takahshi.  The MIT License.
' Last update 2020-08-21
' Program ID VWX240

DrawGrid()

Sub DrawGrid
    gw = GraphicsWindow.Width
    gh = GraphicsWindow.Height
    fn = GraphicsWindow.FontName
    If (fn = "Tahoma") Or (fn = "Segoe UI") Then
        c10 = "#99CCCCCC"
        c100 = "#99666666"
    Else    ' for SBO
        c10 = "#CCCCCC99"
        c100 = "#66666699"
    EndIf
    For x = 0 To gw Step 10
        If Math.Remainder(x, 100) = 0 Then
            GraphicsWindow.PenColor = c100
        Else
            GraphicsWindow.PenColor = c10
        EndIf
        GraphicsWindow.DrawLine(x, 0, x, gh)
    EndFor
    For y = 0 To gh Step 10
        If Math.Remainder(y, 100) = 0 Then
            GraphicsWindow.PenColor = c100
        Else
            GraphicsWindow.PenColor = c10
        EndIf
        GraphicsWindow.DrawLine(0, y, gw, y)
    EndFor
EndSub

Copyright © 2020 たかはしのんき. All rights reserved.