screenshot

package
v1.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2022 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package screenshot implements the screenshot edit window.

It's the main part of the application: it may be run after a fork(), if the main program was started as a system tray app.

Index

Constants

View Source
const (
	GoogleDriveTokenPreference = "google_drive_token"
	QiNiuAccessKey             = "qiNiuAccessKey"
	QiNiuSecretKey             = "qiNiuSecretKey"
	QiNiuBucket                = "qiNiuBucket"
)
View Source
const (
	BackgroundColorPreference = "BackgroundColor"
	DrawingColorPreference    = "DrawingColor"
	FontSizePreference        = "FontSize"
	ThicknessPreference       = "Thickness"
)
View Source
const DefaultPathPreference = "DefaultPath"
View Source
const DelayTimePreference = "DelayTime"
View Source
const FireShotFontSize = "FireShotFontSize"
View Source
const SelectScreenIndex = "SelectScreen"

Variables

View Source
var (
	Red         = color.RGBA{R: 255, G: 64, B: 64, A: 255}
	Yellow      = color.RGBA{R: 255, G: 255, B: 64, A: 255}
	Transparent = color.RGBA{}
)
View Source
var (
	GoogleDrivePath = []string{"FireShotGO"}
)

Functions

func Run

func Run()

Run 截图的主程序

Types

type FireShotFont added in v1.0.6

type FireShotFont struct {
	// contains filtered or unexported fields
}

func (*FireShotFont) FireShotFontEdit added in v1.0.6

func (ff *FireShotFont) FireShotFontEdit(gs *FireShotGO)

func (*FireShotFont) GetFireFontSize added in v1.0.6

func (ff *FireShotFont) GetFireFontSize(gs *FireShotGO) float32

type FireShotGO

type FireShotGO struct {
	// 应用和窗口
	App fyne.App
	// 主窗口
	Win fyne.Window
	// topLevel 备份top层的窗口,用于更改主题一类的刷新使用
	TopLevelContainer fyne.Container

	// 原始截图信息
	OriginalScreenshot *image.RGBA
	// 截图时间记录
	ScreenshotTime time.Time

	// 编辑之后的截图信息,每添加一个fileter这里都进行叠加一次
	Screenshot *image.RGBA // The edited/composed screenshot
	CropRect   image.Rectangle
	// 所有的fileter都添加到这里
	Filters []ImageFilter // Configured filters: each filter is one edition to the image.
	// contains filtered or unexported fields
}

func (*FireShotGO) ApplyFilters

func (fs *FireShotGO) ApplyFilters(full bool)

ApplyFilters will apply `Filters` to the `CropRect` of the original image and regenerate Screenshot. If full == true, regenerates full Screenshot. If false, regenerates only visible area. 绘制预览图

func (*FireShotGO) BuildEditWindow

func (fs *FireShotGO) BuildEditWindow()

func (*FireShotGO) ConnectUsPage added in v1.0.8

func (gs *FireShotGO) ConnectUsPage()

func (*FireShotGO) CopyImageToClipboard

func (gs *FireShotGO) CopyImageToClipboard()

func (*FireShotGO) DefaultName

func (gs *FireShotGO) DefaultName() string

DefaultName returns a default name to the screenshot, based on date/time it was made.

func (*FireShotGO) DelayedScreenshot

func (gs *FireShotGO) DelayedScreenshot(seconds int)

func (*FireShotGO) DelayedScreenshotForm

func (gs *FireShotGO) DelayedScreenshotForm()

func (*FireShotGO) FireShotNameByTime added in v1.0.7

func (gs *FireShotGO) FireShotNameByTime() string

func (*FireShotGO) GetColorPreference

func (gs *FireShotGO) GetColorPreference(key string, defaultColor color.RGBA) color.RGBA

GetColorPreference 颜色信息设置,若是环境变量中没有设置就使用默认值

func (*FireShotGO) GetStatusHandle added in v1.0.6

func (gs *FireShotGO) GetStatusHandle() (status *widget.Label)

func (*FireShotGO) MakeFireShotMenu added in v1.0.8

func (fs *FireShotGO) MakeFireShotMenu() *fyne.MainMenu

MakeFireShotMenu 创建FireShotGo菜单栏

func (*FireShotGO) MakeInputTab added in v1.0.11

func (gs *FireShotGO) MakeInputTab(_ fyne.Window) fyne.CanvasObject

func (*FireShotGO) MakeScreenshot

func (gs *FireShotGO) MakeScreenshot() error

MakeScreenshot 开始截屏

func (*FireShotGO) RegisterShortcuts

func (gs *FireShotGO) RegisterShortcuts()

RegisterShortcuts adds all the shortcuts and keys FireShotGO listens to. When updating here, please update also the `fs.ShowShortcutsPage()` method to reflect the changes.

func (*FireShotGO) SaveImage

func (gs *FireShotGO) SaveImage()

SaveImage opens a file save dialog box to save the currently edited screenshot.

func (*FireShotGO) SetColorPreference

func (gs *FireShotGO) SetColorPreference(key string, c color.Color)

SetColorPreference sets the given color in the given preferences key.

func (*FireShotGO) ShareWithGoogleDrive

func (gs *FireShotGO) ShareWithGoogleDrive()

func (*FireShotGO) ShareWithQiNiuDrive added in v1.0.7

func (gs *FireShotGO) ShareWithQiNiuDrive()

func (*FireShotGO) ShowShortcutsPage

func (gs *FireShotGO) ShowShortcutsPage()

func (*FireShotGO) UndoLastFilter

func (gs *FireShotGO) UndoLastFilter()

UndoLastFilter cancels the last filter applied, and regenerates everything.

type ImageFilter

type ImageFilter interface {
	// Apply filter, shifted (dx, dy) pixels -- e.g. if a filter draws a circle on
	// top of the image, it should add (dx, dy) to the circle center.
	Apply(image image.Image) image.Image
}

type MiniMap

type MiniMap struct {
	widget.BaseWidget
	// contains filtered or unexported fields
}

func NewMiniMap

func NewMiniMap(gs *FireShotGO, vp *ViewPort) (mm *MiniMap)

func (*MiniMap) BackgroundColor

func (mm *MiniMap) BackgroundColor() color.Color

func (*MiniMap) CreateRenderer

func (mm *MiniMap) CreateRenderer() fyne.WidgetRenderer

func (*MiniMap) Destroy

func (mm *MiniMap) Destroy()

func (*MiniMap) DragEnd

func (mm *MiniMap) DragEnd()

DragEnd implements fyne.Draggable

func (*MiniMap) Dragged

func (mm *MiniMap) Dragged(ev *fyne.DragEvent)

Dragged implements fyne.Draggable

func (*MiniMap) Layout

func (mm *MiniMap) Layout(size fyne.Size)

func (*MiniMap) MinSize

func (mm *MiniMap) MinSize() fyne.Size

func (*MiniMap) Objects

func (mm *MiniMap) Objects() []fyne.CanvasObject

func (*MiniMap) Refresh

func (mm *MiniMap) Refresh()

func (*MiniMap) Resize

func (mm *MiniMap) Resize(size fyne.Size)

func (*MiniMap) SetMinSize

func (mm *MiniMap) SetMinSize(size fyne.Size)

func (*MiniMap) Tapped

func (mm *MiniMap) Tapped(ev *fyne.PointEvent)

type OperationType

type OperationType int

OperationType 操作类型

const (
	NoOp OperationType = iota
	// CropTopLeft 裁剪点 - 左上角
	CropTopLeft
	// CropBottomRight 裁剪点 - 右下角
	CropBottomRight
	// DrawCircle 绘制圆 包括椭圆和圆
	DrawCircle
	// DrawArrow 绘制剪头
	DrawArrow
	// DrawText 绘制文本
	DrawText
	// DrawStraightLine 绘制直线
	DrawStraightLine
	// DrawDottedLine 绘制虚线
	DrawDottedLine
	// DrawShieldBlock 绘制遮挡块
	DrawShieldBlock
	// DrawRectangle 绘制矩形
	DrawRectangle
	// DrawPen 使用画笔进行绘制
	DrawPen
)

type ViewPort

type ViewPort struct {
	widget.BaseWidget

	// Geometry of what is being displayed:
	// Log2Zoom is the log2 of the zoom multiplier, it's what we show to the user. It
	// is set by the "zoomEntry" field in the UI
	Log2Zoom float64

	// Thickness 存储绘制直线等元素的宽度元素.
	Thickness float64

	// DrawingColor 绘制图形的颜色信息. BackgroundColor text文本的背景颜色信息
	DrawingColor, BackgroundColor color.Color

	// FontSize 字体的大小
	FontSize float64

	// 虚线间隔配置
	DottedLineSpacing float64

	fyne.ShortcutHandler
	// contains filtered or unexported fields
}

ViewPort is our view port for the image being edited. It's a specialized widget that will display the image according to zoom / window select.

It is both a CanvasObject and a WidgetRenderer -- the abstractions in Fyne are not clear, but when those were implemented it worked (mostly copy&paste code).

Loosely based on github.com/fyne-io/pixeledit

func NewViewPort

func NewViewPort(gs *FireShotGO) (vp *ViewPort)

NewViewPort 视窗,放置需要编辑的视图

func (*ViewPort) CreateRenderer

func (vp *ViewPort) CreateRenderer() fyne.WidgetRenderer

func (*ViewPort) Destroy

func (vp *ViewPort) Destroy()

func (*ViewPort) DragEnd

func (vp *ViewPort) DragEnd()

DragEnd implements fyne.Draggable

func (*ViewPort) DragPen added in v1.0.12

func (vp *ViewPort) DragPen(toPos fyne.Position)

func (*ViewPort) Dragged

func (vp *ViewPort) Dragged(ev *fyne.DragEvent)

Dragged implements fyne.Draggable 拖动时候将对应图像实现放入到fileter中

func (*ViewPort) Layout

func (vp *ViewPort) Layout(size fyne.Size)

func (*ViewPort) MinSize

func (vp *ViewPort) MinSize() fyne.Size

func (*ViewPort) MouseIn

func (vp *ViewPort) MouseIn(ev *desktop.MouseEvent)

MouseIn implements desktop.Hoverable.

func (*ViewPort) MouseMoved

func (vp *ViewPort) MouseMoved(ev *desktop.MouseEvent)

MouseMoved implements desktop.Hoverable.

func (*ViewPort) MouseOut

func (vp *ViewPort) MouseOut()

MouseOut implements desktop.Hoverable.

func (*ViewPort) Objects

func (vp *ViewPort) Objects() []fyne.CanvasObject

func (*ViewPort) PixelSize

func (vp *ViewPort) PixelSize() (x, y int)

PixelSize returns the size in pixels of the this CanvasObject, based on the last request to redraw.

func (*ViewPort) PosToPixel

func (vp *ViewPort) PosToPixel(pos fyne.Position) (x, y int)

PosToPixel converts from the undocumented Fyne screen float dimension to actual number of pixels position in the image.

func (*ViewPort) Refresh

func (vp *ViewPort) Refresh()

func (*ViewPort) Resize

func (vp *ViewPort) Resize(size fyne.Size)

func (*ViewPort) Scrolled

func (vp *ViewPort) Scrolled(ev *fyne.ScrollEvent)

func (*ViewPort) SetMinSize

func (vp *ViewPort) SetMinSize(size fyne.Size)

func (*ViewPort) SetOp

func (vp *ViewPort) SetOp(op OperationType)

SetOp changes the current op on the edit window. It interrupts any dragging event going on. 在编辑窗口选择需要进行的操作,比如选择绘制直线

func (*ViewPort) Tapped

func (vp *ViewPort) Tapped(ev *fyne.PointEvent)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL