Aardio - 旋转图片

admin2022-01-02  81

原图:

旋转30度后的效果:

代码:

import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio form";right=316;bottom=294)
winform.add(
plus={cls="plus";left=4;top=4;right=302;bottom=277;bgcolor=32768;forecolor=32768;z=1}
)
/*}}*/
 
winform.show();
 
import inet.http
var b1=gdip.bitmap("https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png")
 
var w=270
var h=129
var a=math.rad(30)
var cw = w*..math.cos(a) ..math.sin(a)*h
var ch = w*..math.sin(a) ..math.cos(a)*h
winform.plus.width=cw
winform.plus.height=ch
 
var xpay = (w-cw)/2
var ypay = (h-ch)/2
 
var b = ..gdip.bitmap(cw,ch)
var g = ..gdip.graphics(b)
g.rotateRect(::RECT(0,0,cw,ch),30)
 
g.fillRectangle(..gdip.solidBrush(0xFFFFFFFF),-xpay,-ypay,w,h)
g.drawImageStretch(b1,::RECT(-xpay,-ypay,w-xpay,h-ypay))
 
winform.plus.foreground=b
winform.plus.update()
 
win.loopMessage();


弄个完整的小功能:

 

import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio form";right=919;bottom=609)
winform.add(
plus={cls="plus";left=366;top=69;right=664;bottom=342;bgcolor=16777215;z=1};
trackbar={cls="trackbar";left=58;top=195;right=269;bottom=225;max=180;min=0;z=2}
)
/*}}*/
 
import inet.http
var b1=gdip.bitmap("https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png")
 
var u=function(v){
    var w=270
    var h=129
    var a=math.rad(math.abs(v))
    var cw = w*..math.cos(a) ..math.sin(a)*h
    var ch = w*..math.sin(a) ..math.cos(a)*h
    winform.plus.width=cw
    winform.plus.height=ch
    var xpay = (w-cw)/2
    var ypay = (h-ch)/2
    var b = ..gdip.bitmap(cw,ch)
    var g = ..gdip.graphics(b)
    g.rotateRect(::RECT(0,0,cw,ch),v)
    g.drawImageStretch(b1,::RECT(-xpay,-ypay,w-xpay,h-ypay))
     winform.plus.foreground=b
    winform.plus.redrawTransparent()
}
 
winform.trackbar.oncommand = function(id,event,pos){
    if( event == 5 ){
        u(pos-90);
    }
}
 
winform.show();
win.loopMessage();

————————————————
版权声明:本文为CSDN博主「卢光庆」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/sdlgq/article/details/122213899

转载请注明原文地址: http://www.aardio.net/read-282.html
最新回复(0)
aardio问答
aardio编程语言