Assign Hit Regions in a loop

Discuss Lemur and share techniques.
Post Reply
shanekoss
Newbie
Posts:26
Joined:27 Jun 2012 13:27
Assign Hit Regions in a loop

Post by shanekoss » 12 Apr 2014 19:33

HI - Using this script to create 8 squares and all works well except assigning a hit region for each one - am i missing a step?

thanks!

decl i,offy,offset;
canvas_clear(c);
for(i=0;i<8;i++){
if(i<4){
offy=0;
offset=0;
}
else{
offy=150;
offset=600;
}
canvas_setStrokeStyle(c, 0.5);
canvas_setLineWidth(c, 10);
canvas_setFillStyle(c, 1);
canvas_fillRect(c, i*150-offset, offy, 150, 150);
canvas_addHitRegion(c,0,i);
canvas_setStrokeStyle(c, border);
canvas_setLineWidth(c, 10);
canvas_strokeRect(c, i*150-offset,offy , 150, 150);
canvas_setTextAlign(c, 1);
canvas_setFontSize(c,18 );
canvas_setTextBaseline(c, 1);
canvas_setFillStyle(c, {0,0,0});
canvas_fillText(c, 'Drummer'+(i+1), 75+i*150-offset, offy+75, 140);
}

Macciza
Regular
Posts:1325
Joined:07 Dec 2011 04:57
Location:Sydney, Australia.

Re: Assign Hit Regions in a loop

Post by Macciza » 14 Apr 2014 14:30

Hi
Try canvas_rect instead of canvas_fillRect - fillRect is a shortcut method I think and does not give you a Path it seems . .
And add a canvas_beginPath in there somewhere to make sure you get separate paths in the end . . .
HTH
MM
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]

Post Reply