<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Работа с GDI+. Линия диаметра круга без остатка]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=10726&amp;type=atom" />
	<updated>2015-07-01T21:46:58Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=10726</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Работа с GDI+. Линия диаметра круга без остатка]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=94852#p94852" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Ну и немного баловства</p></blockquote></div><p>Интересный пример.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2015-07-01T21:46:58Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=94852#p94852</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Работа с GDI+. Линия диаметра круга без остатка]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=94794#p94794" />
			<content type="html"><![CDATA[<p>Первый вариант:<br /></p><div class="codebox"><pre><code>#Include gdip.ahk
Width := Height := 402
GuiX := (A_ScreenWidth-Width)//2
GuiY := (A_ScreenHeight-Height)//2
Radius := 200  ; радиус круга

BackColor := 0xE69900CC  ; цвет круга
CircumferenceColor := 0xff000000  ; цвет окружности
CircumferenceThickness := 2  ; толщина окружности

DiameterColor := 0xff000000   ; цвет диаметра
DiameterThickness := 1  ; толщина диаметра
DiameterAngle := 68  ; угол наклона

oGraph := new Graphics(GuiX, GuiY, Width, Height)
oGraph.DrawCircle(BackColor, 201, 201, Radius)  ; 201, 201 — x и y центра круга
oGraph.DrawCircumference(CircumferenceColor, CircumferenceThickness, 201, 201, Radius - CircumferenceThickness/2)
oGraph.DrawDiameter(DiameterColor, DiameterThickness, 201, 201, Radius, DiameterAngle)
oGraph := &quot;&quot;
Return

Esc:: ExitApp

class Graphics
{
   __New(GuiX, GuiY, Width, Height)  {
      static WS_EX_LAYERED := 0x80000, WS_EX_TRANSPARENT := 0x20
      
      Pi := 4*(4*ATan(1/5) - ATan(1/239))
      this.Gr := Pi/180
      this.Width := Width
      this.Height := Height
      
      this.pToken := Gdip_Startup()
      Gui, Graphics:Default
      Gui, % &quot;-Caption +E&quot; WS_EX_LAYERED &quot; +ToolWindow +AlwaysOnTop +hwndhGui -DPIScale&quot;
      this.hGui := hGui
      Gui, Show, NA x%GuiX% y%GuiY% w%Width% h%Height%
      
      this.GraphicObjects := []
      this.CreateNewGraphicObj(Width, Height)
   }
   
   __Delete()  {
      this.GraphicObjects := &quot;&quot;
      Gdip_Shutdown(this.pToken)
   }
   
   __Get(key)  {
      if RegExMatch(key, &quot;i)(G|hdc)(\d+)&quot;, match)
         Return this.GraphicObjects[match2][match1]
   }
   
   CreateNewGraphicObj(Width, Height)  {
      GrObj := new this.NewGraphicObj(Width, Height)
      Return this.GraphicObjects.Push(GrObj)
   }
   
   DrawCircle(color, CX, CY, R)  {
      pBrush := Gdip_BrushCreateSolid(color)
      Gdip_FillEllipse(this.G1, pBrush, CX - R, CY - R, 2*R, 2*R)
      Gdip_DeleteBrush(pBrush)
      UpdateLayeredWindow(this.hGui, this.hdc1)
   }
   
   DrawCircumference(color, thickness, CX, CY, R)  {
      pPen := Gdip_CreatePen(color, thickness)
      Gdip_DrawEllipse(this.G1, pPen, CX - R, CY - R, 2*R, 2*R)
      Gdip_DeletePen(pPen)
      UpdateLayeredWindow(this.hGui, this.hdc1)
   }
   
   DrawDiameter(color, thickness, CX, CY, R, angle)  {
      Gr := this.Gr
      x1 := Cos(angle*Gr)*R + CX
      y1 := Sin(angle*Gr)*R + CY
      x2 := Cos((angle + 180)*Gr)*R + CX
      y2 := Sin((angle + 180)*Gr)*R + CY
      pPen := Gdip_CreatePen(color, thickness)
      Gdip_DrawLine(this.G1, pPen, x1, y1, x2, y2)
      Gdip_DeletePen(pPen)
      UpdateLayeredWindow(this.hGui, this.hdc1)
   }
   
   class NewGraphicObj
   {
      __New(Width, Height)  {
         this.hbm := CreateDIBSection(Width, Height)
         this.hdc := CreateCompatibleDC()
         this.obm := SelectObject(this.hdc, this.hbm)
         this.G := Gdip_GraphicsFromHDC(this.hdc)
         Gdip_SetSmoothingMode(this.G, 4)
      }
      
      __Delete()  {
         SelectObject(this.hdc, this.obm), DeleteObject(this.hbm)
         DeleteDC(this.hdc), Gdip_DeleteGraphics(this.G)
      }
   }
}</code></pre></div><p>Второй по аналогии:<br /></p><div class="codebox"><pre><code>#Include gdip.ahk
Width := Height := 402
GuiX := (A_ScreenWidth-Width)//2
GuiY := (A_ScreenHeight-Height)//2
Radius := 200  ; радиус круга

BackColor := 0xE69900CC  ; цвет круга
CircumferenceColor := 0xff000000  ; цвет окружности

oGraph := new Graphics(GuiX, GuiY, Width, Height)
oGraph.DrawCircle(BackColor, 201, 201, Radius)  ; 201, 201 — x и y центра круга
oGraph.DrawCircumference(CircumferenceColor, 2, 201, 201, Radius - 1)
oGraph.DrawCircumference(CircumferenceColor, 1, 201, 201, Radius/3)

angle := -135  ; угол наклона первого радиуса
Loop 3
   oGraph.DrawRadiusBetweenCircles(0xff000000, 1, 201, 201, Radius - 1, Radius/3, angle + 45 * (A_Index - 1))
Graphics := &quot;&quot;
Return

class Graphics
{
   __New(GuiX, GuiY, Width, Height)  {
      static WS_EX_LAYERED := 0x80000, WS_EX_TRANSPARENT := 0x20
      
      Pi := 4*(4*ATan(1/5) - ATan(1/239))
      this.Gr := Pi/180
      this.Width := Width
      this.Height := Height
      
      this.pToken := Gdip_Startup()
      Gui, Graphics:Default
      Gui, % &quot;-Caption +E&quot; WS_EX_LAYERED &quot; +ToolWindow +AlwaysOnTop +hwndhGui -DPIScale&quot;
      this.hGui := hGui
      Gui, Show, NA x%GuiX% y%GuiY% w%Width% h%Height%
      
      this.GraphicObjects := []
      this.CreateNewGraphicObj(Width, Height)
   }
   
   __Delete()  {
      this.GraphicObjects := &quot;&quot;
      Gdip_Shutdown(this.pToken)
   }
   
   __Get(key)  {
      if RegExMatch(key, &quot;i)(G|hdc)(\d+)&quot;, match)
         Return this.GraphicObjects[match2][match1]
   }
   
   CreateNewGraphicObj(Width, Height)  {
      GrObj := new this.NewGraphicObj(Width, Height)
      Return this.GraphicObjects.Push(GrObj)
   }
   
   DrawCircle(color, CX, CY, R)  {
      pBrush := Gdip_BrushCreateSolid(color)
      Gdip_FillEllipse(this.G1, pBrush, CX - R, CY - R, 2*R, 2*R)
      Gdip_DeleteBrush(pBrush)
      UpdateLayeredWindow(this.hGui, this.hdc1)
   }
   
   DrawCircumference(color, thickness, CX, CY, R)  {
      pPen := Gdip_CreatePen(color, thickness)
      Gdip_DrawEllipse(this.G1, pPen, CX - R, CY - R, 2*R, 2*R)
      Gdip_DeletePen(pPen)
      UpdateLayeredWindow(this.hGui, this.hdc1)
   }
   
   DrawRadiusBetweenCircles(color, thickness, CX, CY, R1, R2, angle)  {
      Gr := this.Gr
      x1 := Cos(angle*Gr)*R1 + CX
      y1 := Sin(angle*Gr)*R1 + CY
      x2 := Cos(angle*Gr)*R2 + CX
      y2 := Sin(angle*Gr)*R2 + CY
      pPen := Gdip_CreatePen(color, thickness)
      Gdip_DrawLine(this.G1, pPen, x1, y1, x2, y2)
      Gdip_DeletePen(pPen)
      UpdateLayeredWindow(this.hGui, this.hdc1)
   }
   
   class NewGraphicObj
   {
      __New(Width, Height)  {
         this.hbm := CreateDIBSection(Width, Height)
         this.hdc := CreateCompatibleDC()
         this.obm := SelectObject(this.hdc, this.hbm)
         this.G := Gdip_GraphicsFromHDC(this.hdc)
         Gdip_SetSmoothingMode(this.G, 4)
      }
      
      __Delete()  {
         SelectObject(this.hdc, this.obm), DeleteObject(this.hbm)
         DeleteDC(this.hdc), Gdip_DeleteGraphics(this.G)
      }
   }
}</code></pre></div><div class="quotebox"><blockquote><p>можно ли сделать заливку определенного куска не вырисовывая отдельную часть нужного цвета?</p></blockquote></div><p>Gdip_FillPolygon()<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Ну и немного баловства</div><div class="fancy_spoiler"><div class="codebox"><pre><code>SetBatchLines, -1
SetWinDelay, 0
global WS_EX_LAYERED := 0x80000, WS_EX_TRANSPARENT := 0x20
#Include gdip.ahk  ; закомментировать, если не нужно

