pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

pastebin - collaborative debugging tool View Help


Posted by Chris on Thu 1 Oct 01:14
report abuse | download | new post

  1. GIMP 2.6.1 Python Console
  2. Python 2.5.2 (r252:60911, Oct  5 2008, 19:24:49)
  3. [GCC 4.3.2]
  4.  
  5. >>> img = gimp.image_list()[0];
  6. >>> print img
  7. <gimp.Image 'Untitled'>
  8.  
  9. >>> print img.vectors
  10. []
  11. >>> print img.vectors
  12. [<gimp.Vectors 'path1'>, <gimp.Vectors 'Unnamed'>]
  13. >>> dir(img.vectors)
  14. ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__str__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
  15. >>> print img.vectors[0]
  16. <gimp.Vectors 'path1'>
  17.  
  18.  
  19. >>> print img.vectors[0].strokes
  20. [<gimp.VectorsBezierStroke 1 of gimp.Vectors 'path1'>]
  21. >>> dir(img.vectors[0].strokes[0])
  22. ['ID', '__class__', '__cmp__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'close', 'conicto', 'cubicto', 'flip', 'flip_free', 'get_length', 'get_point_at_dist', 'interpolate', 'lineto', 'new_ellipse', 'new_moveto', 'points', 'rotate', 'scale', 'translate', 'vectors_ID']
  23. >>> print img.vectors[0].strokes[0].points
  24. ([293.29108458216916, 368.30403860807724, 291.6248412496825, 368.30403860807724, 289.95859791719585, 368.30403860807724, 141.66294132588266, 291.86004572009142, 141.66294132588266, 291.86004572009142, 141.66294132588266, 291.86004572009142], False)
  25. >>> startx = img.vectors[0].strokes[0].points[0]
  26. >>> print startx
  27. [293.29108458216916, 368.30403860807724, 291.6248412496825, 368.30403860807724, 289.95859791719585, 368.30403860807724, 141.66294132588266, 291.86004572009142, 141.66294132588266, 291.86004572009142, 141.66294132588266, 291.86004572009142]
  28. >>> startx = img.vectors[0].strokes[0].points[1]
  29. >>> print startx
  30. False
  31. >>> startx = img.vectors[0].strokes[0].points[0][0]
  32. >>> print startx
  33. 293.291084582
  34. >>> starty = img.vectors[0].strokes[0].points[0][1]
  35. >>> print starty
  36. 368.304038608
  37. >>> desty = img.vectors[0].strokes[0].points.pop()
  38. Traceback (most recent call last):
  39.   File "<input>", line 1, in <module>
  40. AttributeError: 'tuple' object has no attribute 'pop'
  41. >>> desty = img.vectors[0].strokes[0].points[0].pop()
  42. >>> print desty
  43. 291.86004572
  44. >>> destx = img.vectors[0].strokes[0].points[0].pop()
  45. >>> print destx
  46. 291.86004572
  47.  
  48.  
  49.  
  50. >>> destx = img.vectors[0].strokes[0].points[0].pop(-1)
  51. >>> print destx
  52. 291.86004572
  53. >>> print img.vectors[0].strokes[0].points
  54. ([293.29108458216916, 368.30403860807724, 291.6248412496825, 368.30403860807724, 289.95859791719585, 368.30403860807724, 141.66294132588266, 291.86004572009142, 141.66294132588266, 291.86004572009142, 141.66294132588266, 291.86004572009142], False)
  55. >>> destx = img.vectors[0].strokes[0].points[0].pop(1)
  56. >>> print destx
  57. 368.304038608
  58. >>> destx = img.vectors[0].strokes[0].points[0].pop(-2)
  59. >>> print destx
  60. 141.662941326
  61.  
  62. >>> origin1 = ((img.layers[0].width/2), img.layers[0].height/2)
  63. >>> print origin1
  64. (320, 200)
  65.  
  66. >>> origin = ((img.width/2), (img.height/2))
  67. >>> print origin
  68. (320, 200)
  69. >>> sideA = origin[0] - destx
  70. >>> print sideA
  71. 178.337058674
  72. >>> import math
  73.  
  74.  
  75. >>> sideA = math.sqrt(((origin[0]-destx)**2)+(origin[1]-desty)**2)
  76. >>> print sideA
  77. 200.605021114
  78. >>> sideB = math.sqrt(((origin[0]-startx)**2)+(origin[1]-starty)**2)
  79. >>> print sideB
  80. 170.410139295
  81. >>> sideB = math.sqrt((sideA**2)+(sideB**2))
  82. >>> sideB = math.sqrt(((origin[0]-startx)**2)+(origin[1]-starty)**2)
  83. >>> sideC = math.sqrt((sideA**2)+(sideB**2))
  84.  
  85.  
  86.  
  87. >>> angleC = math.acos((sideA**2 + sideB**2 - sideA**2)/(2*sideA*sideB)
  88. ...
  89. ...
  90. ... )
  91. >>> print angleC
  92. 1.1321211413
  93. >>> print math.degrees(angleC)
  94. 64.8657632943
  95.  
  96.  
  97. >>> help(img.layers[1].transform_rotate)
  98. Help on built-in function transform_rotate:
  99.  
  100. transform_rotate(...)
  101.  
  102. >>> img.layers[1].transform_rotate(math.degrees(angleC), 0, origin[0], origin[1], 1, 0)
  103. <gimp.Layer 'Background'>
  104. >>> img.layers[1].transform_rotate(math.degrees(angleC), 0, origin[0], origin[1], 1, 0)
  105. <gimp.Layer 'Background'>
  106. >>> print img.layers
  107. [<gimp.Layer 'New Layer'>, <gimp.Layer 'Background'>]
  108. >>> img.layers[0].transform_rotate(math.degrees(angleC), 0, origin[0], origin[1], 1, 0)
  109. <gimp.Layer 'New Layer'>
  110.  
  111. >>> img.layers[0].transform_rotate(math.degrees(angleC), 0, origin[0], origin[1], 1, 1)
  112. <gimp.Layer 'New Layer'>
  113. >>> img.layers[0].transform_rotate(math.degrees(angleC), 1, origin[0], origin[1], 1, 1)
  114. <gimp.Layer 'New Layer'>
  115. >>> img.layers[0].transform_rotate_default(math.degrees(angleC), 1, origin[0], origin[1], 1, 1)
  116. <gimp.Layer 'New Layer'>
  117. >>> img.layers[0].transform_rotate_default(math.degrees(angleC), 0, origin[0], origin[1], 1, 0)
  118. <gimp.Layer 'New Layer'>
  119. >>> pdb.gimp_rotate(img.layers[0], FALSE, math.degrees(angleC))
  120. /usr/lib/gimp/2.0/plug-ins/python-console.py:1: DeprecationWarning: gimpenums.FALSE is deprecated, use False instead
  121.   #!/usr/bin/env python
  122. <gimp.Layer 'New Layer'>
  123. >>> pdb.gimp_rotate(img.layers[0], FALSE, math.degrees(angleC))
  124. <gimp.Layer 'New Layer'>
  125. >>>

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post