Ticket #3185 (assigned feature)

Opened 3 years ago

Last modified 3 years ago

canvas: drawExternalGraphic either misplaced or not drawn

Reported by: rduivenvoorde Owned by: tschaub
Priority: minor Milestone: 2.13 Release
Component: Renderer.Canvas Version: 2.10
Keywords: Cc:
State: Review

Description

In current implementation of Canvas.drawExternalGraphic I found two problems:

1) if using a (point) style with an external graphic, and NOT defining a pointRadius AND (graphicWidth OR graphicHeight), NO graphic was draws (there seems to be no default size for a graphic

2) when using an external graphic and using the style properties graphicXOffset and graphicYOffset the offset was too big (eg using a marker graphic 24 pixels hight with a pointer to the bottom of the graphic, you had to give an y-offset of 24 to have the pointer point to the real point ...).

I will attach a patch for both problems

Attachments

patch3185 Download (1.4 KB) - added by rduivenvoorde 3 years ago.
first patch
patch3185-2 Download (1.1 KB) - added by rduivenvoorde 3 years ago.
same patch for after r11581

Change History

Changed 3 years ago by rduivenvoorde

first patch

follow-up: ↓ 2   Changed 3 years ago by rduivenvoorde

patch3185 defines the width of the image to draw as either a defined width or the height or half of the point radius

same for height

if a graphic-offset is defined it is added to half of the image (otherwise the offset is too large)

in reply to: ↑ 1   Changed 3 years ago by rduivenvoorde

Replying to rduivenvoorde:

patch3185 defines the width of the image to draw as either a defined width or the height or half of the point radius

OR defaults to 20

  Changed 3 years ago by tschaub

  • owner set to tschaub
  • status changed from new to assigned
  • component changed from general to Renderer.Canvas
  • milestone changed from 2.11 Release to 2.12 Release

r11581 addresses some issues with external graphic rendering. Please update this ticket with details of the situation after r11581.

Changed 3 years ago by rduivenvoorde

same patch for after r11581

  Changed 3 years ago by rduivenvoorde

Work done for r11581 is not related to this ticket/patch.

I have updated patch for the newer Canvas code.

It still solves two problems:

ad 1) it actually defines a default value for the width and height of the graphic (without this ticket, a style like

default:{externalGraphic: "img/marker-gold.png"}

will NOT show the marker because it will have NO width or height. With the patch it will at least be shown with the default width and height of 20x20 (width and height is also more important now for hit-detection).

ad 2) the code for drawing the external graphic was not taking into account the width/height of the graphic itself when applying an offset, so the style

default:{externalGraphic: "img/marker-gold.png", ,graphicXOffset: 20}

versus

default:{externalGraphic: "img/marker-gold.png", ,graphicXOffset: -20}

were not mirrored. The positive offset is drawn half the size of the image too much while the negative offset is drawn half the size image too few.

  Changed 3 years ago by rduivenvoorde

  • state set to Review
Note: See TracTickets for help on using tickets.