AutoHotkey Community

It is currently May 26th, 2012, 8:44 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 1000 posts ]  Go to page Previous  1 ... 14, 15, 16, 17, 18, 19, 20 ... 67  Next
Author Message
 Post subject:
PostPosted: August 27th, 2009, 12:46 pm 
Offline

Joined: April 30th, 2009, 12:35 pm
Posts: 29
@StevenSanders

You're going to have to try it yourself.



@leef_me

Concerning Keystoning:

see here

http://msdn.microsoft.com/en-us/library ... 85%29.aspx

Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx="", sy="", sw="", sh="", Matrix=1)

Concerning fading in and out:

see my post "Wed Aug 19, 2009 12:53 pm"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 27th, 2009, 6:23 pm 
Shouldn't this produce a 03D12F (r=3, g=209, b=47) output? ... or where am I working this wrong? I am very puzzled by this. Hopefully you can shine some light on this :D

Code:

myColMat = ("0|0|0|-1|1|3|209|47|0|0|3|209|47|0|0|3|209|47|0|0|3|209|47|0|0")



Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 27th, 2009, 7:30 pm 
Online

Joined: April 8th, 2009, 7:49 pm
Posts: 6065
Location: San Diego, California
mrr19121970 wrote:
@leef_me

Concerning fading in and out:

see my post "Wed Aug 19, 2009 12:53 pm"

Thank you for your response, concerning fading. I have it working :!: :) BTW, I found your post by date, we are in different timezones :wink:
I have two suggestions for your original post:

>>Change (blank) line 33 to (initially 50%):

Code:
Gui, 1: Add, Slider, x10 y+20 w300 Tooltip vTransparency Range1-100, 50


>>Change line 124 (correct typo):

Code:
Gdip_DrawImage(G, pBitmap, 0, 0, Width, Height, 0, 0, OriginalWidth, OriginalHeight, Transparency/100)


I'll still have to look at the Keystone link you gave.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 28th, 2009, 4:44 pm 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1833
Something to note when making things fade is that you should never have a continual sleep when looping:

Never do:

Code:
Transparency := 255
Loop, % Transparency/5
{
   Gdip_GraphicsClear(G)
   Gdip_DrawImage(G, pBitmap, 0, 0, dWidth, dHeight, 0, 0, sWidth, sHeight, Transparency)
   Transparency -= 5
   Sleep, 10
}


but instead you should do something like the following. It will fade out

Code:
TotalTime := 250
StartTime := A_TickCount
Loop
{
   Transparency := ((TimeElapsed := A_TickCount-StartTime) < TotalTime) ? 255*(1-(TimeElapsed/TotalTime)) : 0
   If (Transparency = 0)
   Break
   Gdip_GraphicsClear(G)
   Gdip_DrawImage(G, pBitmap, 0, 0, dWidth, dHeight, 0, 0, sWidth, sHeight, Transparency)
}


This is a much better method as it does not depend on the speed of the computer, but instead will always take the specified length of time to fade in/out. Just thought Id note it in case anyone does it the other way. It might need to be altered. I just typed it without testing...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 28th, 2009, 6:23 pm 
Online

Joined: April 8th, 2009, 7:49 pm
Posts: 6065
Location: San Diego, California
Hi tic,
Thanks for your suggestion. I haven't taken the time to try your code, but I think I understand your caution.

It's not that the 'sleep' would hurt the code, it's that it would annoy the person viewing the image. Instead of a smooth transition, they'd see:
dim, pause, dim, pause . ... of course 10 ms doesn't seem like a long delay.

BTW, I briefly looked at the suggestion mrr19121970 made for keystone
I'm not sure (maybe I should be quiet and find out :oops: ) if it will handle this shape http://en.wikipedia.org/wiki/Trapezoid

Thanks again for the library and functions.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 28th, 2009, 7:33 pm 
Actually, this is all I really need for a color 0-100 or - conversion in this matrix. It works great once you fine tune it such as with the example you posted, to apply the matrix need. :D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 31st, 2009, 2:12 pm 
Offline

