forked from espruino/BangleApps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Icon for Dane add dane_arwes module
- Loading branch information
1 parent
dbf68a8
commit 3a36580
Showing
6 changed files
with
122 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/* Copyright (c) 2020 OmegaRogue. See the file LICENSE for copying permission. */ | ||
/* | ||
Graphics Functions based on the React Sci-Fi UI Framework Arwes | ||
*/ | ||
|
||
var C = { | ||
cornerSize: 14, // description | ||
cornerOffset: 3, // description | ||
borderWidth: 1 // description | ||
}; | ||
|
||
function Arwes(cornerSize, cornerOffset) { | ||
this.cornerSize = cornerSize; | ||
this.cornerOffset = cornerOffset; | ||
} | ||
|
||
|
||
/** 'public' constants here */ | ||
Arwes.prototype.C = { | ||
color: { | ||
primary: { | ||
base: "#26dafd", | ||
light: "#8bebfe", | ||
dark: "#029dbb" | ||
}, | ||
secondary: { | ||
base: "#df9527", | ||
light: "#ecc180", | ||
dark: "#8b5c15" | ||
}, | ||
header: { | ||
base: "#a1ecfb", | ||
light: "#fff", | ||
dark: "#3fd8f7" | ||
}, | ||
control: { | ||
base: "#acf9fb", | ||
light: "#fff", | ||
dark: "#4bf2f6" | ||
}, | ||
success: { | ||
base: "#00ff00", | ||
light: "#6f6", | ||
dark: "#090" | ||
}, | ||
alert: { | ||
base: "#ff0000", | ||
light: "#f66", | ||
dark: "#900" | ||
}, | ||
disabled: { | ||
base: "#999999", | ||
light: "#ccc", | ||
dark: "#666" | ||
} | ||
} | ||
}; | ||
|
||
|
||
function drawCorner(obj, x, y, n) { | ||
g.setColor(obj.C.color.primary.base); | ||
let s1 = (n&1)?1:-1, s2 = (n&2)?1:-1; | ||
const x1 = x + obj.cornerOffset * s1; | ||
const y1 = y + obj.cornerOffset * s2; | ||
g.fillRect(x1, y1, x - obj.cornerSize*s1 + obj.cornerOffset*s1, y); | ||
g.fillRect(x1, y1, x, y - obj.cornerSize*s2 + obj.cornerOffset*s2); | ||
|
||
} | ||
|
||
Arwes.prototype.drawFrameNoCorners = function (x1, y1, x2, y2) { | ||
g.setColor(this.C.color.primary.dark); | ||
g.drawRect(x1, y1, x2, y2); | ||
} | ||
|
||
Arwes.prototype.drawFrame = function (x1, y1, x2, y2) { | ||
drawCorner(this, x1, y1, 0); | ||
drawCorner(this, x2, y1, 1); | ||
drawCorner(this, x1, y2, 2); | ||
drawCorner(this, x2, y2, 3); | ||
this.drawFrameNoCorners(x1, y1, x2, y2); | ||
} | ||
|
||
Arwes.prototype.drawFrameBottomCorners = function (x1, y1, x2, y2) { | ||
drawCorner(this, x1, y2, 2); | ||
drawCorner(this, x2, y2, 3); | ||
this.drawFrameNoCorners(x1, y1, x2, y2); | ||
} | ||
|
||
Arwes.prototype.drawFrameTopCorners = function (x1, y1, x2, y2) { | ||
drawCorner(this, x1, y1, 0); | ||
drawCorner(this, x2, y1, 1); | ||
this.drawFrameNoCorners(x1, y1, x2, y2); | ||
} | ||
|
||
Arwes.prototype.drawFrameLeftCorners = function (x1, y1, x2, y2) { | ||
drawCorner(this, x1, y1, 0); | ||
drawCorner(this, x1, y2, 2); | ||
this.drawFrameNoCorners(x1, y1, x2, y2); | ||
} | ||
|
||
Arwes.prototype.drawFrameRightCorners = function (x1, y1, x2, y2) { | ||
drawCorner(this, x2, y1, 1); | ||
drawCorner(this, x2, y2, 3); | ||
this.drawFrameNoCorners(x1, y1, x2, y2); | ||
} | ||
|
||
|
||
|
||
|
||
exports.create = function (cornerSize, cornerOffset) { | ||
return new Arwes(cornerSize, cornerOffset); | ||
}; | ||
|
||
exports.default = function () { | ||
return new Arwes(C.cornerSize, C.cornerOffset); | ||
}; |