Elementary Rectangle: Difference between revisions

From Scribus Wiki
Jump to navigation Jump to search
m (Updated tested version)
m (This is just here to rollback purposes so as to save the code before it was augmented)
Line 1: Line 1:
{{Scripting_Index}}
{{Scripting_Index}}


This one is specific to A4 paper, you will need to change the wth and dph constants for different papers.
<big>This script is <u>specific to A4 paper</u>, you will need to change the '''wth''' and '''dph''' constants for different papers.</big>


Introduces: '''CreateRect'''  '''SetFillColor'''  '''SetSetCornerRadius'''.
Introduces: '''CreateRect'''  '''SetFillColor'''  '''SetSetCornerRadius'''.


[[Image:Elementary_rectangle.png|300]]
{| class="wikitable"
!Result
!Python Code
|-
| [[Image:Elementary_rectangle.png|thumb|upright=0.9|left|alt=simple rectangle made with scribus python script|Elementary Rectangle generated from python]] ||
<pre><nowiki>
#!/usr/bin/env python
 
"""
this script draws a black border on A4 and has been tested against 1.4.3. 
Calls used in this script are;
 
newDocument
createRect
setCornerRadius
setLineWidth
setFillColor
setLineColor
saveDocAs
"""
from scribus import *


if newDocument(PAPER_A4, (10, 10, 10, 10), PORTRAIT, 1, UNIT_POINTS, NOFACINGPAGES, FIRSTPAGERIGHT, 1):


      spx=20          # x co-ord Start point
      spy=20          # y co-ord Start point
      wth=595        # A4 width in points
      dph=842        # Depth of frame - adjust to suit
      a=8            # Line width
      b="Black"      # add other colors as required
      b1="Blue"
      w="White"
      h = createRect(spx,spy,wth-2*spx,dph-2*spy)
      setCornerRadius(20, h)
      setLineWidth(8, h)
      setFillColor(w, h)
      setLineColor(b, h)
      saveDocAs("Border_2.sla") #Make sure this is writable
</nowiki>
</pre>
|}
[[Image:Elementary_rectangle.png|frame|200x300px|left|alt=simple rectangle made with scribus python script|Elementary Rectangle generated from python]]
<div style="clear: both"></div>
<pre><nowiki>
<pre><nowiki>
#!/usr/bin/env python
#!/usr/bin/env python


Line 44: Line 87:


       saveDocAs("Border_2.sla") #Make sure this is writable
       saveDocAs("Border_2.sla") #Make sure this is writable
</pre>
</nowiki></pre>
</nowiki>

Revision as of 12:51, 11 November 2013

This article is part of the Scripts series.

This script is specific to A4 paper, you will need to change the wth and dph constants for different papers.

Introduces: CreateRect SetFillColor SetSetCornerRadius.

Result Python Code
simple rectangle made with scribus python script
Elementary Rectangle generated from python
#!/usr/bin/env python

"""
this script draws a black border on A4 and has been tested against 1.4.3.  
Calls used in this script are;

newDocument
createRect
setCornerRadius
setLineWidth
setFillColor
setLineColor
saveDocAs
 
"""
from scribus import *

if newDocument(PAPER_A4, (10, 10, 10, 10), PORTRAIT, 1, UNIT_POINTS, NOFACINGPAGES, FIRSTPAGERIGHT, 1):

      spx=20          # x co-ord Start point
      spy=20          # y co-ord Start point
      wth=595         # A4 width in points
      dph=842         # Depth of frame - adjust to suit
      a=8             # Line width
      b="Black"       # add other colors as required
      b1="Blue"
      w="White"

      h = createRect(spx,spy,wth-2*spx,dph-2*spy)
      setCornerRadius(20, h)
      setLineWidth(8, h)
      setFillColor(w, h)
      setLineColor(b, h)

      saveDocAs("Border_2.sla") #Make sure this is writable

simple rectangle made with scribus python script
Elementary Rectangle generated from python
<nowiki>
#!/usr/bin/env python

"""
this script draws a black border on A4 and has been tested against 1.4.3.  Calls used in this script are;

newDocument
createRect
setCornerRadius
setLineWidth
setFillColor
setLineColor
saveDocAs
 
"""
from scribus import *

if newDocument(PAPER_A4, (10, 10, 10, 10), PORTRAIT, 1, UNIT_POINTS, NOFACINGPAGES, FIRSTPAGERIGHT, 1):

      spx=20          # x co-ord Start point
      spy=20          # y co-ord Start point
      wth=595         # A4 width in points
      dph=842         # Depth of frame - adjust to suit
      a=8             # Line width
      b="Black"       # add other colors as required
      b1="Blue"
      w="White"

      h = createRect(spx,spy,wth-2*spx,dph-2*spy)
      setCornerRadius(20, h)
      setLineWidth(8, h)
      setFillColor(w, h)
      setLineColor(b, h)

      saveDocAs("Border_2.sla") #Make sure this is writable

</nowiki>