Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GCS] Made the contrast label it's own class.
The outlines should now also be less jagged as I am covering all pixel directions.
- Loading branch information
1 parent
74dc09c
commit bca3fea
Showing
6 changed files
with
113 additions
and
34 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
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,59 @@ | ||
(* | ||
* A Label with a contrasting outline | ||
* | ||
* Copyright (C) 2013 Piotr Esden-Tempski <piotr@esden.net> | ||
* | ||
* This file is part of paparazzi. | ||
* | ||
* paparazzi is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* paparazzi is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with paparazzi; see the file COPYING. If not, write to | ||
* the Free Software Foundation, 59 Temple Place - Suite 330, | ||
* Boston, MA 02111-1307, USA. | ||
* | ||
*) | ||
|
||
(* | ||
* This module creates labels with outlines by creating 9 | ||
* overlapping labels slightly offset from eachother. Where the 8 | ||
* labels in the background have a different color from last center one. | ||
*) | ||
|
||
let label_offset_matrix = | ||
[ | ||
(* X Y *) | ||
[ 0.; -1.]; (* N *) | ||
[ 0.; 1.]; (* S *) | ||
[ 1.; 0.]; (* E *) | ||
[-1.; 0.]; (* W *) | ||
[ 1.; -1.]; (* NE *) | ||
[ 1.; 1.]; (* SE *) | ||
[-1.; 1.]; (* SW *) | ||
[-1.; -1.]; (* NW *) | ||
[ 0.; 0.]; (* Z *) | ||
] | ||
|
||
class widget = fun ?(name = "Noname") ?(size = 500) ?(bg_color = "black") ?(color = "red") x y (group:GnoCanvas.group) -> | ||
let new_text offset = | ||
GnoCanvas.text group ~props:[`TEXT name; | ||
`X (x +. (List.nth offset 0)); `Y (y +. (List.nth offset 1)); | ||
`ANCHOR `SW; | ||
`FILL_COLOR (if offset = [0.;0.] then color else bg_color)] in | ||
let labels = List.map new_text label_offset_matrix in | ||
object(self) | ||
method set_name s = List.iter (fun label -> label#set [`TEXT s]) labels | ||
method set_x x = List.iter2 (fun label offset -> label#set [`X (x +. (List.nth offset 0))]) | ||
labels label_offset_matrix | ||
method set_y y = List.iter2 (fun label offset -> label#set [`Y (y +. (List.nth offset 1))]) | ||
labels label_offset_matrix | ||
method affine_absolute a = List.iter (fun label -> label#affine_absolute a) labels | ||
end |
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,38 @@ | ||
(* | ||
* A Label with a contrasting outline | ||
* | ||
* Copyright (C) 2013 Piotr Esden-Tempski <piotr@esden.net> | ||
* | ||
* This file is part of paparazzi. | ||
* | ||
* paparazzi is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* paparazzi is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with paparazzi; see the file COPYING. If not, write to | ||
* the Free Software Foundation, 59 Temple Place - Suite 330, | ||
* Boston, MA 02111-1307, USA. | ||
* | ||
*) | ||
|
||
class widget : | ||
?name:string -> | ||
?size:int -> | ||
?bg_color:string -> | ||
?color:string -> | ||
float -> | ||
float -> | ||
GnoCanvas.group -> | ||
object | ||
method set_name : string -> unit | ||
method set_x : float -> unit | ||
method set_y : float -> unit | ||
method affine_absolute : float array -> unit | ||
end |
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
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
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