Skip to content

Commit

Permalink
defaults for polygon style etc
Browse files Browse the repository at this point in the history
  • Loading branch information
birm authored Jan 15, 2025
1 parent 74649ba commit 60c373c
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion common/DrawHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,11 @@ caDrawHelper.prototype.drawPolygon = function(ctx, paths){
caDrawHelper.prototype.draw = function(ctx, image_data){
for (let i = 0; i < image_data.length; i++) {
const polygon = image_data[i];
if (polygon.properties == undefined || polygon.properties == null){
polygon.properties = {}
}
const style = polygon.properties.style;

// if there is path using path to draw
// if(polygon.geometry.path){
// ctx.fillStyle = hexToRgbA(style.color,0.5);
Expand Down Expand Up @@ -287,6 +290,9 @@ caDrawHelper.prototype.doesDraw = function(bbox, ctx){

caDrawHelper.prototype.drawGrids = function(ctx, image_data){
image_data.forEach(polygon =>{
if (polygon.properties == undefined || polygon.properties == null){
polygon.properties = {}
}
const style = polygon.properties.style;
const size = polygon.properties.size;
//this.setStyle(ctx, style);
Expand All @@ -297,6 +303,9 @@ caDrawHelper.prototype.drawGrids = function(ctx, image_data){
})
}
caDrawHelper.prototype.drawGrid = function(ctx, polygon){
if (polygon.properties == undefined || polygon.properties == null){
polygon.properties = {}
}
const style = polygon.properties.style;
const size = polygon.properties.size;
//this.setStyle(ctx, style);
Expand Down Expand Up @@ -330,6 +339,14 @@ caDrawHelper.prototype.drawGrid = function(ctx, polygon){
* how the end points of every line are drawn. There are three possible values: 'butt', 'round' and 'square'
*/
caDrawHelper.prototype.setStyle = function(ctx,style){
if (style == undefined || style == null){
style = {
"color":"#fccde5",
"lineJoin":"round",
"lineCap":"round",
"isFill":true
};
}
ctx.strokeStyle = style.color;
ctx.lineJoin = style.lineJoin;
ctx.lineCap = style.lineCap;
Expand Down

0 comments on commit 60c373c

Please sign in to comment.