2009年1月31日土曜日

文字列を延々と歪ませる

文字列(&画像&線)を延々と歪ませる ソースコードをこしらえました。
x'=x , y'=1/(e^(x)+e^(-x))+y という式を使って あとは、行列を使って回転移動させたりしただけです。




#module
#uselib "gdi32.dll"
#func GetTextExtentPoint32 "GetTextExtentPoint32A" int,int,int,int
#deffunc messize var tBuf,array tSize
notesel tBuf
repeat notemax
noteget tBuf2,cnt
tBuf3=tBuf2
txtLen=strlen(tBuf3)
dim tSize,2
GetTextExtentPoint32 hdc,varptr(tBuf3),txtLen,varptr(tSize)
if cnt=0:x=tSize(0)
if x<tSize(0):x=tSize(0)
loop
tSize(0)=x
tSize(1)=tSize(1)*notemax
return
#global

#include "hspmath.as"
#define ctype stogx(%1) (( (%1)-offsetx )*(bai)+ginfo_winx/2)
#define ctype stogy(%1) (((%1)-offsety )*(-1.0)*(bai)+ginfo_winy/2)
#define e 2.718281828459045235360287471352
#define pi 3.1415926535897932384626433832795028841971
bai=1.0 //表示倍率
offsetx=0 //表示中心 X
offsety=0 //表示中心 Y
randomize
title "文字列を延々と歪ませる"
onexit *exit
goto *sake
*exit
end
*sake

screen 3

dialog "",16,""
picload refstr,1
skx=-320.0
sky=-240.0
smx=320.0
smy=240.0

color 255,128,128

repeat
x+=30
line x,-1,x,ginfo_winy
if x>ginfo_winx:break
loop

repeat
y+=30
line -1,y,ginfo_winx,y
if y>ginfo_winy:break
loop


font "",30

buf=""

repeat 8
f=rnd(2)
buf+=strf("%c",f*(rnd(26)+65)+(f!1)*(rnd(26)+97))
loop
messize Buf,textSize

pos stogx(-textSize(0)/2),stogy(-textSize(1)/2)
color 0,0,0
mes buf

gsel 0,1


repeat

x_=skx
y_=sky

ox=1.0*rnd(300)-150
sx=1.0*rnd(60)+5
bx=1.0*rnd(100)+5
rad=1.0*rnd(360)*pi/180

repeat
x__=x_*cos(rad)-y_*sin(rad)
y__=x_*sin(rad)+y_*cos(rad)
x=x__*cos(rad)+(1.0/(pow(e,(x__-ox)/sx)+pow(e,-(x__-ox)/sx))*bx+y__)*sin(rad)
y=-x__*sin(rad)+(1.0/(pow(e,(x__-ox)/sx)+pow(e,-(x__-ox)/sx))*bx+y__)*cos(rad)

gsel 3
pget stogx(x),stogy(y)
r=ginfo_r
g=ginfo_g
b=ginfo_b

gsel 0
color r,g,b
pset stogx(x_),stogy(y_)

x_+
if x_>=smx:x_=skx:y_+:if y_>=smy:y_=sky:break

wait 0
loop
gsel 3
gmode 0,640,480,0
pos 0,0
gcopy 0,0,0,640,480

loop

0 件のコメント: