update gojs
This commit is contained in:
parent
cc31aa8248
commit
d703db0190
18
go.mod
18
go.mod
@ -1,15 +1,15 @@
|
|||||||
module apigo.cc/gojs/img
|
module apigo.cc/gojs/img
|
||||||
|
|
||||||
go 1.24
|
go 1.24.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
apigo.cc/gojs v0.0.25
|
apigo.cc/gojs v0.0.29
|
||||||
apigo.cc/gojs/console v0.0.2
|
apigo.cc/gojs/console v0.0.3
|
||||||
github.com/disintegration/imaging v1.6.2
|
github.com/disintegration/imaging v1.6.2
|
||||||
github.com/flopp/go-findfont v0.1.0
|
github.com/flopp/go-findfont v0.1.0
|
||||||
github.com/fogleman/gg v1.3.0
|
github.com/fogleman/gg v1.3.0
|
||||||
github.com/ssgo/u v1.7.21
|
github.com/ssgo/u v1.7.23
|
||||||
golang.org/x/image v0.29.0
|
golang.org/x/image v0.33.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
@ -17,12 +17,12 @@ require (
|
|||||||
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||||
github.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect
|
github.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect
|
||||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
|
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
|
||||||
github.com/google/pprof v0.0.0-20250630185457-6e76a2b096b5 // indirect
|
github.com/google/pprof v0.0.0-20250903194437-c28834ac2320 // indirect
|
||||||
github.com/ssgo/config v1.7.9 // indirect
|
github.com/ssgo/config v1.7.10 // indirect
|
||||||
github.com/ssgo/log v1.7.9 // indirect
|
github.com/ssgo/log v1.7.9 // indirect
|
||||||
github.com/ssgo/standard v1.7.7 // indirect
|
github.com/ssgo/standard v1.7.7 // indirect
|
||||||
github.com/ssgo/tool v0.4.29 // indirect
|
github.com/ssgo/tool v0.4.29 // indirect
|
||||||
golang.org/x/sys v0.34.0 // indirect
|
golang.org/x/sys v0.38.0 // indirect
|
||||||
golang.org/x/text v0.27.0 // indirect
|
golang.org/x/text v0.31.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
7
img.go
7
img.go
@ -14,6 +14,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"apigo.cc/gojs"
|
"apigo.cc/gojs"
|
||||||
|
"apigo.cc/gojs/goja"
|
||||||
"github.com/disintegration/imaging"
|
"github.com/disintegration/imaging"
|
||||||
"github.com/fogleman/gg"
|
"github.com/fogleman/gg"
|
||||||
"golang.org/x/image/font"
|
"golang.org/x/image/font"
|
||||||
@ -61,7 +62,8 @@ func CreateImage(width, height int, c *string) *Graphics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// LoadImage 从文件加载图像
|
// LoadImage 从文件加载图像
|
||||||
func LoadImage(filePath string) (*Graphics, error) {
|
func LoadImage(filePath string, vm *goja.Runtime) (*Graphics, error) {
|
||||||
|
filePath = gojs.FixPath(vm, filePath)
|
||||||
file, err := os.Open(filePath)
|
file, err := os.Open(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -256,7 +258,8 @@ func (g *Graphics) FillAreaWithImage(src *Graphics, x, y, width, height int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ExportImage 导出图像到文件
|
// ExportImage 导出图像到文件
|
||||||
func (g *Graphics) ExportImage(filePath string, quality *int) error {
|
func (g *Graphics) ExportImage(filePath string, quality *int, vm *goja.Runtime) error {
|
||||||
|
filePath = gojs.FixPath(vm, filePath)
|
||||||
file, err := os.Create(filePath)
|
file, err := os.Create(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
Loading…
x
Reference in New Issue
Block a user