test export

Dependencies:   DmTftLibrary mbed

Fork of dm_paint by Display Module

Committer:
displaymodule
Date:
Mon Sep 01 10:57:38 2014 +0000
Revision:
4:34d4f7e491bc
Parent:
0:2ee293544fc1
Removed dependency on mbed-src for LPC1549

Who changed what in which revision?

UserRevisionLine numberNew contents of line
displaymodule 0:2ee293544fc1 1 /**********************************************************************************************
displaymodule 0:2ee293544fc1 2 Copyright (c) 2014 DisplayModule. All rights reserved.
displaymodule 0:2ee293544fc1 3
displaymodule 0:2ee293544fc1 4 Redistribution and use of this source code, part of this source code or any compiled binary
displaymodule 0:2ee293544fc1 5 based on this source code is permitted as long as the above copyright notice and following
displaymodule 0:2ee293544fc1 6 disclaimer is retained.
displaymodule 0:2ee293544fc1 7
displaymodule 0:2ee293544fc1 8 DISCLAIMER:
displaymodule 0:2ee293544fc1 9 THIS SOFTWARE IS SUPPLIED "AS IS" WITHOUT ANY WARRANTIES AND SUPPORT. DISPLAYMODULE ASSUMES
displaymodule 0:2ee293544fc1 10 NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE.
displaymodule 0:2ee293544fc1 11 ********************************************************************************************/
displaymodule 0:2ee293544fc1 12
displaymodule 0:2ee293544fc1 13 #include "Canvas.h"
displaymodule 0:2ee293544fc1 14
displaymodule 0:2ee293544fc1 15 Canvas::Canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t fg, uint16_t bg, uint16_t borderWidth, uint16_t borderColor) :
displaymodule 0:2ee293544fc1 16 _x(x), _y(y), _width(width), _height(height), _borderWidth(borderWidth), _fgColor(fg), _bgColor(bg), _borderColor(borderColor)
displaymodule 0:2ee293544fc1 17 {
displaymodule 0:2ee293544fc1 18 _borderEnabled = _borderWidth > 0;
displaymodule 0:2ee293544fc1 19 }
displaymodule 0:2ee293544fc1 20
displaymodule 0:2ee293544fc1 21 void Canvas::setBorder(uint16_t width, uint16_t color)
displaymodule 0:2ee293544fc1 22 {
displaymodule 0:2ee293544fc1 23 _borderWidth = width;
displaymodule 0:2ee293544fc1 24 _borderColor = color;
displaymodule 0:2ee293544fc1 25 _borderEnabled = _borderWidth > 0;
displaymodule 0:2ee293544fc1 26 }
displaymodule 0:2ee293544fc1 27
displaymodule 0:2ee293544fc1 28 void Canvas::enableBorder(bool enable)
displaymodule 0:2ee293544fc1 29 {
displaymodule 0:2ee293544fc1 30 _borderEnabled = enable;
displaymodule 0:2ee293544fc1 31 }
displaymodule 0:2ee293544fc1 32
displaymodule 0:2ee293544fc1 33 void Canvas::draw(DmTftBase* tft)
displaymodule 0:2ee293544fc1 34 {
displaymodule 0:2ee293544fc1 35 tft->fillRectangle(_x, _y, _x+_width, _y+_height, _bgColor);
displaymodule 0:2ee293544fc1 36 if (_borderEnabled) {
displaymodule 0:2ee293544fc1 37 for (int i = 0; i < _borderWidth; i++) {
displaymodule 0:2ee293544fc1 38 tft->drawRectangle(_x+i, _y+i, _x+_width-i, _y+_height-i, _borderColor);
displaymodule 0:2ee293544fc1 39 }
displaymodule 0:2ee293544fc1 40 }
displaymodule 0:2ee293544fc1 41 }
displaymodule 0:2ee293544fc1 42
displaymodule 0:2ee293544fc1 43 void Canvas::drawString(DmTftBase* tft, const char* msg)
displaymodule 0:2ee293544fc1 44 {
displaymodule 0:2ee293544fc1 45 tft->drawStringCentered(_x, _y, _width, _height, msg);
displaymodule 0:2ee293544fc1 46 }
displaymodule 0:2ee293544fc1 47