Width := Height := 404
GuiX := (A_ScreenWidth-Width)//2
GuiY := (A_ScreenHeight-Height)//2
R1 := 195, R2 := 130
CX := 202, CY := 202
StartAngle := -90
PenColor := 0xFFFEBA4C
BackColor := 0xCA0000AA

oGraph := new Graphics(GuiX, GuiY, Width, Height)
OnExit, Exit
oGraph.DrawCircle(PenColor, 8, CX, CY, R1, StartAngle, 1500, 1)
Sleep, 200
oGraph.DrawCircle(PenColor, 8, CX, CY, R2, StartAngle, 1500, 1)
Sleep, 200
oGraph.DrawCircle(BackColor, t := (R1 - 4) - (R2 + 4), CX, CY, (R1 - 4) - t/2, StartAngle, 1500, 1)
Sleep, 200

oGraph.DrawRays(PenColor, 2, CX, CY, R1 - 2, R2 + 2, StartAngle, 32, 300, 2)
oGraph.Rotation(PenColor, 2, CX, CY, R1 - 2, R2 + 2, StartAngle, 32, 1000, 12)
Return

Esc:: ExitApp
Exit:
   oGraph.GraphicObjects := &quot;&quot;
   (oGraph.Period &amp;&amp; DllCall(&quot;Winmm\timeEndPeriod&quot;, UInt, oGraph.MinPeriod))
   oGraph := &quot;&quot;
   ExitApp

