Creating Markers for positioning and cutting

From Scribus Wiki
Jump to: navigation, search
This article is part of the Scripts series.


#!/usr/bin/env python2.3
# -*- coding: utf-8 -*-
# Schneid-Passer-Marken.py von Albert Dietz, 27.05.05
# this script (my first Pyhton and Scribus-Script) generates markers for 
# positioning cmyk masks and cutting
# the markers will be set onto the existing document at 1cm spacing to the papersize
# that means that your A4-Layout should be 230x317mm
# Attention: disable "under color reduction"! otherwise you will not see the 
# cyan, magenta and yellow markers
# feel free to modify this script and please send comments to albert@jadietz.de
# thank you for reading this.
#
from scribus import *
defineColor("transparent", 0, 0, 0, 0 )
defineColor("cyan", 255, 0, 0, 0 )
defineColor("magenta", 0, 255, 0, 0 )
defineColor("gelb", 0, 0, 255, 0 )
defineColor("cyan50", 128, 0, 0, 0 )
defineColor("magenta50", 0, 128, 0, 0 )
defineColor("gelb50", 0, 0, 128, 0 )
defineColor("rot", 0, 255, 255, 0 )
defineColor("gruen", 255, 0, 255, 0 )
defineColor("blau", 255, 255, 0, 0 )
defineColor("schwarz", 0, 0, 0, 255 )
defineColor("schwarz90", 0, 0, 0, 230 )
defineColor("schwarz80", 0, 0, 0, 205 )
defineColor("schwarz70", 0, 0, 0, 179 )
defineColor("schwarz60", 0, 0, 0, 154 )
defineColor("schwarz50", 0, 0, 0, 128 )
defineColor("schwarz40", 0, 0, 0, 102 )
defineColor("schwarz30", 0, 0, 0,  77 )
defineColor("schwarz20", 0, 0, 0,  51 )
defineColor("schwarz10", 0, 0, 0,  26 )
defineColor("alle", 255, 255, 255, 255 )

def einPasser( x, y, Breite, Farbe ):
	Kreisradius = 0.5*Breite*0.8
	k13 = createEllipse( x-Kreisradius, y-Kreisradius, 2*Kreisradius, 2*Kreisradius)
	setLineWidth(0.5, k13)
	setFillColor("transparent", k13)
	setLineColor(Farbe, k13)
	k11 = createLine( x-Breite/2, y, x+Breite/2, y)           
	setLineWidth(0.5, k11)
	setLineColor(Farbe, k11)
	k12 = createLine( x, y-Breite/2, x, y+Breite/2 )           
	setLineWidth(0.5, k12)
	setLineColor(Farbe, k12)

def allePasser( Breite, Farbe):
	einPasser( 0.5*Breite, pageHeight/2, 0.8*Breite, Farbe )
	einPasser( pageWidth/2, 0.5*Breite, 0.8*Breite, Farbe )
	einPasser( pageWidth-0.5*Breite, pageHeight/2, 0.8*Breite, Farbe )
	einPasser( pageWidth/2, pageHeight-0.5*Breite, 0.8*Breite, Farbe )


def Schnitte( Abstand, Farbe ):
	Laenge = 0.8*Abstand
	l1 = createLine( 0, Abstand, Laenge, Abstand)           
	setLineWidth(0.5, l1)
	setLineColor(Farbe, l1)
	l2 = createLine( Abstand, 0, Abstand, Laenge)
	setLineWidth(0.5, l2)
	setLineColor(Farbe, l2)
	
	l3 = createLine( pageWidth-Abstand, 0, pageWidth-Abstand, Laenge)
	setLineWidth(0.5, l3)
	setLineColor(Farbe, l3)
	l4 = createLine( pageWidth-Laenge, Abstand, pageWidth, Abstand)
	setLineWidth(0.5, l4)
	setLineColor(Farbe, l4)
	
	l5 = createLine( 0, pageHeight-Abstand, Laenge, pageHeight-Abstand)
	setLineWidth(0.5, l5)
	setLineColor(Farbe, l5)
	l6 = createLine( Abstand, pageHeight, Abstand, pageHeight-Laenge)
	setLineWidth(0.5, l6)
	setLineColor(Farbe, l6)

	l7 = createLine( pageWidth-0, pageHeight-Abstand, pageWidth-Laenge, pageHeight-Abstand)
	setLineWidth(0.5, l7)
	setLineColor(Farbe, l7)
	l8 = createLine( pageWidth-Abstand, pageHeight, pageWidth-Abstand, pageHeight-Laenge)
	setLineWidth(0.5, l8)
	setLineColor(Farbe, l8)



if haveDoc():
	setUnit(UNIT_MILLIMETERS) 
	pageWidth, pageHeight = getPageSize()
	Schnitte( 10, "alle" )
	allePasser( 10, "alle" )
	# Graukeil
	x = pageWidth/2 - 12*4
	r01 = createRect( x, 2, 4, 4 )
	setFillColor ("schwarz90", r01 )
	x = x+4
	r02 = createRect( x, 2, 4, 4 )
	setFillColor ("schwarz80", r02 )
	x = x+4
	r03 = createRect( x, 2, 4, 4 )
	setFillColor ("schwarz70", r03 )
	x = x+4
	r04 = createRect( x, 2, 4, 4 )
	setFillColor ("schwarz60", r04 )
	x = x+4
	r05 = createRect( x, 2, 4, 4 )
	setFillColor ("schwarz50", r05 )
	x = x+4
	r06 = createRect( x, 2, 4, 4 )
	setFillColor ("schwarz40", r06 )
	x = x+4
	r07 = createRect( x, 2, 4, 4 )
	setFillColor ("schwarz30", r07 )
	x = x+4
	r08 = createRect( x, 2, 4, 4 )
	setFillColor ("schwarz20", r08 )
	x = x+4
	r09 = createRect( x, 2, 4, 4 )
	setFillColor ("schwarz10", r09 )
	x = x+4
	r10 = createRect( x, 2, 4, 4 )
	setFillColor ("transparent", r10 )
	# Farben	
	x = pageWidth/2 + 2*4
	r11 = createRect( x, 2, 4, 4 )
	setFillColor ("gelb", r11 )
	x = x+4
	r12 = createRect( x, 2, 4, 4 )
	setFillColor ("magenta", r12 )
	x = x+4
	r13 = createRect( x, 2, 4, 4 )
	setFillColor ("cyan", r13 )
	x = x+4
	r14 = createRect( x, 2, 4, 4 )
	setFillColor ("blau", r14 )
	x = x+4
	r15 = createRect( x, 2, 4, 4 )
	setFillColor ("gruen", r15 )
	x = x+4
	r16 = createRect( x, 2, 4, 4 )
	setFillColor ("rot", r16 )
	x = x+4
	r17 = createRect( x, 2, 4, 4 )
	setFillColor ("schwarz", r17 )
	x = x+4
	r18 = createRect( x, 2, 4, 4 )
	setFillColor ("gelb50", r18 )
	x = x+4
	r19 = createRect( x, 2, 4, 4 )
	setFillColor ("magenta50", r19 )
	x = x+4
	r20 = createRect( x, 2, 4, 4 )
	setFillColor ("cyan50", r20 )