【HSP】ペイントソフトみたいにベジェ曲線を描きまくるプログラム【サンプル】
【HSP】ペイントソフトみたいにベジェ曲線を描きまくるプログラム【サンプル】
#module "beziers_m"
#include "gdi32.as"
#deffunc beziers int x1,int y1,int x2, int y2, int x3 ,int y3,int x4,int y4,int size
dim pt,2,3
CreatePen 0,size,(ginfo_r)+(ginfo_g<<8)+(ginfo_b<<16)
hpen=stat
if(hpen=0) : end
SelectObject hdc,hpen
hobj=stat
if(hobj=0) : DeleteObject hpen : end
MoveToEx hdc,x1,y1,0
pt(0,0)=x2,y2
pt(0,1)=x3,y3
pt(0,2)=x4,y4
PolyBezierTo hdc,varptr(pt),3
DeleteObject hpen
return
#globaloncmd gosub *click_down,0x0201
oncmd gosub *click_up,0x0202
#define size 10 // 曲線の太さ設定dim click_ing_flag
repeat
redraw 0
gosub *click_ing
color 0,128,255
boxf
color
line x2,y2,x1,y1
line x3,y3
line x4,y4
line (x2+x3)/2,(y2+y3)/2,(x1+x2)/2,(y1+y2)/2
line (x3+x4)/2,(y3+y4)/2
line (x2+x3+x3+x4)/4,(y2+y3+y3+y4)/4,(x1+x2+x2+x3)/4,(y1+y2+y2+y3)/4
color 255,255, // 曲線の色設定
Beziers x1,y1,x2,y2,x3,y3,x4,y4,size
redraw
await 15
loop*click_down
if(click_ing_flag=0) {
click_ing_flag=1
x1=lparam&0xFFFF
y1=lparam>>16
x2=lparam&0xFFFF
y2=lparam>>16
}
if(click_ing_flag=2) {
click_ing_flag=3
}
if(click_ing_flag=4) {
click_ing_flag=5
}
return
*click_ing
if(click_ing_flag=1) {
x4=mousex
y4=mousey
x3=mousex
y3=mousey
}
if(click_ing_flag=3) {
x2=mousex
y2=mousey
x3=mousex
y3=mousey
}
if(click_ing_flag=5) {
x3=mousex
y3=mousey
}
return
*click_up
if(click_ing_flag=1) {
x4=lparam&0xFFFF
y4=lparam>>16
x3=lparam&0xFFFF
y3=lparam>>16
click_ing_flag=2
}
if(click_ing_flag=3) {
x2=lparam&0xFFFF
y2=lparam>>16
x3=lparam&0xFFFF
y3=lparam>>16
click_ing_flag=4
}
if(click_ing_flag=5) {
x3=lparam&0xFFFF
y3=lparam>>16
click_ing_flag=0
}
return