2
0

prepared library publishing

This commit is contained in:
2018-08-31 15:05:12 +02:00
parent da36b71b2c
commit 04b049f39f
24 changed files with 82 additions and 175 deletions

View File

@@ -1,5 +1,5 @@
{
"name": "nls-guilloche",
"name": "nls-guilloche-generator",
"version": "0.2.0",
"repository": {
"type": "git",

View File

@@ -26,6 +26,9 @@
"url": "https://dailysh.it"
}
],
"dependencies": {
"d3": "^5.3.0"
},
"peerDependencies": {
"@angular/common": "^6.0.0-rc.0 || ^6.0.0",
"@angular/core": "^6.0.0-rc.0 || ^6.0.0"

View File

@@ -14,7 +14,7 @@
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { ElementRef, HostListener, Output, EventEmitter, Input, Directive, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
import { ElementRef, HostListener, Input, Directive, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
import * as Selection from 'd3-selection';
import * as Shape from 'd3-shape';
import * as Random from 'd3-random';
@@ -22,22 +22,20 @@ import * as Drag from 'd3-drag';
import * as Ease from 'd3-ease';
import * as Timer from 'd3-timer';
import { environment as env } from './../../environments/environment';
import { Config } from './../models/config.model';
import { Graph } from './../models/graph.model';
import { Point } from './../models/point.model';
import { Param } from './../models/param.model';
import { CanvasService } from './../services/canvas.service';
import { MathService } from './../services/math.service';
import { GraphService } from '../services/graph.service';
import { AnimationService } from './../services/animation.service';
import { NlsCanvasService } from './../services/canvas.service';
import { NlsMathService } from './../services/math.service';
import { NlsGraphService } from '../services/graph.service';
const ANIMATION_INTERVAL = 60;
@Directive({
selector: '[guilloche]'
selector: '[nlsGuilloche]'
})
export class GuillocheDirective implements OnChanges, OnDestroy {
export class NlsGuillocheDirective implements OnChanges, OnDestroy {
private canvas: any;
private group: any;
@@ -55,14 +53,11 @@ export class GuillocheDirective implements OnChanges, OnDestroy {
@Input() config: any;
@Input() animate: boolean;
@Output() guillocheChange = new EventEmitter();
constructor(
private canvasService: CanvasService,
private canvasService: NlsCanvasService,
private el: ElementRef,
private math: MathService,
private graphService: GraphService,
private animationService: AnimationService
private math: NlsMathService,
private graphService: NlsGraphService
) {
}
@@ -121,7 +116,6 @@ export class GuillocheDirective implements OnChanges, OnDestroy {
this.graph.end.direction,
this.graph.end.point,
]).forEach((points, index) => this.drawGraph(points));
this.guillocheChanged();
}
private animateGraph(x) {
@@ -160,12 +154,6 @@ export class GuillocheDirective implements OnChanges, OnDestroy {
.x(p => p.x)
.y(p => p.y)
.curve(Shape.curveBasis)(points));
// if (env.debug) {
// this.group.selectAll('circle').remove();
// this.group.selectAll('text').remove();
// // this.debugGraph(points);
// }
}
private drawGraph(points: Point[]): void {
@@ -180,14 +168,6 @@ export class GuillocheDirective implements OnChanges, OnDestroy {
.x(p => p.x)
.y(p => p.y)
.curve(Shape.curveBasis)(points)));
if (env.debug) {
this.debugGraph(points);
}
}
public guillocheChanged() {
this.guillocheChange.emit(this.el.nativeElement);
}
private debugGraph(points: Point[]) {
@@ -210,15 +190,4 @@ export class GuillocheDirective implements OnChanges, OnDestroy {
.text(index);
});
}
private debugBounce(point: Point): void {
if (env.debug) {
this.group.append('circle')
.attr('cx', point.x)
.attr('cy', point.y)
.attr('r', 2)
.attr('fill-opacity', 0.4)
.attr('fill', 'darkgray');
}
}
}

View File

@@ -1,25 +0,0 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NlsGuillocheComponent } from './nls-guilloche.component';
describe('NlsGuillocheComponent', () => {
let component: NlsGuillocheComponent;
let fixture: ComponentFixture<NlsGuillocheComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ NlsGuillocheComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(NlsGuillocheComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,19 +0,0 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'lib-nls-guilloche',
template: `
<p>
nls-guilloche works!
</p>
`,
styles: []
})
export class NlsGuillocheComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}

View File

@@ -1,10 +0,0 @@
import { NgModule } from '@angular/core';
import { NlsGuillocheComponent } from './nls-guilloche.component';
@NgModule({
imports: [
],
declarations: [NlsGuillocheComponent],
exports: [NlsGuillocheComponent]
})
export class NlsGuillocheModule { }

View File

@@ -1,15 +0,0 @@
import { TestBed, inject } from '@angular/core/testing';
import { NlsGuillocheService } from './nls-guilloche.service';
describe('NlsGuillocheService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [NlsGuillocheService]
});
});
it('should be created', inject([NlsGuillocheService], (service: NlsGuillocheService) => {
expect(service).toBeTruthy();
}));
});

