View source: R/CRcreate_texture.R
CRcreate_texture | R Documentation |
Creates a texture for window belonging to graphics_list. Arguments width and height specify dimensions of texture. Texture is added to texture_list.
CRcreate_texture(graphics_list, texture_list, widthin, heightin, status = NULL)
graphics_list |
List containing pointers to window, renderer etc. created with |
texture_list |
A (possibly empty) list to store texture in. Created textures should be stored in texture_list and later be passed to |
widthin |
Desired width of texture. |
heightin |
Desired height of texture. |
status |
Optional list |
Window has to be opened first with CRopen
. Textures are like off-screen rendering areas and can be used to render multiple things to before copying the texture to the screen via CRdraw_texture
. The benefit of this is that the rendering operations can take time, while eventual copying of the texture to the screen is very fast, and thus textures can provide considerable speed-up for complicated stimuli. In order to render to a texture, the texture has to be set as rendering target using CRset_render_target
. All the regular rendering operations (CRdraw_rect
, CRfill_circle
, etc.) will now affect the texture, not the screen. After rendering to texture, the rendering target has to be reset to the window using CRreset_render_target
.
Returns updated inpute texture_list with newly created texture included. If everything worked fine, returned texture_list has an integer valid
set to 1
.
mytexture <- CRcreate_texture(mygraphics, list(), 300, 300)
CRset_render_target(mygraphics, mytexture, 1 ) # set rendering target as first texture in mytexture
CRdraw_rect(mygraphics, list(x=50, y=50, w=100, h=100))
CRdraw_rect(mygraphics, list(x=20, y=30, w= 80, h= 80))
CRdraw_rect(mygraphics, list(x=10, y=20, w= 30, h= 40))
CRreset_render_target(mygraphics)
CRdraw_texture(mygraphics, mytexture, 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.