GDI+ standard library 1.45 by tic

Post your working scripts, libraries and tools
Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
GitHub: cocobelgica

Re: GDI+ standard library 1.45 by tic

23 Apr 2015, 13:03

guest3456 wrote:actually, you can thank AHK syntax choices for confusing you about this.
I think GeekDude is implying (in response to tic's statement that b := new A() ; where 'A' is an instance still works) that the fact that an object deriving from another object can become a prototype itself should be attributed to prototype-based OOP - which I think is correct since that is how prototyping works. If so, it has nothing to do with syntax in this context since a := {}, b := new a, c := new b, d := new c kind of sums up prototype-based OOP and is a generally normal syntax of stating that a new object is being created and that it is deriving from another object. Unless you're talking about the choice to store class objects in a normal variable as the "confusing" part... Well a class declaration in AHK is simply: var myClass = { "myMethod": function() { . . . } } in Javascript.
guest3456 wrote:but if a user somehow does MyClass := "" will this class be released and no mechanism to start it back up?
If MyClass contains the only reference to an object, then there's no way to retrieve it. If one removes the "__Class" key you can see it being released via __Delete defined in a base object:

Code: Select all

A := "" ; release
return

class A extends B {
	static ClassName := ObjDelete(A, "__Class") ; remove '__Class' key to allow trigger of __Delete
}

class B {
	__Delete() {
		MsgBox RELEASED
	}
}
guest3456
Posts: 2774
Joined: 09 Oct 2013, 10:31

Re: GDI+ standard library 1.45 by tic

23 Apr 2015, 14:36

Coco wrote:Unless you're talking about the choice to store class objects in a normal variable as the "confusing" part...
you'll have to ask tic why he got confused. my guess is that he didn't already know that by writing class Gdip he already had created an object that was stored in a super global variable named Gdip. that is what both you and GeekDude tried to enlighten him on.

the confusing part is using "class" syntax keywords at all in a prototype based language, leading to tic's, and probably many other's, confusion. its normal to think that no instances exist prior to using new, but thats not exactly the case. the only reason i'm aware of that is because i read the discussion years ago on the other forum when Lexikos was determining whether or not he should introduce "class" syntax and how it may be translated. as well as learning about prototype based OOP at that same time
GeekDude wrote:As usually Coco, your example perplexes me. I am not really sure what's going on there
one special difference of objects defined with the "class" keyword is that a hidden key named "__Class" is present, with its value being the string of the name of the class. apparently one of the voodoo items is that deleting that key allows the object to be fully released somehow
Last edited by guest3456 on 23 Apr 2015, 14:42, edited 1 time in total.

GeekDude
Posts: 853
Joined: 02 Oct 2013, 22:13

Re: GDI+ standard library 1.45 by tic

23 Apr 2015, 14:41

We're getting quite a bit off track here, I think. @tic: Do you have a beta version of the class based gdip library? I'd like to give it a try.
tic
Posts: 92
Joined: 03 Nov 2014, 03:10

Re: GDI+ standard library 1.45 by tic

23 Apr 2015, 16:57

GeekDude wrote:We're getting quite a bit off track here, I think. @tic: Do you have a beta version of the class based gdip library? I'd like to give it a try.

Yep! Very early on and still lots to change and add.
Most of the content of this test will have to be refactored, but nonetheless you can test it if you like.
Download the library and the test:

https://github.com/tariqporter/Gdip/tree/GdipDOM

Excerpt from test:

Code: Select all

#Persistent
#SingleInstance Force

#include Gdip2.ahk

gdip := new Gdip()
win1 := new gdip.Window({ "width":400, "height":400 })
css := { "width":200, "height": 200, "background-color":{A:100, R:20, G:40, B:200}, "border-radius":0, "border-width":20, "border-color":{A:200, R:50, G:150, B:130} }
win1.shapeInsert("#square1.square-class", new gdip.Shape(css))
css.x := 200
win1.shapeInsert("#square2.square-class", new gdip.Shape(css))
win1.Update({ x: (A_ScreenWidth - win1.width) / 2, y: (A_ScreenHeight - win1.height) / 2 })
win1.MainLoop("Update", 10, { tick: A_TickCount, time: 500 })
return

;#####################################################################################

Update(win, p)
{
	if (A_TickCount - p.tick > p.time)
	{
		p.tick := A_TickCount, p.on := !p.on
		css := { "border-color":{A:200, R:200, G:150, B:30}, "border-width":50 }
		win.shapeMatch(p.on ? "#square1" : "#square2").css(css)
		css := { "border-color":{A:200, R:50, G:150, B:130}, "border-width":20 }
		win.shapeMatch(p.on ? "#square2" : "#square1").css(css)
		win.shapeMatch(".square-class").css(p.on ? { "border-radius": 10 } : { "border-radius": 0 })
	}
}

;#####################################################################################

Esc::
ExitApp
return
Guest

Re: GDI+ standard library 1.45 by tic

26 Apr 2015, 11:57

I'm curious, why doesn't the functionality of GDI+ just get coded standard commands in AHK that everyone can easily use?
tic
Posts: 92
Joined: 03 Nov 2014, 03:10

Re: GDI+ standard library 1.45 by tic

27 Apr 2015, 18:53

Guest wrote:I'm curious, why doesn't the functionality of GDI+ just get coded standard commands in AHK that everyone can easily use?
In the old ahk, I think it would have been difficult to have any code be easy to understand and implement without the use of objects. In current ahk, the old Gdip library could be implemented fairly easily, but I'm implementing a large overhaul of the library currently.
tic
Posts: 92
Joined: 03 Nov 2014, 03:10

Re: GDI+ standard library 1.45 by tic

27 Apr 2015, 18:54

Hi

Please could I get feedback of the current state of the Gdip2 library.
Run test 1 and 2:

https://github.com/tariqporter/Gdip/tree/GdipDOM

There is still a lot more to do, but it would be useful to have feedback before progressing

Thanks
GeekDude
Posts: 853
Joined: 02 Oct 2013, 22:13

Re: GDI+ standard library 1.45 by tic

27 Apr 2015, 18:56

Any reason you don't ever join the live chat? It'd make for quick feedback

Edit: The scripts open, I see some squares, then the script immediately crashes with an "AutoHotkey is not responding" window. AHK 1.1.21.03 unicode 32 bit
tic
Posts: 92
Joined: 03 Nov 2014, 03:10

Re: GDI+ standard library 1.45 by tic

27 Apr 2015, 23:16

GeekDude wrote:Any reason you don't ever join the live chat? It'd make for quick feedback

Edit: The scripts open, I see some squares, then the script immediately crashes with an "AutoHotkey is not responding" window. AHK 1.1.21.03 unicode 32 bit
No, you're right, I should. I usually need to concentrate on one thing and can work a long time if I have no distractions.

Strange. I had been having that error, and was to do with Gdip.Timer class. I believe it was because the callback was disposed after it had been called, so had an invalid reference. I thought I had fixed this however, and have it working on 3 different machines. They were running 64-bit 1.1.19.3, but I changed to 32-bit 1.1.21.03 and they are still functioning. Try commenting out line 2016 and 2026

Code: Select all

timers.Remove(v.reference)
DllCall("GlobalFree", "ptr", timer.callBack)
And see if it functions. You can press Esc to escape as the memory should keep growing (Very slowly)
tic
Posts: 92
Joined: 03 Nov 2014, 03:10

Re: GDI+ standard library 1.45 by tic

28 Apr 2015, 14:59

GeekDude wrote:Still crashes immediately
All working now. Thanks for testing GeekDude
If others could please test, it would be appreciated
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: GDI+ standard library 1.45 by tic

28 Apr 2015, 15:22

All three seem to work. (U32 1.1.21.03)
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: GDI+ standard library 1.45 by tic

28 Apr 2015, 15:27

Just tried it with A32 1.1.21.03, I'm not seeing the text in the third test.
tic
Posts: 92
Joined: 03 Nov 2014, 03:10

Re: GDI+ standard library 1.45 by tic

28 Apr 2015, 15:29

kon wrote:Just tried it with A32 1.1.21.03, I'm not seeing the text in the third test.
Thank you for testing kon. I am however dropping ANSI support. It greatly simplifies things to have unicode only going forward
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: GDI+ standard library 1.45 by tic

28 Apr 2015, 15:35

lol, ok I guess I missed that. Thanks.
User avatar
bichlepa
Posts: 159
Joined: 15 Aug 2014, 06:44
GitHub: bichlepa
Contact:

Re: GDI+ standard library 1.45 by tic

25 Jun 2015, 09:10

Hi tic.
I'm using GDI+ for AutoHotFlow.

It works fine, but there is one little issue. The picture is flickering when it is often rendered. The effect is most frequent if the computer is slow. The flickering happens when calling the SetImage() function. Is it possible to avoid flickering?
You may take a look at my script where I use GDI+.
Scripting is too complicated? Try AutoHotFlow, the graphical automation tool! Written in AutoHotkey.
User avatar
jNizM
Posts: 2530
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: GDI+ standard library 1.45 by tic

25 Jun 2015, 09:27

Hey bichlepa.
Can you test the function directly without the lib?

Code: Select all

; Msg => STM_SETIMAGE := 0x0172    |    wParam => IMAGE_BITMAP := 0    |    lParam => hBitmap
hObject := DllCall("user32.dll\SendMessage", "Ptr", hWnd, "UInt", 0x0172, "Ptr", 0, "Ptr", hBitmap, "Ptr")
DllCall("gdi32.dll\DeleteObject", "UPtr", hObject)


/*
SetImage(hwnd, hBitmap)
{
    SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hwnd%
    E := ErrorLevel
    DeleteObject(E)
    return E
}
*/
ps: Ich bin ehrlich gesagt kein Fan von solchen "Riesen" Lib's. Wenn ich was in gdip brauche schreibe ich mir die DllCall's direkt ins Programm und lade mir keine lib mit gefühlten 1000 Funktionen von denen ich 90% nicht mal brauche.
[AHK] 1.1.30.03 x64 Unicode | [WIN] 10 Pro (Version 1909) x64 | [GitHub] Profile
Donations are appreciated if I could help you
tic
Posts: 92
Joined: 03 Nov 2014, 03:10

Re: GDI+ standard library 1.45 by tic

25 Jun 2015, 10:17

bichlepa

That is happening because SetImage is not really meant for rendering a state machine. it is meant for rendering a persistent image.
You will need to call BitBlt with an image created in the way it is created for the gui examples, and BitBlt it in a timer. i can show you an example if you have problems. I demonstrated it in an asteroids example on the old forum.

jNizM

The problem is with WM_PAINT still being called. This won't help. It is not a problem with the library
User avatar
bichlepa
Posts: 159
Joined: 15 Aug 2014, 06:44
GitHub: bichlepa
Contact:

Re: GDI+ standard library 1.45 by tic

25 Jun 2015, 12:21

@ tic
Many thanks! I found your asteroids example and copied all the needed code. Now there is no flickering anymore and the performance is highly increased! :thumbup:

@ jNizM
Also, ich bin ein großer Fan von solchen Libs. Auch wenn man fast nie alles braucht, so wäre es doch für mich erheblich mehr Aufwand, die benutzen Funktionen zu implementieren. Ich habe dank dieser Lib erst erfahren, dass es sowas wie GDI gibt.
Scripting is too complicated? Try AutoHotFlow, the graphical automation tool! Written in AutoHotkey.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: wineguy and 77 guests