Limit to Canvas Script Size or Sub-Paths?

Discuss problems and solutions.
Post Reply
ToolsAndKeys
Newbie
Posts: 6
Joined: 22 Jul 2014 03:59

Limit to Canvas Script Size or Sub-Paths?

Post by ToolsAndKeys »

OK, i have been building my first Canvas script, and have ran into a bunch of flakey behavior. I'm trying to put together a complete 88 note keyboard, so have created a whole lot of repetitive Rectangle sub-paths. I'm just using a brute force method, trying to get to the 88 rectangles. However, I reached a point when I couldn't type any more without everything locking up - a single keystroke and the cursor jumps to either the beginning or the end of the file; I can scroll back to the point i was typing and type another single character, and again, the cursor jumps. It's like I've reached a maximum size of the script. I went in and removed extra carriage returns, and consolidated the file a bit, shortening comments for example, and then I could add some more rectangle sub-paths, but after adding a few more, I again hit the wall when everything locked up once again. Has anyone seen this behavior, or is there perhaps something basic I'm doing wrong to cause this, or a way to split things up to overcome this apparent limitation.

Thanks people!
Macciza
Regular
Posts: 1315
Joined: 07 Dec 2011 04:57
Location: Sydney, Australia.

Re: Limit to Canvas Script Size or Sub-Paths?

Post by Macciza »

Hi
Yes there is a limit to size but it is fairly large... But there are lots of ways to get around it with functions etc
There are also lots of gotchas that will affect how well the whole lot renders and runs . .
Perhaps you are starting out a bit ambitious, get some basic stuff under your belt first...
Go through the lemur canvas demos, check out general canvas tutorials etc

Lots of ways to optimise this sort of project, by not drawing every single key separately but by using logic . .
Key paths can be defined once then called as functions to draw themselves without having to type everything again
Not meaning to discourage you but learning a bit more first might make it all a bit easier . . .

Cheers
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]
ToolsAndKeys
Newbie
Posts: 6
Joined: 22 Jul 2014 03:59

Re: Limit to Canvas Script Size or Sub-Paths?

Post by ToolsAndKeys »

Thanks for the reply, and yes, there's no doubt I have a lot to learn. The project I'm envisioning would allow me to select keyboard split points and layers graphically, real time, where I'd have a graphic of my 88 note keyboard, and then drag to assign note groups to particular MIDI channels. So, the creation of an 88 note keyboard monitor object seemed like a very basic way to start my learning. After some basic setup which I picked up from reviewing the tutorials, I draw a "white key" rectangle, adjust the x position (X = X plus DeltaX), draw another white key via Canvas_Rect, etc; then go back and do the same for the "black key" rectangles. So it's surprising to me that I hit the limitation with this approach, which seems straightforward and efficient to me.

I think you're telling me to find a way to more efficiently define/draw 88 rectangles. So, could you expound a bit more on "key paths can be defined once then called as functions to draw themselves without having to type everything again" - or possibly suggest an example or tutorial that does what you're suggesting? Does the function I would define avoid repeatedly calling the Canvas_Rect function? Is the limit I'm hitting simply script length, or is calling the Canvas_Rect function repeatedly the cause of hitting the limitation?

Thanks very much!!

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

Re: Limit to Canvas Script Size or Sub-Paths?

Post by Macciza »

Hi
Without actually seeing your code its a bit hard to say exactly what the issue might be
88 rectangles can be drawn quite easily with a for loop in only a few lines of code,
Changing it to include some black keys does not add that much more
What can make a huge difference is when you actually stroke or fill things, rather then the path drawing
I have started posteing a bunch of canvas tips in the canvas section , see there for details...

Getting an idea of what you are after is the greatest help, sounds likes cool idea
If the keys are smaller so they fit on screen and don't need to play notes just do the mapping its a bit different
I'll see if I can have a look at it sometime soon
Cheers
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]
ToolsAndKeys
Newbie
Posts: 6
Joined: 22 Jul 2014 03:59

Re: Limit to Canvas Script Size or Sub-Paths?

Post by ToolsAndKeys »

OK, that helps a lot - I was just trying to understand whether the limit I was hitting was in objects being created, but it sounds like it's simply the total number of characters in the script. You've pointed me in the right direction, Thanks!
Post Reply