mirror of
https://github.com/tenox7/wrp.git
synced 2024-11-25 13:30:51 +00:00
rename Scale to Zoom
This commit is contained in:
parent
d1fcd30db8
commit
cfb608c1f3
20
wrp.go
20
wrp.go
@ -68,7 +68,7 @@ type uiData struct {
|
|||||||
NColors int64
|
NColors int64
|
||||||
Width int64
|
Width int64
|
||||||
Height int64
|
Height int64
|
||||||
Scale float64
|
Zoom float64
|
||||||
ImgType string
|
ImgType string
|
||||||
ImgURL string
|
ImgURL string
|
||||||
ImgSize string
|
ImgSize string
|
||||||
@ -94,7 +94,7 @@ type wrpReq struct {
|
|||||||
url string // url
|
url string // url
|
||||||
width int64 // width
|
width int64 // width
|
||||||
height int64 // height
|
height int64 // height
|
||||||
scale float64 // scale
|
zoom float64 // zoom/scale
|
||||||
colors int64 // #colors
|
colors int64 // #colors
|
||||||
mouseX int64 // mouseX
|
mouseX int64 // mouseX
|
||||||
mouseY int64 // mouseY
|
mouseY int64 // mouseY
|
||||||
@ -118,9 +118,9 @@ func parseForm(w *wrpReq) {
|
|||||||
w.width = defGeom.w
|
w.width = defGeom.w
|
||||||
w.height = defGeom.h
|
w.height = defGeom.h
|
||||||
}
|
}
|
||||||
w.scale, _ = strconv.ParseFloat(w.req.FormValue("s"), 64)
|
w.zoom, _ = strconv.ParseFloat(w.req.FormValue("z"), 64)
|
||||||
if w.scale < 0.1 {
|
if w.zoom < 0.1 {
|
||||||
w.scale = 1.0
|
w.zoom = 1.0
|
||||||
}
|
}
|
||||||
w.colors, _ = strconv.ParseInt(w.req.FormValue("c"), 10, 64)
|
w.colors, _ = strconv.ParseInt(w.req.FormValue("c"), 10, 64)
|
||||||
if w.colors < 2 || w.colors > 256 {
|
if w.colors < 2 || w.colors > 256 {
|
||||||
@ -148,7 +148,7 @@ func printHTML(w wrpReq, p printParams) {
|
|||||||
Width: w.width,
|
Width: w.width,
|
||||||
Height: w.height,
|
Height: w.height,
|
||||||
NColors: w.colors,
|
NColors: w.colors,
|
||||||
Scale: w.scale,
|
Zoom: w.zoom,
|
||||||
ImgType: w.imgType,
|
ImgType: w.imgType,
|
||||||
ImgSize: p.imgSize,
|
ImgSize: p.imgSize,
|
||||||
ImgWidth: p.imgWidth,
|
ImgWidth: p.imgWidth,
|
||||||
@ -168,7 +168,7 @@ func action(w wrpReq) chromedp.Action {
|
|||||||
// Mouse Click
|
// Mouse Click
|
||||||
if w.mouseX > 0 && w.mouseY > 0 {
|
if w.mouseX > 0 && w.mouseY > 0 {
|
||||||
log.Printf("%s Mouse Click %d,%d\n", w.req.RemoteAddr, w.mouseX, w.mouseY)
|
log.Printf("%s Mouse Click %d,%d\n", w.req.RemoteAddr, w.mouseX, w.mouseY)
|
||||||
return chromedp.MouseClickXY(float64(w.mouseX)/float64(w.scale), float64(w.mouseY)/float64(w.scale))
|
return chromedp.MouseClickXY(float64(w.mouseX)/float64(w.zoom), float64(w.mouseY)/float64(w.zoom))
|
||||||
}
|
}
|
||||||
// Buttons
|
// Buttons
|
||||||
if len(w.buttons) > 0 {
|
if len(w.buttons) > 0 {
|
||||||
@ -227,7 +227,7 @@ func capture(w wrpReq) {
|
|||||||
var h int64
|
var h int64
|
||||||
var pngcap []byte
|
var pngcap []byte
|
||||||
chromedp.Run(ctx,
|
chromedp.Run(ctx,
|
||||||
emulation.SetDeviceMetricsOverride(int64(float64(w.width)/w.scale), 10, w.scale, false),
|
emulation.SetDeviceMetricsOverride(int64(float64(w.width)/w.zoom), 10, w.zoom, false),
|
||||||
chromedp.Location(&w.url),
|
chromedp.Location(&w.url),
|
||||||
chromedp.ComputedStyle("body", &styles, chromedp.ByQuery),
|
chromedp.ComputedStyle("body", &styles, chromedp.ByQuery),
|
||||||
chromedp.ActionFunc(func(ctx context.Context) error {
|
chromedp.ActionFunc(func(ctx context.Context) error {
|
||||||
@ -244,11 +244,11 @@ func capture(w wrpReq) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Printf("%s Landed on: %s, Height: %v\n", w.req.RemoteAddr, w.url, h)
|
log.Printf("%s Landed on: %s, Height: %v\n", w.req.RemoteAddr, w.url, h)
|
||||||
height := int64(float64(w.height) / w.scale)
|
height := int64(float64(w.height) / w.zoom)
|
||||||
if w.height == 0 && h > 0 {
|
if w.height == 0 && h > 0 {
|
||||||
height = h + 30
|
height = h + 30
|
||||||
}
|
}
|
||||||
chromedp.Run(ctx, emulation.SetDeviceMetricsOverride(int64(float64(w.width)/w.scale), height, w.scale, false))
|
chromedp.Run(ctx, emulation.SetDeviceMetricsOverride(int64(float64(w.width)/w.zoom), height, w.zoom, false))
|
||||||
// Capture screenshot...
|
// Capture screenshot...
|
||||||
err = chromedp.Run(ctx,
|
err = chromedp.Run(ctx,
|
||||||
chromedp.Sleep(time.Second*2),
|
chromedp.Sleep(time.Second*2),
|
||||||
|
18
wrp.html
18
wrp.html
@ -11,14 +11,14 @@
|
|||||||
<INPUT TYPE="SUBMIT" NAME="Fn" VALUE="Re">
|
<INPUT TYPE="SUBMIT" NAME="Fn" VALUE="Re">
|
||||||
W <INPUT TYPE="TEXT" NAME="w" VALUE="{{.Width}}" SIZE="4">
|
W <INPUT TYPE="TEXT" NAME="w" VALUE="{{.Width}}" SIZE="4">
|
||||||
H <INPUT TYPE="TEXT" NAME="h" VALUE="{{.Height}}" SIZE="4">
|
H <INPUT TYPE="TEXT" NAME="h" VALUE="{{.Height}}" SIZE="4">
|
||||||
S <SELECT NAME="s">
|
Z <SELECT NAME="z">
|
||||||
<OPTION VALUE="0.7" {{ if eq .Scale 0.7}}SELECTED{{end}}>0.7</OPTION>
|
<OPTION VALUE="0.7" {{ if eq .Zoom 0.7}}SELECTED{{end}}>0.7 x</OPTION>
|
||||||
<OPTION VALUE="0.8" {{ if eq .Scale 0.8}}SELECTED{{end}}>0.8</OPTION>
|
<OPTION VALUE="0.8" {{ if eq .Zoom 0.8}}SELECTED{{end}}>0.8 x</OPTION>
|
||||||
<OPTION VALUE="0.9" {{ if eq .Scale 0.9}}SELECTED{{end}}>0.9</OPTION>
|
<OPTION VALUE="0.9" {{ if eq .Zoom 0.9}}SELECTED{{end}}>0.9 x</OPTION>
|
||||||
<OPTION VALUE="1.0" {{ if eq .Scale 1.0}}SELECTED{{end}}>1.0</OPTION>
|
<OPTION VALUE="1.0" {{ if eq .Zoom 1.0}}SELECTED{{end}}>1.0 x</OPTION>
|
||||||
<OPTION VALUE="1.1" {{ if eq .Scale 1.1}}SELECTED{{end}}>1.1</OPTION>
|
<OPTION VALUE="1.1" {{ if eq .Zoom 1.1}}SELECTED{{end}}>1.1 x</OPTION>
|
||||||
<OPTION VALUE="1.2" {{ if eq .Scale 1.2}}SELECTED{{end}}>1.2</OPTION>
|
<OPTION VALUE="1.2" {{ if eq .Zoom 1.2}}SELECTED{{end}}>1.2 x</OPTION>
|
||||||
<OPTION VALUE="1.3" {{ if eq .Scale 1.3}}SELECTED{{end}}>1.3</OPTION>
|
<OPTION VALUE="1.3" {{ if eq .Zoom 1.3}}SELECTED{{end}}>1.3 x</OPTION>
|
||||||
</SELECT>
|
</SELECT>
|
||||||
T <SELECT NAME="t">
|
T <SELECT NAME="t">
|
||||||
<OPTION VALUE="gif" {{ if eq .ImgType "gif"}}SELECTED{{end}}>GIF</OPTION>
|
<OPTION VALUE="gif" {{ if eq .ImgType "gif"}}SELECTED{{end}}>GIF</OPTION>
|
||||||
@ -47,7 +47,7 @@
|
|||||||
<P>
|
<P>
|
||||||
{{end}}
|
{{end}}
|
||||||
<FONT SIZE="-2">
|
<FONT SIZE="-2">
|
||||||
<A HREF="/?url=https://github.com/tenox7/wrp/&w={{.Width}}&h={{.Height}}&s={{printf "%.1f" .Scale}}&c={{.NColors}}&t={{.ImgType}}">Web Rendering Proxy {{.Version}}</A> |
|
<A HREF="/?url=https://github.com/tenox7/wrp/&w={{.Width}}&h={{.Height}}&s={{printf "%.1f" .Zoom}}&c={{.NColors}}&t={{.ImgType}}">Web Rendering Proxy {{.Version}}</A> |
|
||||||
<A HREF="/shutdown/">Shutdown WRP</A> |
|
<A HREF="/shutdown/">Shutdown WRP</A> |
|
||||||
<A HREF="/">Page Height: {{.PageHeight}}</A> |
|
<A HREF="/">Page Height: {{.PageHeight}}</A> |
|
||||||
<A HREF="/">Img Size: {{.ImgSize}}</A>
|
<A HREF="/">Img Size: {{.ImgSize}}</A>
|
||||||
|
Loading…
Reference in New Issue
Block a user