Pivot point

Talk about Pixelmator Pro, share tips & tricks, tutorials, and other resources.
User avatar

2020-10-28 17:54:18

I know there are a different topic from 2018 about th ability to change the pivot point which is very useful for rotation. I was wondering when are we getting this feature?

If not many people are requesting this feature and that's why is not implemented yet.. then how people manage to rotate stuff around?

I can group a rectangle (with opacity 0) with the specific node and later rotate the whole group.. but this method is very clunky

I was trying to re-create a blade like this one https://www.youtube.com/watch?v=5ceWu-Czoek but .. without the ability to freely change the pivot point.. the task becomes very hard and time consuming

P.S
tell application "Pixelmator Pro"
	tell front document to tell current layer
		set theName to its name
	end tell
	
	repeat with theIncrementValue from 1 to 9
		
		tell front document to duplicate layer theName
		
		tell front document to tell current layer
			set rotation to theIncrementValue * 40
		end tell
		
	end repeat
	
end tell
With this script I can dublicate the grouped layer and rotate it keeping the pivot rotation at the centre of the document.. but still there have to be a easy and better way!
User avatar

2020-10-28 20:22:58

Here is example how to use Math from JavaScriptCore to make shapes in a circle, maybe its useful for you.
use AppleScript version "2.4"
use framework "JavaScriptCore"
use framework "GameplayKit"

--~~~~~~~~~~~~~~~~~~~~~~~
property shapeAmount : 10
property shapeGap : 225
property shapeWidth : 125
property shapeHeight : 125
-- property xOrigin : 512
-- property yOrigin : 512
--~~~~~~~~~~~~~~~~~~~~~~~

set shapeSize to {shapeWidth, shapeHeight}

my circleOfShapesAt:{512, 512} shapeSize:shapeSize shapeAmount:shapeAmount shapeGap:shapeGap shapeType:"rect"
my circleOfShapesAt:{1024, 512} shapeSize:shapeSize shapeAmount:shapeAmount shapeGap:shapeGap shapeType:"ellipse"
my circleOfShapesAt:{1536, 512} shapeSize:shapeSize shapeAmount:shapeAmount shapeGap:shapeGap shapeType:"star"
my circleOfShapesAt:{2048, 512} shapeSize:shapeSize shapeAmount:shapeAmount shapeGap:shapeGap shapeType:"polygon"

on circleOfShapesAt:_shapeOrigin shapeSize:_shapeSize shapeAmount:_shapeAmount shapeGap:_shapeGap shapeType:_shapeString
	repeat with i from 1 to _shapeAmount
		set tAngle to (i * (360 / _shapeAmount))
		set tRadians to tAngle * pi / 180
		
		set {xOrigin, yOrigin} to _shapeOrigin
		
		set xCentre to xOrigin + _shapeGap * (doJsMath("cos", (tRadians)))
		set yCentre to yOrigin + _shapeGap * (doJsMath("sin", (tRadians)))
		
		set xPos to xCentre
		set yPos to yCentre
		
		-- Make new shape code with position x, y and width and height
		if (_shapeString = "rect") then
			set makeShape to (my makeShapeRect:{xPos, yPos} shapeSize:_shapeSize)
		end if
		if (_shapeString = "ellipse") then
			set makeShape to (my makeShapeEllipse:{xPos, yPos} shapeSize:_shapeSize)
		end if
		if (_shapeString = "polygon") then
			set makeShape to (my makeShapePolygon:{xPos, yPos} shapeSize:_shapeSize)
		end if
		if (_shapeString = "star") then
			set makeShape to (my makeShapeStar:{xPos, yPos} shapeSize:_shapeSize)
		end if
	end repeat
end circleOfShapesAt:shapeSize:shapeAmount:shapeGap:shapeType:

on makeShapeRect:_Pos shapeSize:_Size
	tell application "Pixelmator Pro"
		set {theWidth, theHeight} to _Size
		tell front document
			set theProperties to {position:_Pos, width:theWidth, height:theHeight, rotation:my randomMinMax(1, 360)}
			make new rectangle shape layer at the beginning of layers with properties theProperties
		end tell
	end tell
end makeShapeRect:shapeSize:

on makeShapeEllipse:_Pos shapeSize:_Size
	tell application "Pixelmator Pro"
		set {theWidth, theHeight} to _Size
		tell front document
			set theProperties to {position:_Pos, width:theWidth, height:theHeight}
			make new ellipse shape layer at the beginning of layers with properties theProperties
		end tell
	end tell
end makeShapeEllipse:shapeSize:

on makeShapePolygon:_Pos shapeSize:_Size
	tell application "Pixelmator Pro"
		set {theWidth, theHeight} to _Size
		tell front document
			set theProperties to {position:_Pos, width:theWidth, height:theHeight, rotation:my randomMinMax(1, 360)}
			make new polygon shape layer at the beginning of layers with properties theProperties
		end tell
	end tell
end makeShapePolygon:shapeSize:

on makeShapeStar:_Pos shapeSize:_Size
	tell application "Pixelmator Pro"
		set {theWidth, theHeight} to _Size
		tell front document
			set theProperties to {position:_Pos, width:theWidth, height:theHeight, rotation:my randomMinMax(1, 360)}
			make new star shape layer at the beginning of layers with properties theProperties
		end tell
	end tell
end makeShapeStar:shapeSize:

on randomMinMax(_min, _max)
	set randomSource to current application's GKRandomSource's alloc()'s init()
	set dist to current application's GKShuffledDistribution's alloc()'s initWithRandomSource:randomSource lowestValue:(_min as integer) highestValue:(_max as integer)
	return (dist's nextInt()) as integer
end randomMinMax

on doJsMath(theMethod, argsList)
	if class of argsList is not list then set argsList to {argsList}
	set theContext to current application's JSContext's new()
	set theMathObject to theContext's objectForKeyedSubscript:"Math"
	return (theMathObject's invokeMethod:theMethod withArguments:argsList)'s toDouble()
end doJsMath