class Graphics
{
   __New(GuiX, GuiY, Width, Height)  {
      VarSetCapacity(TIMECAPS, 8, 0)
      if DllCall(&quot;Winmm\timeGetDevCaps&quot;, Ptr, &amp;TIMECAPS, UInt, 8) != 0  {
         MsgBox, Ошибка в timeGetDevCaps()
         ExitApp
      }
      this.MinPeriod := NumGet(TIMECAPS, &quot;UInt&quot;)
      
      Pi := 4*(4*ATan(1/5) - ATan(1/239))
      this.Gr := Pi/180
      this.Width := Width
      this.Height := Height
      
      this.pToken := Gdip_Startup()
      Gui, Graphics:Default
      Gui, % &quot;-Caption +E&quot; WS_EX_LAYERED|WS_EX_TRANSPARENT &quot; +ToolWindow +AlwaysOnTop +hwndhGui -DPIScale&quot;
      this.hGui := hGui
      Gui, Show, NA x%GuiX% y%GuiY% w%Width% h%Height%
      
      this.GraphicObjects := []
      this.CreateNewGraphicObj(Width, Height)
   }
   
   __Delete()  {
      this.GraphicObjects := &quot;&quot;
      Gdip_Shutdown(this.pToken)
      (this.Period &amp;&amp; DllCall(&quot;Winmm\timeEndPeriod&quot;, UInt, this.MinPeriod))
   }
   
