4D Blog

Home Product SVG “non-scaling-stroke” attribute support

SVG “non-scaling-stroke” attribute support

December 5, 2019

Product

Sometimes it’s preferable to have the lines of an object keep their original width, regardless of the applied transformation. For example, you draw a line on a map showing a user’s position and a destination. When the user zooms in on the map, you want to enlarge the map but have the line maintain its width.

In the SVG standard, the “non-scaling-stroke” attribute indicates that the stroke width does not depend on the zoom or scaling. In other words, an object’s lines aren’t affected by transformations and zooming.

Here’s an example of two rectangles with the same line thickness. The rectangle on the left uses the “non-scaling-stroke” attribute, whereas the rectangle on the right does not use this attribute:

Take a look at the SVG file:

<svg viewBox="0 0 90 45" xmlns="http://www.w3.org/2000/svg">
<rect x="1" y="1" width="40" height="40" fill="white" stroke="blue" stroke-width="1px" vector-effect="non-scaling-stroke"/>
<rect x="45" y="1" width="40" height="40" fill="white" stroke="green" stroke-width="1px" />
</svg>

We’ve also added new commands to the “4D SVG” theme. You can define the “non-scaling-stroke” attribute to drawing objects with the SVG_SET_STROKE_VECTOR_EFFECT method.

// Create view box
$svgRef:=SVG_New (90;45)

// First rectangle with the non-scaling-stroke attribute
$rect1:=SVG_New_rect ($svgRef;1;1;40;40;0;0;"blue";"white";1)
SVG_SET_STROKE_VECTOR_EFFECT ($rect1;"non-scaling-stroke")

// Second rectangle
$rect2:=SVG_New_rect ($svgRef;45;1;40;40;0;0;"green";"white";1)

// Save image on disk
File("/RESOURCES/Images/rectangle.svg").create()
SVG_SAVE_AS_TEXT ($svgRef; File("/RESOURCES/Images/rectangle.svg").platformPath)

// Clear reference
SVG_CLEAR ($svgRef)

Discuss

Tags Pictures, SVG, v18

Latest related posts

  • February 3, 2026

    4D Write Pro – Adding a margin automatically when bullets are set using standard actions

  • January 22, 2026

    Transform Static Documents into Actionable Knowledge with AIKit

  • January 22, 2026

    Deploy Fluent UI effortlessly in your 4D applications

Vanessa Talbot
Vanessa Talbot
• Product Owner •Vanessa Talbot joined 4D Program team in June, 2014. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.Since her arrival, she has worked to define key features in 4D. She has worked on most of preemptive multi-threading new features and also on a very complex subject: the new architecture for engined application. Vanessa has a degree from Telecom Saint-Etienne. She began her career at the Criminal Research Institute as a developer for the audiovisual department. She has also worked in media and medical fields as expert in technical support, production as well as documenting new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • Release infos
  • 4D View Pro
  • 4D Write Pro
  • Email, Microsoft 365, Gmail
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • 4D Qodly Pro
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 21 21 R2 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor

Tags

4D-Analyzer 4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 21 21 R2 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor
Subscribe to 4D Newsletter

© 2026 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy