Skip to content

Commit

Permalink
General code style & a few corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
oh-ok committed Jul 9, 2023
1 parent cd0ef82 commit 0e64155
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 17 deletions.
18 changes: 8 additions & 10 deletions mac_scripting/ApplyFilters.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,30 @@
ps.open(fileName)
docRef = ps.current_document()

# Could use "len(docRef.layer_sets())" here too
# but the "count" function is generally better for performance
# since it doesn't resolve and return all layer references
nLayerSets = ps.count(docRef, each=k.layer_set)
nArtLayers = ps.count(docRef, each=k.art_layer)

docRef.current_layer.set(docRef.layer_sets[-1].art_layers[-1])
active_layer = docRef.current_layer()

sel_area = ((0, 212), (300, 212), (300, 300), (0, 300))
ps.select(docRef, region=sel_area)
ps.select(
docRef, region=sel_area, combination_type=k.replaced, feather_amount=20, antialiasing=True
)

active_layer.filter(
using=k.add_noise,
with_options={k.amount: 15, k.distribution: k.Gaussian, k.monochromatic: False}
)

ps.background_color.set({k.class_: k.HSB_color, k.hue:0, k.saturation: 0, k.brightness: 100})
ps.background_color.set({k.class_: k.HSB_color, k.hue: 0, k.saturation: 0, k.brightness: 100})


sel_area2 = ((120, 20), (210, 20), (210, 110), (120, 110))
ps.select(docRef, region=sel_area2)
ps.select(
docRef, region=sel_area2, combination_type=k.replaced, feather_amount=25, antialiasing=False
)

active_layer.filter(
using=k.diffuse_glow,
with_options={k.graininess:9, k.glow_amount:12, k.clear_amount:15}
with_options={k.graininess: 9, k.glow_amount: 12, k.clear_amount: 15}
)

active_layer.filter(
Expand Down
3 changes: 1 addition & 2 deletions mac_scripting/CopyAndPaste.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

srcDoc = ps.make(
new=k.document,
with_properties={k.width:7, k.height:5, k.resolution:72, k.mode: k.RGB, k.initial_fill: k.white}
with_properties={k.width: 7, k.height: 5, k.resolution: 72, k.mode: k.RGB, k.initial_fill: k.white}
)

# Make sure the active layer is not a text layer, which cannot be copied to the clipboard
Expand Down Expand Up @@ -55,4 +55,3 @@


ps.settings.ruler_units.set(strtRulerUnits)

2 changes: 1 addition & 1 deletion mac_scripting/FillSelection.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
docRef = ps.make(
new=k.document,
with_properties={
k.width:320, k.height:240, k.resolution:72, k.mode: k.RGB, k.initial_fill: k.white
k.width: 320, k.height: 240, k.resolution: 72, k.mode: k.RGB, k.initial_fill: k.white
}
)
docRef.make(new=k.art_layer)
Expand Down
3 changes: 1 addition & 2 deletions mac_scripting/LinkLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
# Start up Photoshop application
ps = app(id="com.adobe.Photoshop", terms="sdef")


strtRulerUnits = ps.settings.ruler_units()

if len(ps.documents()) < 1:
ps.settings.ruler_units.set(k.pixel_units)
docRef = ps.make(new=k.document, with_properties={
k.width:320, k.height:240, k.resolution:72, k.mode:k.RGB, k.initial_fill: k.white
k.width: 320, k.height: 240, k.resolution: 72, k.mode: k.RGB, k.initial_fill: k.white
}
)
else:
Expand Down
2 changes: 1 addition & 1 deletion mac_scripting/MakeSelection.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
strtRulerUnits = ps.settings.ruler_units()
ps.settings.ruler_units.set(k.pixel_units)
docRef = ps.make(new=k.document, with_properties={
k.width:320, k.height:240, k.resolution:72, k.mode:k.RGB, k.initial_fill: k.white
k.width: 320, k.height: 240, k.resolution: 72, k.mode:k.RGB, k.initial_fill: k.white
}
)
ps.settings.ruler_units.set(strtRulerUnits)
Expand Down
2 changes: 1 addition & 1 deletion mac_scripting/SelectionStroke.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
strokeColor = {
k.class_: k.CMYK_color,
k.cyan: 20,
k.magenta:90,
k.magenta: 90,
k.yellow: 50,
k.black: 50
}
Expand Down

0 comments on commit 0e64155

Please sign in to comment.