绿色风's Blog
专注AutoIT(Au3)
  • 首页
  • 流●年
  • 笔●记
    • 学习随记
    • 源码示例
  • 脚●本
    • UDF(收集)
    • 工作室UDF
    • 工具●教程
    • 教程之GDI
  • 作●品
  • 下●载
  • 情怀ExcelTip
10月192015

AU3两圆切示例

作者:绿色风   发布:2015-10-19 11:51 Monday   分类:   阅读:4746次   评论:0条  

QQ截图20151019194247.png

```#include <GUIConstantsEx.au3> #include <GDIPLus.au3> #include <WinAPI.au3> #include <ScreenCapture.au3> Global $gui, $pic, $circ1x, $circ1y, $circ1r, $s4, $s5, $circ2r, $msg $gui = GUICreate("圆 测试", 800, 600) $pic = GUICtrlCreatePic("", 0, 0, 600, 600) GUICtrlCreateLabel("圆 1 x", 630, 35) $circ1x = GUICtrlCreateSlider(600, 50, 200, 50) GUICtrlSetLimit(-1, 600, 10) GUICtrlSetData(-1, 400) GUICtrlCreateLabel("圆 1 y", 630, 135) $circ1y = GUICtrlCreateSlider(600, 150, 200, 50) GUICtrlSetLimit(-1, 600, 10) GUICtrlSetData(-1, 300) GUICtrlCreateLabel("圆 1 半径", 630, 235) $circ1r = GUICtrlCreateSlider(600, 250, 200, 50) GUICtrlSetLimit(-1, 300, 10) GUICtrlSetData(-1, 75) GUICtrlCreateLabel("圆 2 x", 630, 335) $circ2x = GUICtrlCreateSlider(600, 350, 200, 50) GUICtrlSetLimit(-1, 600, 10) GUICtrlSetData(-1, 300) GUICtrlCreateLabel("圆 2 y", 630, 435) $circ2y = GUICtrlCreateSlider(600, 450, 200, 50) GUICtrlSetLimit(-1, 600, 10) GUICtrlSetData(-1, 200) GUICtrlCreateLabel("圆 2 半径", 630, 535) $circ2r = GUICtrlCreateSlider(600, 550, 200, 50) GUICtrlSetLimit(-1, 300, 10) GUICtrlSetData(-1, 175) GUISetState() test($pic, 400, 300, 75, 300, 200, 175) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $circ1x, $circ1y, $circ1r, $circ2x, $circ2y, $circ2r refresh() EndSwitch WEnd Func refresh() consolewrite("blarb" & @crlf) Local $c1x, $c1y, $c1r, $c2x, $c2y, $c2r $c1x = GUICtrlRead($circ1x) $c1y = GUICtrlRead($circ1y) $c1r = GUICtrlRead($circ1r) $c2x = GUICtrlRead($circ2x) $c2y = GUICtrlRead($circ2y) $c2r = GUICtrlRead($circ2r) $image = test($pic, $c1x, $c1y, $c1r, $c2x, $c2y, $c2r) return $image EndFunc Func test($ctrl, $circ1x, $circ1y, $circ1r, $circ2x, $circ2y, $circ2r) Local $hBmp, $hPen, $hBitmap1, $hGraphic, $hBitmap2, $OldBmp, $one, $two $hBmp = _WinAPI_CreateBitmap(600, 600, 1, 32) _GDIPlus_Startup() $hPen = _GDIPlus_PenCreate(0xFFFFFFFF) ;~ ConsoleWrite("0x" & Hex(200 / $lines + 55,2) & "FFFFFF" & @crlf) $hBitmap1 = _GDIPlus_BitmapCreateFromHBITMAP($hBmp) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap1) _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 4) _GDIPlus_GraphicsDrawEllipse($hGraphic, $circ1x - ($circ1r), $circ1y - ($circ1r), $circ1r*2, $circ1r*2, $hPen) _GDIPlus_GraphicsDrawEllipse($hGraphic, $circ2x - ($circ2r), $circ2y - ($circ2r), $circ2r*2, $circ2r*2, $hPen) $var = intcircles($circ1x, $circ1y, $circ1r, $circ2x, $circ2y, $circ2r) _GDIPlus_GraphicsDrawEllipse($hGraphic,$var[0] - 5,$var[1] - 5,10,10,$hPen) _GDIPlus_GraphicsDrawEllipse($hGraphic,$var[2] - 5,$var[3] - 5,10,10,$hPen) $hBitmap2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap1) $oldbmp = GUICtrlSendMsg($ctrl, 0x0172, 0, $hBitmap2) If $OldBmp Then _WinAPI_DeleteObject($OldBmp) _WinAPI_DeleteObject($hBitmap2) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_BitmapDispose($hBitmap1) _GDIPlus_PenDispose($hPen) _GDIPlus_Shutdown() _WinAPI_DeleteObject($hBmp) EndFunc ;==>fracircle Func Angle($x1, $y1, $Ang, $Length, $round = 0) If $Ang >= 360 Then $Ang -= 360 Local $Return[2] $Return[0] = $x1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) $Return[1] = $y1 - ($Length * Sin($Ang / 180 * 3.14159265358979)) If $round = 1 Then $Return[0] = Round($Return[0]) $Return[1] = Round($Return[1]) EndIf Return $Return EndFunc ;==>Angle func intcircles($x0,$y0,$r1,$x1,$y1,$r2) Local $xp2, $yp2, $dx, $dy, $d Local $return[4] $dx = $x1 - $x0; $dy = $y1 - $y0; $d = sqrt(($x1 - $x0)^2 + ($y1 - $y0)^2) If ($d > ($r1 + $r2)) or ($d < ($r1 - $r2)) Then SetError(1);unsaluveable Return $return EndIf ;Determine the distance from point 0 to point 2. $a = ($r1^2 - $r2^2 + $d^2) / (2.0 * $d) ;Determine the coordinates of point 2. */ $x2 = $x0 + ($dx * $a/$d); $y2 = $y0 + ($dy * $a/$d); ;Determine the distance from point 2 to either of the intersection points. $h = sqrt(($r1*$r1) - ($a*$a)) ; Now determine the offsets of the intersection points from point 2. $rx = -$dy * ($h/$d); $ry = $dx * ($h/$d); ; Determine the absolute intersection points. ; $return[0] = ($x2 + $rx);+($d/2) $return[2] = ($x2 - $rx);+($d/2) $return[1] = ($y2 + $ry);-($d/2) $return[3] = ($y2 - $ry);-($d/2) ConsoleWrite("$a = " & $a & @crlf) ConsoleWrite("$d = " & $d & @crlf) ConsoleWrite("$dx = " & $dx & @crlf) ConsoleWrite("$dy = " & $dy & @crlf) ConsoleWrite("$return 1 = " & $return[0] & @crlf) ConsoleWrite("$return 2 = " & $return[1] & @crlf) ConsoleWrite("$return 3 = " & $return[2] & @crlf) ConsoleWrite("$return 4 = " & $return[3] & @crlf) return $return EndFunc ```





