Any way to get vacant ID for insertLayer? (id = InsertLayer)

Find quick help here to get you started with Hollywood
Post Reply
Bugala
Posts: 1180
Joined: Sun Feb 14, 2010 7:11 pm

Any way to get vacant ID for insertLayer? (id = InsertLayer)

Post by Bugala »

Heres what I am trying to do:

Code: Select all

ID = InsertLayer(0, #BRUSH, 1, x, y)
SetObjectData(#LAYER, ID, "name", data)
However, InsertLayer doesnt return the ID number when creating it.

Is there any way to get this done this way, or do I have to keep track of next vacant Layer ID myself?
User avatar
airsoftsoftwair
Posts: 5446
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Any way to get vacant ID for insertLayer? (id = InsertLa

Post by airsoftsoftwair »

Layer IDs work differently than normal Hollywood object IDs. Layer IDs are always consecutively numbered from 1 to n. This ID also represents the layer's position in the stack of layers (1=backmost layer, n=frontmost layer) As per definition, passing 0 to InsertLayer() will insert the layer in the last position, but it won't return its ID, see here:
http://www.hollywood-mal.com/docs/html/ ... Layer.html

If you want to get the ID of the last layer, simply query #ATTRLAYERS on the bgpic or display. Thus, the question of a "vacant" layer ID doesn't make much sense. Choosing an ID for a layer depends on where you want your layer to appear.
Bugala
Posts: 1180
Joined: Sun Feb 14, 2010 7:11 pm

Re: Any way to get vacant ID for insertLayer? (id = InsertLa

Post by Bugala »

Ah, thanks. That should do in this case.

Anotehr Layer related question.

Say I have a 10 thousand layers, and only 30 of them are actually drawn to screen. How does Hollywood treat the rest 9970 Layers?

By other words, If screens size is 1980x1080, and i draw a layer to position 2500, 1600 (outside of screen), will Hollywood slow down when there are 10 thousand of these, or will it itself understand that there is no actual need to draw anything, and hence it will still stay somewhat fast.


Reason Why I am asking is that I am going to be making something that you can scroll into all dircetions, and since the size of a whole "map" (so to say) can easily be even 10 000 x 10 000, then I wonder do i need to make my own draw function which would only draw those layers that are actually seen on screen on that time, or can i simply keep drawing each layer everytime refresh is made, regardless if they are actually displayed on screen or outside of screen.
User avatar
airsoftsoftwair
Posts: 5446
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Any way to get vacant ID for insertLayer? (id = InsertLa

Post by airsoftsoftwair »

If the layer is outside the visible area, nothing will be drawn so there should be no slowdown. However, it you call functions like ScaleLayer() or RotateLayer() on layers outside the visible area, Hollywood will still transform the layers' pixel data although it's currently not visible.
Bugala
Posts: 1180
Joined: Sun Feb 14, 2010 7:11 pm

Re: Any way to get vacant ID for insertLayer? (id = InsertLa

Post by Bugala »

Good, good, very good. This will make it much easier for me. I can simply do the program so that it keeps each layers co-ordinates exactly where they supposedly are, even when out of screen, and then i just simply go through every layer and draw them.
Bugala
Posts: 1180
Joined: Sun Feb 14, 2010 7:11 pm

Re: Any way to get vacant ID for insertLayer? (id = InsertLa

Post by Bugala »

Report on missing documentation:

In GetAttribute command at #DISPLAY it doesnt mention the possibility of using #ATTRLAYERS, it only mentions of #ATTLAYERSON. At #BGPIC it does mention the #ATTLAYERS
User avatar
airsoftsoftwair
Posts: 5446
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Any way to get vacant ID for insertLayer? (id = InsertLa

Post by airsoftsoftwair »

No, it does mention #ATTRLAYERS for #DISPLAY, see here:
http://www.hollywood-mal.com/docs/html/ ... ibute.html
Post Reply