1 /++ 2 A module for rendering your own objects on the canvas. 3 4 Macros: 5 LREF = <a href="#$1">$1</a> 6 HREF = <a href="$1">$2</a> 7 8 Authors: $(HREF https://github.com/TodNaz,TodNaz) 9 Copyright: Copyright (c) 2020 - 2021, TodNaz. 10 License: $(HREF https://github.com/TodNaz/Tida/blob/master/LICENSE,MIT) 11 +/ 12 module tida.drawable; 13 14 /++ 15 The interface for normal rendering by coordinates. 16 All properties are specified in the constructor at best. 17 18 Example: 19 --- 20 class Rectangle : IDrawable 21 { 22 public 23 { 24 uint width, height; 25 Color!ubyte color; 26 } 27 28 this(uint width,uint height,Color!ubyte color); 29 30 override void draw(IRenderer renderer,Vecf position) @safe 31 { 32 renderer.rectangle(position,width,height,color,true); 33 } 34 } 35 --- 36 +/ 37 interface IDrawable 38 { 39 import tida.vector; 40 import tida.render; 41 42 /// draw object implemetation 43 void draw(IRenderer renderer,Vecf position) @trusted; 44 } 45 46 /++ 47 Interface for advanced object rendering. 48 It contains both the rotation of the object and such a property as size. 49 +/ 50 interface IDrawableEx 51 { 52 import tida.vector; 53 import tida.render; 54 import tida.color; 55 56 /// draw object implemetation 57 void drawEx(IRenderer renderer, Vecf position, float angle, Vecf center, 58 Vecf size, ubyte alpha, Color!ubyte color) @trusted; 59 }