// 角丸矩形描画モジュール
#include "a2d.hsp"
#module
// ------------------------------------------------------------ //
//
// 命 令 :角丸矩形の描画
//
// 引 数 :x, y : 矩形の左上座標
// w, h : 矩形のサイズ
// r : 角丸半径
//
// 返り値 :なし
//
// 機能説明:
// 引数で指定した位置・サイズの角丸矩形を描画します。
//
// この矩形は、塗りつぶしではなく線で枠を描画した図形です。
//
// ------------------------------------------------------------ //
// Rounded Rectangle
#deffunc DrawRoundRect int p_x, int p_y, int p_w, int p_h, int p_r
r = limit( p_r, 0, p_w/2)
alDrawLine p_x , p_y + r , p_x , p_y + p_h - r
alDrawLine p_x + r , p_y + p_h , p_x + p_w - r, p_y + p_h
alDrawLine p_x + p_w , p_y + p_h - r, p_x + p_w , p_y + r
alDrawLine p_x + p_w - r, p_y , p_x + r , p_y
alDrawArc p_x , p_y , r*2, r*2, 180, 90
alDrawArc p_x , p_y + p_h - r*2, r*2, r*2, 90, 90
alDrawArc p_x + p_w - r*2, p_y + p_h - r*2, r*2, r*2, 0, 90
alDrawArc p_x + p_w - r*2, p_y , r*2, r*2, 270, 90
return
// ------------------------------------------------------------ //
//
// 命 令 :塗りつぶし角丸矩形の描画
//
// 引 数 :x, y : 矩形の左上座標
// w, h : 矩形のサイズ
// r : 角丸半径
//
// 返り値 :なし
//
// 機能説明:
// 引数で指定した位置・サイズの角丸矩形を描画します。
//
// ------------------------------------------------------------ //
// Rounded Rectangle
#deffunc FillRoundRect int p_x, int p_y, int p_w, int p_h, int p_r
r = limit( p_r, 0, p_w/2)
alFillRect p_x , p_y + r , r, p_h - p_r*2
alFillRect p_x + r , p_y + p_h - p_r, p_w - r*2, r
alFillRect p_x + p_w - r , p_y + r , r, p_h - p_r*2
alFillRect p_x + r , p_y , p_w - r*2, r
alFillRect p_x + r , p_y + r , p_w - r*2, p_h - p_r*2
alFillPie p_x , p_y , r*2, r*2, 180, 90
alFillPie p_x , p_y + p_h - r*2, r*2, r*2, 90, 90
alFillPie p_x + p_w - r*2, p_y + p_h - r*2, r*2, r*2, 0, 90
alFillPie p_x + p_w - r*2, p_y , r*2, r*2, 270, 90
return
#global
; 仮想イメージ 0 を作成
alCreateImage 0, 640, 480
if stat = -1 : dialog "GDI+ を初期化できませんでした。" : end
alPenWidth 3
// 背景
alColor 255, 200,200
r = 10
repeat ginfo_winx*2 /r
alDrawLine cnt * r, 0, 0, cnt * r
loop
// 半透明フィルタ
alColor 0, 0, 255, 127
// 角丸
DrawRoundRect 0, 0, 120, 120, 20
// 角丸塗りつぶし
FillRoundRect 0, 150, 120, 120, 20
// グラデーションブラシ
alGradientColor 150, 0, 150+120, 120, RGBA(255, 0, 0), RGBA(0, 0, 255)
DrawRoundRect 150, 0, 120, 120, 30
alGradientColor 150, 150, 150+120, 150+120, RGBA(255, 0, 0), RGBA(0, 0, 255)
FillRoundRect 150, 150, 120, 120, 30
// 半透明グラデーションブラシ
alGradientColor 300, 0, 300+120, 120, RGBA(0, 255, 0, 255), RGBA(0, 255, 0, 0)
DrawRoundRect 300, 0, 120, 120, 40
alGradientColor 300, 150, 300+120, 150+120, RGBA(0, 255, 0, 255), RGBA(0, 255, 0, 0)
FillRoundRect 300, 150, 120, 120, 40
; 仮想イメージ 0 から HSP スクリーンにコピー
alCopyImageToScreen 0, 0
redraw