   __Get(key)  {
      if RegExMatch(key, &quot;i)(G|hdc)(\d+)&quot;, match)
         Return this.GraphicObjects[match2][match1]
   }
   
   CreateNewGraphicObj(Width, Height)  {
      GrObj := new this.NewGraphicObj(Width, Height)
      Return this.GraphicObjects.Push(GrObj)
   }
   
   SnapShot()  {
      n := this.CreateNewGraphicObj(this.Width, this.Height)
      BitBlt(this[&quot;hdc&quot; n], 0, 0, this.Width, this.Height, this.hdc1, 0, 0)
      Return n
   }
   
   DrawCircle(color, thickness, CX, CY, R, StartAngle, Frequency, Duration)  {
      key := this.SnapShot()
      Grads := 0
      
      pPen := Gdip_CreatePen(color, thickness)
      DllCall(&quot;Winmm\timeBeginPeriod&quot;, UInt, this.MinPeriod), this.Period := 1
      Loop % Frequency  {
         Gdip_GraphicsClear(this.G1)
         BitBlt(this.hdc1, 0, 0, this.Width, this.Height, this[&quot;hdc&quot; key], 0, 0)
         Gdip_DrawArc(this.G1, pPen, CX - R, CY - R, 2*R, 2*R, StartAngle, Grads += 360/Frequency)
         UpdateLayeredWindow(this.hGui, this.hdc1)
         DllCall(&quot;Sleep&quot;, UInt, Duration)
      }
      DllCall(&quot;Winmm\timeEndPeriod&quot;, UInt, this.MinPeriod), this.Period := &quot;&quot;
      Gdip_DeletePen(pPen)
      this.GraphicObjects.Pop()
   }
   
   DrawRays(color, thickness, CX, CY, R1, R2, StartAngle, Num, Frequency, Duration)  {
      R := R1
      Gr := this.Gr
      key := this.SnapShot()
      
      pPen := Gdip_CreatePen(color, thickness)
      DllCall(&quot;Winmm\timeBeginPeriod&quot;, UInt, this.MinPeriod), this.Period := 1
      Loop % Frequency  {
         R -= (R1 - R2)/Frequency
         Gdip_GraphicsClear(this.G1)
         BitBlt(this.hdc1, 0, 0, this.Width, this.Height, this[&quot;hdc&quot; key], 0, 0)
         
         Loop % Num  {
            Grads := StartAngle + 360/Num * (A_Index - 1)
            x1 := Cos(Grads*Gr)*R1 + CX
            y1 := Sin(Grads*Gr)*R1 + CY
            x2 := Cos(Grads*Gr)*R + CX
            y2 := Sin(Grads*Gr)*R + CY
            
            Gdip_DrawLine(this.G1, pPen, x1, y1, x2, y2)
         }
         UpdateLayeredWindow(this.hGui, this.hdc1)
         DllCall(&quot;Sleep&quot;, UInt, Duration)
      }
      DllCall(&quot;Winmm\timeEndPeriod&quot;, UInt, this.MinPeriod), this.Period := &quot;&quot;
      Gdip_DeletePen(pPen)
   }

   Rotation(color, thickness, CX, CY, R1, R2, StartAngle, Num, Frequency, Duration)  {
      Gr := this.Gr
      shift := 0
      
      pPen := Gdip_CreatePen(color, thickness)
      DllCall(&quot;Winmm\timeBeginPeriod&quot;, UInt, this.MinPeriod), this.Period := 1
      Loop
      {
         Gdip_GraphicsClear(this.G1)
         BitBlt(this.hdc1, 0, 0, this.Width, this.Height, this[&quot;hdc&quot; this.GraphicObjects.MaxIndex()], 0, 0)
         shift += 360/Frequency
         (shift &gt;= 360 &amp;&amp; shift := 0)
         Loop % Num
         {
            Grads := StartAngle + 360/Num * (A_Index - 1)
            x1 := Cos(Grads*Gr)*R1 + CX
            y1 := Sin(Grads*Gr)*R1 + CY
            x2 := Cos((Grads + shift)*Gr)*R2 + CX
            y2 := Sin((Grads + shift)*Gr)*R2 + CY
            
            Gdip_DrawLine(this.G1, pPen, x1, y1, x2, y2)
         }
         UpdateLayeredWindow(this.hGui, this.hdc1)
         DllCall(&quot;Sleep&quot;, UInt, Duration)
      }
      DllCall(&quot;Winmm\timeEndPeriod&quot;, UInt, this.MinPeriod), this.Period := &quot;&quot;
      Gdip_DeletePen(pPen)
   }

   class NewGraphicObj
   {
      __New(Width, Height)  {
         this.hbm := CreateDIBSection(Width, Height)
         this.hdc := CreateCompatibleDC()
         this.obm := SelectObject(this.hdc, this.hbm)
         this.G := Gdip_GraphicsFromHDC(this.hdc)
         Gdip_SetSmoothingMode(this.G, 4)
      }
      
      __Delete()  {
         SelectObject(this.hdc, this.obm), DeleteObject(this.hbm)
         DeleteDC(this.hdc), Gdip_DeleteGraphics(this.G)
      }
   }
}</code></pre></div></div></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2015-06-28T22:34:59Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=94794#p94794</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Работа с GDI+. Линия диаметра круга без остатка]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=94741#p94741" />
			<content type="html"><![CDATA[<div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;скрипт</div><div class="fancy_spoiler"><div class="codebox"><pre><code>#NoEnv
#SingleInstance FORCE
SetWinDelay,0
SetBatchLines,-1
#Include gdip.ahk    ;https://www.dropbox.com/s/0e9gdfetbfa8v0o/Gdip_All.ahk?dl=1

Global XPos,YPos,layer1,layer2

; запуск gdi+. ширина\длина,
Gdip_Startup()    ,    Width := Height := 400

; Первый слой
Gui, 1: -Caption +E0x80000 +LastFound +OwnDialogs +HWNDlayer1 ;+ToolWindow
Gui, 1: Show,

; отслеживание сообщений.
OnMessage(0x201, &quot;WM_LBUTTONDOWN&quot;) ; нажатие левой кнопки мыши для переноса

;Сообщения
WM_LBUTTONDOWN()
{    
    PostMessage, 0xA1, 2
}

; увеличить рамки картинки под радиус разворота, и развернуть
Angle := 23
Gdip_GetRotatedDimensions(Width, Height, Angle, RWidth, RHeight)
Gdip_GetRotatedTranslation(Width, Height, Angle, xTranslation, yTranslation)



;первый слой
hbm := CreateDIBSection(RWidth, RHeight)     ,    hdc := CreateCompatibleDC()    ,    obm := SelectObject(hdc, hbm)    ,    G := Gdip_GraphicsFromHDC(hdc)    , Gdip_SetInterpolationMode(G, 7)
;Gdip_TranslateWorldTransform(G, xTranslation, yTranslation)
;Gdip_RotateWorldTransform(G, Angle)

Gdip_SetSmoothingMode(G, 5) ; сглаживание на 5

;первый слой
; рисуем основной круг 
pBrush := Gdip_BrushCreateSolid(0xe69900CC) , Gdip_FillEllipse(G, pBrush, 0, 0, Width, Height) , Gdip_DeleteBrush(pBrush)

;разметка
pPen := Gdip_CreatePen(0xfff000000, 1)
;Gdip_DrawLines(G, pPen    , 0 &quot;,&quot; 0 &quot;|&quot; Width &quot;,&quot; Height ) 
cut := Round(Width*0.1464), cut2 := Round((Width//6)*0.1464)

;Gdip_DrawLines(G, pPen    , cut &quot;,&quot; cut &quot;|&quot; Width - cut &quot;,&quot; Height - cut ) ;       \
;Gdip_DrawLines(G, pPen    , cut &quot;,&quot; Height - cut &quot;|&quot; Width - cut &quot;,&quot; cut) ;     /

;Gdip_DrawLines(G, pPen    , 0 &quot;,&quot; Height//2 &quot;|&quot; Width &quot;,&quot; Height//2) ;         ―
;Gdip_DrawLines(G, pPen    , Width//2 &quot;,&quot; 0 &quot;|&quot; Width//2 &quot;,&quot; Height) ;             |


Gdip_DrawLines(G, pPen    , Width//2 - cut + cut2  &quot;,&quot; Height//2 - cut + cut2 &quot;|&quot; cut &quot;,&quot; cut )

Gdip_DrawLines(G, pPen    , Width//2 + cut - cut2  &quot;,&quot; Height//2 - cut + cut2 &quot;|&quot; Width - cut &quot;,&quot; cut)

Gdip_DrawLines(G, pPen    , Width//2  &quot;,&quot; Height//2 - cut - cut2 &quot;|&quot; Width//2 &quot;,&quot; 0)

Gdip_DrawEllipse(G, pPen, Width//3, Height//3, Width//3, Height//3)

Gdip_DeletePen(pPen) 

; обводка
pPen := Gdip_CreatePen(0xfff000000, 2) , Gdip_DrawEllipse(G, pPen, 0, 0, Width, Height) , Gdip_DeletePen(pPen) 


; показать нарисованное
UpdateLayeredWindow(layer1, hdc, (A_ScreenWidth-RWidth)//2, (A_ScreenHeight-RHeight)//2, RWidth, RHeight)
return</code></pre></div></div></div><p>Спасибо. теперь надо что бы линия доходила до внутреннего кольца<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><p><span class="postimg"><img src="http://i.imgur.com/pdfKVZ0.png" alt="http://i.imgur.com/pdfKVZ0.png" /></span></p></div></div><p>но не доходит.</p><p>п.с Простите меня за мои познания в геометрии. <img src="//forum.script-coding.com/img/smilies/big_smile.png" width="15" height="15" /></p><p>И еще можно ли сделать заливку определенного куска не вырисовывая отдельную часть нужного цвета?</p>]]></content>
			<author>
				<name><![CDATA[yalanne]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=32850</uri>
			</author>
			<updated>2015-06-25T08:33:21Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=94741#p94741</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Работа с GDI+. Линия диаметра круга без остатка]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=94732#p94732" />
			<content type="html"><![CDATA[<p>Чтобы нарисовать круг и линию, никакие повороты и обрезки изображения точно не нужны. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2015-06-24T22:42:18Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=94732#p94732</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Работа с GDI+. Линия диаметра круга без остатка]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=94728#p94728" />
			<content type="html"><![CDATA[<p>Строка №45:<br /></p><div class="codebox"><pre><code>cut := Round(Width*0.1464), Gdip_DrawLines(G, pPen    , cut &quot;,&quot; cut &quot;|&quot; Width - cut &quot;,&quot; Height - cut )</code></pre></div><p>Это для частного случая, если W&lt;&gt;H, то расчет будет сложней.</p>]]></content>
			<author>
				<name><![CDATA[Irbis]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27384</uri>
			</author>
			<updated>2015-06-24T22:18:20Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=94728#p94728</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Работа с GDI+. Линия диаметра круга без остатка]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=94727#p94727" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Эта линия рисуется от левого верхнего угла рабочей области до правого нижнего + разворот на 23 градуса</p></blockquote></div><p>Это так сложно вы объясняете, что линия должна быть под углом 68° к горизонтали?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2015-06-24T21:07:56Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=94727#p94727</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Работа с GDI+. Линия диаметра круга без остатка]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=94726#p94726" />
			<content type="html"><![CDATA[<div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;скрипт</div><div class="fancy_spoiler"><div class="codebox"><pre><code>#NoEnv
#SingleInstance FORCE
SetWinDelay,0
SetBatchLines,-1
#Include gdip.ahk    ;https://www.dropbox.com/s/0e9gdfetbfa8v0o/Gdip_All.ahk?dl=1

Global XPos,YPos,layer1,layer2

; запуск gdi+. ширина\длина,
Gdip_Startup()    ,    Width := Height := 400

; Первый слой
Gui, 1: -Caption +E0x80000 +LastFound +ToolWindow +OwnDialogs +HWNDlayer1
Gui, 1: Show,

; отслеживание сообщений.
OnMessage(0x201, &quot;WM_LBUTTONDOWN&quot;) ; нажатие левой кнопки мыши для переноса

;Сообщения
WM_LBUTTONDOWN()
{    
    PostMessage, 0xA1, 2
}

; увеличить рамки картинки под радиус разворота, и развернуть
Angle := 23
Gdip_GetRotatedDimensions(Width, Height, Angle, RWidth, RHeight)
Gdip_GetRotatedTranslation(Width, Height, Angle, xTranslation, yTranslation)



;первый слой
hbm := CreateDIBSection(RWidth, RHeight)     ,    hdc := CreateCompatibleDC()    ,    obm := SelectObject(hdc, hbm)    ,    G := Gdip_GraphicsFromHDC(hdc)    , Gdip_SetInterpolationMode(G, 7)
Gdip_TranslateWorldTransform(G, xTranslation, yTranslation)
Gdip_RotateWorldTransform(G, Angle)

Gdip_SetSmoothingMode(G, 5) ; сглаживание на 5

;первый слой
; рисуем основной круг 
pBrush := Gdip_BrushCreateSolid(0xe69900CC) , Gdip_FillEllipse(G, pBrush, 0, 0, Width, Height) , Gdip_DeleteBrush(pBrush)

;разметка
pPen := Gdip_CreatePen(0xfff000000, 1)
Gdip_DrawLines(G, pPen    , 0 &quot;,&quot; 0 &quot;|&quot; Width &quot;,&quot; Height ) 
Gdip_DeletePen(pPen) 

; обводка
pPen := Gdip_CreatePen(0xfff000000, 2) , Gdip_DrawEllipse(G, pPen, 0, 0, Width, Height) , Gdip_DeletePen(pPen) 


; показать нарисованное
UpdateLayeredWindow(layer1, hdc, (A_ScreenWidth-RWidth)//2, (A_ScreenHeight-RHeight)//2, RWidth, RHeight)
return

~1::
;убрать лишние линии которые зашли за границу
pPen := Gdip_CreatePen(0x00000000, 100) , Gdip_SetCompositingMode(G, 1) , Gdip_DrawEllipse(G, pPen, -50, -50, Width+100, Height+100) , Gdip_SetCompositingMode(G, 0) , Gdip_DeletePen(pPen)
; обводка
pPen := Gdip_CreatePen(0xfff000000, 2) , Gdip_DrawEllipse(G, pPen, 0, 0, Width, Height) , Gdip_DeletePen(pPen) 
UpdateLayeredWindow(layer1, hdc, (A_ScreenWidth-RWidth)//2, (A_ScreenHeight-RHeight)//2, RWidth, RHeight)
return</code></pre></div></div></div><p>Этот скрипт рисует круг, а на круге линию диаметра. Проблема в том что линия выходит за круг:<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><p><span class="postimg"><img src="http://i.imgur.com/pn0JTDQ.png" alt="http://i.imgur.com/pn0JTDQ.png" /></span></p></div></div><p>Приходится отдельно вырезать линии. На кнопку 1 отрезает лишнее.(можно и автоматом, просто для наглядности)<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><p><span class="postimg"><img src="http://i.imgur.com/gwL9mcA.png" alt="http://i.imgur.com/gwL9mcA.png" /></span></p></div></div><p>Эта линия рисуется от левого верхнего угла рабочей области до правого нижнего + разворот на 23 градуса<br />Задача: что бы линия сразу же на рисовалась нужного размера под круг, как это сделать?</p>]]></content>
			<author>
				<name><![CDATA[yalanne]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=32850</uri>
			</author>
			<updated>2015-06-24T20:15:53Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=94726#p94726</id>
		</entry>
</feed>