Joined: April 30th, 2009, 12:35 pm
Posts: 29
to expand on TIC's post to make it into a working example...

Starting with Gdip.Tutorial.10-Rotate.Flip.or.Mirror.an.image.ahk

Comment out lines 124 & 130. After line 130 add the following code:

Code:
TotalTime := 5000
StartTime := A_TickCount
Loop
{
   Transparency := ((TimeElapsed := A_TickCount-StartTime) < TotalTime) ? 100*(1-(TimeElapsed/TotalTime)) : 0
   If (Transparency = 0)
      Break
   Gdip_GraphicsClear(G)
   Gdip_DrawImage(G, pBitmap, 0, 0, Width, Height, 0, 0, OriginalWidth, OriginalHeight, Transparency/100)
   UpdateLayeredWindow(hwnd2, hdc, (A_ScreenWidth-RWidth)//2, (A_ScreenHeight-RHeight)//2, RWidth, RHeight)
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 7th, 2009, 1:50 am 
Hi, I have seen some great basic examples how to draw with these libraries. They are great! I have had fun trying to draw things, ... and I am hoping to see an example of how to draw a wavie line?

This is kind of what I want, just a line that is wavie? :)

Image


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2009, 1:25 pm 
Offline

Joined: April 30th, 2009, 12:35 pm
Posts: 29
using Gdip.Tutorial.1-Draw.Shapes.ahk as a starting point. Replace the code:

Code:
; Create a fully opaque red brush (ARGB = Transparency, red, green, blue) to draw a circle
pBrush := Gdip_BrushCreateSolid(0xffff0000)

; Fill the graphics of the bitmap with an ellipse using the brush created
; Filling from coordinates (100,50) an ellipse of 200x300
Gdip_FillEllipse(G, pBrush, 100, 50, 200, 300)

; Delete the brush as it is no longer needed and wastes memory
Gdip_DeleteBrush(pBrush)

; Create a slightly transparent (66) blue brush (ARGB = Transparency, red, green, blue) to draw a rectangle
pBrush := Gdip_BrushCreateSolid(0x660000ff)

; Fill the graphics of the bitmap with a rectangle using the brush created
; Filling from coordinates (250,80) a rectangle of 300x200
Gdip_FillRectangle(G, pBrush, 250, 80, 300, 200)

; Delete the brush as it is no longer needed and wastes memory
Gdip_DeleteBrush(pBrush)


With

Code:
; Create a fully opaque red pen (ARGB = Transparency, red, green, blue)
pPen1 := Gdip_CreatePen(0xffff0000,3)

; Create a fully opaque green pen (ARGB = Transparency, red, green, blue)
pPen2 := Gdip_CreatePen(0xff00ff00,3)

; The length of the wavy line
WavyLen := 200

; The number of the waves (smaller=more, larger=less)
WavyX := 20

; The depth of the waves (smaller=flatter, larger=curved)
WavyY := 10

; The starting position
StartX := 10
StartY := 10
PrevX := StartX
PrevY := StartY

; Paint the Sine Wave
WavyIdx=0
Loop,%WavyLen%
{
   NewX := StartX + WavyIdx
   NewY := StartY + (Sin(WavyIdx/WavyX)*WavyY)
   Gdip_DrawLine(G, pPen1, PrevX, PrevY, NewX, NewY)
   PrevX := NewX
   PrevY := NewY
   WavyIdx++
}
Gdip_DrawLine(G, pPen2, StartX, StartY+(WavyY*2), StartX+WavyLen, StartY+(WavyY*2))

; Delete the pens as they are no longer needed and wastes memory
Gdip_DeletePen(pPen1)
Gdip_DeletePen(pPen2)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 9th, 2009, 5:28 pm 
This is neat & cool how easy the function is to configure! ~~ But - I noticed the sine-wave itself, with any Pen size over 1, had some impurities in it. The larger it is drawn, the more evident it is. Can that be fixed? I tried to run it twice, but overdrawing it does not help. :D :D Staci


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 9th, 2009, 7:01 pm 
Offline

Joined: April 30th, 2009, 12:35 pm
Posts: 29
There is always more than one way to skin a rabbit :D

Code:
; Pen Thickness
PenThickness := 50

; Create a fully opaque red pen (ARGB = Transparency, red, green, blue)
pPen1 := Gdip_CreatePen(0xffff0000,PenThickness)

; Create a fully opaque green pen (ARGB = Transparency, red, green, blue)
pPen2 := Gdip_CreatePen(0xff00ff00,1)

; The length of the wavy line
WavyLen := 1000

; The number of the waves (smaller=more, larger=less)
WavyX := 50

; The depth of the waves (smaller=flatter, larger=curved)
WavyY := 20

; The starting position
StartX := 10
StartY := 10
PrevX := StartX
PrevY := StartY

; Paint the Sine Wave
WavyIdx=0
Loop,%WavyLen%
{
   NewX := StartX + WavyIdx
   NewY := StartY + (Sin(WavyIdx/WavyX)*WavyY)
   Gdip_DrawLine(G, pPen1, PrevX, PrevY, NewX, NewY)
   PrevX := NewX
   PrevY := NewY
   WavyIdx++
}

; The starting position
StartX := 10
StartY := StartY + PenThickness

; Paint the Sine Wave
WavyIdx=0
Loop,%WavyLen%
{
   NewX := StartX + WavyIdx
   NewY := StartY + (Sin(WavyIdx/WavyX)*WavyY)
   Gdip_DrawLine(G, pPen2, NewX, NewY, NewX, NewY+PenThickness)
   WavyIdx++
}

; Delete the pens as they are no longer needed and wastes memory
Gdip_DeletePen(pPen1)
Gdip_DeletePen(pPen2)


Last edited by mrr19121970 on September 9th, 2009, 9:56 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 9th, 2009, 7:44 pm 
YOU ARE AWESOME


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 9th, 2009, 10:03 pm 
Offline

Joined: April 30th, 2009, 12:35 pm
Posts: 29
Similarly for vertical waves:
Code:
; Paint the Sine Wave
WavyIdx=0
Loop,%WavyLen%
{
   NewX := StartX + (Sin(WavyIdx/WavyX)*WavyY)
   NewY := StartY + WavyIdx
   Gdip_DrawLine(G, pPen2, NewX, NewY, NewX+PenThickness, NewY)
   WavyIdx++
}


I think you'd be best rotating if you wanted something slightly at an angle.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Question : How to erase
PostPosted: September 11th, 2009, 12:13 pm 
Offline

Joined: July 23rd, 2009, 5:15 pm
Posts: 4
Is it possible to 'erase' some part of what has been painted on the "LayeredWindow" ?

Based on Tutorial 2 it is possible to paint on LayeredWindow. Now I would like to have an 'eraser' to erase parts of what has been painted.

I try by painting over some "white", with more or less transparency, but, as expected, it paints white over the 'shapes'. This is not erasing and recovering the screen below the shapes.

If any one has some hints, many thanks.

Thanks to Tic's library and tutorial GDI usage is made easy and fun.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 11th, 2009, 1:31 pm 
Offline

Joined: April 30th, 2009, 12:35 pm
Posts: 29
Lexikos wrote:
mrr19121970, I think there are (at least) two ways to erase:
  • Gdip_GraphicsClear. To erase only part, set clipping with Gdip_SetClipRect.
  • Set overwrite mode with Gdip_SetCompositingMode, create a transparent brush with Gdip_BrushCreateSolid (passing an ARGB value with zero for the alpha component), then call Gdip_FillRectangle.


This was asked & answered 2 pages back.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1000 posts ]  Go to page Previous  1 ... 14, 15, 16, 17, 18, 19, 20 ... 67  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Blackholyman, RoAltmann and 11 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group