自定义Web界面图标:修订间差异
第85行: | 第85行: | ||
<br> | <br> | ||
= | =图标格式= | ||
图标均为.PNG文件, 分辨率48x48px(像素)。你可以在其它网站中查找图标或者自己画一个。<br> | |||
图标建议使用透明背景。 | |||
推荐图标库 http://www.easyicon.net/ https://www.iconfinder.com http://www.iconspedia.com <br> | |||
请注意,大部分在线图标都有版权,请不要随意传播分发(即使是修改后)! | |||
=编辑图标描述文件= | =编辑图标描述文件= |
2017年5月27日 (六) 11:06的版本
Domoticz内置了一些图标供Web界面使用。不过,你可能希望用一些个性化图标(例如你的手机图标),此页面介绍如何实现。
#2215版开始可以上传自定义图标
你可以将你自制的图标包发送到:
domoticzicons@gmail.com
每个图标包的格式应该是一个包含以下四个文件的zip压缩包:3种不同版本/尺寸的PNG图标文件,以及图标描述文本文件,具体信息请查看下方介绍。
在创建自己的图标之前,您可能需要首先检查目前的图标在线存储库:
Domoticz Icons'
论坛中也有相关主题:
Custom Icons
自制图标
有一个非常简单的方法来创建漂亮的开关图标:
在线生成
- 本教程使用Paint.NET(基于.NET框架),只适用与windows用户,其它操作系统可以使用GIMP,当然你可以使用其它顺手的工具,比如Photoshop等。
- In this example we're going to use the Domoticz logo used on the Wiki page; DOMOTICZ_LOGO
- It's best to save the created images in a separately-created folder
- Be sure to save (CTRL + S) your image multiple times throughout the editing. This way you won't have to start all over again if something goes wrong.
1.
Download and install Paint.NET
2.
Launch the Paint.NET application
3.
Search for the correct image/icon of your choice on the internet. Most of the images are larger than the 48x48 dimensions we need. Since we probably are going to do some editing, don't pick any image smaller than 250x250. Otherwise most of the details will be lost after resizing.
4.
Open the image (Domoticz Logo)
5.
Delete the areas of the image you don't want to use. In this case the white corners.
This is easily done by using the Magic Wand tool. Just click the Magic Wand tool and then click on the white corner in the image. The entire white area is now selected. Click for Example
It's possible to select multiple items bij holding the CTRL button. You can delete a selected-area by pressing the DELETE button on your keyboard.
You can now see that the background is transparent because of the checkered pattern. If you repeat this step for all 4 corners you'll end up with only the Domoticz logo on a transparent background.
Click for Example
6.
Now we have the correct image details but still with the wrong size.
Resize the image through the resize menu; Image - Resize (CTRL + R).
Resize By absolute size. This way you can enter the exact pixels for your image; Width: 48 pixels, Height: 48 pixels.
Click the OK button; Voila! Your image has been resized.
Click for Example
7.
We can use the current image as the 'ON' image.
Save (As) the image as a .PNG file (default) and name it; domoticz48_On.png
- On the Save Configuration screen use the 'Auto-detect'
8.
Since we still have the 'ON' image opened we now can make the small image (16x16) used on your floorplan.
Again use the resize menu (CTRL + R) only this time resize the image to: Width: 16 pixels, Height: 16 pixels
Save (As) the image as a .PNG file (default) and name it; domoticz.png
9.
We now want to create the exact same 48x48 icon but it must look like an 'Off' status. The best way to do this is by making it grey style and/or adjusting the Brightness/Contrast.
Use the "History" window to go back through the editing step(s) to the point at which you are back in the 48x48 pixel image. (Or open the Domoticz48_On.png file again)
Go to the Adjustments-menu and select Black and White (CTRL + SHIFT + G)
If you are happy with the result just save (as) the image as; domoticz48_Off.png.
Otherwise you can adjust the image by using the Brightness / Contrast setting and afterwards save the image.
Click for Example
10.
Almost there; We need to create the icons.txt file.
In this case it looks as follows;
Domoticz;Domoticz;Domoticz Logo
You'll eventually end up with 4 files;
- Domoticz.png
- Domoticz48_On.png
- Domoticz48_Off.png
- icons.txt
Click for Example
11.
Final step
Add all 4 files to a ZIP file; Select all 4 files, right-click your mouse button and select: Send To - Compressed (zipped) folder.
You can now use this Zipped folder with your freshly-created logo in Domoticz by uploading it in the Setup--Custom Icon -menu.
- Note:
This is a very basic and easy-to-edit logo. If you play with the different options in Paint.NET you'll eventually start using the other selection tools, erasers, clone stamps and of course; LAYERS! It all comes down to your own creativity and imagination.
图标格式
图标均为.PNG文件, 分辨率48x48px(像素)。你可以在其它网站中查找图标或者自己画一个。
图标建议使用透明背景。
推荐图标库 http://www.easyicon.net/ https://www.iconfinder.com http://www.iconspedia.com
请注意,大部分在线图标都有版权,请不要随意传播分发(即使是修改后)!
编辑图标描述文件
图标描述文件位于/home/pi/domoticz/www/switch_icons.txt
此文件用来描述特定图标。
将新图标的描述加入最后一行。
例如新增一个名为iPhone.png的图标,描述文件如下:
Light;Light/Switch;A Lamp or Switch
WallSocket;Wall Socket;Power Wall Socket
TV;Television;Television Screen
Harddisk;Hard disk;Hard disk drive
Printer;Printer;Printer
Amplifier;Amplifier;Device that controls audio
Computer;Computer;Personal Computer System
Fan;Fan;Airflow Producer
Speaker;Speaker;Audio Speaker
Generic;Generic;Generic On/Off switch
Fireplace;Fireplace;Fireplace
Water;Water;Water
Media;Media Player;Multi Media player
Alarm;Alarm;Alarm
iPhone;iPhone;My iPhone
最后一行的'iPhone'就是新增的图标的描述文件。
第一个参数是图标文件名,第二个参数是用于显示在网页中的名字,第三个参数是图标介绍。
重启Domoticz
sudo service domoticz.sh restart
Selecting the icon you've created
When you navigate to the Domoticz web-interface, edit a switch. If you performed all the steps correctly, your custom icon(s) should now be visible!
Backup
If the icons you have made are working correctly, it is advisable to make a backup of the icons together with the modified icon-description file (switch_icons.txt). Otherwise they might be accidentally overwritten when you update Domoticz.