/graphics/pen.d

http://github.com/wilkie/djehuty · D · 54 lines · 33 code · 16 blank · 5 comment · 2 complexity · e0acca60db5d961cc57e6772a266d30b MD5 · raw file

  1. module graphics.pen;
  2. import platform.vars.pen;
  3. import Scaffold = scaffold.graphics;
  4. import core.color;
  5. import graphics.view;
  6. import graphics.brush;
  7. class Pen {
  8. public:
  9. // Constructor
  10. this(Color clr, double width = 1.0) {
  11. _width = width;
  12. Scaffold.createPen(&_pfvars, clr, width);
  13. }
  14. this(Brush brush, double width = 1.0) {
  15. _width = width;
  16. Scaffold.createPenWithBrush(&_pfvars, brush._pfvars, width);
  17. }
  18. // Destructor
  19. ~this() {
  20. Scaffold.destroyPen(&_pfvars);
  21. }
  22. // Sets color of a solid brush
  23. void setColor(Color clr) {
  24. Scaffold.destroyPen(&_pfvars);
  25. Scaffold.createPen(&_pfvars, clr, _width);
  26. // when tied to a locked view, update the brush being used
  27. if (_view !is null) {
  28. if (_view._locked) {
  29. _view._graphics.pen = _view._pen;
  30. }
  31. }
  32. }
  33. private:
  34. double _width;
  35. package PenPlatformVars _pfvars;
  36. // tied to a view?
  37. package View _view; // will be null if no view is tied with it
  38. }