canvas_addHitRegion question

Discuss problems and solutions.
Post Reply
Phil999
Regular
Posts: 919
Joined: 11 Jan 2012 01:53

canvas_addHitRegion question

Post by Phil999 »

I try to understand how canvas_addHitRegion(c, path, id) works. In the attachment I have two examples of this command. One is working, but it has no path. The other one is not working (red script) and has a path.

- what is the name of the path if one is present (other than the default path)?
- what is the identifier?

In the Hexapads example the path is set to 0, but the identifier to a mathematical expression. Can somebody shed some light on this matter? I'm completely in the dark.

What I want is very simple: a custom button with transparent corners. What I can do is to use the brown canvas as background and put the transparent canvas on top of it, problem solved. But I prefer to understand how the hit region works, and integrate it into one Canvas object.
hitRegion.jzml
(2.92 KiB) Downloaded 55 times
Edit: alright, I found (rather by accident) a solution. When I put the HitRegion-line (still with 0 for path and id) into the 'draw' script I can do things inside the 'touch' script. It works. In the Hexapads template the id is declared (decl ...) before the HitRegion-line. Maybe one has to declare the identifier for a HitRegion? Yeah I admit I haven't quite understood how it works, but at least I've made a little step further with that problem solved.

Edit2: oh no, in the "touch"-script I was referencing "c" which was not declared (in that script). Of course the script will be in red. Silly mistake, sorry about that. Although obsolete now I don't delete this thread because there might be someone who can give me more insight into the nature of using the hit region, or I may add some tips later when I found them out.
Formant+Eurorack, PPG wave 2.2, Korg MS-20, etc., EWI 4000s, QuNeo, etc., Mixbus32c, u-he, MadronaLabs, Samplemodeling, NI, etc., iPad2/4/Pro
Macciza
Regular
Posts: 1315
Joined: 07 Dec 2011 04:57
Location: Sydney, Australia.

Re: canvas_addHitRegion question

Post by Macciza »

Have you gone through the examples in the CanvasLearningPackage? They may help...

Path is often 0 in loops because it is referring to Path just made...
ID has to vary if you want the paths individually identified ...
The various OnCursor functions return the ID in the hit variable ...

Hope that helps
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: canvas_addHitRegion question

Post by Softcore »

Not sure why you need hit regions for a single button....I guess you would need them though for multiple buttons designed with one canvas.....

here is how far I've went (without hit regions)......

colors and radius of corners (r) are set with custom expressions so that you can easily change them. Midi output is named "out"
Attachments
CanvasSwitch2.jzml
(3.14 KiB) Downloaded 55 times
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: canvas_addHitRegion question

Post by Softcore »

And here is the Pad version (push button, momentary button)
Attachments
CanvasPad2.jzml
(3.39 KiB) Downloaded 57 times
Post Reply