create account

Image Editor Application With Electron(Part-4) by pckurdu

View this thread on: hive.blogpeakd.comecency.com
· @pckurdu ·
$23.76
Image Editor Application With Electron(Part-4)
![image-editor.png](https://cdn.steemitimages.com/DQmexrE35uk8rQeynXZ1T4aGcG4EbBnjiarHGwe3u9DMRQ8/image-editor.png)

# Repository

### Electron GitHub Address
https://github.com/electron/electron

### My GitHub Address
https://github.com/pckurdu

### This Project GitHub Address
https://github.com/pckurdu/Image-Editor-Application-With-Electron-Part-4

# What Will I Learn?

- You will learn `ng-click` events in angularjs.
- You will learn `ng-change` events in angularjs.
- You will learn `ng-repeat` events in angularjs.
- You will learn `ng-show` events in angularjs.

# Requirements

-    basic electronjs knowledge
-    basic css knowledge
-    basic angularjs knowledge
-    <a href="https://atom.io/">Atom Editor</a>

# Difficulty

- Basic

# Tutorial Contents

In this tutorial we will continue to develop image editor application.

We have completed the installation of images into the application and we will place effect buttons to apply this tutorial to images with the help of these buttons we can edit images.

We will keep the effects in a series and set the properties on each element of the array.

We will use the `ng-repeat` feature when accessing the elements in the array. `ng-repeat` is a feature that allows rotation in more than one object. Here, we will use the ng-repeat feature according to the structure of our object.

I'll show `ng-click` for the button click event and show how to use the `ng-repeat` object in `ng-click`.

After clicking on the buttons, I will use the `html range input` to show how the `ng-show` is used.

Let's start.

### Create Buttons
We were showing the image uploaded in the `edit.html` page. I will put the picture effect buttons next to the loaded picture.
For this, let's create a div called `id=imageControl` and let's create the effects we will use in this div.
```
<div id="imageControl">
        <div class="effectType">Contrast</div>
        <div class="effectType">Invert</div>
        <div class="effectType">Brightness</div>
        <div class="effectType">Grayscale</div>
        <div class="effectType">Sepia</div>
        <div class="effectType">Blur</div>
        
</div>
```
<br>
![electron1.JPG](https://cdn.steemitimages.com/DQmZeqBgkW9UACFNHWToKEcsFcSkBTVdFnpTGq8wRAWrQJH/electron1.JPG)
<br>
We have created buttons.

I want the picture and buttons to be next to each other. I'm going to need to design the `imageControl` , `preview` and `imageEditor` divs in this `style.css` file.
```
div#imageControl,div#preview
{
    display:flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    flex-direction: row;
    flex-wrap: wrap;
}

div#imageEditor
{
    display: flex;
    flex-direction: row;
}
```
<br>
Now our application appears as follows.
![electron2.JPG](https://cdn.steemitimages.com/DQmbx7xtMAjWHkWkkhokRs9dK7Jqzv3LipLkSfrggoVuThR/electron2.JPG)
<br>
We centered image and buttons but the buttons do not look nice, but also make the user's work harder.

To solve this problem, we need to edit the `effectType` class.

In style.css
```
div.effectType
{
    width: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    align-self: stretch;
    font-size: 1.5rem;
    cursor: pointer;
}
```
<br>
Now our effects look like buttons.
![electron3.JPG](https://cdn.steemitimages.com/DQmd9jUYVMhTjzRBb2puJZeYbVf7GkfxDLwpVwRWBhJ3TPa/electron3.JPG)
<br>
### Effects With an Array
It will not be wise to use effects like this because you will need values like max and min values in the future.
Instead, we define these effects in the array with a number of properties. Thus, we increase the usage characteristics.
Let's define an array of the effects in `editCtrl`.
```
$scope.effects={
        'Contrast':{val:100,min:0,max:200,scale:'%'},
        'Invert':{val:0,min:0,max:100,scale:'%'},
        'Brightness':{val:100,min:0,max:200,scale:'%'},
        'Grayscale':{val:0,min:0,max:100,scale:'%'},
        'Sepia':{val:0,min:0,max:100,scale:'%'},
        'Blur':{val:0,min:0,max:5,scale:'px'},
    };
```
<br>
Here I have defined the `value` properties with the name of the effects. I'll check each effect with this value property in the future.

Now I can display these effect names in `imageControl` using `ng-repeat`.
```
<div class="effectType" ng-repeat="(effect,props) in effects" ng-click="imageEffect(effect)">
      {{effect}}
</div>
```
<br>
I named two variables called effect and props with `ng-repeat`. I'm holding effect names in the variable called effect, and I'm keeping properties in the called props variable.

When I gave the `ng-click` feature, these structures won the button feature exactly.

In the `ng-click` event, one function is running and taking `effect` as a parameter.

We need to define this function in `editCtrl`, and let's print the consola to see what the incoming value is.
```
  $scope.imageEffect=function(effectName){
        console.log(effectName);
    }
```
<br>
### Adding  Slider Input

When the buttons are pressed, a slider should appear and the picture should be adjusted with the slider.

When the button is clicked I want to show the slider where the buttons are.

For this, firstly, we should write the slider with the information of which button was clicked.
```
<div id="liveEffect">
     <div class="effect" ng-repeat="(effect,props) in effects">
     <div class="effectName">{{effect}}</div>
     <div class="quantity">{{props.val+props.scale}}</div>
     <div class="range-slider">
          <input type="range" class="slider-input" min="{{props.min}}" max="{{props.max}}" ng-value="props.val" ng-model="props.val" ng-change="setEffect(props.val)"/>
            </div>
     </div>
</div>
```
<br>
Here, we clicked the button to show what to write, but the problem was clicked which button was clicked.

We need to use the ng-show feature and we should just show the slider of the clicked button.
```
<div class="effect" ng-repeat="(effect,props) in effects" ng-show="effect==activeEffect">
```
<br>
If the `effect` object is equal to the `activeEffect` object, no other states to be displayed will be displayed.

In order for this query to work, we must ensure equality in `editCtrl`.
```
$scope.imageEffect=function(effectName){
        console.log(effectName);
        $scope.activeEffect=effectName;

    }
```
<br>
We defined the `ng-change` property in the slider.

With `ng-change`, we can capture the value of the slider. Each time the slider runs, the value will change with `ng-change`.

When we click on the button, we reveal the slider, but when the image is added to the application, two div also appear.
The slider should be displayed when the buttons are clicked and the buttons should not be displayed while the slider is displayed.

We define a variable called controlActive and set true when the button is clicked.
```
$scope.imageEffect=function(effectName){
        console.log(effectName);
        $scope.activeEffect=effectName;
        $scope.controlActive=true;

    }
```
<br>
Let set false when `editCtrl` is running.

In editCtrl
```
$scope.controlActive=false;
```
<br>
We can show the slider or buttons according to this variable.
```
<div id="imageControl" ng-show="!controlActive">
…
</div>
<div id="liveEffect" ng-show="controlActive">
…
</div>
```
<br>
We have added the slider but it doesn't look nice.
![electron4.JPG](https://cdn.steemitimages.com/DQmcG4hAPDY2WVmXsQ3ocwYFG9BCQoJM9zrmkuu4WemvkYh/electron4.JPG)
<br>
In `style.css` file, we need to give `liveEffect` div style.
```
div#liveEffect
{
    flex:1;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}
```
<br>
Also we will give style in the range-slider and slider-input classes.
```
.range-slider
{
    text-align: center;
    width: 100px;
}

.slider-input
{
    -webkit-appearance: none;
    width:100px;
    height: 10px;
    border-radius: 5px;
    background: #d7dfdf;
    outline: none;
    padding: 0;
    margin: 0;

}
```
<br>
Thus the final version of the application is as follows.
![gif1.gif](https://cdn.steemitimages.com/DQmb2EVsFmvTrt5tLfLJjd7hEKcCXWH3zNyNdDcP1RxoV6W/gif1.gif)
<br>

# Curriculum

https://steemit.com/utopian-io/@pckurdu/image-editor-application-with-electron-part-1

https://steemit.com/utopian-io/@pckurdu/image-editor-application-with-electron-part-2

https://steemit.com/utopian-io/@pckurdu/image-editor-application-with-electron-part-3

# Proof of Work Done

https://github.com/pckurdu/Image-Editor-Application-With-Electron-Part-4
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 32 others
properties (23)
authorpckurdu
permlinkimage-editor-application-with-electron-part-4
categoryutopian-io
json_metadata{"tags":["utopian-io","tutorials","electron","image-editor"],"image":["https://cdn.steemitimages.com/DQmexrE35uk8rQeynXZ1T4aGcG4EbBnjiarHGwe3u9DMRQ8/image-editor.png","https://cdn.steemitimages.com/DQmZeqBgkW9UACFNHWToKEcsFcSkBTVdFnpTGq8wRAWrQJH/electron1.JPG","https://cdn.steemitimages.com/DQmbx7xtMAjWHkWkkhokRs9dK7Jqzv3LipLkSfrggoVuThR/electron2.JPG","https://cdn.steemitimages.com/DQmd9jUYVMhTjzRBb2puJZeYbVf7GkfxDLwpVwRWBhJ3TPa/electron3.JPG","https://cdn.steemitimages.com/DQmcG4hAPDY2WVmXsQ3ocwYFG9BCQoJM9zrmkuu4WemvkYh/electron4.JPG","https://cdn.steemitimages.com/DQmb2EVsFmvTrt5tLfLJjd7hEKcCXWH3zNyNdDcP1RxoV6W/gif1.gif"],"links":["https://github.com/electron/electron","https://github.com/pckurdu","https://github.com/pckurdu/Image-Editor-Application-With-Electron-Part-4","https://atom.io/","https://steemit.com/utopian-io/@pckurdu/image-editor-application-with-electron-part-1","https://steemit.com/utopian-io/@pckurdu/image-editor-application-with-electron-part-2","https://steemit.com/utopian-io/@pckurdu/image-editor-application-with-electron-part-3"],"app":"steemit/0.1","format":"markdown"}
created2018-09-25 12:06:57
last_update2018-09-25 12:06:57
depth0
children4
last_payout2018-10-02 12:06:57
cashout_time1969-12-31 23:59:59
total_payout_value18.001 HBD
curator_payout_value5.759 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length8,492
author_reputation23,385,816,696,918
root_title"Image Editor Application With Electron(Part-4)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id72,223,297
net_rshares16,948,584,601,259
author_curate_reward""
vote details (96)
@portugalcoin ·
$9.27
Thank you for your contribution.
We suggest the points below:

- Your tutorial is quite short for a good tutorial. We recommend you aim for capturing at least 2-3 concepts. You've focused a lot on CSS in this tutorial.

- Nice work on the explanations of your code, although adding a bit more comments to the code can be helpful as well.

In general your tutorial is well explained and easy to understand. We hope to see more of your tutorials. Thank you.

Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/8/31311324).

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
πŸ‘  , , , , , , , , ,
properties (23)
authorportugalcoin
permlinkre-pckurdu-image-editor-application-with-electron-part-4-20180926t222546234z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"links":["https://join.utopian.io/guidelines","https://review.utopian.io/result/8/31311324","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2018-09-26 22:25:45
last_update2018-09-26 22:25:45
depth1
children1
last_payout2018-10-03 22:25:45
cashout_time1969-12-31 23:59:59
total_payout_value6.961 HBD
curator_payout_value2.308 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length947
author_reputation599,460,589,822,571
root_title"Image Editor Application With Electron(Part-4)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id72,251,049
net_rshares5,707,424,425,291
author_curate_reward""
vote details (10)
@utopian-io ·
Thank you for your review, @portugalcoin!

So far this week you've reviewed 8 contributions. Keep up the good work!
properties (22)
authorutopian-io
permlinkre-re-pckurdu-image-editor-application-with-electron-part-4-20180926t222546234z-20181002t084223z
categoryutopian-io
json_metadata"{"app": "beem/0.20.1"}"
created2018-10-02 08:42:24
last_update2018-10-02 08:42:24
depth2
children0
last_payout2018-10-09 08:42:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length115
author_reputation152,955,367,999,756
root_title"Image Editor Application With Electron(Part-4)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id72,466,373
net_rshares0
@shares ·
fossbot voter comment
Upvoted.

DISCLAIMER: Your post is upvoted based on curation algorithm configured to find good articles e.g. stories, arts, photography, health, community, etc. This is to reward you (authors) for sharing good content using the Steem platform especially newbies.

If you're a dolphin or whales, and wish not to be included in future selection, please let me know so I can exclude your account. And if you find the upvoted post is inappropriate, FLAG if you must. This will help a better selection of post.

Keep steeming good content.
@Shares - Curation Service

Posted using https://Steeming.com condenser site.
properties (22)
authorshares
permlinkre-pckurdu-image-editor-application-with-electron-part-4-20180925t124217221z
categoryutopian-io
json_metadata{}
created2018-09-25 12:42:18
last_update2018-09-25 12:42:18
depth1
children0
last_payout2018-10-02 12:42:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length621
author_reputation3,918,810,970,357
root_title"Image Editor Application With Electron(Part-4)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id72,226,270
net_rshares0
@utopian-io ·
Hey, @pckurdu!

**Thanks for contributing on Utopian**.
We’re already looking forward to your next contribution!

**Get higher incentives and support Utopian.io!**
 Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via [SteemPlus](https://chrome.google.com/webstore/detail/steemplus/mjbkjgcplmaneajhcbegoffkedeankaj?hl=en) or [Steeditor](https://steeditor.app)).

**Want to chat? Join us on Discord https://discord.gg/h52nFrV.**

<a href='https://steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
authorutopian-io
permlinkre-image-editor-application-with-electron-part-4-20181001t162316z
categoryutopian-io
json_metadata"{"app": "beem/0.20.1"}"
created2018-10-01 16:23:18
last_update2018-10-01 16:23:18
depth1
children0
last_payout2018-10-08 16:23:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length589
author_reputation152,955,367,999,756
root_title"Image Editor Application With Electron(Part-4)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id72,423,791
net_rshares0