高度なSVGグラデーションとパターン:複雑なエフェクトの作成
洗練されたビジュアルエフェクトのためにSVGグラデーションとパターンをマスターしましょう。リニア、ラジアルグラデーションとパターン技法を学びます。

Founder of VectoSolve
Self-taught developer, founder and sole developer of VectoSolve since 2024. He builds the conversion engine and the cutting, embroidery and 3D printing exports.
How this article was made: drafted with AI assistance, then edited and fact-checked before publication. About the author
Key Takeaways
- SVGはリニアグラデーション、ラジアルグラデーション、繰り返しタイルパターンをサポートします — すべてXMLで定義
- 透明度付きマルチストップグラデーションにより、スムーズなフェード、スポットライト、グローエフェクトが可能
-
パターンは
patternUnitsとpatternTransformを使用してタイリングと回転を完全制御 - グラデーションはパターン内にネストでき、SMILまたはCSSでアニメーション化してダイナミックなビジュアルを実現
- グラデーションストップを制限し、アニメーションコンテキストで複雑なパターンを避けることで最適化
フラットカラーを超えて
SVGグラデーションとパターンはベクターグラフィックスに深みと視覚的な面白さを加えます。このガイドではプロフェッショナルなエフェクトを作成する高度なテクニックを探ります。
リニアグラデーション
基本構造
<defs>
<linearGradient id="gradient1" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" stop-color="#ff0000"/>
<stop offset="100%" stop-color="#0000ff"/>
</linearGradient>
</defs>
<rect fill="url(#gradient1)" width="200" height="100"/>
方向制御
<!-- 水平 -->
<linearGradient x1="0%" y1="0%" x2="100%" y2="0%">
<!-- 垂直 -->
<linearGradient x1="0%" y1="0%" x2="0%" y2="100%">
<!-- 対角線 -->
<linearGradient x1="0%" y1="0%" x2="100%" y2="100%">
<!-- カスタム角度(45度) -->
<linearGradient gradientTransform="rotate(45)">
マルチストップグラデーション
<linearGradient id="rainbow">
<stop offset="0%" stop-color="#ff0000"/>
<stop offset="17%" stop-color="#ff8000"/>
<stop offset="33%" stop-color="#ffff00"/>
<stop offset="50%" stop-color="#00ff00"/>
<stop offset="67%" stop-color="#0000ff"/>
<stop offset="83%" stop-color="#4b0082"/>
<stop offset="100%" stop-color="#8f00ff"/>
</linearGradient>
Pro Tip: 角度付きグラデーションにはx1/y1/x2/y2を手動で計算する代わりにgradientTransform="rotate(45)"を使用しましょう。より読みやすく、後から調整も簡単です。
ラジアルグラデーション
基本ラジアル
<radialGradient id="radial1" cx="50%" cy="50%" r="50%">
<stop offset="0%" stop-color="#ffffff"/>
<stop offset="100%" stop-color="#000000"/>
</radialGradient>
オフセットセンター(スポットライトエフェクト)
<radialGradient id="spotlight"
cx="30%" cy="30%"
fx="25%" fy="25%"
r="50%">
<stop offset="0%" stop-color="#ffffff"/>
<stop offset="100%" stop-color="#333333"/>
</radialGradient>
楕円グラデーション
<radialGradient id="ellipse"
cx="50%" cy="50%"
rx="50%" ry="25%">
<stop offset="0%" stop-color="#ff0000"/>
<stop offset="100%" stop-color="#000000"/>
</radialGradient>
A Full Year of Conversions for $49
Starter Annual: 25 conversions every month, $49 for the whole year. That is about $4.08 a month · Cancel anytime
Get the Annual Dealグラデーションの透明度
フェードエフェクト
<linearGradient id="fade-out">
<stop offset="0%" stop-color="#000000" stop-opacity="1"/>
<stop offset="100%" stop-color="#000000" stop-opacity="0"/>
</linearGradient>
透明な中心
<radialGradient id="glow">
<stop offset="0%" stop-color="#00ff00" stop-opacity="0.8"/>
<stop offset="50%" stop-color="#00ff00" stop-opacity="0.3"/>
<stop offset="100%" stop-color="#00ff00" stop-opacity="0"/>
</radialGradient>
「グラデーションとパターンは、ベクターグラフィックスにおけるフラットデザインとフォトリアリズムの架け橋です — 適切に配置されたstop-opacityの繊細さがコンポジションを左右します。」 - Lea Verou、CSS/SVG著者
パターンの基本
シンプルなパターン
<defs>
<pattern id="dots" width="20" height="20" patternUnits="userSpaceOnUse">
<circle cx="10" cy="10" r="3" fill="#333"/>
</pattern>
</defs>
<rect fill="url(#dots)" width="200" height="200"/>
ストライプパターン
<pattern id="stripes" width="10" height="10" patternUnits="userSpaceOnUse">
<rect width="5" height="10" fill="#ff0000"/>
<rect x="5" width="5" height="10" fill="#ffffff"/>
</pattern>
複雑なパターン
<pattern id="plaid" width="40" height="40" patternUnits="userSpaceOnUse">
<!-- ベース -->
<rect width="40" height="40" fill="#e0e0e0"/>
<!-- 水平ストライプ -->
<rect width="40" height="10" fill="#c0c0c0"/>
<rect y="20" width="40" height="10" fill="#c0c0c0"/>
<!-- 垂直ストライプ -->
<rect width="10" height="40" fill="#a0a0a0" opacity="0.5"/>
<rect x="20" width="10" height="40" fill="#a0a0a0" opacity="0.5"/>
</pattern>
パターン変換
回転パターン
<pattern id="diagonal"
width="10" height="10"
patternTransform="rotate(45)"
patternUnits="userSpaceOnUse">
<line x1="0" y1="0" x2="0" y2="10" stroke="#000" stroke-width="2"/>
</pattern>
スケーリングパターン
<pattern id="scaled"
width="20" height="20"
patternTransform="scale(0.5)"
patternUnits="userSpaceOnUse">
<!-- 2xのパターンコンテンツ、1xで表示 -->
</pattern>
Free SVG Tools for Crafters
Design Checker · Color Separator · Mat Preview · Offset Generator · Text to SVG
Check Your SVG Free高度なテクニック
パターン内のグラデーション
<defs>
<linearGradient id="grad">
<stop offset="0%" stop-color="#ff0000"/>
<stop offset="100%" stop-color="#00ff00"/>
</linearGradient>
<pattern id="gradient-dots" width="20" height="20" patternUnits="userSpaceOnUse">
<circle cx="10" cy="10" r="8" fill="url(#grad)"/>
</pattern>
</defs>
グラデーション背景のパターン
<defs>
<radialGradient id="bg-grad">
<stop offset="0%" stop-color="#ffffff"/>
<stop offset="100%" stop-color="#cccccc"/>
</radialGradient>
<pattern id="textured" width="4" height="4" patternUnits="userSpaceOnUse">
<rect width="4" height="4" fill="url(#bg-grad)"/>
<circle cx="2" cy="2" r="1" fill="#000" opacity="0.1"/>
</pattern>
</defs>
ノイズ/グレインエフェクト
<filter id="noise">
<feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="4"/>
<feColorMatrix type="saturate" values="0"/>
</filter>
<rect filter="url(#noise)" opacity="0.1" width="100%" height="100%"/>
グラデーションのCSSアニメーション
アニメーショングラデーション
<svg>
<defs>
<linearGradient id="animated-grad" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" stop-color="#ff0000">
<animate attributeName="stop-color"
values="#ff0000;#00ff00;#0000ff;#ff0000"
dur="4s" repeatCount="indefinite"/>
</stop>
<stop offset="100%" stop-color="#0000ff">
<animate attributeName="stop-color"
values="#0000ff;#ff0000;#00ff00;#0000ff"
dur="4s" repeatCount="indefinite"/>
</stop>
</linearGradient>
</defs>
</svg>
SMIL (<animate>) によるアニメーショングラデーションは、JavaScriptなしで全てのモダンブラウザでネイティブに動作します。より複雑なグラデーションアニメーション — ストップ位置の時間経過による移動など — にはSMILと親要素のCSSトランジションを組み合わせてください。
パフォーマンスの考慮事項
最適化のヒント
- グラデーションストップを制限する
- アニメーションで複雑なパターンを避ける
- will-changeを控えめに使用する
- フォールバックカラーを検討する
- モバイルデバイスでテストする
ラスタライズすべきとき
以下の場合にラスタライズを検討:
- 極めて複雑なパターン
- 重いフィルターエフェクト
- パフォーマンスが重要なアプリケーション
- 静的グラフィックス
A Full Year of Conversions for $49
Starter Annual: 25 conversions every month, $49 for the whole year. That is about $4.08 a month · Cancel anytime
Get the Annual DealVectoSolveとグラデーション
グラデーション処理
VectoSolveはグラデーション変換を処理します:
- グラデーションカラーの抽出
- カラーストップの保持
- クリーンなSVG出力
変換後のグラデーション作業
ベクター化後:
- 抽出されたグラデーションを確認
- 必要に応じてストップを調整
- ユースケースに合わせて最適化
- パターンを手動で追加
まとめ
SVGグラデーションとパターンは、ラスターの制限なしに洗練されたビジュアルエフェクトを実現します。ベクターグラフィックスに深み、テクスチャ、視覚的な面白さを作り出すためにこれらのテクニックをマスターしましょう。VectoSolveのクリーンなベクターから始めて、必要に応じてグラデーションとパターンで強化してください。
| グラデーション/パターンタイプ | SVG要素 | 一般的なユースケース |
|---|---|---|
| リニアグラデーション | <linearGradient> | 背景、ボタン、空のエフェクト |
| ラジアルグラデーション | <radialGradient> | スポットライト、グロー、円形フェード |
| 繰り返しパターン | <pattern> | テクスチャ、布地、タイリング背景 |
| メッシュグラデーション | <meshGradient> (SVG2) | フォトリアリスティックな色のブレンド |
出典と参考文献
- MDN Web Docs: SVG Gradients — linearGradient、radialGradient、pattern要素の包括的リファレンス
- W3C SVG 2: Paint Servers — SVGグラデーション、パターン、メッシュグラデーションの公式仕様
- CSS-Tricks: SVG Gradients — SVGグラデーションとパターンの作成・アニメーションに関するビジュアルチュートリアル
- Smashing Magazine: Advanced SVG — パターン変換とグラデーションコンポジションに関する深い技術記事