View File

@@ -1,9 +0,0 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class NlsGuillocheService {
constructor() { }
}

View File

@@ -19,11 +19,11 @@ import { interval, Observable } from 'rxjs';
import * as Selection from 'd3-selection';
import { Graph } from '../models/graph.model';
import { MathService } from './math.service';
import { HistoryService } from './history.service';
import { NlsMathService } from './math.service';
import { NlsHistoryService } from './history.service';
@Injectable()
export class AnimationService {
export class NlsAnimationService {
public graphs: Graph[];
public speed: number;
@@ -33,8 +33,8 @@ export class AnimationService {
// private subscribtion: any;
constructor(
private math: MathService,
private historyService: HistoryService,
private math: NlsMathService,
private historyService: NlsHistoryService,
) {
}

View File

@@ -18,7 +18,7 @@ import { Inject, Injectable, Renderer2, RendererFactory2 } from '@angular/core';
import * as Selection from 'd3-selection';
@Injectable()
export class CanvasService {
export class NlsCanvasService {
private renderer: Renderer2;
public canvas: any;

View File

@@ -18,17 +18,17 @@ import { Validators } from '@angular/forms';
import { Inject, Injectable, Renderer2, RendererFactory2 } from '@angular/core';
import * as Selection from 'd3-selection';
import { MathService } from './math.service';
import { NlsMathService } from './math.service';
import { Graph } from './../models/graph.model';
import { Point } from './../models/point.model';
@Injectable()
export class GraphService {
export class NlsGraphService {
private graphs: Graph[];
private animation: boolean | null;
constructor(
private math: MathService
private math: NlsMathService
) {}
public get() {

View File

@@ -20,7 +20,7 @@ import * as Selection from 'd3-selection';
import { Graph } from '../models/graph.model';
@Injectable()
export class HistoryService {
export class NlsHistoryService {
public history: any[];

View File

@@ -22,7 +22,7 @@ import { Point } from './../models/point.model';
import { Graph } from './../models/graph.model';
@Injectable()
export class MathService {
export class NlsMathService {
/**
* Calculate distance between to points with coordinates.

View File

@@ -2,6 +2,13 @@
* Public API Surface of nls-guilloche
*/
export * from './lib/nls-guilloche.service';
export * from './lib/nls-guilloche.component';
export * from './lib/nls-guilloche.module';
export * from './lib/directives/guilloche.directive';
export * from './lib/models/config.model';
export * from './lib/models/graph.model';
export * from './lib/models/param.model';
export * from './lib/models/point.model';
export * from './lib/services/animation.service';
export * from './lib/services/canvas.service';
export * from './lib/services/graph.service';
export * from './lib/services/history.service';
export * from './lib/services/math.service';

View File

@@ -18,18 +18,16 @@ import { ConfigForm } from './forms/config.form';
import { Component, OnInit, HostListener } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
// import { Moment } from 'moment';
import * as moment from 'moment';
import 'moment/min/locales';
import { environment as env } from '../environments/environment';
import { Param } from './models/param.model';
import { Config } from './models/config.model';
import { CanvasService } from './services/canvas.service';
import { HistoryService } from './services/history.service';
import { Graph } from './models/graph.model';
import { GraphService } from './services/graph.service';
import { AnimationService } from './services/animation.service';
import { Param } from './../../projects/nls-guilloche/src/lib/models/param.model';
import { Config } from './../../projects/nls-guilloche/src/lib/models/config.model';
import { Graph } from './../../projects/nls-guilloche/src/lib/models/graph.model';
import { NlsCanvasService } from './../../projects/nls-guilloche/src/lib/services/canvas.service';
import { NlsHistoryService } from './../../projects/nls-guilloche/src/lib/services/history.service';
import { NlsGraphService } from './../../projects/nls-guilloche/src/lib/services/graph.service';
@Component({
selector: 'app-root',
@@ -48,9 +46,9 @@ export class AppComponent implements OnInit {
public animationActive: boolean;
constructor(
private canvasService: CanvasService,
private historyService: HistoryService,
private graphService: GraphService,
private canvasService: NlsCanvasService,
private historyService: NlsHistoryService,
private graphService: NlsGraphService,
) {
moment.locale('de');

View File

@@ -22,18 +22,18 @@ import { MomentModule } from 'ngx-moment';
import { AppComponent } from './app.component';
import { GraphsComponent } from './components/graphs.component';
import { GuillocheDirective } from './directives/guilloche.directive';
import { CanvasService } from './services/canvas.service';
import { HistoryService } from './services/history.service';
import { AnimationService } from './services/animation.service';
import { MathService } from './services/math.service';
import { GraphService } from './services/graph.service';
import { NlsGuillocheDirective } from './../../projects/nls-guilloche/src/lib/directives/guilloche.directive';
import { NlsCanvasService } from './../../projects/nls-guilloche/src/lib/services/canvas.service';
import { NlsHistoryService } from './../../projects/nls-guilloche/src/lib/services/history.service';
import { NlsAnimationService } from './../../projects/nls-guilloche/src/lib/services/animation.service';
import { NlsMathService } from './../../projects/nls-guilloche/src/lib/services/math.service';
import { NlsGraphService } from './../../projects/nls-guilloche/src/lib/services/graph.service';
@NgModule({
declarations: [
AppComponent,
GraphsComponent,
GuillocheDirective
NlsGuillocheDirective
],
imports: [
BrowserModule,
@@ -43,11 +43,11 @@ import { GraphService } from './services/graph.service';
MomentModule,
],
providers: [
CanvasService,
HistoryService,
AnimationService,
MathService,
GraphService,
NlsCanvasService,
NlsHistoryService,
NlsAnimationService,
NlsMathService,
NlsGraphService,
],
bootstrap: [AppComponent]
})

View File

@@ -1,6 +1,6 @@
<svg #svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg"
version="1.1" shape-rendering="geometricPrecision">
<g guilloche [graph]="graphs[0]" [matrix]="matrix" [config]="config" [animate]="true" (guillocheChange)="prepareGuillocheExport($event)"></g>
<g guilloche [graph]="graphs[1]" [matrix]="matrix" [config]="config" [animate]="true" (guillocheChange)="prepareGuillocheExport($event)"></g>
<!-- <g guilloche *ngFor="let graph of graphs" [graph]="graph" [matrix]="matrix" [config]="config" [animate]="true" (guillocheChange)="prepareGuillocheExport($event)"></g> -->
<g nlsGuilloche [graph]="graphs[0]" [matrix]="matrix" [config]="config" [animate]="true"></g>
<g nlsGuilloche [graph]="graphs[1]" [matrix]="matrix" [config]="config" [animate]="true"></g>
<!-- <g nlsGuilloche *ngFor="let graph of graphs" [graph]="graph" [matrix]="matrix" [config]="config" [animate]="true"></g> -->
</svg>

Before

Width:  |  Height:  |  Size: 597 B

After

Width:  |  Height:  |  Size: 453 B

View File

@@ -14,9 +14,9 @@
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
svg {
// opacity: 0.4;
}
// svg {
// // opacity: 0.4;
// }
// svg {
// stroke-dasharray: 1000px;

View File

@@ -22,14 +22,13 @@ import * as Random from 'd3-random';
import * as Drag from 'd3-drag';
import { environment as env } from '../../environments/environment';
import { CanvasService } from './../services/canvas.service';
import { HistoryService } from './../services/history.service';
import { AnimationService } from '../services/animation.service';
import { MathService } from '../services/math.service';
import { GuillocheDirective } from './../directives/guilloche.directive';
import { Graph } from '../models/graph.model';
import { Point } from '../models/point.model';
import { GraphService } from '../services/graph.service';
import { Graph } from './../../../projects/nls-guilloche/src/lib/models/graph.model';
import { Point } from './../../../projects/nls-guilloche/src/lib/models/point.model';
import { NlsCanvasService } from './../../../projects/nls-guilloche/src/lib/services/canvas.service';
import { NlsHistoryService } from './../../../projects/nls-guilloche/src/lib/services/history.service';
import { NlsMathService } from './../../../projects/nls-guilloche/src/lib/services/math.service';
import { NlsGuillocheDirective } from './../../../projects/nls-guilloche/src/lib/directives/guilloche.directive';
import { NlsGraphService } from './../../../projects/nls-guilloche/src/lib/services/graph.service';
@Component({
selector: 'app-graphs',
@@ -63,11 +62,10 @@ export class GraphsComponent implements OnChanges, OnInit {
}
constructor(
private canvasService: CanvasService,
private historyService: HistoryService,
private animationService: AnimationService,
private math: MathService,
private graphService: GraphService
private canvasService: NlsCanvasService,
private historyService: NlsHistoryService,
private math: NlsMathService,
private graphService: NlsGraphService
) {
this.genLoadedAllGraphs = this.countLoadedGraphs();
this.timer = interval(500);

View File

@@ -4288,6 +4288,10 @@ mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0:
dependencies:
minimist "0.0.8"
moment@^2.22.2:
version "2.22.2"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.2.tgz#3c257f9839fc0e93ff53149632239eb90783ff66"
move-concurrently@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92"
@@ -4394,6 +4398,12 @@ ng-packagr@^3.0.0-rc.2:
uglify-js "^3.0.7"
update-notifier "^2.3.0"
ngx-moment@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/ngx-moment/-/ngx-moment-3.1.0.tgz#41380b4dd8b68e7bd6d17cc6fe7f703ae506dc3a"
dependencies:
tslib "^1.9.0"
no-case@^2.2.0:
version "2.3.2"
resolved "https://registry.yarnpkg.com/no-case/-/no-case-2.3.2.tgz#60b813396be39b3f1288a4c1ed5d1e7d28b464ac"