- エーオーシステム コーポレートサイト
https://www.aosystem.co.jp/ - エーオーシステム プロダクトサイト
https://ao-system.net/ - レンタルサーバー
- バーチャル展示会
- ウェブカタログサービス
- 3Dグラフィック
- Android アプリ
- iOS (iPhone,iPad) アプリ
- Flutter開発
- プログラミング記録QuickAnswer
- 無料画像素材
- スカイボックス 3D SKY BOX
このページのQRコード
色相を変更:
/**
* 左から右へ移動のSVG画像出力
*
* @author ao-system, Inc.
* @date 2024-02-03
*/
export class LineImage {
'use strict';
#place;
#color = ['rgba(100,150,255,0.1)','rgba(100,120,255,1)'];
#filter = 'blur(3px) drop-shadow(-10px 100px 0px rgba(190,170,255,1))';
#linearGradient;
#rect;
#rectX = 200;
#rectWidth = 0;
#speed = (Math.random() * 4 + 2);
constructor(param) {
if (param.place) {
this.#place = param.place;
}
if (param.color) {
this.#color = param.color;
}
if (param.filter) {
this.#filter = param.filter;
}
this.#init();
}
set place(val) {
if (this.#place instanceof Element) {
this.#place.innerHTML = '';
}
this.#place = val;
this.#createSvg();
}
set color(val) {
if (this.#place instanceof Element) {
this.#place.innerHTML = '';
}
this.#color = val;
this.#createSvg();
}
set filter(val) {
if (this.#place instanceof Element) {
this.#place.innerHTML = '';
}
this.#filter = val;
this.#createSvg();
}
#init() {
this.#createSvg();
setTimeout(() => {
this.#animateSvg();
},Math.random() * 2000);
}
//<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200px" height="50px" viewBox="0 0 200 50" preserveAspectRatio="none">
//<linearGradient id="lg" gradientUnits="userSpaceOnUse" x1="0" y1="25" x2="200" y2="25">
// <stop offset="0" style="stop-color:#fff"/>
// <stop offset="1" style="stop-color:#aaa"/>
//</linearGradient>
// <rect fill="url(#lg)" x="22" width="70" height="50"/>
//</svg>
#createSvg() {
const linearGradientId = this.#generateRandomId();
const svgElm = document.createElementNS('http://www.w3.org/2000/svg','svg');
svgElm.setAttribute('xmlns','http://www.w3.org/2000/svg');
svgElm.setAttribute('viewBox','0 0 200 50');
svgElm.setAttribute('preserveAspectRatio','none');
svgElm.style.filter = this.#filter;
this.#linearGradient = document.createElementNS('http://www.w3.org/2000/svg','linearGradient');
this.#linearGradient.setAttribute('id',linearGradientId);
this.#linearGradient.setAttribute('gradientUnits','userSpaceOnUse');
this.#linearGradient.setAttribute('x1',0);
this.#linearGradient.setAttribute('y1',25);
this.#linearGradient.setAttribute('x2',200);
this.#linearGradient.setAttribute('y2',25);
const stop1 = document.createElementNS('http://www.w3.org/2000/svg','stop');
stop1.setAttribute('offset',0);
stop1.setAttribute('style','stop-color:' + this.#color[0]);
const stop2 = document.createElementNS('http://www.w3.org/2000/svg','stop');
stop2.setAttribute('offset',1);
stop2.setAttribute('style','stop-color:' + this.#color[1]);
this.#rect = document.createElementNS('http://www.w3.org/2000/svg','rect');
this.#rect.setAttribute('fill','url(#' + linearGradientId + ')');
this.#rect.setAttribute('x',0);
this.#rect.setAttribute('width',0);
this.#rect.setAttribute('height',50);
this.#linearGradient.appendChild(stop1);
this.#linearGradient.appendChild(stop2);
svgElm.appendChild(this.#linearGradient);
svgElm.appendChild(this.#rect);
this.#place?.appendChild(svgElm);
}
#generateRandomId(idLength = 12) {
const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
return Array.from({length:idLength}, () => characters[Math.floor(Math.random() * characters.length)]).join('');
}
#animateSvg() {
if (this.#rectX >= 200) {
this.#rectWidth = Math.random() * 30 + 40;
this.#rectX = -this.#rectWidth - (Math.random() * 50);
}
this.#rectX += this.#speed;
this.#rect.setAttribute('x',this.#rectX);
this.#rect.setAttribute('width',this.#rectWidth);
this.#linearGradient.setAttribute('x1',this.#rectX);
this.#linearGradient.setAttribute('x2',this.#rectX + this.#rectWidth);
requestAnimationFrame(() => this.#animateSvg());
}
}
このページのQRコード
便利ウェブサイト
便利 Android アプリ
便利 iOS(iPhone,iPad) アプリ