Skip to content

Commit 4404e3a

Browse files
committed
Complete software
1 parent 9146820 commit 4404e3a

File tree

8 files changed

+201
-0
lines changed

8 files changed

+201
-0
lines changed

Css-VisualSize_Calculator.py

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
import time
2+
import os
3+
4+
class ViewportSize:
5+
def __init__(self,vwMax,vhMax):
6+
self.VwMax = float(vwMax)
7+
self.VhMax = float(vhMax)
8+
def FixedToViewport_width(self,width):
9+
viewportWidth = float(width) / self.VwMax
10+
viewportWidth = str(viewportWidth)
11+
viewportWidth_list = viewportWidth.split('.')
12+
viewportWidth_backup = ""
13+
digit = 0
14+
for number in viewportWidth_list[1]:
15+
if (len(viewportWidth_list[1]) == 1):
16+
number += "0"
17+
if (len(viewportWidth_list[1]) > 4):
18+
if (int(viewportWidth_list[1][4]) > 6 and digit == 3):
19+
number = str(int(number) + 1)
20+
viewportWidth_backup += number
21+
if (digit == 1):
22+
viewportWidth_backup += "."
23+
if(digit == 3):
24+
break
25+
digit += 1
26+
return viewportWidth_backup
27+
def FixedToViewport_height(self,height):
28+
viewportHeight = float(height) / self.VhMax
29+
viewportHeight = str(viewportHeight)
30+
viewportHeight_list = viewportHeight.split('.')
31+
viewportHeight_backup = ""
32+
digit = 0
33+
for number in viewportHeight_list[1]:
34+
if(len(viewportHeight_list[1]) == 1):
35+
number += "0"
36+
if(len(viewportHeight_list[1]) > 4):
37+
if (int(viewportHeight_list[1][4]) > 6 and digit == 3):
38+
number = str(int(number) + 1)
39+
viewportHeight_backup += number
40+
if(digit == 1):
41+
viewportHeight_backup += "."
42+
if(digit == 3):
43+
break
44+
return viewportHeight_backup
45+
46+
def Speaker(sentence,pause=1):
47+
print(sentence)
48+
time.sleep(pause)
49+
50+
def LogoPrinter():
51+
print("_________ ____ ____.__ .__ _________.__ _________ .__ .__ __ ")
52+
print("\_ ___ \ ______ ______ \ \ / /|__| ________ _______ | | / _____/|__|_______ ____ \_ ___ \_____ | | ____ __ __| | _____ _/ |_ ___________ ")
53+
print("/ \ \/ / ___// ___/ \ Y / | |/ ___/ | \__ \ | | \_____ \ | \___ // __ \ / \ \/\__ \ | | _/ ___\| | \ | \__ \\ __\/ _ \_ __ ")
54+
print("\ \____\___ \ \___ \ \ / | |\___ \| | // __ \| |__/ \| |/ /\ ___/ \ \____/ __ \| |_\ \___| | / |__/ __ \| | ( <_> ) | \/")
55+
print(" \______ /____ >____ > \___/ |__/____ >____/(____ /____/_______ /|__/_____ \\___ > \______ (____ /____/\___ >____/|____(____ /__| \____/|__| ")
56+
print(" \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ ")
57+
58+
def Helper():
59+
Speaker("1. Firstly, you must set the max values of viewport width and viewport height by cmd:")
60+
Speaker(" set <maxValue:fixedWidth> <maxValue:fixedHeight>")
61+
Speaker("2. And then, you will enter the workspace, calculate and get the result by cmd:")
62+
Speaker(" w<value:fixedWidth> - FixedWidth to viewportWidth")
63+
Speaker(" h<value:fixedHeight> - FixedHeight to viewportHeight")
64+
Speaker("3. Also ,you can back to the first step by cmd:")
65+
Speaker(" r or return")
66+
Speaker("4. Exit the software by cmd:")
67+
Speaker(" x or exit")
68+
Speaker("Attention!!! Don't input the value with unit.")
69+
Speaker("\nNext, an example is used to demonstrate the animation to show the process of a solution:",2)
70+
Speaker("You: Input << set 1440 1024")
71+
Speaker("Output >> You have entered the workspace, please begin your calculating work.")
72+
Speaker("You: Input << w144")
73+
Speaker("Output >> 10vw")
74+
Speaker("You: Input << h102.4")
75+
Speaker("Output >> 10vh")
76+
Speaker("You can copy the result to somewhere you need.")
77+
Speaker("You: Input << return")
78+
Speaker("Output >> You have came out the workspace, please reset the max values of viewport width and viewport height.")
79+
Speaker("You: Input << 428 926")
80+
Speaker("...")
81+
Speaker("Understand? So, let you start the work.")
82+
83+
def main():
84+
LogoPrinter()
85+
time.sleep(0.5)
86+
Speaker("This is a light tool for convert fixed size to viewport size conveniently in web pages design of Css.",0.5)
87+
Speaker("Copyright (C) 2022 leoweyr",0.5)
88+
Speaker("Using the software for the first time?Get help by cmd: help or ?",0.5)
89+
workspace = 0
90+
while True:
91+
argv = input("Css ViewportSize Calculator>")
92+
if(argv == "help" or argv == "?"):
93+
Helper()
94+
elif(argv[0:3] == "set"):
95+
argv_list = argv.split(" ")
96+
viewportSize = ViewportSize(argv_list[1],argv_list[2])
97+
workspace = 1
98+
Speaker("You have entered the workspace, please begin your calculating work.")
99+
elif(argv == "x" or argv == "exit"):
100+
os._exit(0)
101+
else:
102+
Speaker("Need help?Get help by cmd: help or ?",0.5)
103+
if (workspace == 1):
104+
while True:
105+
argv = input("Workspace fixedMax[Width:" + str(viewportSize.VwMax) + "|Height:" + str(viewportSize.VhMax) + "]>")
106+
if(argv[0] == "w"):
107+
if(float(argv[1:]) > viewportSize.VwMax):
108+
Speaker("Oops! The value have been larger than the max of fixed width.")
109+
else:
110+
print(viewportSize.FixedToViewport_width(argv[1:]) + "vw")
111+
elif(argv[0] == "h"):
112+
if (float(argv[1:]) > viewportSize.VhMax):
113+
Speaker("Oops! The value have been larger than the max of fixed width.")
114+
else:
115+
print(viewportSize.FixedToViewport_height(argv[1:]) + "vh")
116+
elif(argv == "r" or argv == "return"):
117+
print("You have came out the workspace, please reset the max values of viewport width and viewport height.")
118+
return False
119+
elif (argv == "x" or argv == "exit"):
120+
os._exit(0)
121+
elif(argv == "help" or argv == "?"):
122+
Helper()
123+
else:
124+
Speaker("Need help?Get help by cmd: help or ?", 0.5)
125+
126+
if (__name__ == '__main__'):
127+
main()

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Css-VisualSize_Calculator - Converts fixed size to viewport size by lite way for web design aids.
2+
3+
![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/leoweyr/Css-VisualSize_Calculator?include_prereleases)
4+
5+
##### English | [简体中文](README_zh-cn.md)
6+
7+
Do you have the same confusion as me? That is, when numerical processing is performed in Css web design, the fixed size is calculated as the viewport size, and use the `Calculator` software to tap the symbols one by one **it feels very hard to pinch**, even with full keyboard operations such as `Powershell`, some **steps are redundant**.
8+
9+
![problem](assets/problem.png)
10+
11+
But now you can say goodbye to the frustrating times of the past!
12+
13+
14+
15+
## 💎Advantage
16+
17+
- Pure command line interface & full keyboard operation
18+
19+
![advantage1](assets/advantage1.png)
20+
21+
- The maximum value of the viewport size is preset in advance, not need to repeatedly substitute
22+
23+
![advantage2](assets/advantage2.png)
24+
25+
- More direct numerical input
26+
27+
![advantage3](assets/advantage3.png)
28+
29+
- Copy and paste the formatted result where you need it
30+
31+
![advantage4](assets/advantage4.png)
32+
33+
34+
35+
## 🤝Help
36+
37+
Type `help` or `?` in ` Css-VisualSize_Calculator` for **full and friendly help**.

