mieki256's diary



2021/04/30(金) [n年前の日記]

#2 [basic] FreeBASICのグラフィックスライブラリを試用

ググっていたら、FreeBASIC にもグラフィックスライブラリ・描画機能があることを知った。

_さらにFreeBASIC | PIC AVR 工作室 ブログ

であれば、それら機能を試しに使ってみようかなと。環境は Windows10 x64 20H2 + FreeBASIC 1.07.3 (2021-04-10) 32bit。

_gdemo.bas
dim as integer x, y, radius, w, h, i, cnt, r, g, b
dim s as string

w = 512
h = 512
screenres w, h, 32
randomize

cls

cnt = 256
for i=0 to cnt
  x = rnd * w
  y = rnd * h
  radius = (w / 3) * i / cnt
  r = rnd * 255
  g = rnd * 255
  b = rnd * 255
  circle (x, y), radius, RGBA(r, g, b, 32)
next i

color RGB(255, 255, 255)
locate 4, 1
input "input any word : ", s
print "input text is ... " + s
print "push any key"

sleep

fbc gdemo.bas で、gdemo.exe を生成。gdemo.exe を実行。描画ウインドウ内に円をたくさん書いた後、文字列の入力待ちになる。入力した文字列を描画して、キー入力待ちになる。

freebasic_gdemo_ss.png

各命令について補足。
ということで、今回色々触ってみたBASICの中で、線だの何だのを描画できるモノとなると、以下のような感じになるのだろうか…。

以上です。

過去ログ表示

Prev - 2021/04 - Next
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30

カテゴリで表示

検索機能は Namazu for hns で提供されています。(詳細指定/ヘルプ


注意: 現在使用の日記自動生成システムは Version 2.19.6 です。
公開されている日記自動生成システムは Version 2.19.5 です。

Powered by hns-2.19.6, HyperNikkiSystem Project