mirror of
https://github.com/sbrow/ps.git
synced 2025-12-29 18:47:38 -05:00
Merge branch 'release/v1.1' into develop
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
package ps
|
package ps
|
||||||
|
|
||||||
import (
|
import "fmt"
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ModeEnum determines how aggressively the package will attempt to sync with Photoshop.
|
// ModeEnum determines how aggressively the package will attempt to sync with Photoshop.
|
||||||
// Loading Photoshop files from scratch takes a long time, so the package saves
|
// Loading Photoshop files from scratch takes a long time, so the package saves
|
||||||
|
|||||||
@@ -1,22 +1,13 @@
|
|||||||
package colors
|
package ps
|
||||||
|
|
||||||
import (
|
import "encoding/hex"
|
||||||
"encoding/hex"
|
|
||||||
// "fmt"
|
var (
|
||||||
|
ColorBlack Color = RGB{0, 0, 0}
|
||||||
|
ColorGray Color = RGB{128, 128, 128}
|
||||||
|
ColorWhite Color = RGB{255, 255, 255}
|
||||||
)
|
)
|
||||||
|
|
||||||
func Black() Color {
|
|
||||||
return &RGB{0, 0, 0}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Gray() Color {
|
|
||||||
return &RGB{128, 128, 128}
|
|
||||||
}
|
|
||||||
|
|
||||||
func White() Color {
|
|
||||||
return &RGB{255, 255, 255}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Color is an interface for color objects, allowing colors to be
|
// Color is an interface for color objects, allowing colors to be
|
||||||
// used in various formats.
|
// used in various formats.
|
||||||
//
|
//
|
||||||
1
ps.go
1
ps.go
@@ -16,7 +16,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
// "update"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// The name of the program that runs scripts on this OS.
|
// The name of the program that runs scripts on this OS.
|
||||||
|
|||||||
25
structs.go
25
structs.go
@@ -5,7 +5,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/sbrow/ps/colors"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
@@ -184,14 +183,14 @@ func (d *Document) Dump() {
|
|||||||
//
|
//
|
||||||
// TODO: (2) Make TextLayer a subclass of ArtLayer.
|
// TODO: (2) Make TextLayer a subclass of ArtLayer.
|
||||||
type ArtLayer struct {
|
type ArtLayer struct {
|
||||||
name string // The layer's name.
|
name string // The layer's name.
|
||||||
bounds [2][2]int // The corners of the layer's bounding box.
|
bounds [2][2]int // The corners of the layer's bounding box.
|
||||||
parent Group // The LayerSet/Document this layer is in.
|
parent Group // The LayerSet/Document this layer is in.
|
||||||
visible bool // Whether or not the layer is visible.
|
visible bool // Whether or not the layer is visible.
|
||||||
current bool // Whether we've checked this layer since we loaded from disk.
|
current bool // Whether we've checked this layer since we loaded from disk.
|
||||||
colors.Color // The layer's color overlay effect (if any).
|
Color // The layer's color overlay effect (if any).
|
||||||
*colors.Stroke // The layer's stroke effect (if any).
|
*Stroke // The layer's stroke effect (if any).
|
||||||
*TextItem // The layer's text, if it's a text layer.
|
*TextItem // The layer's text, if it's a text layer.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bounds returns the coordinates of the corners of the ArtLayer's bounding box.
|
// Bounds returns the coordinates of the corners of the ArtLayer's bounding box.
|
||||||
@@ -233,8 +232,8 @@ func (a *ArtLayer) UnmarshalJSON(b []byte) error {
|
|||||||
}
|
}
|
||||||
a.name = tmp.Name
|
a.name = tmp.Name
|
||||||
a.bounds = tmp.Bounds
|
a.bounds = tmp.Bounds
|
||||||
a.Color = colors.RGB{tmp.Color[0], tmp.Color[1], tmp.Color[2]}
|
a.Color = RGB{tmp.Color[0], tmp.Color[1], tmp.Color[2]}
|
||||||
a.Stroke = &colors.Stroke{tmp.StrokeAmt, colors.RGB{tmp.Stroke[0], tmp.Stroke[1], tmp.Stroke[2]}}
|
a.Stroke = &Stroke{tmp.StrokeAmt, RGB{tmp.Stroke[0], tmp.Stroke[1], tmp.Stroke[2]}}
|
||||||
a.visible = tmp.Visible
|
a.visible = tmp.Visible
|
||||||
a.current = false
|
a.current = false
|
||||||
a.TextItem = tmp.TextItem
|
a.TextItem = tmp.TextItem
|
||||||
@@ -285,7 +284,7 @@ func (a *ArtLayer) SetActive() ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetColor creates a color overlay for the layer
|
// SetColor creates a color overlay for the layer
|
||||||
func (a *ArtLayer) SetColor(c colors.Color) {
|
func (a *ArtLayer) SetColor(c Color) {
|
||||||
if a.Color.RGB() == c.RGB() {
|
if a.Color.RGB() == c.RGB() {
|
||||||
if Mode == 2 || (Mode == 0 && a.current) {
|
if Mode == 2 || (Mode == 0 && a.current) {
|
||||||
// log.Println("Skipping color: already set.")
|
// log.Println("Skipping color: already set.")
|
||||||
@@ -319,7 +318,7 @@ func (a *ArtLayer) SetColor(c colors.Color) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *ArtLayer) SetStroke(stk colors.Stroke, fill colors.Color) {
|
func (a *ArtLayer) SetStroke(stk Stroke, fill Color) {
|
||||||
if stk.Size == 0 {
|
if stk.Size == 0 {
|
||||||
a.Stroke = &stk
|
a.Stroke = &stk
|
||||||
a.SetColor(fill)
|
a.SetColor(fill)
|
||||||
|
|||||||
Reference in New Issue
Block a user