mirror of
https://github.com/sbrow/ps.git
synced 2025-12-29 18:47:38 -05:00
Updated to use v2 imports (removes dependancy on v1)
various doc updates as well.
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/sbrow/ps/runner"
|
"github.com/sbrow/ps/v2/runner"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ArtLayer reflects some values from an Art Layer in a Photoshop document.
|
// ArtLayer reflects some values from an Art Layer in a Photoshop document.
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ type Color interface {
|
|||||||
func Compare(a, b Color) Color {
|
func Compare(a, b Color) Color {
|
||||||
A := a.RGB()
|
A := a.RGB()
|
||||||
B := b.RGB()
|
B := b.RGB()
|
||||||
Aavg := (A[0] + A[1] + A[2]) / 3
|
avgA := (A[0] + A[1] + A[2]) / 3
|
||||||
Bavg := (B[0] + B[1] + B[2]) / 3
|
avgB := (B[0] + B[1] + B[2]) / 3
|
||||||
if Aavg > Bavg {
|
if avgA > avgB {
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
return b
|
return b
|
||||||
@@ -42,7 +42,7 @@ func (r RGB) RGB() [3]int {
|
|||||||
return [3]int{r.Red, r.Green, r.Blue}
|
return [3]int{r.Red, r.Green, r.Blue}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hex returns the color coverted to hexidecimal format.
|
// Hex returns the color converted to hexadecimal format.
|
||||||
func (r RGB) Hex() []uint8 {
|
func (r RGB) Hex() []uint8 {
|
||||||
src := []uint8{uint8(r.Red), uint8(r.Green), uint8(r.Blue)}
|
src := []uint8{uint8(r.Red), uint8(r.Green), uint8(r.Blue)}
|
||||||
hex := make([]byte, hex.EncodedLen(len(src)))
|
hex := make([]byte, hex.EncodedLen(len(src)))
|
||||||
|
|||||||
3
doc.go
3
doc.go
@@ -4,4 +4,5 @@
|
|||||||
// Use it to control Photoshop, edit documents, and perform batch operations.
|
// Use it to control Photoshop, edit documents, and perform batch operations.
|
||||||
//
|
//
|
||||||
// Currently only supports Photoshop CS5 Windows x86_64.
|
// Currently only supports Photoshop CS5 Windows x86_64.
|
||||||
package ps
|
//
|
||||||
|
package ps // import "github.com/sbrow/ps/v2"
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ func (d *Document) LayerSet(name string) *LayerSet {
|
|||||||
//
|
//
|
||||||
// TODO(sbrow): Reduce cyclomatic complexity of ActiveDocument().
|
// TODO(sbrow): Reduce cyclomatic complexity of ActiveDocument().
|
||||||
func ActiveDocument() (*Document, error) {
|
func ActiveDocument() (*Document, error) {
|
||||||
log.Println("Loading ActiveDoucment")
|
log.Println("Loading ActiveDocument")
|
||||||
d := &Document{}
|
d := &Document{}
|
||||||
|
|
||||||
byt, err := DoJS("activeDocName.jsx")
|
byt, err := DoJS("activeDocName.jsx")
|
||||||
@@ -248,8 +248,6 @@ func (d *Document) MustExist(name string) Layer {
|
|||||||
// Save saves the Document in place.
|
// Save saves the Document in place.
|
||||||
func (d *Document) Save() error {
|
func (d *Document) Save() error {
|
||||||
js := fmt.Sprintf("var d=app.open(File('%s'));\nd.save();", d.FullName())
|
js := fmt.Sprintf("var d=app.open(File('%s'));\nd.save();", d.FullName())
|
||||||
if _, err := DoJS("compilejs", js); err != nil {
|
_, err := DoJS("compilejs", js)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -82,10 +82,10 @@ func TestDocument_Save(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := DoAction("DK", "Undo"); err != nil {
|
if err = DoAction("DK", "Undo"); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
err := d.Save()
|
err = d.Save()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ func (l *LayerSet) SetVisible(b bool) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetPos snaps the given layerset boundry to the given point.
|
// SetPos snaps the given layerset boundary to the given point.
|
||||||
// Valid options for bound are: "TL", "TR", "BL", "BR"
|
// Valid options for bound are: "TL", "TR", "BL", "BR"
|
||||||
func (l *LayerSet) SetPos(x, y int, bound string) {
|
func (l *LayerSet) SetPos(x, y int, bound string) {
|
||||||
if !l.visible || (x == 0 && y == 0) {
|
if !l.visible || (x == 0 && y == 0) {
|
||||||
|
|||||||
2
ps.go
2
ps.go
@@ -12,7 +12,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/sbrow/ps/runner"
|
"github.com/sbrow/ps/v2/runner"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The full path to this directory.
|
// The full path to this directory.
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/sbrow/ps/runner"
|
"github.com/sbrow/ps/v2/runner"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user