Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: [object] [VID] Some other questions

From: moliad:aei:ca at: 22-Nov-2003 3:37

> === Original Message > > > > 7) Trying to find a solution to the problem above I looked around the > REBOL webpages and searched for a possibility to create threads - there > doesn't seem to be anything like that - how is "parallel processing" > achieved in REBOL ? > > Cooperative multi-tasking. There is only the one thread in Rebol.
Handling threads in any os-independant way leads to major head-aches which means they risk bein only partially implemented. python threads, for example, cannot kill other threads, even the main thread is completely unable to kill other threads. This is because most OSes handle threads differently and this makes threading hard/impossible to uniformitize. I'm not saying threads aren't usefull, I'm just saying that because of rebols extensive multiplatform nature, threads would be a nightmare to support evenly, which is one of the reasons (I'm pretty sure) why RebolTechnologies (RT) has kept away from them. you'll have to use multiple processes with a network port interfacing. optionaly, you might want to build yourself your own protocol handler to make communication with the different "threads" easier... or just a simple event loop waiting on one or more ports. ask around, you'll see that many of the people on this list have played around with port handlers, there are also very good tutorials ... like this one: http://www.rebolforces.com/articles/protocols/ -MAx
> > I read it would be possible to create images on the fly and work with > these then - is it possible to store an entire (view) layout within such > an > image ? > > Yes. There's an example or two of this on the Rebol site.
its as easy as: ;------------------------------------------------- img: to-image layout [ button "hello" button "there" ] ; proof! view layout [image img] ;-------------------------------------------------
> > 13) I didn't see any designated function to set pixels at certain > coordinates in a layout- my workaround was using the line word - with 1 > width/height. How is this really done ? > > There is a pixel dialect for Rebol; but it seems to be concealed to > casual > visitors. :-/
well, you can pick/poke in any image like so: (using previously generated image) ; SETTING COLOR PIXELS ;------------------------------------------------- poke img 40 255.255.255 poke img 43 255.255.255 poke img 46 255.255.255 view layout [image img] ; you should see a dotted white line ;------------------------------------------------- ; GETTING COLOR PIXELS ;------------------------------------------------- pixel-clr: pick img 40 == 255.255.255 the only thing which is less cool about the above pixel color set/get is that you must know the size of the image and then find the index of a specific pixel by multiplying line width by the pixel's Y position you want and THEN adding the pixel's X coordinate to it. basically: pixel-index: (img/size/x * (py)) + px so you can easily write these functions: ;---- get-color-at-point: func [image coordinate][ ; be carefull math coordinates start at (0,0) not (1x1) pick image image/size/x * coordinate/2 + coordinate/1 + 1 ] set-color-at-point: func [image coordinate color][ ; be carefull math coordinates start at (0,0) not (1x1) poke image image/size/x * coordinate/2 + coordinate/1 + 1 color ] note that these functions are not meant to be specifically FAST, but can let you create images and then save them out, so that you can build them slowly but use them quickly. I sometimes prebuild some vid effects within graphics and later on remove all the effects, while loading the prerendered image, so that the ui zooms faster. -MAx