Skip to content

Commit

Permalink
optimize controls
Browse files Browse the repository at this point in the history
  • Loading branch information
dronperminov committed Jun 21, 2022

Verified

This commit was signed with the committer’s verified signature.
Jeffail Ashley Jeffs
1 parent 30e93a0 commit d15afbb
Showing 2 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions js/init.js
Original file line number Diff line number Diff line change
@@ -36,17 +36,17 @@ StringArtGenerator.prototype.InitControls = function() {
this.controlsBox = document.getElementById('controls-box')

this.formTypeBox = document.getElementById('form-type-box')
this.formTypeBox.addEventListener('change', () => this.Reset(false))
this.formTypeBox.addEventListener('change', () => this.DrawLoadedImage())

this.contrastBox = document.getElementById('contrast-box')
this.contrastValue = document.getElementById('contrast-value')
this.contrastBox.addEventListener('change', () => { this.UpdateContrast(); this.DrawLoadedImage() })
this.contrastBox.addEventListener('input', () => this.UpdateContrast())
this.contrastBox.addEventListener('change', () => this.DrawLoadedImage())

this.brightnessBox = document.getElementById('brightness-box')
this.brightnessValue = document.getElementById('brightness-value')
this.brightnessBox.addEventListener('change', () => { this.UpdateBrightness(); this.DrawLoadedImage() })
this.brightnessBox.addEventListener('input', () => this.UpdateBrightness())
this.brightnessBox.addEventListener('change', () => this.DrawLoadedImage())

this.nailsCountBox = document.getElementById('nails-count-box')
this.linesCountBox = document.getElementById('lines-count-box')
16 changes: 11 additions & 5 deletions js/string_art_generator.js
Original file line number Diff line number Diff line change
@@ -153,15 +153,21 @@ StringArtGenerator.prototype.Reset = function(needResetImage = true) {
this.infoBox.innerHTML = ''
this.isGenerating = false
this.isLineDrawing = false
this.sequence = []

for (let control of this.controls)
control.removeAttribute('disabled')

this.generateBtn.removeAttribute('disabled')

this.DrawLoadedImage()
}

StringArtGenerator.prototype.StartGenerate = function(){
this.Reset(false)
StringArtGenerator.prototype.StartGenerate = function() {
this.saveBox.style.display = 'none'
this.infoBox.innerHTML = ''
this.sequence = []

this.DrawLoadedImage()

this.isLineDrawing = true
this.isGenerating = true
@@ -176,8 +182,8 @@ StringArtGenerator.prototype.EndGenerate = function() {
this.saveBox.style.display = ''
this.isGenerating = false

for (let control of this.controls)
control.removeAttribute('disabled')
this.resetBtn.removeAttribute('disabled')
this.selectBtn.removeAttribute('disabled')
}

StringArtGenerator.prototype.GenerateIteration = function(nail, linesCount, pixels, lineWeight, startTime) {

0 comments on commit d15afbb

Please sign in to comment.