{{tag>dragonscript behavior}} [[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[abstractions#behavior_elementsquick_and_easy_development|Behavior Elements: Quick and Easy Development]] >> **ECBehaviorRenderableCanvas** * [[behaviors_use_cases|Behaviors Explained: By Use-Case]] * [[behaviors_a_to_z|Behaviors Explained: From A to Z]] ====== ECBehaviorRenderableCanvas ====== Behavior element behavior adding a renderable canvas view. This behavior is useful for models with a complex dynamic texture where the content of the texture is provided by one or more Canvas resources. Multiple other behaviors can add their content to the canvas renderable to separate logic for reuse. A convenient base class to use is ECBehaviorRenderableCanvasBase. To use this behavior add an [[behavior_dynamicskin|ECBehaviorDynamicSkin]] to the element class before adding this behavior. Create ECBehaviorRenderableCanvas behavior and set the dynamic skin and canvas background color or image. The background color empty by default so make sure to set an appropriate background. Now you can add other behaviors targeting the ECBehaviorRenderableCanvas to add Canvas resources to. If the background is not set the behaviors using this canvas have to make sure they cover the entire background to avoid artifacts. Background CanvasPaint or CanvasImage have order 0 respective 1 if both are used. Both canvas can be used for example if the image has transparency. The canvas is created with a default size of 512x512 . You can change the size using the element property to fit the texture requirements. See also: * [[gamedev:renderables|Dynamic Content using Renderables]] * [[dragengine:modules:dragonscript:guitheme|Gui Themes]] * [[gamedev:deigde:editors:skin|IGDE Skin Editor]] ====== Instance Counts ====== Multiple ECBehaviorRenderableCanvas instances can be added to affect individual dynamic skin textures. ====== Element Class Properties ====== Element class properties have the prefix ''renderableCanvas.'' or ''renderableCanvas({id}).'' if id is not empty. ===== renderable ===== Set renderable name. Adds renderable of canvas type. * Full name: ''renderableCanvas.renderable'' or ''renderableCanvas({id}).renderable'' * Type: string * Default Value: empty string * Example (*.deeclass) display ===== size ===== Set size of canvas in pixels. * Full name: ''renderableCanvas.size'' or ''renderableCanvas({id}).size'' * Type: 2-component point * Default Value: (512,512) * Example (*.deeclass) ===== backgroundColor ===== Set background color or ''null'' to not use. * Full name: ''renderableCanvas.backgroundColor'' or ''renderableCanvas({id}).backgroundColor'' * Type: 3-component color * Default Value: ''null'' * Example (*.deeclass) ===== backgroundImage ===== Set path to background image resource to use or ''null'' to not use a background image. * Full name: ''renderableCanvas.value'' or ''renderableCanvas({id}).value'' * Type: string * Default Value: empty string * Expected File Type: ''*.webp'', ''*.png'', ''*.jpg'' (all image type modules) * Example (*.deeclass) panel.webp ====== Events ====== This behavior has no events. ====== Required Behaviors ====== * [[behavior_dynamicskin|ECBehaviorDynamicSkin]] ====== Optional Behaviors ====== This behavior does not support optional behaviors. ====== Persistency ====== This behavior does not required element class to be persistable (setPersistable). ====== API Documentation ====== #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorRenderableCanvas.html,ECBehaviorRenderableCanvas~@#. Since DragonScript Module Version ''1.0'' ====== Use Cases ====== * Add canvas based renderable to dynamic skin for use by other behaviors to add content to. ====== Element Class Example ====== This example defines an element which contains a resources. class MyElement extends BehaviorElementClass public var ECBehaviorComponent component public var ECBehaviorDynamicSkin dynamicSkin public var ECBehaviorRenderableCanvas renderableCanvas func new() component = ECBehaviorComponent.new(this, null) dynamicSkin = ECBehaviorDynamicSkin.new(this, collider) renderableCanvas = ECBehaviorRenderableCanvas.new(this, dynamicSkin) end end ====== Behavior Factory ====== Using element class supporting adding behaviors the behavior can be added like this: second Color 1 ====== Live Examples ====== * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]