Help us understand the problem. What is going on with this article?

SVGの図形を拡大した際にストロークまで太くなってしまうのを防ぐ

More than 1 year has passed since last update.

概要

tranfrom属性のscaleを使って図表を拡大した際に、図形のストロークまで太くなってしまうのを防ぐ。

エレメントの「vector-effect」属性に「non-scaling-stroke」を指定する。

<svg>
  <g transform="scale(3)">
    <circle cx="60" cy="60" r="50" fill="#ffcccc"  stroke="black"></circle>
    <circle cx="180" cy="60" r="50" fill="#ccccff" stroke="black" vector-effect="non-scaling-stroke"></circle>
  </g>
</svg>

実行結果

Create a new fiddle - JSFiddle 2019-01-22 17-39-28.png

何に使うのか

D3でパン・ズーム実装していると必要になることが多い。

_shimizu
群馬・東京間を行き来する出稼ぎエンジニアです。ブログではGIS(地理情報システム)・データビジュアライゼーション・オープンデータなどについて書いてます。JavaScript勉強中
http://shimz.me/blog/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした