Now let's order this in a simple example:Assumed our objects are just geometric shapes as triangles, rectangles and circles drawn in 2d.What will all of these have in common?
Type tBasicShape ' information of type and identity Type$ as String Name$ as String Index as Long ' ability to enable and disable events ' like clicking or dragging Enabled as Boolean ' visibility - (if not visible it's not ' necessary to process this object) Visible as Boolean ' an individual color Red as Byte Green as Byte Blue as Byte ' a location where this object will appear ' we might calculate it somehow so it should ' be more precise than Integer or Single PosX as Double PosY as Double ' that should be enough properties for the meantime End Type
For the position we will always use the center of the object and calculate all other points/corners/radius or whatever our object defines in relation to the centers position. Now let's setup the types for 3 kinds of objects:
Type tShapeRectangle Extends tBasicShape ' it has 4 corners CornerX(4) as Double CornerY(4) as Double ' and it gets drawn it's own way: Function DrawIt() ' UseColor (Me.Red, Me.Green, Me.Blue ' now here we calculate the 4 positions of ' the corners and draw a rectangular shape End FunctionEnd TypeType tShapeTriangle Extends tBasicShape ' has 3 corners CornerX(3) as Double CornerY(3) as Double Function DrawIt() UseColor (Me.Red, Me.Green, Me.Blue) ' calculate the corners position and draw End FunctionEnd TypeType tShapeCircle Extends tBasicShape Radius As Double Function DrawIt() ' guess... End FunctionEnd Type
...
Bookmarks