README_zh-cn.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Css视窗尺寸计算器 - 将固定尺寸转化成视窗尺寸的网页设计辅助轻量工具
2+
3+
![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/leoweyr/Css-VisualSize_Calculator?include_prereleases)
4+
5+
##### [English](README.md) | 简体中文
6+
7+
您是否和我一样有同一个困惑?就是在Css网页设计中进行数值处理时,将固定尺寸计算成视窗尺寸,使用`计算器`软件一个个符号去敲**感觉很别捏**,就算使用`Powershell`等全键盘操作进行计算还是有些**步骤显得重复冗余**
8+
9+
![problem](assets/problem.png)
10+
11+
但现在您可以跟过去憋屈的时代告别啦!
12+
13+
14+
15+
## 💎优势
16+
17+
- 纯命令行界面 & 全键盘操作
18+
19+
![advantage1](assets/advantage1.png)
20+
21+
- 预先设定视窗尺寸最大值,不用反复代入
22+
23+
![advantage2](assets/advantage2.png)
24+
25+
- 更直接的数值输入
26+
27+
![advantage3](assets/advantage3.png)
28+
29+
- 将格式化后的结果复制粘贴到您需要的地方
30+
31+
![advantage4](assets/advantage4.png)
32+
33+
34+
35+
## 🤝帮助
36+
37+
` Css视窗尺寸计算器` 中输入`help``?`获得**全面且友善的帮助**

assets/advantage1.png

39.7 KB
Loading

assets/advantage2.png

52 KB
Loading

assets/advantage3.png

51.1 KB
Loading

assets/advantage4.png

56.9 KB
Loading

assets/problem.png

1.32 MB
Loading

0 commit comments

Comments
 (0)