Initial commit
This commit is contained in:
commit
758503d33f
12 changed files with 164 additions and 0 deletions
18
.gitignore
vendored
Normal file
18
.gitignore
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Don’t commit the following directories created by pub.
|
||||
.buildlog
|
||||
.pub/
|
||||
build/
|
||||
packages
|
||||
.packages
|
||||
|
||||
# Or the files created by dart2js.
|
||||
*.dart.js
|
||||
*.js_
|
||||
*.js.deps
|
||||
*.js.map
|
||||
|
||||
# Include when developing application packages.
|
||||
pubspec.lock
|
||||
|
||||
# Ignore idea files
|
||||
.idea/
|
5
CHANGELOG.md
Normal file
5
CHANGELOG.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Changelog
|
||||
|
||||
## 0.0.1
|
||||
|
||||
- Initial version, created by Stagehand
|
2
LICENSE.md
Normal file
2
LICENSE.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
|
||||
Copyright (C) 2018
|
6
README.md
Normal file
6
README.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
# dart_floyd_steinberg_dithering
|
||||
|
||||
An absolute bare-bones web app.
|
||||
|
||||
Created from templates made available by Stagehand under a BSD-style
|
||||
[license](https://github.com/dart-lang/stagehand/blob/master/LICENSE).
|
15
analysis_options.yaml
Normal file
15
analysis_options.yaml
Normal file
|
@ -0,0 +1,15 @@
|
|||
analyzer:
|
||||
strong-mode: true
|
||||
# exclude:
|
||||
# - path/to/excluded/files/**
|
||||
|
||||
# Lint rules and documentation, see http://dart-lang.github.io/linter/lints
|
||||
linter:
|
||||
rules:
|
||||
- cancel_subscriptions
|
||||
- hash_and_equals
|
||||
- iterable_contains_unrelated_type
|
||||
- list_remove_unrelated_type
|
||||
- test_types_in_equals
|
||||
- unrelated_type_equality_checks
|
||||
- valid_regexps
|
25
pubspec.yaml
Normal file
25
pubspec.yaml
Normal file
|
@ -0,0 +1,25 @@
|
|||
name: dart_floyd_steinberg_dithering
|
||||
description: An absolute bare-bones web app.
|
||||
version: 0.0.1
|
||||
#homepage: https://www.example.com
|
||||
#author: marty <email@example.com>
|
||||
|
||||
environment:
|
||||
sdk: '>=1.20.1 <2.0.0'
|
||||
|
||||
dependencies:
|
||||
image: "^1.1.29"
|
||||
# path: ^1.4.1
|
||||
|
||||
dev_dependencies:
|
||||
browser: ^0.10.0
|
||||
dart_to_js_script_rewriter: ^1.0.1
|
||||
|
||||
transformers:
|
||||
- dart_to_js_script_rewriter
|
||||
|
||||
# Uncomment the following in sdk 1.24+ to make pub serve
|
||||
# use dartdevc (webdev.dartlang.org/tools/dartdevc).
|
||||
#web:
|
||||
# compiler:
|
||||
# debug: dartdevc
|
BIN
web/cat.png
Normal file
BIN
web/cat.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 238 KiB |
BIN
web/favicon.ico
Normal file
BIN
web/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
21
web/index.html
Normal file
21
web/index.html
Normal file
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="scaffolded-by" content="https://github.com/google/stagehand">
|
||||
<title>dart_floyd_steinberg_dithering</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
<link rel="icon" href="favicon.ico">
|
||||
<script defer src="main.dart" type="application/dart"></script>
|
||||
<script defer src="packages/browser/dart.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<canvas id="input" width="712" height="470"></canvas>
|
||||
|
||||
<canvas id="output" width="712" height="470"></canvas>
|
||||
</body>
|
||||
</html>
|
BIN
web/kitten.jpg
Normal file
BIN
web/kitten.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
56
web/main.dart
Normal file
56
web/main.dart
Normal file
|
@ -0,0 +1,56 @@
|
|||
import 'dart:html';
|
||||
import 'package:image/image.dart';
|
||||
|
||||
CanvasElement input;
|
||||
CanvasElement output;
|
||||
|
||||
ImageElement inputImg;
|
||||
|
||||
void main() {
|
||||
inputImg = new ImageElement(src: 'kitten.jpg', width: 712, height: 470);
|
||||
|
||||
input = document.querySelector('#input');
|
||||
print(input);
|
||||
inputImg.onLoad.listen(imgLoaded);
|
||||
|
||||
output = document.querySelector('#output');
|
||||
|
||||
output.context2D.fillRect(0, 0, output.width, output.height);
|
||||
}
|
||||
|
||||
void imgLoaded(Event e) {
|
||||
print("image loaded");
|
||||
input.context2D.drawImage(inputImg, 0, 0);
|
||||
|
||||
Image outputImg = editImage( getImageFromCanvas(input) );
|
||||
|
||||
drawImageToCanvas(output, outputImg ) ;
|
||||
}
|
||||
|
||||
Image getImageFromCanvas(CanvasElement input) {
|
||||
ImageData data = input.context2D.getImageData(0, 0, input.width, input.height);
|
||||
return new Image.fromBytes(input.width, input.height, data.data);
|
||||
}
|
||||
|
||||
void drawImageToCanvas(CanvasElement canvas, Image image) {
|
||||
var imageData = canvas.context2D.createImageData(image.width, image.height);
|
||||
imageData.data.setRange(0, imageData.data.length, image.getBytes());
|
||||
|
||||
canvas.context2D.putImageData(imageData, 0, 0);
|
||||
}
|
||||
|
||||
Image editImage(Image image) {
|
||||
|
||||
|
||||
image = contrast( image, 200);
|
||||
|
||||
for (var y = 0; y < image.height; y++) {
|
||||
for (var x = 0; x < image.width; x++) {
|
||||
// print(image.getPixel(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return image;
|
||||
}
|
16
web/styles.css
Normal file
16
web/styles.css
Normal file
|
@ -0,0 +1,16 @@
|
|||
@import url(https://fonts.googleapis.com/css?family=Roboto);
|
||||
|
||||
html, body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
background: gainsboro;
|
||||
}
|
||||
|
||||
canvas {
|
||||
padding: 00px;
|
||||
text-align: center;
|
||||
}
|
||||
|
Loading…
Reference in a new issue