From c234ab733b36933954403b456dd7216a0e5d0ac6 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 2 Mar 2023 17:59:54 +0100 Subject: [PATCH] Timeline: Bugfix in drawing code ...the gap at the lower end of the line was caused by an unintended conversion from double to int, prior to scaling --- src/stage/timeline/stave-bracket-widget.cpp | 20 +- wiki/thinkPad.ichthyo.mm | 344 +++++++++++++++----- 2 files changed, 276 insertions(+), 88 deletions(-) diff --git a/src/stage/timeline/stave-bracket-widget.cpp b/src/stage/timeline/stave-bracket-widget.cpp index 0769fad67..c56b1d154 100644 --- a/src/stage/timeline/stave-bracket-widget.cpp +++ b/src/stage/timeline/stave-bracket-widget.cpp @@ -128,10 +128,9 @@ namespace timeline { * @return scale factor to apply to the base layout */ double - determineScale (StyleC style, CairoC cox) + determineScale (StyleC style) { - return BASE_WIDTH_PER_EM * getAbsoluteFontSize (style) - / deviceUnitsPerUserUnit (cox); + return BASE_WIDTH_PER_EM * getAbsoluteFontSize (style); } /** place left anchor reference line to right side of bold bar. @@ -164,14 +163,14 @@ namespace timeline { = canvasHeight - (style->get_padding().get_bottom() - scale * SQUARE_TIP_Y); - auto minHeight = 2*PHISQUARE*scale + style->get_padding().get_top(); - return max (lowerAnchor, minHeight); + auto minHeight = PHISQUARE*scale + style->get_padding().get_top(); + return max (lowerAnchor, minHeight); // Fallback: both caps back to back } /** * Draw the curved end cap of the bracket, inspired by musical notation. - * @param ox horizontal offset of the anchor point in pixels + * @param ox horizontal offset of the anchor point; pixels in target device space * @param oy vertical anchor point offset, downwards is positive * @param scale stretch the design; default is bracket line width = 1.0 * @param upside whether to draw the upper cup (`true`) or the lower @@ -203,11 +202,11 @@ namespace timeline { drawBar (CairoC cox, double leftX, double upperY, double lowerY, double scale) { cox->save(); - cox->translate (leftX,upperY); + cox->translate (leftX, upperY); cox->scale (scale, scale); cox->set_source_rgb(0.0, 0.0, 0.8); ///////TICKET #1168 : retrieve colour from stylesheet // - double height = max (0, (lowerY - upperY)/scale); + double height = max (0.0, (lowerY - upperY)/scale); cox->rectangle(BAR_LEFT, -SQUARE_MINOR, BAR_WIDTH, height + 2*SQUARE_MINOR); cox->rectangle(LIN_LEFT, ORG, LIN_WIDTH, height); // @@ -250,8 +249,11 @@ namespace timeline { cox->stroke(); /////////////////////////////////////////////TICKET #1018 : placeholder drawing + REQUIRE (1.0 == deviceUnitsPerUserUnit (cox) + ,"Cairo surface in device coordinates assumed"); + StyleC style = this->get_style_context(); - double scale = determineScale (style, cox); + double scale = determineScale (style); double left = anchorLeft (style, scale); double upper = anchorUpper (style,scale); double lower = anchorLower (style, scale, h); diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 25037e800..26ae31781 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -28632,79 +28632,35 @@ - - + + - - +

- der Druck-Metapher gemäß ist das die „Farbwalze“ oder das „Stempelkissen“ + die Cairo Zeichen-Operationen sind modelliert als Druckvorgang

- -
-
- - - - - -
  • - Kann angezeigt werden + ein Pfad definiert die Maske
  • - Kann in ein Bitmap gerendered werden -
  • -
  • - Kann als »source« für weitere Zeichenvorgänge dienen + durch diese hindurch wird die Source auf die Surface  (Ausgabe) gestempelt
-
- - - - - - -

- wird mit jeder stroke() oder fill()-Operation geleert. Ist Teil des Context, und weitere Zeichen-Operationen fügen zu dem Pfad hinzu -

- -
-
- - - - - - - - - - - + - - - - - - - - - + @@ -28799,9 +28755,9 @@ - - - + + + @@ -28813,6 +28769,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ es war der int vs double +

+ +
+
+
+ + + + + + + @@ -28893,7 +28903,7 @@ - + @@ -28946,13 +28956,14 @@ - + + - - + + @@ -29115,8 +29126,8 @@ - - + + @@ -29148,7 +29159,7 @@ - + @@ -29159,6 +29170,25 @@

+ + +
+ + + + + + + The device-space coordinate system is tied to the surface, and cannot change. The user-space coordinate system + +

+ matches that space by default, but can be changed for the above reasons. The helper functions +

+

+ cairo_user_to_device() and cairo_user_to_device_distance()  tell you what the device-coordinates are for a user-coordinates position or distance. +

+ +
@@ -32922,7 +32952,7 @@
- + @@ -70820,22 +70850,6 @@ - - - - - - - - - - - - - - - - @@ -70843,6 +70857,178 @@ + + + + + + + + + +

+ der Druck-Metapher gemäß ist das die „Farbwalze“ oder das „Stempelkissen“ +

+ +
+ + + + + + + + + + + +

+ wird mit jeder stroke() oder fill()-Operation geleert. Ist Teil des Context, und weitere Zeichen-Operationen fügen zu dem Pfad hinzu +

+ +
+ + + + + + + + + + + + + + +

+ die Source wird durch die Mask hindurch „gestempelt“ +

+ +
+ + + + + + + + + +
    +
  • + Kann angezeigt werden +
  • +
  • + Kann in ein Bitmap gerendered werden +
  • +
  • + Kann als »source« für weitere Zeichenvorgänge dienen +
  • +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ current transformation matrix (CTM) : User-Space ⟼ Device-Space +

+ +
+
+ + + + + + + + + +

+ Transformations-Definition wird eingangsseitig vor die aktuelle CTM vorgeschaltet +

+ +
+ +
+ + + + + + + + +

+ Beispiel: +

+

+    cairo_scale (cr, 100, 100); +

+

+    cairo_translate (cr, 0.1, 0.1); +

+ +
+ + + + + +
+ + + + + + +

+ ...die aktuellen Transformations-Einstellungen (current transformation matrix CTM) +

+

+ ...und nicht nur das, auch die Source-Einstellungen wie Linienstärke und Zeichenfarben +

+ +
+ + +
+
+