js+css实现图片转成ASCII码艺术效果代码
代码语言:html
所属分类:其他
代码描述:js+css实现图片转成ASCII码艺术效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
body {
margin: 0;
font-family: system-ui, sans-serif;
background-color: #000; /* Dark theme by default */
color: #eee;
}
.layout {
display: flex;
height: 100vh;
}
/* Increase sidebar width to fit labels and numeric values */
.sidebar {
width: 380px;
flex-shrink: 0;
background: #111; /* Matches dark theme */
color: #eee;
padding: 20px;
box-sizing: border-box;
overflow-y: auto;
position: fixed;
top: 0;
bottom: 0;
left: 0;
}
.sidebar h3 {
margin: 10px 0;
font-size: 1.1rem;
}
.control-group {
margin-bottom: 20px;
border-bottom: 1px solid #666;
padding-bottom: 10px;
}
.control-group:last-of-type {
border-bottom: none;
}
.control {
display: flex;
align-items: center;
margin: 8px 0;
}
.control label {
flex: 0 0 150px;
margin-right: 10px;
font-size: 0.9rem;
white-space: nowrap;
}
.control input[type="range"],
.control select,
.control input[type="text"] {
flex: 1;
}
.value-label {
display: inline-block;
width: 40px;
text-align: center;
margin-left: 8px;
font-size: 0.9rem;
}
.main-content {
flex: 1;
margin-left: 380px;
padding: 20px;
overflow-y: auto;
background: #000;
color: #eee;
box-sizing: border-box;
}
#ascii-art {
background: #000;
padding: 10px;
white-space: pre;
font-family: Consolas, Monaco, "Liberation Mono", monospace;
font-size: 7px;
line-height: 7px;
}
button {
margin-right: 10px;
padding: 5px 10px;
}
body.light-mode {
background-color: #fff;
color: #000;
}
body.light-mode .sidebar {
background: #F4F4F4;
color: #000;
}
body.light-mode .main-content {
background: #fff;
color: #000;
}
body.light-mode #ascii-art {
background: #fff;
}
</style>
</head>
<body translate="no">
<div class="layout">
<aside class="sidebar">
<section class="control-group global-settings">
<h3>Global Settings</h3>
<div class="control">
<label for="theme">Theme:</label>
<select id="theme">
<option value="dark" selected>Dark</option>
<option value="light">Light</option>
</select>
</div>
<div class="control">
<label for="ignoreWhite">Ignore Pure White:</label>
<input type="checkbox" id="ignoreWhite" checked>
</div>
</section>
<section class="control-group upload-group">
<h3>1. Upload Your File</h3>
<div class="control">
<input type="file" id="upload" accept="image/*">
</div>
</section>
<section class="control-group image-processing">
<h3>2. Basic Adjustments</h3>
<div class="control">
<label for="asciiWidth">Output Width (chars):</label>
<input type="range" id="asciiWidth" min="20" max="300" value="150">
<span class="value-label" id="asciiWidthVal">100</span>
</div>
<div class="control">
<label for="brightness">Brightness:</label>
<input type="range" id="brightness" min="-100" max="100" value="0">
<span class="value-label" id="brightnessVal">0</span>
</div>
<div class="control">
<label for="contrast">Contrast:</label>
<input type="range" id="contrast" min="-100" max="100" value="0">
<span class="value-label" id="contrastVal">0</span>
</div>
<div class="control">
<label for="blur">Blur (px):</label>
<input type="range" id="blur" min="0" max="10" step="0.01" value="0">
<span class="value-label" id="blurVal">0</span>
</div>
<div class="control">
<label for="invert">Invert Colors:</label>
<input type="checkbox" id="invert">
</div>
</section>
<section class="control-group dithering-settings">
<h3>3. Dithering Options</h3>
<div class="control">
<label for="dithering">Enable Dithering:</label>
<input type="checkbox" id="dithering" checked>
</div>
<div class="control">
<label for="ditherAlgorithm">Dither Algorithm:</label>
<select id="ditherAlgorithm">
<option value="floyd" selected>Floyd–Steinberg</option>
<option value="atkinson">Atkinson</option>
<option value="noise">Noise</option>
<option value="ordered">Ordered</option>
</select>
</div>
</section>
<section class="control-group charset-settings">
<h3>4. Character Set</h3>
<div class="control">
<label for="charset">Select Set:</label>
<select id="charset">
<option value="detailed" selected>Detailed</option&g.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0