tailwind自定义 Web 组件将文本转换为可配置的 SVG 手绘手写文字效果代码

代码语言:html

所属分类:其他

代码描述:tailwind自定义 Web 组件将文本转换为可配置的 SVG 手绘手写文字效果代码

代码标签: tailwind 自定义 Web 组件 文本 转换 配置 SVG 手绘 文字 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >
<head>
 
<meta charset="UTF-8">

<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/tailwindcss.3.4.3.js"></script>
</head>
<body class="bg-gray-50 p-4">
 
<div class="max-w-2xl mx-auto">
                 
<div class="text-center">
     
<h1 class="text-3xl font-bold text-gray-900 mb-3">&lt;scribble-text&gt;</h1>
     
<p class="text-lg text-gray-600 mb-2">A Custom Element for Generating SVG Text Scribbles</p>
     
<div class="prose max-w-none text-sm text-gray-600 bg-white rounded-lg p-4 border border-gray-200">
       
<p class="font-medium mb-2">TL;DR:</p>
       
<p>A Web Component that converts text into randomized, configurable SVG "scribbles" that mimic handwritten text. Created through a conversation between Claude and Netsi1964, who prompted the development of a component that could render text as SVG with adjustable parameters like font size, weight, and wiggle factor. The component separates rendering logic from UI, making it flexible for various use cases.</p>
       
<p class="text-xs mt-2 text-gray-500">Created: October 2024 | Prompted by: Netsi1964</p>
     
</div>
   
</div>
   
<!-- Main Container -->
   
<div class="bg-white rounded-lg shadow p-6">
     
<!-- Text Input -->
     
<textarea
       
id="text-input"
       
class="w-full p-3 mb-4 border border-gray-200 rounded-lg h-24 focus:border-blue-500 focus:ring-2 focus:ring-blue-200 outline-none transition-all"
       
placeholder="Type something... (use Enter for new lines)"
     
>Hello world&#13;&#10;This is a new line</textarea>
     
     
<!-- Controls Grid -->
     
<div class="grid grid-cols-2 gap-4 mb-4">
       
<!-- Font Size -->
       
<div class="space-y-1">
         
<label class="block text-sm text-gray-600">Font Size (<span id="fontSize-value">24</span>px)</label>
         
<input
           
type="range"
           
id="font-size"
           
min="12"
           
max="48"
           
value="24"
           
class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-blue-500"
         
>
       
</div>

       
<!-- Font Weight -->
       
<div class="space-y-1">
         
<label class="block text-sm text-gray-600">Font Weight (<span id="fontWeight-value">400</span> - <span id="fontWeight-label">Regular</span>)</label>
         
<input
           
type="range"
           
id="font-weight"
           
min="100"
           
max="900"
           
step="100"
           
value="400"
           
class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-blue-500"
         
>
         
<!-- Weight Presets -->
          <div class="flex flex-wrap gap-2 mt-2" id="weig.........完整代码请登录后点击上方下载按钮下载查看

网友评论0