本文固定链接: http://www.jianyiit.com/post-143.html

blogger
该日志由 绿色风 于2015-10-19 11:51 Monday发表在 分类下。
版权所有:《绿色风's Blog》 → 《AU3两圆切示例》;
除特别标注,本博客很多文章均为原创. 互联分享,尊重版权,转载请以链接形式标明本文地址;
本文标签:

扫描二维码,在手机上阅读
上一篇::音量条频率
下一篇:分享紫色壁纸一张

热门文章

相关文章

  • pubmed 文献应助 抢单源码
  • 获取打开的IE窗口的句柄与TAB标题
  • 根据自定义公式自动画图的强大工具
  • Au3[规则验证码]自动识别,并输出程序
  • WMI方式 获取计算机的类型
取消回复

发表评论

亲,头像对么?

21 + 18 =

提交中,请稍候……


木有头像就木JJ啦!还木有头像吗?点这里申请属于你的个性Gravatar头像吧!


    站点统计
    • 运行时间: 20254 天
    • 日志总数: 365 篇
    • 评论数量: 7252 条
    • 微语数量: 6 条
    • 附件总量: 388 件
  • 逝出的青春

  • 打赏"绿色风"



      扫码关注本站公众号 可搜本站内容

  • Autoit V3 脚本交流群

      常驻群1:905774875
      常驻群2:40672266


  • 链接

    • AU3中文论坛
    • Excel资料库
    • 完美者博客
    • 顺网小哥'S Blog
    • 猛牛哥的博客
    • 网吧系统下载
  • 分类

    • 流●年(66)
    • 笔●记(0)
    • 脚●本(0)
    • 作品(21)
    • 学习随记(51)
    • 源码示例(68)
    • UDF(收集)(26)
    • 工作室UDF(30)
    • 工具●教程(62)
    • 教程之GDI(24)
Copyright © 2013 绿色风's Blog. Powered by emlog. Theme by 射雕天龙. 鄂ICP备2021011689号-1 鄂公网安备42102302000078号 sitemap