working model
This commit is contained in:
parent
7b69abdd9d
commit
9d1b159e83
@ -2,10 +2,9 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="f410c5c2-3ffe-4260-93eb-e3d83256d263" name="Default Changelist" comment="">
|
<list default="true" id="f410c5c2-3ffe-4260-93eb-e3d83256d263" name="Default Changelist" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/python-backend.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/python-backend.iml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/image_diff_color.py" beforeDir="false" afterPath="$PROJECT_DIR$/image_tools.py" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/index.py" beforeDir="false" afterPath="$PROJECT_DIR$/index.py" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -17,8 +16,8 @@
|
|||||||
<file pinned="false" current-in-tab="true">
|
<file pinned="false" current-in-tab="true">
|
||||||
<entry file="file://$PROJECT_DIR$/index.py">
|
<entry file="file://$PROJECT_DIR$/index.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="240">
|
<state relative-caret-position="270">
|
||||||
<caret line="16" lean-forward="true" selection-start-line="16" selection-end-line="16" />
|
<caret line="18" column="46" selection-start-line="18" selection-start-column="46" selection-end-line="18" selection-end-column="46" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="e#0#21#0" expanded="true" />
|
<element signature="e#0#21#0" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
@ -26,20 +25,37 @@
|
|||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
</file>
|
</file>
|
||||||
|
<file pinned="false" current-in-tab="false">
|
||||||
|
<entry file="file://$PROJECT_DIR$/lib/test-images/lot-5-cars-B.jpg">
|
||||||
|
<provider selected="true" editor-type-id="images" />
|
||||||
|
</entry>
|
||||||
|
</file>
|
||||||
|
<file pinned="false" current-in-tab="false">
|
||||||
|
<entry file="file://$PROJECT_DIR$/camera.py">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="165">
|
||||||
|
<caret line="11" column="14" selection-start-line="11" selection-start-column="14" selection-end-line="11" selection-end-column="14" />
|
||||||
|
<folding>
|
||||||
|
<element signature="e#0#13#0" expanded="true" />
|
||||||
|
</folding>
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
</file>
|
||||||
<file pinned="false" current-in-tab="false">
|
<file pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/.gitignore">
|
<entry file="file://$PROJECT_DIR$/.gitignore">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="15">
|
<state relative-caret-position="15">
|
||||||
<caret line="1" column="13" lean-forward="true" selection-start-line="1" selection-start-column="13" selection-end-line="1" selection-end-column="13" />
|
<caret line="1" column="13" selection-start-line="1" selection-start-column="13" selection-end-line="1" selection-end-column="13" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
</file>
|
</file>
|
||||||
<file pinned="false" current-in-tab="false">
|
<file pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/image_diff_color.py">
|
<entry file="file://$PROJECT_DIR$/image_tools.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="435">
|
<state relative-caret-position="-379">
|
||||||
<caret line="29" column="30" selection-start-line="29" selection-start-column="30" selection-end-line="29" selection-end-column="30" />
|
<caret line="27" column="1" selection-start-line="27" selection-start-column="1" selection-end-line="27" selection-end-column="1" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
@ -59,8 +75,9 @@
|
|||||||
<component name="IdeDocumentHistory">
|
<component name="IdeDocumentHistory">
|
||||||
<option name="CHANGED_PATHS">
|
<option name="CHANGED_PATHS">
|
||||||
<list>
|
<list>
|
||||||
<option value="$PROJECT_DIR$/image_diff_color.py" />
|
|
||||||
<option value="$PROJECT_DIR$/.gitignore" />
|
<option value="$PROJECT_DIR$/.gitignore" />
|
||||||
|
<option value="$PROJECT_DIR$/image_diff_color.py" />
|
||||||
|
<option value="$PROJECT_DIR$/camera.py" />
|
||||||
<option value="$PROJECT_DIR$/index.py" />
|
<option value="$PROJECT_DIR$/index.py" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
@ -83,6 +100,17 @@
|
|||||||
<item name="python-backend" type="b2602c69:ProjectViewProjectNode" />
|
<item name="python-backend" type="b2602c69:ProjectViewProjectNode" />
|
||||||
<item name="python-backend" type="462c0819:PsiDirectoryNode" />
|
<item name="python-backend" type="462c0819:PsiDirectoryNode" />
|
||||||
</path>
|
</path>
|
||||||
|
<path>
|
||||||
|
<item name="python-backend" type="b2602c69:ProjectViewProjectNode" />
|
||||||
|
<item name="python-backend" type="462c0819:PsiDirectoryNode" />
|
||||||
|
<item name="lib" type="462c0819:PsiDirectoryNode" />
|
||||||
|
</path>
|
||||||
|
<path>
|
||||||
|
<item name="python-backend" type="b2602c69:ProjectViewProjectNode" />
|
||||||
|
<item name="python-backend" type="462c0819:PsiDirectoryNode" />
|
||||||
|
<item name="lib" type="462c0819:PsiDirectoryNode" />
|
||||||
|
<item name="test-images" type="462c0819:PsiDirectoryNode" />
|
||||||
|
</path>
|
||||||
</expand>
|
</expand>
|
||||||
<select />
|
<select />
|
||||||
</subPane>
|
</subPane>
|
||||||
@ -123,18 +151,18 @@
|
|||||||
<frame x="0" y="27" width="1920" height="1053" extended-state="6" />
|
<frame x="0" y="27" width="1920" height="1053" extended-state="6" />
|
||||||
<editor active="true" />
|
<editor active="true" />
|
||||||
<layout>
|
<layout>
|
||||||
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.18133895" />
|
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.18133895" />
|
||||||
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
||||||
<window_info id="Favorites" order="2" side_tool="true" />
|
<window_info id="Favorites" order="2" side_tool="true" />
|
||||||
<window_info anchor="bottom" id="Message" order="0" />
|
<window_info anchor="bottom" id="Message" order="0" />
|
||||||
<window_info anchor="bottom" id="Find" order="1" />
|
<window_info anchor="bottom" id="Find" order="1" weight="0.32972974" />
|
||||||
<window_info anchor="bottom" id="Run" order="2" />
|
<window_info anchor="bottom" id="Run" order="2" />
|
||||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
|
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
|
||||||
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
||||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||||
<window_info anchor="bottom" id="TODO" order="6" />
|
<window_info anchor="bottom" id="TODO" order="6" />
|
||||||
<window_info anchor="bottom" id="Version Control" order="7" />
|
<window_info anchor="bottom" id="Version Control" order="7" />
|
||||||
<window_info active="true" anchor="bottom" id="Terminal" order="8" visible="true" weight="0.32972974" />
|
<window_info anchor="bottom" id="Terminal" order="8" visible="true" weight="0.32972974" />
|
||||||
<window_info anchor="bottom" id="Python Console" order="9" />
|
<window_info anchor="bottom" id="Python Console" order="9" />
|
||||||
<window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
|
<window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
|
||||||
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
|
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
|
||||||
@ -143,9 +171,6 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</component>
|
</component>
|
||||||
<component name="editorHistoryManager">
|
<component name="editorHistoryManager">
|
||||||
<entry file="file://$PROJECT_DIR$/lib/test-images/lot-1-car.jpg">
|
|
||||||
<provider selected="true" editor-type-id="images" />
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/image_diff_simple.py" />
|
<entry file="file://$PROJECT_DIR$/image_diff_simple.py" />
|
||||||
<entry file="file://$PROJECT_DIR$/image_diff_ssim.py" />
|
<entry file="file://$PROJECT_DIR$/image_diff_ssim.py" />
|
||||||
<entry file="file://$PROJECT_DIR$/lib/test-images/lot-empty.jpg">
|
<entry file="file://$PROJECT_DIR$/lib/test-images/lot-empty.jpg">
|
||||||
@ -154,24 +179,46 @@
|
|||||||
<entry file="file://$PROJECT_DIR$/lib/test-images/lot-3-cars.jpg">
|
<entry file="file://$PROJECT_DIR$/lib/test-images/lot-3-cars.jpg">
|
||||||
<provider selected="true" editor-type-id="images" />
|
<provider selected="true" editor-type-id="images" />
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/image_diff_color.py">
|
<entry file="file://$PROJECT_DIR$/test.jpg">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="images" />
|
||||||
<state relative-caret-position="435">
|
</entry>
|
||||||
<caret line="29" column="30" selection-start-line="29" selection-start-column="30" selection-end-line="29" selection-end-column="30" />
|
<entry file="file://$PROJECT_DIR$/capture.jpg">
|
||||||
</state>
|
<provider selected="true" editor-type-id="images" />
|
||||||
</provider>
|
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/.gitignore">
|
<entry file="file://$PROJECT_DIR$/.gitignore">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="15">
|
<state relative-caret-position="15">
|
||||||
<caret line="1" column="13" lean-forward="true" selection-start-line="1" selection-start-column="13" selection-end-line="1" selection-end-column="13" />
|
<caret line="1" column="13" selection-start-line="1" selection-start-column="13" selection-end-line="1" selection-end-column="13" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/camera.py">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="165">
|
||||||
|
<caret line="11" column="14" selection-start-line="11" selection-start-column="14" selection-end-line="11" selection-end-column="14" />
|
||||||
|
<folding>
|
||||||
|
<element signature="e#0#13#0" expanded="true" />
|
||||||
|
</folding>
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/image_tools.py">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="-379">
|
||||||
|
<caret line="27" column="1" selection-start-line="27" selection-start-column="1" selection-end-line="27" selection-end-column="1" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/lib/test-images/lot-1-car.jpg">
|
||||||
|
<provider selected="true" editor-type-id="images" />
|
||||||
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/lib/test-images/lot-5-cars-B.jpg">
|
||||||
|
<provider selected="true" editor-type-id="images" />
|
||||||
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/index.py">
|
<entry file="file://$PROJECT_DIR$/index.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="240">
|
<state relative-caret-position="270">
|
||||||
<caret line="16" lean-forward="true" selection-start-line="16" selection-end-line="16" />
|
<caret line="18" column="46" selection-start-line="18" selection-start-column="46" selection-end-line="18" selection-end-column="46" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="e#0#21#0" expanded="true" />
|
<element signature="e#0#21#0" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
|
14
camera.py
Normal file
14
camera.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import pygame
|
||||||
|
import pygame.camera
|
||||||
|
|
||||||
|
|
||||||
|
def capture():
|
||||||
|
pygame.camera.init()
|
||||||
|
pygame.camera.list_cameras()
|
||||||
|
cam = pygame.camera.Camera('/dev/video4', (640, 480))
|
||||||
|
cam.start()
|
||||||
|
img = cam.get_image()
|
||||||
|
pygame.image.save(img, './capture.jpg')
|
||||||
|
return './capture.jpg'
|
||||||
|
|
||||||
|
|
BIN
capture.jpg
Normal file
BIN
capture.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
@ -1,84 +0,0 @@
|
|||||||
from PIL import Image
|
|
||||||
|
|
||||||
def average_color(x, y, n, image):
|
|
||||||
r, g, b = 0, 0, 0
|
|
||||||
count = 0
|
|
||||||
for s in range(x, x + n + 1):
|
|
||||||
for t in range(y, y + n + 1):
|
|
||||||
pixlr, pixlg, pixlb = image[s, t]
|
|
||||||
r += pixlr
|
|
||||||
g += pixlg
|
|
||||||
b += pixlb
|
|
||||||
count += 1
|
|
||||||
return ((r / count), (g / count), (b / count))
|
|
||||||
|
|
||||||
def differences(rgb_tuple1, rgb_tuple2):
|
|
||||||
r1, g1, b1 = rgb_tuple1
|
|
||||||
r2, g2, b2 = rgb_tuple2
|
|
||||||
|
|
||||||
return ((r1-r2), (g1-g2), (b1-b2))
|
|
||||||
|
|
||||||
def threshold(diff_tuple, trigger=4):
|
|
||||||
dr, dg, db = diff_tuple
|
|
||||||
return (((( dr**4 + dg**4 + db**4 ) / 3)**0.25) > trigger) # Thanks to Thomas Atkins, math whiz
|
|
||||||
|
|
||||||
|
|
||||||
reference_image = Image.open('./lib/test-images/lot-empty.jpg').load()
|
|
||||||
compare_image = Image.open('./lib/test-images/lot-1-car.jpg').load()
|
|
||||||
|
|
||||||
stall_1 = {
|
|
||||||
'location': (54, 79, 109),
|
|
||||||
'reference': average_color(54, 79, 109, reference_image),
|
|
||||||
'compare': average_color(54, 79, 109, compare_image)
|
|
||||||
}
|
|
||||||
|
|
||||||
stall_2 = {
|
|
||||||
'location': (186, 81, 116),
|
|
||||||
'reference': average_color(186, 81, 116, reference_image),
|
|
||||||
'compare': average_color(186, 81, 116, compare_image)
|
|
||||||
}
|
|
||||||
|
|
||||||
stall_3 = {
|
|
||||||
'location': (317, 71, 127),
|
|
||||||
'reference': average_color(317, 71, 127, reference_image),
|
|
||||||
'compare': average_color(317, 71, 127, compare_image)
|
|
||||||
}
|
|
||||||
|
|
||||||
stall_4 = {
|
|
||||||
'location': (469, 76, 100),
|
|
||||||
'reference': average_color(469, 76, 100, reference_image),
|
|
||||||
'compare': average_color(469, 76, 100, compare_image)
|
|
||||||
}
|
|
||||||
|
|
||||||
stall_5 = {
|
|
||||||
'location': (27, 237, 119),
|
|
||||||
'reference': average_color(27, 237, 119, reference_image),
|
|
||||||
'compare': average_color(27, 237, 119, compare_image)
|
|
||||||
}
|
|
||||||
|
|
||||||
stall_6 = {
|
|
||||||
'location': (172, 240, 130),
|
|
||||||
'reference': average_color(172, 240, 130, reference_image),
|
|
||||||
'compare': average_color(172, 240, 130, compare_image)
|
|
||||||
}
|
|
||||||
|
|
||||||
stall_7 = {
|
|
||||||
'location': (317, 234, 144),
|
|
||||||
'reference': average_color(317, 234, 144, reference_image),
|
|
||||||
'compare': average_color(317, 234, 144, compare_image)
|
|
||||||
}
|
|
||||||
|
|
||||||
stall_8 = {
|
|
||||||
'location': (481, 233, 112),
|
|
||||||
'reference': average_color(481, 233, 112, reference_image),
|
|
||||||
'compare': average_color(481, 233, 112, compare_image)
|
|
||||||
}
|
|
||||||
|
|
||||||
print(threshold(differences(stall_1['reference'], stall_1['compare'])))
|
|
||||||
print(threshold(differences(stall_2['reference'], stall_2['compare'])))
|
|
||||||
print(threshold(differences(stall_3['reference'], stall_3['compare'])))
|
|
||||||
print(threshold(differences(stall_4['reference'], stall_4['compare'])))
|
|
||||||
print(threshold(differences(stall_5['reference'], stall_5['compare'])))
|
|
||||||
print(threshold(differences(stall_6['reference'], stall_6['compare'])))
|
|
||||||
print(threshold(differences(stall_7['reference'], stall_7['compare'])))
|
|
||||||
print(threshold(differences(stall_8['reference'], stall_8['compare'])))
|
|
84
image_tools.py
Normal file
84
image_tools.py
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
def average_color(x, y, n, image):
|
||||||
|
r, g, b = 0, 0, 0
|
||||||
|
count = 0
|
||||||
|
for s in range(x, x + n + 1):
|
||||||
|
for t in range(y, y + n + 1):
|
||||||
|
pixlr, pixlg, pixlb = image[s, t]
|
||||||
|
r += pixlr
|
||||||
|
g += pixlg
|
||||||
|
b += pixlb
|
||||||
|
count += 1
|
||||||
|
return ((r / count), (g / count), (b / count))
|
||||||
|
|
||||||
|
def differences(rgb_tuple1, rgb_tuple2):
|
||||||
|
r1, g1, b1 = rgb_tuple1
|
||||||
|
r2, g2, b2 = rgb_tuple2
|
||||||
|
|
||||||
|
return ((r1-r2), (g1-g2), (b1-b2))
|
||||||
|
|
||||||
|
def threshold(diff_tuple, trigger=4):
|
||||||
|
dr, dg, db = diff_tuple
|
||||||
|
return (((( dr**4 + dg**4 + db**4 ) / 3)**0.25) > trigger) # Thanks to Thomas Atkins, math whiz
|
||||||
|
|
||||||
|
#
|
||||||
|
# reference_image = Image.open('./lib/test-images/lot-empty.jpg').load()
|
||||||
|
# compare_image = Image.open('./lib/test-images/lot-1-car.jpg').load()
|
||||||
|
#
|
||||||
|
# stall_1 = {
|
||||||
|
# 'location': (54, 79, 109),
|
||||||
|
# 'reference': average_color(54, 79, 109, reference_image),
|
||||||
|
# 'compare': average_color(54, 79, 109, compare_image)
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# stall_2 = {
|
||||||
|
# 'location': (186, 81, 116),
|
||||||
|
# 'reference': average_color(186, 81, 116, reference_image),
|
||||||
|
# 'compare': average_color(186, 81, 116, compare_image)
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# stall_3 = {
|
||||||
|
# 'location': (317, 71, 127),
|
||||||
|
# 'reference': average_color(317, 71, 127, reference_image),
|
||||||
|
# 'compare': average_color(317, 71, 127, compare_image)
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# stall_4 = {
|
||||||
|
# 'location': (469, 76, 100),
|
||||||
|
# 'reference': average_color(469, 76, 100, reference_image),
|
||||||
|
# 'compare': average_color(469, 76, 100, compare_image)
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# stall_5 = {
|
||||||
|
# 'location': (27, 237, 119),
|
||||||
|
# 'reference': average_color(27, 237, 119, reference_image),
|
||||||
|
# 'compare': average_color(27, 237, 119, compare_image)
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# stall_6 = {
|
||||||
|
# 'location': (172, 240, 130),
|
||||||
|
# 'reference': average_color(172, 240, 130, reference_image),
|
||||||
|
# 'compare': average_color(172, 240, 130, compare_image)
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# stall_7 = {
|
||||||
|
# 'location': (317, 234, 144),
|
||||||
|
# 'reference': average_color(317, 234, 144, reference_image),
|
||||||
|
# 'compare': average_color(317, 234, 144, compare_image)
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# stall_8 = {
|
||||||
|
# 'location': (481, 233, 112),
|
||||||
|
# 'reference': average_color(481, 233, 112, reference_image),
|
||||||
|
# 'compare': average_color(481, 233, 112, compare_image)
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# print(threshold(differences(stall_1['reference'], stall_1['compare'])))
|
||||||
|
# print(threshold(differences(stall_2['reference'], stall_2['compare'])))
|
||||||
|
# print(threshold(differences(stall_3['reference'], stall_3['compare'])))
|
||||||
|
# print(threshold(differences(stall_4['reference'], stall_4['compare'])))
|
||||||
|
# print(threshold(differences(stall_5['reference'], stall_5['compare'])))
|
||||||
|
# print(threshold(differences(stall_6['reference'], stall_6['compare'])))
|
||||||
|
# print(threshold(differences(stall_7['reference'], stall_7['compare'])))
|
||||||
|
# print(threshold(differences(stall_8['reference'], stall_8['compare'])))
|
27
include/site/python3.7/pygame/_camera.h
Normal file
27
include/site/python3.7/pygame/_camera.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
pygame - Python Game Library
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CAMERA_H
|
||||||
|
#define _CAMERA_H
|
||||||
|
|
||||||
|
#include "_pygame.h"
|
||||||
|
#include "camera.h"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
715
include/site/python3.7/pygame/_pygame.h
Normal file
715
include/site/python3.7/pygame/_pygame.h
Normal file
@ -0,0 +1,715 @@
|
|||||||
|
/*
|
||||||
|
pygame - Python Game Library
|
||||||
|
Copyright (C) 2000-2001 Pete Shinners
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
Pete Shinners
|
||||||
|
pete@shinners.org
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _PYGAME_H
|
||||||
|
#define _PYGAME_H
|
||||||
|
|
||||||
|
/** This header file includes all the definitions for the
|
||||||
|
** base pygame extensions. This header only requires
|
||||||
|
** SDL and Python includes. The reason for functions
|
||||||
|
** prototyped with #define's is to allow for maximum
|
||||||
|
** python portability. It also uses python as the
|
||||||
|
** runtime linker, which allows for late binding. For more
|
||||||
|
** information on this style of development, read the Python
|
||||||
|
** docs on this subject.
|
||||||
|
** http://www.python.org/doc/current/ext/using-cobjects.html
|
||||||
|
**
|
||||||
|
** If using this to build your own derived extensions,
|
||||||
|
** you'll see that the functions available here are mainly
|
||||||
|
** used to help convert between python objects and SDL objects.
|
||||||
|
** Since this library doesn't add a lot of functionality to
|
||||||
|
** the SDL libarary, it doesn't need to offer a lot either.
|
||||||
|
**
|
||||||
|
** When initializing your extension module, you must manually
|
||||||
|
** import the modules you want to use. (this is the part about
|
||||||
|
** using python as the runtime linker). Each module has its
|
||||||
|
** own import_xxx() routine. You need to perform this import
|
||||||
|
** after you have initialized your own module, and before
|
||||||
|
** you call any routines from that module. Since every module
|
||||||
|
** in pygame does this, there are plenty of examples.
|
||||||
|
**
|
||||||
|
** The base module does include some useful conversion routines
|
||||||
|
** that you are free to use in your own extension.
|
||||||
|
**
|
||||||
|
** When making changes, it is very important to keep the
|
||||||
|
** FIRSTSLOT and NUMSLOT constants up to date for each
|
||||||
|
** section. Also be sure not to overlap any of the slots.
|
||||||
|
** When you do make a mistake with this, it will result
|
||||||
|
** is a dereferenced NULL pointer that is easier to diagnose
|
||||||
|
** than it could be :]
|
||||||
|
**/
|
||||||
|
#if defined(HAVE_SNPRINTF) /* defined in python.h (pyerrors.h) and SDL.h (SDL_config.h) */
|
||||||
|
#undef HAVE_SNPRINTF /* remove GCC redefine warning */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// This must be before all else
|
||||||
|
#if defined(__SYMBIAN32__) && defined( OPENC )
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#if defined(__WINS__)
|
||||||
|
void* _alloca(size_t size);
|
||||||
|
# define alloca _alloca
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This is unconditionally defined in Python.h */
|
||||||
|
#if defined(_POSIX_C_SOURCE)
|
||||||
|
#undef _POSIX_C_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Python.h>
|
||||||
|
|
||||||
|
/* Cobjects vanish in Python 3.2; so we will code as though we use capsules */
|
||||||
|
#if defined(Py_CAPSULE_H)
|
||||||
|
#define PG_HAVE_CAPSULE 1
|
||||||
|
#else
|
||||||
|
#define PG_HAVE_CAPSULE 0
|
||||||
|
#endif
|
||||||
|
#if defined(Py_COBJECT_H)
|
||||||
|
#define PG_HAVE_COBJECT 1
|
||||||
|
#else
|
||||||
|
#define PG_HAVE_COBJECT 0
|
||||||
|
#endif
|
||||||
|
#if !PG_HAVE_CAPSULE
|
||||||
|
#define PyCapsule_New(ptr, n, dfn) PyCObject_FromVoidPtr(ptr, dfn)
|
||||||
|
#define PyCapsule_GetPointer(obj, n) PyCObject_AsVoidPtr(obj)
|
||||||
|
#define PyCapsule_CheckExact(obj) PyCObject_Check(obj)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Pygame uses Py_buffer (PEP 3118) to exchange array information internally;
|
||||||
|
* define here as needed.
|
||||||
|
*/
|
||||||
|
#if !defined(PyBUF_SIMPLE)
|
||||||
|
typedef struct bufferinfo {
|
||||||
|
void *buf;
|
||||||
|
PyObject *obj;
|
||||||
|
Py_ssize_t len;
|
||||||
|
Py_ssize_t itemsize;
|
||||||
|
int readonly;
|
||||||
|
int ndim;
|
||||||
|
char *format;
|
||||||
|
Py_ssize_t *shape;
|
||||||
|
Py_ssize_t *strides;
|
||||||
|
Py_ssize_t *suboffsets;
|
||||||
|
void *internal;
|
||||||
|
} Py_buffer;
|
||||||
|
|
||||||
|
/* Flags for getting buffers */
|
||||||
|
#define PyBUF_SIMPLE 0
|
||||||
|
#define PyBUF_WRITABLE 0x0001
|
||||||
|
/* we used to include an E, backwards compatible alias */
|
||||||
|
#define PyBUF_WRITEABLE PyBUF_WRITABLE
|
||||||
|
#define PyBUF_FORMAT 0x0004
|
||||||
|
#define PyBUF_ND 0x0008
|
||||||
|
#define PyBUF_STRIDES (0x0010 | PyBUF_ND)
|
||||||
|
#define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
|
||||||
|
#define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
|
||||||
|
#define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
|
||||||
|
#define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
|
||||||
|
|
||||||
|
#define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITABLE)
|
||||||
|
#define PyBUF_CONTIG_RO (PyBUF_ND)
|
||||||
|
|
||||||
|
#define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITABLE)
|
||||||
|
#define PyBUF_STRIDED_RO (PyBUF_STRIDES)
|
||||||
|
|
||||||
|
#define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT)
|
||||||
|
#define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT)
|
||||||
|
|
||||||
|
#define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT)
|
||||||
|
#define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT)
|
||||||
|
|
||||||
|
|
||||||
|
#define PyBUF_READ 0x100
|
||||||
|
#define PyBUF_WRITE 0x200
|
||||||
|
#define PyBUF_SHADOW 0x400
|
||||||
|
|
||||||
|
typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
|
||||||
|
typedef void (*releasebufferproc)(Py_buffer *);
|
||||||
|
#endif /* #if !defined(PyBUF_SIMPLE) */
|
||||||
|
|
||||||
|
/* Flag indicating a Pg_buffer; used for assertions within callbacks */
|
||||||
|
#ifndef NDEBUG
|
||||||
|
#define PyBUF_PYGAME 0x4000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define PyBUF_HAS_FLAG(f, F) (((f) & (F)) == (F))
|
||||||
|
|
||||||
|
/* Array information exchange struct C type; inherits from Py_buffer
|
||||||
|
*
|
||||||
|
* Pygame uses its own Py_buffer derived C struct as an internal representation
|
||||||
|
* of an imported array buffer. The extended Py_buffer allows for a
|
||||||
|
* per-instance release callback,
|
||||||
|
*/
|
||||||
|
typedef void (*pybuffer_releaseproc)(Py_buffer *);
|
||||||
|
|
||||||
|
typedef struct pg_bufferinfo_s {
|
||||||
|
Py_buffer view;
|
||||||
|
PyObject *consumer; /* Input: Borrowed reference */
|
||||||
|
pybuffer_releaseproc release_buffer;
|
||||||
|
} Pg_buffer;
|
||||||
|
|
||||||
|
/* Operating system specific adjustments
|
||||||
|
*/
|
||||||
|
// No signal()
|
||||||
|
#if defined(__SYMBIAN32__) && defined(HAVE_SIGNAL_H)
|
||||||
|
#undef HAVE_SIGNAL_H
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_SNPRINTF)
|
||||||
|
#undef HAVE_SNPRINTF
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MS_WIN32 /*Python gives us MS_WIN32, SDL needs just WIN32*/
|
||||||
|
#ifndef WIN32
|
||||||
|
#define WIN32
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/// Prefix when initializing module
|
||||||
|
#define MODPREFIX ""
|
||||||
|
/// Prefix when importing module
|
||||||
|
#define IMPPREFIX "pygame."
|
||||||
|
|
||||||
|
#ifdef __SYMBIAN32__
|
||||||
|
#undef MODPREFIX
|
||||||
|
#undef IMPPREFIX
|
||||||
|
// On Symbian there is no pygame package. The extensions are built-in or in sys\bin.
|
||||||
|
#define MODPREFIX "pygame_"
|
||||||
|
#define IMPPREFIX "pygame_"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
|
/* macros used throughout the source */
|
||||||
|
#define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
|
||||||
|
|
||||||
|
#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 3
|
||||||
|
# define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
|
||||||
|
# define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
|
||||||
|
# define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Py_ssize_t availability. */
|
||||||
|
#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
|
||||||
|
typedef int Py_ssize_t;
|
||||||
|
#define PY_SSIZE_T_MAX INT_MAX
|
||||||
|
#define PY_SSIZE_T_MIN INT_MIN
|
||||||
|
typedef inquiry lenfunc;
|
||||||
|
typedef intargfunc ssizeargfunc;
|
||||||
|
typedef intobjargproc ssizeobjargproc;
|
||||||
|
typedef intintargfunc ssizessizeargfunc;
|
||||||
|
typedef intintobjargproc ssizessizeobjargproc;
|
||||||
|
typedef getreadbufferproc readbufferproc;
|
||||||
|
typedef getwritebufferproc writebufferproc;
|
||||||
|
typedef getsegcountproc segcountproc;
|
||||||
|
typedef getcharbufferproc charbufferproc;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define PyType_Init(x) (((x).ob_type) = &PyType_Type)
|
||||||
|
#define PYGAMEAPI_LOCAL_ENTRY "_PYGAME_C_API"
|
||||||
|
|
||||||
|
#ifndef MIN
|
||||||
|
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAX
|
||||||
|
#define MAX(a,b) ( (a) > (b) ? (a) : (b))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ABS
|
||||||
|
#define ABS(a) (((a) < 0) ? -(a) : (a))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* test sdl initializations */
|
||||||
|
#define VIDEO_INIT_CHECK() \
|
||||||
|
if(!SDL_WasInit(SDL_INIT_VIDEO)) \
|
||||||
|
return RAISE(PyExc_SDLError, "video system not initialized")
|
||||||
|
|
||||||
|
#define CDROM_INIT_CHECK() \
|
||||||
|
if(!SDL_WasInit(SDL_INIT_CDROM)) \
|
||||||
|
return RAISE(PyExc_SDLError, "cdrom system not initialized")
|
||||||
|
|
||||||
|
#define JOYSTICK_INIT_CHECK() \
|
||||||
|
if(!SDL_WasInit(SDL_INIT_JOYSTICK)) \
|
||||||
|
return RAISE(PyExc_SDLError, "joystick system not initialized")
|
||||||
|
|
||||||
|
/* BASE */
|
||||||
|
#define VIEW_CONTIGUOUS 1
|
||||||
|
#define VIEW_C_ORDER 2
|
||||||
|
#define VIEW_F_ORDER 4
|
||||||
|
|
||||||
|
#define PYGAMEAPI_BASE_FIRSTSLOT 0
|
||||||
|
#define PYGAMEAPI_BASE_NUMSLOTS 19
|
||||||
|
#ifndef PYGAMEAPI_BASE_INTERNAL
|
||||||
|
#define PyExc_SDLError ((PyObject*)PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT])
|
||||||
|
|
||||||
|
#define PyGame_RegisterQuit \
|
||||||
|
(*(void(*)(void(*)(void)))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 1])
|
||||||
|
|
||||||
|
#define IntFromObj \
|
||||||
|
(*(int(*)(PyObject*, int*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 2])
|
||||||
|
|
||||||
|
#define IntFromObjIndex \
|
||||||
|
(*(int(*)(PyObject*, int, int*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 3])
|
||||||
|
|
||||||
|
#define TwoIntsFromObj \
|
||||||
|
(*(int(*)(PyObject*, int*, int*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 4])
|
||||||
|
|
||||||
|
#define FloatFromObj \
|
||||||
|
(*(int(*)(PyObject*, float*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 5])
|
||||||
|
|
||||||
|
#define FloatFromObjIndex \
|
||||||
|
(*(int(*)(PyObject*, int, float*)) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 6])
|
||||||
|
|
||||||
|
#define TwoFloatsFromObj \
|
||||||
|
(*(int(*)(PyObject*, float*, float*)) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 7])
|
||||||
|
|
||||||
|
#define UintFromObj \
|
||||||
|
(*(int(*)(PyObject*, Uint32*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 8])
|
||||||
|
|
||||||
|
#define UintFromObjIndex \
|
||||||
|
(*(int(*)(PyObject*, int, Uint32*)) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 9])
|
||||||
|
|
||||||
|
#define PyGame_Video_AutoQuit \
|
||||||
|
(*(void(*)(void))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 10])
|
||||||
|
|
||||||
|
#define PyGame_Video_AutoInit \
|
||||||
|
(*(int(*)(void))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 11])
|
||||||
|
|
||||||
|
#define RGBAFromObj \
|
||||||
|
(*(int(*)(PyObject*, Uint8*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 12])
|
||||||
|
|
||||||
|
#define PgBuffer_AsArrayInterface \
|
||||||
|
(*(PyObject*(*)(Py_buffer*)) PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 13])
|
||||||
|
|
||||||
|
#define PgBuffer_AsArrayStruct \
|
||||||
|
(*(PyObject*(*)(Py_buffer*)) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 14])
|
||||||
|
|
||||||
|
#define PgObject_GetBuffer \
|
||||||
|
(*(int(*)(PyObject*, Pg_buffer*, int)) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 15])
|
||||||
|
|
||||||
|
#define PgBuffer_Release \
|
||||||
|
(*(void(*)(Pg_buffer*)) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 16])
|
||||||
|
|
||||||
|
#define PgDict_AsBuffer \
|
||||||
|
(*(int(*)(Pg_buffer*, PyObject*, int)) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 17])
|
||||||
|
|
||||||
|
#define PgExc_BufferError \
|
||||||
|
((PyObject*)PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 18])
|
||||||
|
|
||||||
|
#define import_pygame_base() IMPORT_PYGAME_MODULE(base, BASE)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* RECT */
|
||||||
|
#define PYGAMEAPI_RECT_FIRSTSLOT \
|
||||||
|
(PYGAMEAPI_BASE_FIRSTSLOT + PYGAMEAPI_BASE_NUMSLOTS)
|
||||||
|
#define PYGAMEAPI_RECT_NUMSLOTS 4
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int x, y;
|
||||||
|
int w, h;
|
||||||
|
}GAME_Rect;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD
|
||||||
|
GAME_Rect r;
|
||||||
|
PyObject *weakreflist;
|
||||||
|
} PyRectObject;
|
||||||
|
|
||||||
|
#define PyRect_AsRect(x) (((PyRectObject*)x)->r)
|
||||||
|
#ifndef PYGAMEAPI_RECT_INTERNAL
|
||||||
|
#define PyRect_Check(x) \
|
||||||
|
((x)->ob_type == (PyTypeObject*)PyGAME_C_API[PYGAMEAPI_RECT_FIRSTSLOT + 0])
|
||||||
|
#define PyRect_Type (*(PyTypeObject*)PyGAME_C_API[PYGAMEAPI_RECT_FIRSTSLOT + 0])
|
||||||
|
#define PyRect_New \
|
||||||
|
(*(PyObject*(*)(SDL_Rect*))PyGAME_C_API[PYGAMEAPI_RECT_FIRSTSLOT + 1])
|
||||||
|
#define PyRect_New4 \
|
||||||
|
(*(PyObject*(*)(int,int,int,int))PyGAME_C_API[PYGAMEAPI_RECT_FIRSTSLOT + 2])
|
||||||
|
#define GameRect_FromObject \
|
||||||
|
(*(GAME_Rect*(*)(PyObject*, GAME_Rect*)) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_RECT_FIRSTSLOT + 3])
|
||||||
|
|
||||||
|
#define import_pygame_rect() IMPORT_PYGAME_MODULE(rect, RECT)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* CDROM */
|
||||||
|
#define PYGAMEAPI_CDROM_FIRSTSLOT \
|
||||||
|
(PYGAMEAPI_RECT_FIRSTSLOT + PYGAMEAPI_RECT_NUMSLOTS)
|
||||||
|
#define PYGAMEAPI_CDROM_NUMSLOTS 2
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD
|
||||||
|
int id;
|
||||||
|
} PyCDObject;
|
||||||
|
|
||||||
|
#define PyCD_AsID(x) (((PyCDObject*)x)->id)
|
||||||
|
#ifndef PYGAMEAPI_CDROM_INTERNAL
|
||||||
|
#define PyCD_Check(x) \
|
||||||
|
((x)->ob_type == (PyTypeObject*)PyGAME_C_API[PYGAMEAPI_CDROM_FIRSTSLOT + 0])
|
||||||
|
#define PyCD_Type (*(PyTypeObject*)PyGAME_C_API[PYGAMEAPI_CDROM_FIRSTSLOT + 0])
|
||||||
|
#define PyCD_New \
|
||||||
|
(*(PyObject*(*)(int))PyGAME_C_API[PYGAMEAPI_CDROM_FIRSTSLOT + 1])
|
||||||
|
|
||||||
|
#define import_pygame_cd() IMPORT_PYGAME_MODULE(cdrom, CDROM)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* JOYSTICK */
|
||||||
|
#define PYGAMEAPI_JOYSTICK_FIRSTSLOT \
|
||||||
|
(PYGAMEAPI_CDROM_FIRSTSLOT + PYGAMEAPI_CDROM_NUMSLOTS)
|
||||||
|
#define PYGAMEAPI_JOYSTICK_NUMSLOTS 2
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD
|
||||||
|
int id;
|
||||||
|
} PyJoystickObject;
|
||||||
|
|
||||||
|
#define PyJoystick_AsID(x) (((PyJoystickObject*)x)->id)
|
||||||
|
|
||||||
|
#ifndef PYGAMEAPI_JOYSTICK_INTERNAL
|
||||||
|
#define PyJoystick_Check(x) \
|
||||||
|
((x)->ob_type == (PyTypeObject*) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_JOYSTICK_FIRSTSLOT + 0])
|
||||||
|
|
||||||
|
#define PyJoystick_Type \
|
||||||
|
(*(PyTypeObject*)PyGAME_C_API[PYGAMEAPI_JOYSTICK_FIRSTSLOT + 0])
|
||||||
|
#define PyJoystick_New \
|
||||||
|
(*(PyObject*(*)(int))PyGAME_C_API[PYGAMEAPI_JOYSTICK_FIRSTSLOT + 1])
|
||||||
|
|
||||||
|
#define import_pygame_joystick() IMPORT_PYGAME_MODULE(joystick, JOYSTICK)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* DISPLAY */
|
||||||
|
#define PYGAMEAPI_DISPLAY_FIRSTSLOT \
|
||||||
|
(PYGAMEAPI_JOYSTICK_FIRSTSLOT + PYGAMEAPI_JOYSTICK_NUMSLOTS)
|
||||||
|
#define PYGAMEAPI_DISPLAY_NUMSLOTS 2
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD
|
||||||
|
SDL_VideoInfo info;
|
||||||
|
} PyVidInfoObject;
|
||||||
|
|
||||||
|
#define PyVidInfo_AsVidInfo(x) (((PyVidInfoObject*)x)->info)
|
||||||
|
#ifndef PYGAMEAPI_DISPLAY_INTERNAL
|
||||||
|
#define PyVidInfo_Check(x) \
|
||||||
|
((x)->ob_type == (PyTypeObject*) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_DISPLAY_FIRSTSLOT + 0])
|
||||||
|
|
||||||
|
#define PyVidInfo_Type \
|
||||||
|
(*(PyTypeObject*)PyGAME_C_API[PYGAMEAPI_DISPLAY_FIRSTSLOT + 0])
|
||||||
|
#define PyVidInfo_New \
|
||||||
|
(*(PyObject*(*)(SDL_VideoInfo*)) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_DISPLAY_FIRSTSLOT + 1])
|
||||||
|
#define import_pygame_display() IMPORT_PYGAME_MODULE(display, DISPLAY)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* SURFACE */
|
||||||
|
#define PYGAMEAPI_SURFACE_FIRSTSLOT \
|
||||||
|
(PYGAMEAPI_DISPLAY_FIRSTSLOT + PYGAMEAPI_DISPLAY_NUMSLOTS)
|
||||||
|
#define PYGAMEAPI_SURFACE_NUMSLOTS 3
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD
|
||||||
|
SDL_Surface* surf;
|
||||||
|
struct SubSurface_Data* subsurface; /*ptr to subsurface data (if a
|
||||||
|
* subsurface)*/
|
||||||
|
PyObject *weakreflist;
|
||||||
|
PyObject *locklist;
|
||||||
|
PyObject *dependency;
|
||||||
|
} PySurfaceObject;
|
||||||
|
#define PySurface_AsSurface(x) (((PySurfaceObject*)x)->surf)
|
||||||
|
#ifndef PYGAMEAPI_SURFACE_INTERNAL
|
||||||
|
#define PySurface_Check(x) \
|
||||||
|
((x)->ob_type == (PyTypeObject*) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_SURFACE_FIRSTSLOT + 0])
|
||||||
|
#define PySurface_Type \
|
||||||
|
(*(PyTypeObject*)PyGAME_C_API[PYGAMEAPI_SURFACE_FIRSTSLOT + 0])
|
||||||
|
#define PySurface_New \
|
||||||
|
(*(PyObject*(*)(SDL_Surface*)) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_SURFACE_FIRSTSLOT + 1])
|
||||||
|
#define PySurface_Blit \
|
||||||
|
(*(int(*)(PyObject*,PyObject*,SDL_Rect*,SDL_Rect*,int)) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_SURFACE_FIRSTSLOT + 2])
|
||||||
|
|
||||||
|
#define import_pygame_surface() do { \
|
||||||
|
IMPORT_PYGAME_MODULE(surface, SURFACE); \
|
||||||
|
if (PyErr_Occurred() != NULL) break; \
|
||||||
|
IMPORT_PYGAME_MODULE(surflock, SURFLOCK); \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* SURFLOCK */ /*auto import/init by surface*/
|
||||||
|
#define PYGAMEAPI_SURFLOCK_FIRSTSLOT \
|
||||||
|
(PYGAMEAPI_SURFACE_FIRSTSLOT + PYGAMEAPI_SURFACE_NUMSLOTS)
|
||||||
|
#define PYGAMEAPI_SURFLOCK_NUMSLOTS 8
|
||||||
|
struct SubSurface_Data
|
||||||
|
{
|
||||||
|
PyObject* owner;
|
||||||
|
int pixeloffset;
|
||||||
|
int offsetx, offsety;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
PyObject_HEAD
|
||||||
|
PyObject *surface;
|
||||||
|
PyObject *lockobj;
|
||||||
|
PyObject *weakrefs;
|
||||||
|
} PyLifetimeLock;
|
||||||
|
|
||||||
|
#ifndef PYGAMEAPI_SURFLOCK_INTERNAL
|
||||||
|
#define PyLifetimeLock_Check(x) \
|
||||||
|
((x)->ob_type == (PyTypeObject*) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_SURFLOCK_FIRSTSLOT + 0])
|
||||||
|
#define PySurface_Prep(x) \
|
||||||
|
if(((PySurfaceObject*)x)->subsurface) \
|
||||||
|
(*(*(void(*)(PyObject*)) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_SURFLOCK_FIRSTSLOT + 1]))(x)
|
||||||
|
|
||||||
|
#define PySurface_Unprep(x) \
|
||||||
|
if(((PySurfaceObject*)x)->subsurface) \
|
||||||
|
(*(*(void(*)(PyObject*)) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_SURFLOCK_FIRSTSLOT + 2]))(x)
|
||||||
|
|
||||||
|
#define PySurface_Lock \
|
||||||
|
(*(int(*)(PyObject*))PyGAME_C_API[PYGAMEAPI_SURFLOCK_FIRSTSLOT + 3])
|
||||||
|
#define PySurface_Unlock \
|
||||||
|
(*(int(*)(PyObject*))PyGAME_C_API[PYGAMEAPI_SURFLOCK_FIRSTSLOT + 4])
|
||||||
|
#define PySurface_LockBy \
|
||||||
|
(*(int(*)(PyObject*,PyObject*)) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_SURFLOCK_FIRSTSLOT + 5])
|
||||||
|
#define PySurface_UnlockBy \
|
||||||
|
(*(int(*)(PyObject*,PyObject*)) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_SURFLOCK_FIRSTSLOT + 6])
|
||||||
|
#define PySurface_LockLifetime \
|
||||||
|
(*(PyObject*(*)(PyObject*,PyObject*)) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_SURFLOCK_FIRSTSLOT + 7])
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* EVENT */
|
||||||
|
#define PYGAMEAPI_EVENT_FIRSTSLOT \
|
||||||
|
(PYGAMEAPI_SURFLOCK_FIRSTSLOT + PYGAMEAPI_SURFLOCK_NUMSLOTS)
|
||||||
|
#define PYGAMEAPI_EVENT_NUMSLOTS 4
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD
|
||||||
|
int type;
|
||||||
|
PyObject* dict;
|
||||||
|
} PyEventObject;
|
||||||
|
|
||||||
|
#ifndef PYGAMEAPI_EVENT_INTERNAL
|
||||||
|
#define PyEvent_Check(x) \
|
||||||
|
((x)->ob_type == (PyTypeObject*)PyGAME_C_API[PYGAMEAPI_EVENT_FIRSTSLOT + 0])
|
||||||
|
#define PyEvent_Type \
|
||||||
|
(*(PyTypeObject*)PyGAME_C_API[PYGAMEAPI_EVENT_FIRSTSLOT + 0])
|
||||||
|
#define PyEvent_New \
|
||||||
|
(*(PyObject*(*)(SDL_Event*))PyGAME_C_API[PYGAMEAPI_EVENT_FIRSTSLOT + 1])
|
||||||
|
#define PyEvent_New2 \
|
||||||
|
(*(PyObject*(*)(int, PyObject*))PyGAME_C_API[PYGAMEAPI_EVENT_FIRSTSLOT + 2])
|
||||||
|
#define PyEvent_FillUserEvent \
|
||||||
|
(*(int (*)(PyEventObject*, SDL_Event*)) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_EVENT_FIRSTSLOT + 3])
|
||||||
|
#define import_pygame_event() IMPORT_PYGAME_MODULE(event, EVENT)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* RWOBJECT */
|
||||||
|
/*the rwobject are only needed for C side work, not accessable from python*/
|
||||||
|
#define PYGAMEAPI_RWOBJECT_FIRSTSLOT \
|
||||||
|
(PYGAMEAPI_EVENT_FIRSTSLOT + PYGAMEAPI_EVENT_NUMSLOTS)
|
||||||
|
#define PYGAMEAPI_RWOBJECT_NUMSLOTS 7
|
||||||
|
#ifndef PYGAMEAPI_RWOBJECT_INTERNAL
|
||||||
|
#define RWopsFromObject \
|
||||||
|
(*(SDL_RWops*(*)(PyObject*))PyGAME_C_API[PYGAMEAPI_RWOBJECT_FIRSTSLOT + 0])
|
||||||
|
#define RWopsCheckObject \
|
||||||
|
(*(int(*)(SDL_RWops*))PyGAME_C_API[PYGAMEAPI_RWOBJECT_FIRSTSLOT + 1])
|
||||||
|
#define RWopsFromFileObjectThreaded \
|
||||||
|
(*(SDL_RWops*(*)(PyObject*))PyGAME_C_API[PYGAMEAPI_RWOBJECT_FIRSTSLOT + 2])
|
||||||
|
#define RWopsCheckObjectThreaded \
|
||||||
|
(*(int(*)(SDL_RWops*))PyGAME_C_API[PYGAMEAPI_RWOBJECT_FIRSTSLOT + 3])
|
||||||
|
#define RWopsEncodeFilePath \
|
||||||
|
(*(PyObject*(*)(PyObject*, PyObject*)) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_RWOBJECT_FIRSTSLOT + 4])
|
||||||
|
#define RWopsEncodeString \
|
||||||
|
(*(PyObject*(*)(PyObject*, const char*, const char*, PyObject*)) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_RWOBJECT_FIRSTSLOT + 5])
|
||||||
|
#define RWopsFromFileObject \
|
||||||
|
(*(SDL_RWops*(*)(PyObject*))PyGAME_C_API[PYGAMEAPI_RWOBJECT_FIRSTSLOT + 6])
|
||||||
|
#define import_pygame_rwobject() IMPORT_PYGAME_MODULE(rwobject, RWOBJECT)
|
||||||
|
|
||||||
|
/* For backward compatibility */
|
||||||
|
#define RWopsFromPython RWopsFromObject
|
||||||
|
#define RWopsCheckPython RWopsCheckObject
|
||||||
|
#define RWopsFromPythonThreaded RWopsFromFileObjectThreaded
|
||||||
|
#define RWopsCheckPythonThreaded RWopsCheckObjectThreaded
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* PixelArray */
|
||||||
|
#define PYGAMEAPI_PIXELARRAY_FIRSTSLOT \
|
||||||
|
(PYGAMEAPI_RWOBJECT_FIRSTSLOT + PYGAMEAPI_RWOBJECT_NUMSLOTS)
|
||||||
|
#define PYGAMEAPI_PIXELARRAY_NUMSLOTS 2
|
||||||
|
#ifndef PYGAMEAPI_PIXELARRAY_INTERNAL
|
||||||
|
#define PyPixelArray_Check(x) \
|
||||||
|
((x)->ob_type == (PyTypeObject*) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_PIXELARRAY_FIRSTSLOT + 0])
|
||||||
|
#define PyPixelArray_New \
|
||||||
|
(*(PyObject*(*)) PyGAME_C_API[PYGAMEAPI_PIXELARRAY_FIRSTSLOT + 1])
|
||||||
|
#define import_pygame_pixelarray() IMPORT_PYGAME_MODULE(pixelarray, PIXELARRAY)
|
||||||
|
#endif /* PYGAMEAPI_PIXELARRAY_INTERNAL */
|
||||||
|
|
||||||
|
/* Color */
|
||||||
|
#define PYGAMEAPI_COLOR_FIRSTSLOT \
|
||||||
|
(PYGAMEAPI_PIXELARRAY_FIRSTSLOT + PYGAMEAPI_PIXELARRAY_NUMSLOTS)
|
||||||
|
#define PYGAMEAPI_COLOR_NUMSLOTS 4
|
||||||
|
#ifndef PYGAMEAPI_COLOR_INTERNAL
|
||||||
|
#define PyColor_Check(x) \
|
||||||
|
((x)->ob_type == (PyTypeObject*) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_COLOR_FIRSTSLOT + 0])
|
||||||
|
#define PyColor_Type (*(PyObject *) PyGAME_C_API[PYGAMEAPI_COLOR_FIRSTSLOT])
|
||||||
|
#define PyColor_New \
|
||||||
|
(*(PyObject *(*)(Uint8*)) PyGAME_C_API[PYGAMEAPI_COLOR_FIRSTSLOT + 1])
|
||||||
|
#define PyColor_NewLength \
|
||||||
|
(*(PyObject *(*)(Uint8*, Uint8)) PyGAME_C_API[PYGAMEAPI_COLOR_FIRSTSLOT + 3])
|
||||||
|
|
||||||
|
#define RGBAFromColorObj \
|
||||||
|
(*(int(*)(PyObject*, Uint8*)) PyGAME_C_API[PYGAMEAPI_COLOR_FIRSTSLOT + 2])
|
||||||
|
#define import_pygame_color() IMPORT_PYGAME_MODULE(color, COLOR)
|
||||||
|
#endif /* PYGAMEAPI_COLOR_INTERNAL */
|
||||||
|
|
||||||
|
|
||||||
|
/* Math */
|
||||||
|
#define PYGAMEAPI_MATH_FIRSTSLOT \
|
||||||
|
(PYGAMEAPI_COLOR_FIRSTSLOT + PYGAMEAPI_COLOR_NUMSLOTS)
|
||||||
|
#define PYGAMEAPI_MATH_NUMSLOTS 2
|
||||||
|
#ifndef PYGAMEAPI_MATH_INTERNAL
|
||||||
|
#define PyVector2_Check(x) \
|
||||||
|
((x)->ob_type == (PyTypeObject*) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_MATH_FIRSTSLOT + 0])
|
||||||
|
#define PyVector3_Check(x) \
|
||||||
|
((x)->ob_type == (PyTypeObject*) \
|
||||||
|
PyGAME_C_API[PYGAMEAPI_MATH_FIRSTSLOT + 1])
|
||||||
|
/*
|
||||||
|
#define PyVector2_New \
|
||||||
|
(*(PyObject*(*)) PyGAME_C_API[PYGAMEAPI_MATH_FIRSTSLOT + 1])
|
||||||
|
*/
|
||||||
|
#define import_pygame_math() IMPORT_PYGAME_MODULE(math, MATH)
|
||||||
|
#endif /* PYGAMEAPI_MATH_INTERNAL */
|
||||||
|
|
||||||
|
#define PG_CAPSULE_NAME(m) (IMPPREFIX m "." PYGAMEAPI_LOCAL_ENTRY)
|
||||||
|
|
||||||
|
#define _IMPORT_PYGAME_MODULE(module, MODULE, api_root) { \
|
||||||
|
PyObject *_module = PyImport_ImportModule (IMPPREFIX #module); \
|
||||||
|
\
|
||||||
|
if (_module != NULL) { \
|
||||||
|
PyObject *_c_api = \
|
||||||
|
PyObject_GetAttrString (_module, PYGAMEAPI_LOCAL_ENTRY); \
|
||||||
|
\
|
||||||
|
Py_DECREF (_module); \
|
||||||
|
if (_c_api != NULL && PyCapsule_CheckExact (_c_api)) { \
|
||||||
|
void **localptr = \
|
||||||
|
(void**) PyCapsule_GetPointer (_c_api, \
|
||||||
|
PG_CAPSULE_NAME(#module)); \
|
||||||
|
\
|
||||||
|
if (localptr != NULL) { \
|
||||||
|
memcpy (api_root + PYGAMEAPI_##MODULE##_FIRSTSLOT, \
|
||||||
|
localptr, \
|
||||||
|
sizeof(void **)*PYGAMEAPI_##MODULE##_NUMSLOTS); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
Py_XDECREF(_c_api); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NO_PYGAME_C_API
|
||||||
|
#define IMPORT_PYGAME_MODULE(module, MODULE) \
|
||||||
|
_IMPORT_PYGAME_MODULE(module, MODULE, PyGAME_C_API)
|
||||||
|
#define PYGAMEAPI_TOTALSLOTS \
|
||||||
|
(PYGAMEAPI_MATH_FIRSTSLOT + PYGAMEAPI_MATH_NUMSLOTS)
|
||||||
|
|
||||||
|
#ifdef PYGAME_H
|
||||||
|
void* PyGAME_C_API[PYGAMEAPI_TOTALSLOTS] = { NULL };
|
||||||
|
#else
|
||||||
|
extern void* PyGAME_C_API[PYGAMEAPI_TOTALSLOTS];
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PG_HAVE_CAPSULE
|
||||||
|
#define encapsulate_api(ptr, module) \
|
||||||
|
PyCapsule_New(ptr, PG_CAPSULE_NAME(module), NULL)
|
||||||
|
#else
|
||||||
|
#define encapsulate_api(ptr, module) \
|
||||||
|
PyCObject_FromVoidPtr(ptr, NULL)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*last platform compiler stuff*/
|
||||||
|
#if defined(macintosh) && defined(__MWERKS__) || defined(__SYMBIAN32__)
|
||||||
|
#define PYGAME_EXPORT __declspec(export)
|
||||||
|
#else
|
||||||
|
#define PYGAME_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__SYMBIAN32__) && PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 2
|
||||||
|
|
||||||
|
// These are missing from Python 2.2
|
||||||
|
#ifndef Py_RETURN_NONE
|
||||||
|
|
||||||
|
#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
|
||||||
|
#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
|
||||||
|
#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
|
||||||
|
|
||||||
|
#ifndef intrptr_t
|
||||||
|
#define intptr_t int
|
||||||
|
|
||||||
|
// No PySlice_GetIndicesEx on Py 2.2
|
||||||
|
#define PySlice_GetIndicesEx(a,b,c,d,e,f) PySlice_GetIndices(a,b,c,d,e)
|
||||||
|
|
||||||
|
#define PyBool_FromLong(x) Py_BuildValue("b", x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// _symport_free and malloc are not exported in python.dll
|
||||||
|
// See http://discussion.forum.nokia.com/forum/showthread.php?t=57874
|
||||||
|
#undef PyObject_NEW
|
||||||
|
#define PyObject_NEW PyObject_New
|
||||||
|
#undef PyMem_MALLOC
|
||||||
|
#define PyMem_MALLOC PyMem_Malloc
|
||||||
|
#undef PyObject_DEL
|
||||||
|
#define PyObject_DEL PyObject_Del
|
||||||
|
|
||||||
|
#endif // intptr_t
|
||||||
|
|
||||||
|
#endif // __SYMBIAN32__ Python 2.2.2
|
||||||
|
|
||||||
|
#endif /* PYGAME_H */
|
31
include/site/python3.7/pygame/_surface.h
Normal file
31
include/site/python3.7/pygame/_surface.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
pygame - Python Game Library
|
||||||
|
Copyright (C) 2000-2001 Pete Shinners
|
||||||
|
Copyright (C) 2007 Marcus von Appen
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
Pete Shinners
|
||||||
|
pete@shinners.org
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SURFACE_H
|
||||||
|
#define _SURFACE_H
|
||||||
|
|
||||||
|
#include "_pygame.h"
|
||||||
|
#include "surface.h"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
146
include/site/python3.7/pygame/bitmask.h
Normal file
146
include/site/python3.7/pygame/bitmask.h
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
/*
|
||||||
|
Bitmask 1.7 - A pixel-perfect collision detection library.
|
||||||
|
|
||||||
|
Copyright (C) 2002-2005 Ulf Ekstrom except for the bitcount
|
||||||
|
function which is copyright (C) Donald W. Gillies, 1992.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#ifndef BITMASK_H
|
||||||
|
#define BITMASK_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
/* Define INLINE for different compilers. If your compiler does not
|
||||||
|
support inlining then there might be a performance hit in
|
||||||
|
bitmask_overlap_area().
|
||||||
|
*/
|
||||||
|
#ifndef INLINE
|
||||||
|
# ifdef __GNUC__
|
||||||
|
# define INLINE inline
|
||||||
|
# else
|
||||||
|
# ifdef _MSC_VER
|
||||||
|
# define INLINE __inline
|
||||||
|
# else
|
||||||
|
# define INLINE
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define BITMASK_W unsigned long int
|
||||||
|
#define BITMASK_W_LEN (sizeof(BITMASK_W)*CHAR_BIT)
|
||||||
|
#define BITMASK_W_MASK (BITMASK_W_LEN - 1)
|
||||||
|
#define BITMASK_N(n) ((BITMASK_W)1 << (n))
|
||||||
|
|
||||||
|
typedef struct bitmask
|
||||||
|
{
|
||||||
|
int w,h;
|
||||||
|
BITMASK_W bits[1];
|
||||||
|
} bitmask_t;
|
||||||
|
|
||||||
|
/* Creates a bitmask of width w and height h, where
|
||||||
|
w and h must both be greater than 0.
|
||||||
|
The mask is automatically cleared when created.
|
||||||
|
*/
|
||||||
|
bitmask_t *bitmask_create(int w, int h);
|
||||||
|
|
||||||
|
/* Frees all the memory allocated by bitmask_create for m. */
|
||||||
|
void bitmask_free(bitmask_t *m);
|
||||||
|
|
||||||
|
/* Clears all bits in the mask */
|
||||||
|
void bitmask_clear(bitmask_t *m);
|
||||||
|
|
||||||
|
/* Sets all bits in the mask */
|
||||||
|
void bitmask_fill(bitmask_t *m);
|
||||||
|
|
||||||
|
/* Flips all bits in the mask */
|
||||||
|
void bitmask_invert(bitmask_t *m);
|
||||||
|
|
||||||
|
/* Counts the bits in the mask */
|
||||||
|
unsigned int bitmask_count(bitmask_t *m);
|
||||||
|
|
||||||
|
/* Returns nonzero if the bit at (x,y) is set. Coordinates start at
|
||||||
|
(0,0) */
|
||||||
|
static INLINE int bitmask_getbit(const bitmask_t *m, int x, int y)
|
||||||
|
{
|
||||||
|
return (m->bits[x/BITMASK_W_LEN*m->h + y] & BITMASK_N(x & BITMASK_W_MASK)) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sets the bit at (x,y) */
|
||||||
|
static INLINE void bitmask_setbit(bitmask_t *m, int x, int y)
|
||||||
|
{
|
||||||
|
m->bits[x/BITMASK_W_LEN*m->h + y] |= BITMASK_N(x & BITMASK_W_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clears the bit at (x,y) */
|
||||||
|
static INLINE void bitmask_clearbit(bitmask_t *m, int x, int y)
|
||||||
|
{
|
||||||
|
m->bits[x/BITMASK_W_LEN*m->h + y] &= ~BITMASK_N(x & BITMASK_W_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns nonzero if the masks overlap with the given offset.
|
||||||
|
The overlap tests uses the following offsets (which may be negative):
|
||||||
|
|
||||||
|
+----+----------..
|
||||||
|
|A | yoffset
|
||||||
|
| +-+----------..
|
||||||
|
+--|B
|
||||||
|
|xoffset
|
||||||
|
| |
|
||||||
|
: :
|
||||||
|
*/
|
||||||
|
int bitmask_overlap(const bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset);
|
||||||
|
|
||||||
|
/* Like bitmask_overlap(), but will also give a point of intersection.
|
||||||
|
x and y are given in the coordinates of mask a, and are untouched
|
||||||
|
if there is no overlap. */
|
||||||
|
int bitmask_overlap_pos(const bitmask_t *a, const bitmask_t *b,
|
||||||
|
int xoffset, int yoffset, int *x, int *y);
|
||||||
|
|
||||||
|
/* Returns the number of overlapping 'pixels' */
|
||||||
|
int bitmask_overlap_area(const bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset);
|
||||||
|
|
||||||
|
/* Fills a mask with the overlap of two other masks. A bitwise AND. */
|
||||||
|
void bitmask_overlap_mask (const bitmask_t *a, const bitmask_t *b, bitmask_t *c, int xoffset, int yoffset);
|
||||||
|
|
||||||
|
/* Draws mask b onto mask a (bitwise OR). Can be used to compose large
|
||||||
|
(game background?) mask from several submasks, which may speed up
|
||||||
|
the testing. */
|
||||||
|
|
||||||
|
void bitmask_draw(bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset);
|
||||||
|
|
||||||
|
void bitmask_erase(bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset);
|
||||||
|
|
||||||
|
/* Return a new scaled bitmask, with dimensions w*h. The quality of the
|
||||||
|
scaling may not be perfect for all circumstances, but it should
|
||||||
|
be reasonable. If either w or h is 0 a clear 1x1 mask is returned. */
|
||||||
|
bitmask_t *bitmask_scale(const bitmask_t *m, int w, int h);
|
||||||
|
|
||||||
|
/* Convolve b into a, drawing the output into o, shifted by offset. If offset
|
||||||
|
* is 0, then the (x,y) bit will be set if and only if
|
||||||
|
* bitmask_overlap(a, b, x - b->w - 1, y - b->h - 1) returns true.
|
||||||
|
*
|
||||||
|
* Modifies bits o[xoffset ... xoffset + a->w + b->w - 1)
|
||||||
|
* [yoffset ... yoffset + a->h + b->h - 1). */
|
||||||
|
void bitmask_convolve(const bitmask_t *a, const bitmask_t *b, bitmask_t *o, int xoffset, int yoffset);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* End of extern "C" { */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
201
include/site/python3.7/pygame/camera.h
Normal file
201
include/site/python3.7/pygame/camera.h
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
/*
|
||||||
|
pygame - Python Game Library
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pygame.h"
|
||||||
|
#include "doc/camera_doc.h"
|
||||||
|
|
||||||
|
#if defined(__unix__)
|
||||||
|
#include <structmember.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include <fcntl.h> /* low-level i/o */
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
|
/* on freebsd there is no asm/types */
|
||||||
|
#ifdef linux
|
||||||
|
#include <asm/types.h> /* for videodev2.h */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <linux/videodev2.h>
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#include <AvailabilityMacros.h>
|
||||||
|
/* We support OSX 10.6 and below. */
|
||||||
|
#if __MAC_OS_X_VERSION_MAX_ALLOWED <= 1060
|
||||||
|
#define PYGAME_MAC_CAMERA_OLD 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PYGAME_MAC_CAMERA_OLD)
|
||||||
|
#include <QuickTime/QuickTime.h>
|
||||||
|
#include <QuickTime/Movies.h>
|
||||||
|
#include <QuickTime/ImageCompression.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* some constants used which are not defined on non-v4l machines. */
|
||||||
|
#ifndef V4L2_PIX_FMT_RGB24
|
||||||
|
#define V4L2_PIX_FMT_RGB24 'RGB3'
|
||||||
|
#endif
|
||||||
|
#ifndef V4L2_PIX_FMT_RGB444
|
||||||
|
#define V4L2_PIX_FMT_RGB444 'R444'
|
||||||
|
#endif
|
||||||
|
#ifndef V4L2_PIX_FMT_YUYV
|
||||||
|
#define V4L2_PIX_FMT_YUYV 'YUYV'
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define CLEAR(x) memset (&(x), 0, sizeof (x))
|
||||||
|
#define SAT(c) if (c & (~255)) { if (c < 0) c = 0; else c = 255; }
|
||||||
|
#define SAT2(c) ((c) & (~255) ? ((c) < 0 ? 0 : 255) : (c))
|
||||||
|
#define DEFAULT_WIDTH 640
|
||||||
|
#define DEFAULT_HEIGHT 480
|
||||||
|
#define RGB_OUT 1
|
||||||
|
#define YUV_OUT 2
|
||||||
|
#define HSV_OUT 4
|
||||||
|
#define CAM_V4L 1 /* deprecated. the incomplete support in pygame was removed */
|
||||||
|
#define CAM_V4L2 2
|
||||||
|
|
||||||
|
struct buffer {
|
||||||
|
void * start;
|
||||||
|
size_t length;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if defined(__unix__)
|
||||||
|
typedef struct PyCameraObject {
|
||||||
|
PyObject_HEAD
|
||||||
|
char* device_name;
|
||||||
|
int camera_type;
|
||||||
|
unsigned long pixelformat;
|
||||||
|
unsigned int color_out;
|
||||||
|
struct buffer* buffers;
|
||||||
|
unsigned int n_buffers;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int size;
|
||||||
|
int hflip;
|
||||||
|
int vflip;
|
||||||
|
int brightness;
|
||||||
|
int fd;
|
||||||
|
} PyCameraObject;
|
||||||
|
#elif defined(PYGAME_MAC_CAMERA_OLD)
|
||||||
|
typedef struct PyCameraObject {
|
||||||
|
PyObject_HEAD
|
||||||
|
char* device_name; /* unieke name of the device */
|
||||||
|
OSType pixelformat;
|
||||||
|
unsigned int color_out;
|
||||||
|
SeqGrabComponent component; /* A type used by the Sequence Grabber API */
|
||||||
|
SGChannel channel; /* Channel of the Sequence Grabber */
|
||||||
|
GWorldPtr gworld; /* Pointer to the struct that holds the data of the captured image */
|
||||||
|
Rect boundsRect; /* bounds of the image frame */
|
||||||
|
long size; /* size of the image in our buffer to draw */
|
||||||
|
int hflip;
|
||||||
|
int vflip;
|
||||||
|
short depth;
|
||||||
|
struct buffer pixels;
|
||||||
|
//struct buffer tmp_pixels /* place where the flipped image in temporarly stored if hflip or vflip is true.*/
|
||||||
|
} PyCameraObject;
|
||||||
|
|
||||||
|
#else
|
||||||
|
/* generic definition.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct PyCameraObject {
|
||||||
|
PyObject_HEAD
|
||||||
|
char* device_name;
|
||||||
|
int camera_type;
|
||||||
|
unsigned long pixelformat;
|
||||||
|
unsigned int color_out;
|
||||||
|
struct buffer* buffers;
|
||||||
|
unsigned int n_buffers;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int size;
|
||||||
|
int hflip;
|
||||||
|
int vflip;
|
||||||
|
int brightness;
|
||||||
|
int fd;
|
||||||
|
} PyCameraObject;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* internal functions for colorspace conversion */
|
||||||
|
void colorspace (SDL_Surface *src, SDL_Surface *dst, int cspace);
|
||||||
|
void rgb24_to_rgb (const void* src, void* dst, int length, SDL_PixelFormat* format);
|
||||||
|
void rgb444_to_rgb (const void* src, void* dst, int length, SDL_PixelFormat* format);
|
||||||
|
void rgb_to_yuv (const void* src, void* dst, int length,
|
||||||
|
unsigned long source, SDL_PixelFormat* format);
|
||||||
|
void rgb_to_hsv (const void* src, void* dst, int length,
|
||||||
|
unsigned long source, SDL_PixelFormat* format);
|
||||||
|
void yuyv_to_rgb (const void* src, void* dst, int length, SDL_PixelFormat* format);
|
||||||
|
void yuyv_to_yuv (const void* src, void* dst, int length, SDL_PixelFormat* format);
|
||||||
|
void uyvy_to_rgb (const void* src, void* dst, int length, SDL_PixelFormat* format);
|
||||||
|
void uyvy_to_yuv (const void* src, void* dst, int length, SDL_PixelFormat* format);
|
||||||
|
void sbggr8_to_rgb (const void* src, void* dst, int width, int height,
|
||||||
|
SDL_PixelFormat* format);
|
||||||
|
void yuv420_to_rgb (const void* src, void* dst, int width, int height,
|
||||||
|
SDL_PixelFormat* format);
|
||||||
|
void yuv420_to_yuv (const void* src, void* dst, int width, int height,
|
||||||
|
SDL_PixelFormat* format);
|
||||||
|
|
||||||
|
#if defined(__unix__)
|
||||||
|
/* internal functions specific to v4l2 */
|
||||||
|
char** v4l2_list_cameras (int* num_devices);
|
||||||
|
int v4l2_get_control (int fd, int id, int *value);
|
||||||
|
int v4l2_set_control (int fd, int id, int value);
|
||||||
|
PyObject* v4l2_read_raw (PyCameraObject* self);
|
||||||
|
int v4l2_xioctl (int fd, int request, void *arg);
|
||||||
|
int v4l2_process_image (PyCameraObject* self, const void *image,
|
||||||
|
unsigned int buffer_size, SDL_Surface* surf);
|
||||||
|
int v4l2_query_buffer (PyCameraObject* self);
|
||||||
|
int v4l2_read_frame (PyCameraObject* self, SDL_Surface* surf);
|
||||||
|
int v4l2_stop_capturing (PyCameraObject* self);
|
||||||
|
int v4l2_start_capturing (PyCameraObject* self);
|
||||||
|
int v4l2_uninit_device (PyCameraObject* self);
|
||||||
|
int v4l2_init_mmap (PyCameraObject* self);
|
||||||
|
int v4l2_init_device (PyCameraObject* self);
|
||||||
|
int v4l2_close_device (PyCameraObject* self);
|
||||||
|
int v4l2_open_device (PyCameraObject* self);
|
||||||
|
|
||||||
|
#elif defined(PYGAME_MAC_CAMERA_OLD)
|
||||||
|
/* internal functions specific to mac */
|
||||||
|
char** mac_list_cameras(int* num_devices);
|
||||||
|
int mac_open_device (PyCameraObject* self);
|
||||||
|
int mac_init_device(PyCameraObject* self);
|
||||||
|
int mac_close_device (PyCameraObject* self);
|
||||||
|
int mac_start_capturing(PyCameraObject* self);
|
||||||
|
int mac_stop_capturing (PyCameraObject* self);
|
||||||
|
|
||||||
|
int mac_get_control(PyCameraObject* self, int id, int* value);
|
||||||
|
int mac_set_control(PyCameraObject* self, int id, int value);
|
||||||
|
|
||||||
|
PyObject* mac_read_raw(PyCameraObject *self);
|
||||||
|
int mac_read_frame(PyCameraObject* self, SDL_Surface* surf);
|
||||||
|
int mac_camera_idle(PyCameraObject* self);
|
||||||
|
int mac_copy_gworld_to_surface(PyCameraObject* self, SDL_Surface* surf);
|
||||||
|
|
||||||
|
void flip_image(const void* image, void* flipped_image, int width, int height,
|
||||||
|
short depth, int hflip, int vflip);
|
||||||
|
|
||||||
|
#endif
|
48
include/site/python3.7/pygame/fastevents.h
Normal file
48
include/site/python3.7/pygame/fastevents.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#ifndef _FASTEVENTS_H_
|
||||||
|
#define _FASTEVENTS_H_
|
||||||
|
/*
|
||||||
|
NET2 is a threaded, event based, network IO library for SDL.
|
||||||
|
Copyright (C) 2002 Bob Pendleton
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2.1
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
|
02111-1307 USA
|
||||||
|
|
||||||
|
If you do not wish to comply with the terms of the LGPL please
|
||||||
|
contact the author as other terms are available for a fee.
|
||||||
|
|
||||||
|
Bob Pendleton
|
||||||
|
Bob@Pendleton.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "SDL.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int FE_Init(void); // Initialize FE
|
||||||
|
void FE_Quit(void); // shutdown FE
|
||||||
|
|
||||||
|
void FE_PumpEvents(void); // replacement for SDL_PumpEvents
|
||||||
|
int FE_PollEvent(SDL_Event *event); // replacement for SDL_PollEvent
|
||||||
|
int FE_WaitEvent(SDL_Event *event); // replacement for SDL_WaitEvent
|
||||||
|
int FE_PushEvent(SDL_Event *event); // replacement for SDL_PushEvent
|
||||||
|
|
||||||
|
char *FE_GetError(void); // get the last error
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
57
include/site/python3.7/pygame/font.h
Normal file
57
include/site/python3.7/pygame/font.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
pygame - Python Game Library
|
||||||
|
Copyright (C) 2000-2001 Pete Shinners
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
Pete Shinners
|
||||||
|
pete@shinners.org
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Python.h>
|
||||||
|
#if defined(HAVE_SNPRINTF) /* also defined in SDL_ttf (SDL.h) */
|
||||||
|
#undef HAVE_SNPRINTF /* remove GCC macro redefine warning */
|
||||||
|
#endif
|
||||||
|
#include <SDL_ttf.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* test font initialization */
|
||||||
|
#define FONT_INIT_CHECK() \
|
||||||
|
if(!(*(int*)PyFONT_C_API[2])) \
|
||||||
|
return RAISE(PyExc_SDLError, "font system not initialized")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define PYGAMEAPI_FONT_FIRSTSLOT 0
|
||||||
|
#define PYGAMEAPI_FONT_NUMSLOTS 3
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD
|
||||||
|
TTF_Font* font;
|
||||||
|
PyObject* weakreflist;
|
||||||
|
} PyFontObject;
|
||||||
|
#define PyFont_AsFont(x) (((PyFontObject*)x)->font)
|
||||||
|
|
||||||
|
#ifndef PYGAMEAPI_FONT_INTERNAL
|
||||||
|
#define PyFont_Check(x) ((x)->ob_type == (PyTypeObject*)PyFONT_C_API[0])
|
||||||
|
#define PyFont_Type (*(PyTypeObject*)PyFONT_C_API[0])
|
||||||
|
#define PyFont_New (*(PyObject*(*)(TTF_Font*))PyFONT_C_API[1])
|
||||||
|
/*slot 2 taken by FONT_INIT_CHECK*/
|
||||||
|
|
||||||
|
#define import_pygame_font() \
|
||||||
|
_IMPORT_PYGAME_MODULE(font, FONT, PyFONT_C_API)
|
||||||
|
|
||||||
|
static void* PyFONT_C_API[PYGAMEAPI_FONT_NUMSLOTS] = {NULL};
|
||||||
|
#endif
|
||||||
|
|
137
include/site/python3.7/pygame/freetype.h
Normal file
137
include/site/python3.7/pygame/freetype.h
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
/*
|
||||||
|
pygame - Python Game Library
|
||||||
|
Copyright (C) 2009 Vicent Marti
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
*/
|
||||||
|
#ifndef _PYGAME_FREETYPE_H_
|
||||||
|
#define _PYGAME_FREETYPE_H_
|
||||||
|
|
||||||
|
#define PGFT_PYGAME1_COMPAT
|
||||||
|
#define HAVE_PYGAME_SDL_VIDEO
|
||||||
|
#define HAVE_PYGAME_SDL_RWOPS
|
||||||
|
|
||||||
|
#include "pygame.h"
|
||||||
|
#include "pgcompat.h"
|
||||||
|
|
||||||
|
#if PY3
|
||||||
|
# define IS_PYTHON_3
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ft2build.h>
|
||||||
|
#include FT_FREETYPE_H
|
||||||
|
#include FT_CACHE_H
|
||||||
|
#include FT_XFREE86_H
|
||||||
|
#include FT_TRIGONOMETRY_H
|
||||||
|
|
||||||
|
/**********************************************************
|
||||||
|
* Global module constants
|
||||||
|
**********************************************************/
|
||||||
|
|
||||||
|
/* Render styles */
|
||||||
|
#define FT_STYLE_NORMAL 0x00
|
||||||
|
#define FT_STYLE_STRONG 0x01
|
||||||
|
#define FT_STYLE_OBLIQUE 0x02
|
||||||
|
#define FT_STYLE_UNDERLINE 0x04
|
||||||
|
#define FT_STYLE_WIDE 0x08
|
||||||
|
#define FT_STYLE_DEFAULT 0xFF
|
||||||
|
|
||||||
|
/* Bounding box modes */
|
||||||
|
#define FT_BBOX_EXACT FT_GLYPH_BBOX_SUBPIXELS
|
||||||
|
#define FT_BBOX_EXACT_GRIDFIT FT_GLYPH_BBOX_GRIDFIT
|
||||||
|
#define FT_BBOX_PIXEL FT_GLYPH_BBOX_TRUNCATE
|
||||||
|
#define FT_BBOX_PIXEL_GRIDFIT FT_GLYPH_BBOX_PIXELS
|
||||||
|
|
||||||
|
/* Rendering flags */
|
||||||
|
#define FT_RFLAG_NONE (0)
|
||||||
|
#define FT_RFLAG_ANTIALIAS (1 << 0)
|
||||||
|
#define FT_RFLAG_AUTOHINT (1 << 1)
|
||||||
|
#define FT_RFLAG_VERTICAL (1 << 2)
|
||||||
|
#define FT_RFLAG_HINTED (1 << 3)
|
||||||
|
#define FT_RFLAG_KERNING (1 << 4)
|
||||||
|
#define FT_RFLAG_TRANSFORM (1 << 5)
|
||||||
|
#define FT_RFLAG_PAD (1 << 6)
|
||||||
|
#define FT_RFLAG_ORIGIN (1 << 7)
|
||||||
|
#define FT_RFLAG_UCS4 (1 << 8)
|
||||||
|
#define FT_RFLAG_USE_BITMAP_STRIKES (1 << 9)
|
||||||
|
#define FT_RFLAG_DEFAULTS (FT_RFLAG_HINTED | \
|
||||||
|
FT_RFLAG_USE_BITMAP_STRIKES | \
|
||||||
|
FT_RFLAG_ANTIALIAS)
|
||||||
|
|
||||||
|
|
||||||
|
#define FT_RENDER_NEWBYTEARRAY 0x0
|
||||||
|
#define FT_RENDER_NEWSURFACE 0x1
|
||||||
|
#define FT_RENDER_EXISTINGSURFACE 0x2
|
||||||
|
|
||||||
|
/**********************************************************
|
||||||
|
* Global module types
|
||||||
|
**********************************************************/
|
||||||
|
|
||||||
|
typedef struct _scale_s {
|
||||||
|
FT_UInt x, y;
|
||||||
|
} Scale_t;
|
||||||
|
typedef FT_Angle Angle_t;
|
||||||
|
|
||||||
|
struct fontinternals_;
|
||||||
|
struct freetypeinstance_;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
FT_Long font_index;
|
||||||
|
FT_Open_Args open_args;
|
||||||
|
} PgFontId;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD
|
||||||
|
PgFontId id;
|
||||||
|
PyObject *path;
|
||||||
|
int is_scalable;
|
||||||
|
|
||||||
|
Scale_t face_size;
|
||||||
|
FT_Int16 style;
|
||||||
|
FT_Int16 render_flags;
|
||||||
|
double strength;
|
||||||
|
double underline_adjustment;
|
||||||
|
FT_UInt resolution;
|
||||||
|
Angle_t rotation;
|
||||||
|
FT_Matrix transform;
|
||||||
|
FT_Byte fgcolor[4];
|
||||||
|
|
||||||
|
struct freetypeinstance_ *freetype; /* Personal reference */
|
||||||
|
struct fontinternals_ *_internals;
|
||||||
|
} PgFontObject;
|
||||||
|
|
||||||
|
#define PgFont_IS_ALIVE(o) \
|
||||||
|
(((PgFontObject *)(o))->_internals != 0)
|
||||||
|
|
||||||
|
/**********************************************************
|
||||||
|
* Module declaration
|
||||||
|
**********************************************************/
|
||||||
|
#define PYGAMEAPI_FREETYPE_FIRSTSLOT 0
|
||||||
|
#define PYGAMEAPI_FREETYPE_NUMSLOTS 2
|
||||||
|
|
||||||
|
#ifndef PYGAME_FREETYPE_INTERNAL
|
||||||
|
|
||||||
|
#define PgFont_Check(x) ((x)->ob_type == (PyTypeObject*)PgFREETYPE_C_API[0])
|
||||||
|
#define PgFont_Type (*(PyTypeObject*)PgFREETYPE_C_API[1])
|
||||||
|
#define PgFont_New (*(PyObject*(*)(const char*, long))PgFREETYPE_C_API[1])
|
||||||
|
|
||||||
|
#define import_pygame_freetype() \
|
||||||
|
_IMPORT_PYGAME_MODULE(freetype, FREETYPE, PgFREETYPE_C_API)
|
||||||
|
|
||||||
|
static void *PgFREETYPE_C_API[PYGAMEAPI_FREETYPE_NUMSLOTS] = {0};
|
||||||
|
#endif /* PYGAME_FREETYPE_INTERNAL */
|
||||||
|
|
||||||
|
#endif /* _PYGAME_FREETYPE_H_ */
|
25
include/site/python3.7/pygame/mask.h
Normal file
25
include/site/python3.7/pygame/mask.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#include <Python.h>
|
||||||
|
#include "bitmask.h"
|
||||||
|
|
||||||
|
#define PYGAMEAPI_MASK_FIRSTSLOT 0
|
||||||
|
#define PYGAMEAPI_MASK_NUMSLOTS 1
|
||||||
|
#define PYGAMEAPI_LOCAL_ENTRY "_PYGAME_C_API"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD
|
||||||
|
bitmask_t *mask;
|
||||||
|
} PyMaskObject;
|
||||||
|
|
||||||
|
#define PyMask_AsBitmap(x) (((PyMaskObject*)x)->mask)
|
||||||
|
|
||||||
|
#ifndef PYGAMEAPI_MASK_INTERNAL
|
||||||
|
|
||||||
|
#define PyMask_Type (*(PyTypeObject*)PyMASK_C_API[0])
|
||||||
|
#define PyMask_Check(x) ((x)->ob_type == &PyMask_Type)
|
||||||
|
|
||||||
|
#define import_pygame_mask() \
|
||||||
|
_IMPORT_PYGAME_MODULE(mask, MASK, PyMASK_C_API)
|
||||||
|
|
||||||
|
static void* PyMASK_C_API[PYGAMEAPI_MASK_NUMSLOTS] = {NULL};
|
||||||
|
#endif /* #ifndef PYGAMEAPI_MASK_INTERNAL */
|
||||||
|
|
66
include/site/python3.7/pygame/mixer.h
Normal file
66
include/site/python3.7/pygame/mixer.h
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
pygame - Python Game Library
|
||||||
|
Copyright (C) 2000-2001 Pete Shinners
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
Pete Shinners
|
||||||
|
pete@shinners.org
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Python.h>
|
||||||
|
#include <SDL_mixer.h>
|
||||||
|
#include <structmember.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* test mixer initializations */
|
||||||
|
#define MIXER_INIT_CHECK() \
|
||||||
|
if(!SDL_WasInit(SDL_INIT_AUDIO)) \
|
||||||
|
return RAISE(PyExc_SDLError, "mixer system not initialized")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define PYGAMEAPI_MIXER_FIRSTSLOT 0
|
||||||
|
#define PYGAMEAPI_MIXER_NUMSLOTS 7
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD
|
||||||
|
Mix_Chunk *chunk;
|
||||||
|
Uint8 *mem;
|
||||||
|
PyObject *weakreflist;
|
||||||
|
} PySoundObject;
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD
|
||||||
|
int chan;
|
||||||
|
} PyChannelObject;
|
||||||
|
#define PySound_AsChunk(x) (((PySoundObject*)x)->chunk)
|
||||||
|
#define PyChannel_AsInt(x) (((PyChannelObject*)x)->chan)
|
||||||
|
|
||||||
|
#ifndef PYGAMEAPI_MIXER_INTERNAL
|
||||||
|
#define PySound_Check(x) ((x)->ob_type == (PyTypeObject*)PyMIXER_C_API[0])
|
||||||
|
#define PySound_Type (*(PyTypeObject*)PyMIXER_C_API[0])
|
||||||
|
#define PySound_New (*(PyObject*(*)(Mix_Chunk*))PyMIXER_C_API[1])
|
||||||
|
#define PySound_Play (*(PyObject*(*)(PyObject*, PyObject*))PyMIXER_C_API[2])
|
||||||
|
#define PyChannel_Check(x) ((x)->ob_type == (PyTypeObject*)PyMIXER_C_API[3])
|
||||||
|
#define PyChannel_Type (*(PyTypeObject*)PyMIXER_C_API[3])
|
||||||
|
#define PyChannel_New (*(PyObject*(*)(int))PyMIXER_C_API[4])
|
||||||
|
#define PyMixer_AutoInit (*(PyObject*(*)(PyObject*, PyObject*))PyMIXER_C_API[5])
|
||||||
|
#define PyMixer_AutoQuit (*(void(*)(void))PyMIXER_C_API[6])
|
||||||
|
|
||||||
|
#define import_pygame_mixer() \
|
||||||
|
_IMPORT_PYGAME_MODULE(mixer, MIXER, PyMIXER_C_API)
|
||||||
|
|
||||||
|
static void* PyMIXER_C_API[PYGAMEAPI_MIXER_NUMSLOTS] = {NULL};
|
||||||
|
#endif
|
||||||
|
|
26
include/site/python3.7/pygame/pgarrinter.h
Normal file
26
include/site/python3.7/pygame/pgarrinter.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/* array structure interface version 3 declarations */
|
||||||
|
|
||||||
|
#if !defined(PG_ARRAYINTER_HEADER)
|
||||||
|
#define PG_ARRAYINTER_HEADER
|
||||||
|
|
||||||
|
static const int PAI_CONTIGUOUS = 0x01;
|
||||||
|
static const int PAI_FORTRAN = 0x02;
|
||||||
|
static const int PAI_ALIGNED = 0x100;
|
||||||
|
static const int PAI_NOTSWAPPED = 0x200;
|
||||||
|
static const int PAI_WRITEABLE = 0x400;
|
||||||
|
static const int PAI_ARR_HAS_DESCR = 0x800;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int two; /* contains the integer 2 -- simple sanity check */
|
||||||
|
int nd; /* number of dimensions */
|
||||||
|
char typekind; /* kind in array -- character code of typestr */
|
||||||
|
int itemsize; /* size of each element */
|
||||||
|
int flags; /* flags indicating how the data should be */
|
||||||
|
/* interpreted */
|
||||||
|
Py_intptr_t *shape; /* A length-nd array of shape information */
|
||||||
|
Py_intptr_t *strides; /* A length-nd array of stride information */
|
||||||
|
void *data; /* A pointer to the first element of the array */
|
||||||
|
PyObject *descr; /* NULL or a data-description */
|
||||||
|
} PyArrayInterface;
|
||||||
|
|
||||||
|
#endif
|
52
include/site/python3.7/pygame/pgbufferproxy.h
Normal file
52
include/site/python3.7/pygame/pgbufferproxy.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
pygame - Python Game Library
|
||||||
|
Copyright (C) 2000-2001 Pete Shinners
|
||||||
|
Copyright (C) 2007 Rene Dudfield, Richard Goedeken
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
Pete Shinners
|
||||||
|
pete@shinners.org
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Bufferproxy module C api.
|
||||||
|
Depends on pygame.h being included first.
|
||||||
|
*/
|
||||||
|
#if !defined(PG_BUFPROXY_HEADER)
|
||||||
|
|
||||||
|
#define PYGAMEAPI_BUFPROXY_NUMSLOTS 4
|
||||||
|
#define PYGAMEAPI_BUFPROXY_FIRSTSLOT 0
|
||||||
|
|
||||||
|
#if !(defined(PYGAMEAPI_BUFPROXY_INTERNAL) || defined(NO_PYGAME_C_API))
|
||||||
|
static void *PgBUFPROXY_C_API[PYGAMEAPI_BUFPROXY_NUMSLOTS];
|
||||||
|
|
||||||
|
typedef PyObject *(*_pgbufproxy_new_t)(PyObject *, getbufferproc);
|
||||||
|
typedef PyObject *(*_pgbufproxy_get_obj_t)(PyObject *);
|
||||||
|
typedef int (*_pgbufproxy_trip_t)(PyObject *);
|
||||||
|
|
||||||
|
#define PgBufproxy_Type (*(PyTypeObject*)PgBUFPROXY_C_API[0])
|
||||||
|
#define PgBufproxy_New (*(_pgbufproxy_new_t)PgBUFPROXY_C_API[1])
|
||||||
|
#define PgBufproxy_GetParent \
|
||||||
|
(*(_pgbufproxy_get_obj_t)PgBUFPROXY_C_API[2])
|
||||||
|
#define PgBufproxy_Trip (*(_pgbufproxy_trip_t)PgBUFPROXY_C_API[3])
|
||||||
|
#define PgBufproxy_Check(x) ((x)->ob_type == (PgBufproxy_Type))
|
||||||
|
#define import_pygame_bufferproxy() \
|
||||||
|
_IMPORT_PYGAME_MODULE(bufferproxy, BUFPROXY, PgBUFPROXY_C_API)
|
||||||
|
|
||||||
|
#endif /* #if !(defined(PYGAMEAPI_BUFPROXY_INTERNAL) || ... */
|
||||||
|
|
||||||
|
#define PG_BUFPROXY_HEADER
|
||||||
|
|
||||||
|
#endif /* #if !defined(PG_BUFPROXY_HEADER) */
|
210
include/site/python3.7/pygame/pgcompat.h
Normal file
210
include/site/python3.7/pygame/pgcompat.h
Normal file
@ -0,0 +1,210 @@
|
|||||||
|
/* Python 2.x/3.x compitibility tools
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(PGCOMPAT_H)
|
||||||
|
#define PGCOMPAT_H
|
||||||
|
|
||||||
|
#if PY_MAJOR_VERSION >= 3
|
||||||
|
|
||||||
|
#define PY3 1
|
||||||
|
|
||||||
|
/* Define some aliases for the removed PyInt_* functions */
|
||||||
|
#define PyInt_Check(op) PyLong_Check(op)
|
||||||
|
#define PyInt_FromString PyLong_FromString
|
||||||
|
#define PyInt_FromUnicode PyLong_FromUnicode
|
||||||
|
#define PyInt_FromLong PyLong_FromLong
|
||||||
|
#define PyInt_FromSize_t PyLong_FromSize_t
|
||||||
|
#define PyInt_FromSsize_t PyLong_FromSsize_t
|
||||||
|
#define PyInt_AsLong PyLong_AsLong
|
||||||
|
#define PyInt_AsSsize_t PyLong_AsSsize_t
|
||||||
|
#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
|
||||||
|
#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
|
||||||
|
#define PyInt_AS_LONG PyLong_AS_LONG
|
||||||
|
#define PyNumber_Int PyNumber_Long
|
||||||
|
|
||||||
|
/* Weakrefs flags changed in 3.x */
|
||||||
|
#define Py_TPFLAGS_HAVE_WEAKREFS 0
|
||||||
|
|
||||||
|
/* Module init function returns new module instance. */
|
||||||
|
#define MODINIT_RETURN(x) return x
|
||||||
|
#define MODINIT_DEFINE(mod_name) PyMODINIT_FUNC PyInit_##mod_name (void)
|
||||||
|
#define DECREF_MOD(mod) Py_DECREF (mod)
|
||||||
|
|
||||||
|
/* Type header differs. */
|
||||||
|
#define TYPE_HEAD(x,y) PyVarObject_HEAD_INIT(x,y)
|
||||||
|
|
||||||
|
/* Text interface. Use unicode strings. */
|
||||||
|
#define Text_Type PyUnicode_Type
|
||||||
|
#define Text_Check PyUnicode_Check
|
||||||
|
#define Text_FromUTF8 PyUnicode_FromString
|
||||||
|
#define Text_FromUTF8AndSize PyUnicode_FromStringAndSize
|
||||||
|
#define Text_FromFormat PyUnicode_FromFormat
|
||||||
|
#define Text_GetSize PyUnicode_GetSize
|
||||||
|
#define Text_GET_SIZE PyUnicode_GET_SIZE
|
||||||
|
|
||||||
|
/* Binary interface. Use bytes. */
|
||||||
|
#define Bytes_Type PyBytes_Type
|
||||||
|
#define Bytes_Check PyBytes_Check
|
||||||
|
#define Bytes_Size PyBytes_Size
|
||||||
|
#define Bytes_AsString PyBytes_AsString
|
||||||
|
#define Bytes_AsStringAndSize PyBytes_AsStringAndSize
|
||||||
|
#define Bytes_FromStringAndSize PyBytes_FromStringAndSize
|
||||||
|
#define Bytes_FromFormat PyBytes_FromFormat
|
||||||
|
#define Bytes_AS_STRING PyBytes_AS_STRING
|
||||||
|
#define Bytes_GET_SIZE PyBytes_GET_SIZE
|
||||||
|
#define Bytes_AsDecodeObject PyBytes_AsDecodedObject
|
||||||
|
|
||||||
|
#define Object_Unicode PyObject_Str
|
||||||
|
|
||||||
|
#define IsTextObj(x) (PyUnicode_Check(x) || PyBytes_Check(x))
|
||||||
|
|
||||||
|
/* Renamed builtins */
|
||||||
|
#define BUILTINS_MODULE "builtins"
|
||||||
|
#define BUILTINS_UNICODE "str"
|
||||||
|
#define BUILTINS_UNICHR "chr"
|
||||||
|
|
||||||
|
/* Defaults for unicode file path encoding */
|
||||||
|
#define UNICODE_DEF_FS_CODEC Py_FileSystemDefaultEncoding
|
||||||
|
#if defined(MS_WIN32)
|
||||||
|
#define UNICODE_DEF_FS_ERROR "replace"
|
||||||
|
#else
|
||||||
|
#define UNICODE_DEF_FS_ERROR "surrogateescape"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else /* #if PY_MAJOR_VERSION >= 3 */
|
||||||
|
|
||||||
|
#define PY3 0
|
||||||
|
|
||||||
|
/* Module init function returns nothing. */
|
||||||
|
#define MODINIT_RETURN(x) return
|
||||||
|
#define MODINIT_DEFINE(mod_name) PyMODINIT_FUNC init##mod_name (void)
|
||||||
|
#define DECREF_MOD(mod)
|
||||||
|
|
||||||
|
/* Type header differs. */
|
||||||
|
#define TYPE_HEAD(x,y) \
|
||||||
|
PyObject_HEAD_INIT(x) \
|
||||||
|
0,
|
||||||
|
|
||||||
|
/* Text interface. Use ascii strings. */
|
||||||
|
#define Text_Type PyString_Type
|
||||||
|
#define Text_Check PyString_Check
|
||||||
|
#define Text_FromUTF8 PyString_FromString
|
||||||
|
#define Text_FromUTF8AndSize PyString_FromStringAndSize
|
||||||
|
#define Text_FromFormat PyString_FromFormat
|
||||||
|
#define Text_GetSize PyString_GetSize
|
||||||
|
#define Text_GET_SIZE PyString_GET_SIZE
|
||||||
|
|
||||||
|
/* Binary interface. Use ascii strings. */
|
||||||
|
#define Bytes_Type PyString_Type
|
||||||
|
#define Bytes_Check PyString_Check
|
||||||
|
#define Bytes_Size PyString_Size
|
||||||
|
#define Bytes_AsString PyString_AsString
|
||||||
|
#define Bytes_AsStringAndSize PyString_AsStringAndSize
|
||||||
|
#define Bytes_FromStringAndSize PyString_FromStringAndSize
|
||||||
|
#define Bytes_FromFormat PyString_FromFormat
|
||||||
|
#define Bytes_AS_STRING PyString_AS_STRING
|
||||||
|
#define Bytes_GET_SIZE PyString_GET_SIZE
|
||||||
|
#define Bytes_AsDecodedObject PyString_AsDecodedObject
|
||||||
|
|
||||||
|
#define Object_Unicode PyObject_Unicode
|
||||||
|
|
||||||
|
/* Renamed builtins */
|
||||||
|
#define BUILTINS_MODULE "__builtin__"
|
||||||
|
#define BUILTINS_UNICODE "unicode"
|
||||||
|
#define BUILTINS_UNICHR "unichr"
|
||||||
|
|
||||||
|
/* Defaults for unicode file path encoding */
|
||||||
|
#define UNICODE_DEF_FS_CODEC Py_FileSystemDefaultEncoding
|
||||||
|
#define UNICODE_DEF_FS_ERROR "strict"
|
||||||
|
|
||||||
|
#endif /* #if PY_MAJOR_VERSION >= 3 */
|
||||||
|
|
||||||
|
#define PY2 (!PY3)
|
||||||
|
|
||||||
|
#define MODINIT_ERROR MODINIT_RETURN (NULL)
|
||||||
|
|
||||||
|
/* Module state. These macros are used to define per-module macros.
|
||||||
|
* v - global state variable (Python 2.x)
|
||||||
|
* s - global state structure (Python 3.x)
|
||||||
|
*/
|
||||||
|
#define PY2_GETSTATE(v) (&(v))
|
||||||
|
#define PY3_GETSTATE(s, m) ((struct s *) PyModule_GetState (m))
|
||||||
|
|
||||||
|
/* Pep 3123: Making PyObject_HEAD conform to standard C */
|
||||||
|
#if !defined(Py_TYPE)
|
||||||
|
#define Py_TYPE(o) (((PyObject *)(o))->ob_type)
|
||||||
|
#define Py_REFCNT(o) (((PyObject *)(o))->ob_refcnt)
|
||||||
|
#define Py_SIZE(o) (((PyVarObject *)(o))->ob_size)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Encode a unicode file path */
|
||||||
|
#define Unicode_AsEncodedPath(u) \
|
||||||
|
PyUnicode_AsEncodedString ((u), UNICODE_DEF_FS_CODEC, UNICODE_DEF_FS_ERROR)
|
||||||
|
|
||||||
|
/* Relative paths introduced in Python 2.6 */
|
||||||
|
#if PY_VERSION_HEX >= 0x02060000
|
||||||
|
#define HAVE_RELATIVE_IMPORT 1
|
||||||
|
#else
|
||||||
|
#define HAVE_RELATIVE_IMPORT 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_RELATIVE_IMPORT
|
||||||
|
#define RELATIVE_MODULE(m) ("." m)
|
||||||
|
#else
|
||||||
|
#define RELATIVE_MODULE(m) (m)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Python 3 (PEP 3118) buffer protocol */
|
||||||
|
#if PY_VERSION_HEX >= 0x02060000
|
||||||
|
#define HAVE_NEW_BUFPROTO 1
|
||||||
|
#else
|
||||||
|
#define HAVE_NEW_BUFPROTO 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define HAVE_OLD_BUFPROTO PY2
|
||||||
|
|
||||||
|
#if !defined(PG_ENABLE_OLDBUF) /* allow for command line override */
|
||||||
|
#if HAVE_OLD_BUFPROTO
|
||||||
|
#define PG_ENABLE_OLDBUF 1
|
||||||
|
#else
|
||||||
|
#define PG_ENABLE_OLDBUF 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
|
||||||
|
#define Py_TPFLAGS_HAVE_NEWBUFFER 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef Py_TPFLAGS_HAVE_CLASS
|
||||||
|
#define Py_TPFLAGS_HAVE_CLASS 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef Py_TPFLAGS_CHECKTYPES
|
||||||
|
#define Py_TPFLAGS_CHECKTYPES 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PY_VERSION_HEX >= 0x03020000
|
||||||
|
#define Slice_GET_INDICES_EX(slice, length, start, stop, step, slicelength) \
|
||||||
|
PySlice_GetIndicesEx(slice, length, start, stop, step, slicelength)
|
||||||
|
#else
|
||||||
|
#define Slice_GET_INDICES_EX(slice, length, start, stop, step, slicelength) \
|
||||||
|
PySlice_GetIndicesEx((PySliceObject *)(slice), length, \
|
||||||
|
start, stop, step, slicelength)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Python 2.4 (PEP 353) ssize_t */
|
||||||
|
#if PY_VERSION_HEX < 0x02050000
|
||||||
|
#define PyInt_AsSsize_t PyInt_AsLong
|
||||||
|
#define PyInt_FromSsizt_t PyInt_FromLong
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Support new buffer protocol? */
|
||||||
|
#if !defined(PG_ENABLE_NEWBUF) /* allow for command line override */
|
||||||
|
#if HAVE_NEW_BUFPROTO && !defined(PYPY_VERSION)
|
||||||
|
#define PG_ENABLE_NEWBUF 1
|
||||||
|
#else
|
||||||
|
#define PG_ENABLE_NEWBUF 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* #if !defined(PGCOMPAT_H) */
|
16
include/site/python3.7/pygame/pgopengl.h
Normal file
16
include/site/python3.7/pygame/pgopengl.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#if !defined(PGOPENGL_H)
|
||||||
|
#define PGOPENGL_H
|
||||||
|
|
||||||
|
/** This header includes definitions of Opengl functions as pointer types for
|
||||||
|
** use with the SDL function SDL_GL_GetProcAddress.
|
||||||
|
**/
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#define GL_APIENTRY __stdcall
|
||||||
|
#else
|
||||||
|
#define GL_APIENTRY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef void (GL_APIENTRY *GL_glReadPixels_Func)(int, int, int, int, unsigned int, unsigned int, void*);
|
||||||
|
|
||||||
|
#endif
|
34
include/site/python3.7/pygame/pygame.h
Normal file
34
include/site/python3.7/pygame/pygame.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
pygame - Python Game Library
|
||||||
|
Copyright (C) 2000-2001 Pete Shinners
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
Pete Shinners
|
||||||
|
pete@shinners.org
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* To allow the Pygame C api to be globally shared by all code within an
|
||||||
|
* extension module built from multiple C files, only include the pygame.h
|
||||||
|
* header within the top level C file, the one which calls the
|
||||||
|
* 'import_pygame_*' macros. All other C source files of the module should
|
||||||
|
* include _pygame.h instead.
|
||||||
|
*/
|
||||||
|
#ifndef PYGAME_H
|
||||||
|
#define PYGAME_H
|
||||||
|
|
||||||
|
#include "_pygame.h"
|
||||||
|
|
||||||
|
#endif
|
143
include/site/python3.7/pygame/scrap.h
Normal file
143
include/site/python3.7/pygame/scrap.h
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
/*
|
||||||
|
pygame - Python Game Library
|
||||||
|
Copyright (C) 2006, 2007 Rene Dudfield, Marcus von Appen
|
||||||
|
|
||||||
|
Originally put in the public domain by Sam Lantinga.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This is unconditionally defined in Python.h */
|
||||||
|
#if defined(_POSIX_C_SOURCE)
|
||||||
|
#undef _POSIX_C_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Python.h>
|
||||||
|
|
||||||
|
/* Handle clipboard text and data in arbitrary formats */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Predefined supported pygame scrap types.
|
||||||
|
*/
|
||||||
|
#define PYGAME_SCRAP_TEXT "text/plain"
|
||||||
|
#define PYGAME_SCRAP_BMP "image/bmp"
|
||||||
|
#define PYGAME_SCRAP_PPM "image/ppm"
|
||||||
|
#define PYGAME_SCRAP_PBM "image/pbm"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The supported scrap clipboard types.
|
||||||
|
*
|
||||||
|
* This is only relevant in a X11 environment, which supports mouse
|
||||||
|
* selections as well. For Win32 and MacOS environments the default
|
||||||
|
* clipboard is used, no matter what value is passed.
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SCRAP_CLIPBOARD,
|
||||||
|
SCRAP_SELECTION /* only supported in X11 environments. */
|
||||||
|
} ScrapClipType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro for initialization checks.
|
||||||
|
*/
|
||||||
|
#define PYGAME_SCRAP_INIT_CHECK() \
|
||||||
|
if(!pygame_scrap_initialized()) \
|
||||||
|
return (PyErr_SetString (PyExc_SDLError, \
|
||||||
|
"scrap system not initialized."), NULL)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Checks, whether the pygame scrap module was initialized.
|
||||||
|
*
|
||||||
|
* \return 1 if the modules was initialized, 0 otherwise.
|
||||||
|
*/
|
||||||
|
extern int
|
||||||
|
pygame_scrap_initialized (void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Initializes the pygame scrap module internals. Call this before any
|
||||||
|
* other method.
|
||||||
|
*
|
||||||
|
* \return 1 on successful initialization, 0 otherwise.
|
||||||
|
*/
|
||||||
|
extern int
|
||||||
|
pygame_scrap_init (void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Checks, whether the pygame window lost the clipboard focus or not.
|
||||||
|
*
|
||||||
|
* \return 1 if the window lost the focus, 0 otherwise.
|
||||||
|
*/
|
||||||
|
extern int
|
||||||
|
pygame_scrap_lost (void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Places content of a specific type into the clipboard.
|
||||||
|
*
|
||||||
|
* \note For X11 the following notes are important: The following types
|
||||||
|
* are reserved for internal usage and thus will throw an error on
|
||||||
|
* setting them: "TIMESTAMP", "TARGETS", "SDL_SELECTION".
|
||||||
|
* Setting PYGAME_SCRAP_TEXT ("text/plain") will also automatically
|
||||||
|
* set the X11 types "STRING" (XA_STRING), "TEXT" and "UTF8_STRING".
|
||||||
|
*
|
||||||
|
* For Win32 the following notes are important: Setting
|
||||||
|
* PYGAME_SCRAP_TEXT ("text/plain") will also automatically set
|
||||||
|
* the Win32 type "TEXT" (CF_TEXT).
|
||||||
|
*
|
||||||
|
* For QNX the following notes are important: Setting
|
||||||
|
* PYGAME_SCRAP_TEXT ("text/plain") will also automatically set
|
||||||
|
* the QNX type "TEXT" (Ph_CL_TEXT).
|
||||||
|
*
|
||||||
|
* \param type The type of the content.
|
||||||
|
* \param srclen The length of the content.
|
||||||
|
* \param src The NULL terminated content.
|
||||||
|
* \return 1, if the content could be successfully pasted into the clipboard,
|
||||||
|
* 0 otherwise.
|
||||||
|
*/
|
||||||
|
extern int
|
||||||
|
pygame_scrap_put (char *type, int srclen, char *src);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Gets the current content from the clipboard.
|
||||||
|
*
|
||||||
|
* \note The received content does not need to be the content previously
|
||||||
|
* placed in the clipboard using pygame_put_scrap(). See the
|
||||||
|
* pygame_put_scrap() notes for more details.
|
||||||
|
*
|
||||||
|
* \param type The type of the content to receive.
|
||||||
|
* \param count The size of the returned content.
|
||||||
|
* \return The content or NULL in case of an error or if no content of the
|
||||||
|
* specified type was available.
|
||||||
|
*/
|
||||||
|
extern char*
|
||||||
|
pygame_scrap_get (char *type, unsigned long *count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Gets the currently available content types from the clipboard.
|
||||||
|
*
|
||||||
|
* \return The different available content types or NULL in case of an
|
||||||
|
* error or if no content type is available.
|
||||||
|
*/
|
||||||
|
extern char**
|
||||||
|
pygame_scrap_get_types (void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Checks whether content for the specified scrap type is currently
|
||||||
|
* available in the clipboard.
|
||||||
|
*
|
||||||
|
* \param type The type to check for.
|
||||||
|
* \return 1, if there is content and 0 otherwise.
|
||||||
|
*/
|
||||||
|
extern int
|
||||||
|
pygame_scrap_contains (char *type);
|
359
include/site/python3.7/pygame/surface.h
Normal file
359
include/site/python3.7/pygame/surface.h
Normal file
@ -0,0 +1,359 @@
|
|||||||
|
/*
|
||||||
|
pygame - Python Game Library
|
||||||
|
Copyright (C) 2000-2001 Pete Shinners
|
||||||
|
Copyright (C) 2007 Marcus von Appen
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
Pete Shinners
|
||||||
|
pete@shinners.org
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SURFACE_H
|
||||||
|
#define SURFACE_H
|
||||||
|
|
||||||
|
/* This is defined in SDL.h */
|
||||||
|
#if defined(_POSIX_C_SOURCE)
|
||||||
|
#undef _POSIX_C_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
|
#include "pygame.h"
|
||||||
|
|
||||||
|
#define PYGAME_BLEND_ADD 0x1
|
||||||
|
#define PYGAME_BLEND_SUB 0x2
|
||||||
|
#define PYGAME_BLEND_MULT 0x3
|
||||||
|
#define PYGAME_BLEND_MIN 0x4
|
||||||
|
#define PYGAME_BLEND_MAX 0x5
|
||||||
|
|
||||||
|
#define PYGAME_BLEND_RGB_ADD 0x1
|
||||||
|
#define PYGAME_BLEND_RGB_SUB 0x2
|
||||||
|
#define PYGAME_BLEND_RGB_MULT 0x3
|
||||||
|
#define PYGAME_BLEND_RGB_MIN 0x4
|
||||||
|
#define PYGAME_BLEND_RGB_MAX 0x5
|
||||||
|
|
||||||
|
#define PYGAME_BLEND_RGBA_ADD 0x6
|
||||||
|
#define PYGAME_BLEND_RGBA_SUB 0x7
|
||||||
|
#define PYGAME_BLEND_RGBA_MULT 0x8
|
||||||
|
#define PYGAME_BLEND_RGBA_MIN 0x9
|
||||||
|
#define PYGAME_BLEND_RGBA_MAX 0x10
|
||||||
|
#define PYGAME_BLEND_PREMULTIPLIED 0x11
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||||
|
#define GET_PIXEL_24(b) (b[0] + (b[1] << 8) + (b[2] << 16))
|
||||||
|
#else
|
||||||
|
#define GET_PIXEL_24(b) (b[2] + (b[1] << 8) + (b[0] << 16))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define GET_PIXEL(pxl, bpp, source) \
|
||||||
|
switch (bpp) \
|
||||||
|
{ \
|
||||||
|
case 2: \
|
||||||
|
pxl = *((Uint16 *) (source)); \
|
||||||
|
break; \
|
||||||
|
case 4: \
|
||||||
|
pxl = *((Uint32 *) (source)); \
|
||||||
|
break; \
|
||||||
|
default: \
|
||||||
|
{ \
|
||||||
|
Uint8 *b = (Uint8 *) source; \
|
||||||
|
pxl = GET_PIXEL_24(b); \
|
||||||
|
} \
|
||||||
|
break; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define GET_PIXELVALS(_sR, _sG, _sB, _sA, px, fmt, ppa) \
|
||||||
|
_sR = ((px & fmt->Rmask) >> fmt->Rshift); \
|
||||||
|
_sR = (_sR << fmt->Rloss) + (_sR >> (8 - (fmt->Rloss << 1))); \
|
||||||
|
_sG = ((px & fmt->Gmask) >> fmt->Gshift); \
|
||||||
|
_sG = (_sG << fmt->Gloss) + (_sG >> (8 - (fmt->Gloss << 1))); \
|
||||||
|
_sB = ((px & fmt->Bmask) >> fmt->Bshift); \
|
||||||
|
_sB = (_sB << fmt->Bloss) + (_sB >> (8 - (fmt->Bloss << 1))); \
|
||||||
|
if (ppa) \
|
||||||
|
{ \
|
||||||
|
_sA = ((px & fmt->Amask) >> fmt->Ashift); \
|
||||||
|
_sA = (_sA << fmt->Aloss) + (_sA >> (8 - (fmt->Aloss << 1))); \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
_sA = 255; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define GET_PIXELVALS_1(sr, sg, sb, sa, _src, _fmt) \
|
||||||
|
sr = _fmt->palette->colors[*((Uint8 *) (_src))].r; \
|
||||||
|
sg = _fmt->palette->colors[*((Uint8 *) (_src))].g; \
|
||||||
|
sb = _fmt->palette->colors[*((Uint8 *) (_src))].b; \
|
||||||
|
sa = 255;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||||
|
#define SET_OFFSETS_24(or, og, ob, fmt) \
|
||||||
|
{ \
|
||||||
|
or = (fmt->Rshift == 0 ? 0 : \
|
||||||
|
fmt->Rshift == 8 ? 1 : \
|
||||||
|
2 ); \
|
||||||
|
og = (fmt->Gshift == 0 ? 0 : \
|
||||||
|
fmt->Gshift == 8 ? 1 : \
|
||||||
|
2 ); \
|
||||||
|
ob = (fmt->Bshift == 0 ? 0 : \
|
||||||
|
fmt->Bshift == 8 ? 1 : \
|
||||||
|
2 ); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SET_OFFSETS_32(or, og, ob, fmt) \
|
||||||
|
{ \
|
||||||
|
or = (fmt->Rshift == 0 ? 0 : \
|
||||||
|
fmt->Rshift == 8 ? 1 : \
|
||||||
|
fmt->Rshift == 16 ? 2 : \
|
||||||
|
3 ); \
|
||||||
|
og = (fmt->Gshift == 0 ? 0 : \
|
||||||
|
fmt->Gshift == 8 ? 1 : \
|
||||||
|
fmt->Gshift == 16 ? 2 : \
|
||||||
|
3 ); \
|
||||||
|
ob = (fmt->Bshift == 0 ? 0 : \
|
||||||
|
fmt->Bshift == 8 ? 1 : \
|
||||||
|
fmt->Bshift == 16 ? 2 : \
|
||||||
|
3 ); \
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define SET_OFFSETS_24(or, og, ob, fmt) \
|
||||||
|
{ \
|
||||||
|
or = (fmt->Rshift == 0 ? 2 : \
|
||||||
|
fmt->Rshift == 8 ? 1 : \
|
||||||
|
0 ); \
|
||||||
|
og = (fmt->Gshift == 0 ? 2 : \
|
||||||
|
fmt->Gshift == 8 ? 1 : \
|
||||||
|
0 ); \
|
||||||
|
ob = (fmt->Bshift == 0 ? 2 : \
|
||||||
|
fmt->Bshift == 8 ? 1 : \
|
||||||
|
0 ); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SET_OFFSETS_32(or, og, ob, fmt) \
|
||||||
|
{ \
|
||||||
|
or = (fmt->Rshift == 0 ? 3 : \
|
||||||
|
fmt->Rshift == 8 ? 2 : \
|
||||||
|
fmt->Rshift == 16 ? 1 : \
|
||||||
|
0 ); \
|
||||||
|
og = (fmt->Gshift == 0 ? 3 : \
|
||||||
|
fmt->Gshift == 8 ? 2 : \
|
||||||
|
fmt->Gshift == 16 ? 1 : \
|
||||||
|
0 ); \
|
||||||
|
ob = (fmt->Bshift == 0 ? 3 : \
|
||||||
|
fmt->Bshift == 8 ? 2 : \
|
||||||
|
fmt->Bshift == 16 ? 1 : \
|
||||||
|
0 ); \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define CREATE_PIXEL(buf, r, g, b, a, bp, ft) \
|
||||||
|
switch (bp) \
|
||||||
|
{ \
|
||||||
|
case 2: \
|
||||||
|
*((Uint16 *) (buf)) = \
|
||||||
|
((r >> ft->Rloss) << ft->Rshift) | \
|
||||||
|
((g >> ft->Gloss) << ft->Gshift) | \
|
||||||
|
((b >> ft->Bloss) << ft->Bshift) | \
|
||||||
|
((a >> ft->Aloss) << ft->Ashift); \
|
||||||
|
break; \
|
||||||
|
case 4: \
|
||||||
|
*((Uint32 *) (buf)) = \
|
||||||
|
((r >> ft->Rloss) << ft->Rshift) | \
|
||||||
|
((g >> ft->Gloss) << ft->Gshift) | \
|
||||||
|
((b >> ft->Bloss) << ft->Bshift) | \
|
||||||
|
((a >> ft->Aloss) << ft->Ashift); \
|
||||||
|
break; \
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Pretty good idea from Tom Duff :-). */
|
||||||
|
#define LOOP_UNROLLED4(code, n, width) \
|
||||||
|
n = (width + 3) / 4; \
|
||||||
|
switch (width & 3) \
|
||||||
|
{ \
|
||||||
|
case 0: do { code; \
|
||||||
|
case 3: code; \
|
||||||
|
case 2: code; \
|
||||||
|
case 1: code; \
|
||||||
|
} while (--n > 0); \
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Used in the srcbpp == dstbpp == 1 blend functions */
|
||||||
|
#define REPEAT_3(code) \
|
||||||
|
code; \
|
||||||
|
code; \
|
||||||
|
code;
|
||||||
|
|
||||||
|
#define REPEAT_4(code) \
|
||||||
|
code; \
|
||||||
|
code; \
|
||||||
|
code; \
|
||||||
|
code;
|
||||||
|
|
||||||
|
|
||||||
|
#define BLEND_ADD(tmp, sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||||
|
tmp = dR + sR; dR = (tmp <= 255 ? tmp : 255); \
|
||||||
|
tmp = dG + sG; dG = (tmp <= 255 ? tmp : 255); \
|
||||||
|
tmp = dB + sB; dB = (tmp <= 255 ? tmp : 255);
|
||||||
|
|
||||||
|
#define BLEND_SUB(tmp, sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||||
|
tmp = dR - sR; dR = (tmp >= 0 ? tmp : 0); \
|
||||||
|
tmp = dG - sG; dG = (tmp >= 0 ? tmp : 0); \
|
||||||
|
tmp = dB - sB; dB = (tmp >= 0 ? tmp : 0);
|
||||||
|
|
||||||
|
#define BLEND_MULT(sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||||
|
dR = (dR && sR) ? (dR * sR) >> 8 : 0; \
|
||||||
|
dG = (dG && sG) ? (dG * sG) >> 8 : 0; \
|
||||||
|
dB = (dB && sB) ? (dB * sB) >> 8 : 0;
|
||||||
|
|
||||||
|
#define BLEND_MIN(sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||||
|
if(sR < dR) { dR = sR; } \
|
||||||
|
if(sG < dG) { dG = sG; } \
|
||||||
|
if(sB < dB) { dB = sB; }
|
||||||
|
|
||||||
|
#define BLEND_MAX(sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||||
|
if(sR > dR) { dR = sR; } \
|
||||||
|
if(sG > dG) { dG = sG; } \
|
||||||
|
if(sB > dB) { dB = sB; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define BLEND_RGBA_ADD(tmp, sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||||
|
tmp = dR + sR; dR = (tmp <= 255 ? tmp : 255); \
|
||||||
|
tmp = dG + sG; dG = (tmp <= 255 ? tmp : 255); \
|
||||||
|
tmp = dB + sB; dB = (tmp <= 255 ? tmp : 255); \
|
||||||
|
tmp = dA + sA; dA = (tmp <= 255 ? tmp : 255);
|
||||||
|
|
||||||
|
#define BLEND_RGBA_SUB(tmp, sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||||
|
tmp = dR - sR; dR = (tmp >= 0 ? tmp : 0); \
|
||||||
|
tmp = dG - sG; dG = (tmp >= 0 ? tmp : 0); \
|
||||||
|
tmp = dB - sB; dB = (tmp >= 0 ? tmp : 0); \
|
||||||
|
tmp = dA - sA; dA = (tmp >= 0 ? tmp : 0);
|
||||||
|
|
||||||
|
#define BLEND_RGBA_MULT(sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||||
|
dR = (dR && sR) ? (dR * sR) >> 8 : 0; \
|
||||||
|
dG = (dG && sG) ? (dG * sG) >> 8 : 0; \
|
||||||
|
dB = (dB && sB) ? (dB * sB) >> 8 : 0; \
|
||||||
|
dA = (dA && sA) ? (dA * sA) >> 8 : 0;
|
||||||
|
|
||||||
|
#define BLEND_RGBA_MIN(sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||||
|
if(sR < dR) { dR = sR; } \
|
||||||
|
if(sG < dG) { dG = sG; } \
|
||||||
|
if(sB < dB) { dB = sB; } \
|
||||||
|
if(sA < dA) { dA = sA; }
|
||||||
|
|
||||||
|
#define BLEND_RGBA_MAX(sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||||
|
if(sR > dR) { dR = sR; } \
|
||||||
|
if(sG > dG) { dG = sG; } \
|
||||||
|
if(sB > dB) { dB = sB; } \
|
||||||
|
if(sA > dA) { dA = sA; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
/* Choose an alpha blend equation. If the sign is preserved on a right shift
|
||||||
|
* then use a specialized, faster, equation. Otherwise a more general form,
|
||||||
|
* where all additions are done before the shift, is needed.
|
||||||
|
*/
|
||||||
|
#if (-1 >> 1) < 0
|
||||||
|
#define ALPHA_BLEND_COMP(sC, dC, sA) ((((sC - dC) * sA + sC) >> 8) + dC)
|
||||||
|
#else
|
||||||
|
#define ALPHA_BLEND_COMP(sC, dC, sA) (((dC << 8) + (sC - dC) * sA + sC) >> 8)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||||
|
do { \
|
||||||
|
if (dA) \
|
||||||
|
{ \
|
||||||
|
dR = ALPHA_BLEND_COMP(sR, dR, sA); \
|
||||||
|
dG = ALPHA_BLEND_COMP(sG, dG, sA); \
|
||||||
|
dB = ALPHA_BLEND_COMP(sB, dB, sA); \
|
||||||
|
dA = sA + dA - ((sA * dA) / 255); \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
dR = sR; \
|
||||||
|
dG = sG; \
|
||||||
|
dB = sB; \
|
||||||
|
dA = sA; \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
#define ALPHA_BLEND_PREMULTIPLIED_COMP(sC, dC, sA) (sC + dC - ((dC * sA) >> 8))
|
||||||
|
|
||||||
|
#define ALPHA_BLEND_PREMULTIPLIED(tmp, sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||||
|
do { \
|
||||||
|
tmp = ALPHA_BLEND_PREMULTIPLIED_COMP(sR, dR, sA); dR = (tmp > 255 ? 255 : tmp); \
|
||||||
|
tmp = ALPHA_BLEND_PREMULTIPLIED_COMP(sG, dG, sA); dG = (tmp > 255 ? 255 : tmp); \
|
||||||
|
tmp = ALPHA_BLEND_PREMULTIPLIED_COMP(sB, dB, sA); dB = (tmp > 255 ? 255 : tmp); \
|
||||||
|
dA = sA + dA - ((sA * dA) / 255); \
|
||||||
|
} while(0)
|
||||||
|
#elif 0
|
||||||
|
|
||||||
|
#define ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||||
|
do { \
|
||||||
|
if(sA){ \
|
||||||
|
if(dA && sA < 255){ \
|
||||||
|
int dContrib = dA*(255 - sA)/255; \
|
||||||
|
dA = sA+dA - ((sA*dA)/255); \
|
||||||
|
dR = (dR*dContrib + sR*sA)/dA; \
|
||||||
|
dG = (dG*dContrib + sG*sA)/dA; \
|
||||||
|
dB = (dB*dContrib + sB*sA)/dA; \
|
||||||
|
}else{ \
|
||||||
|
dR = sR; \
|
||||||
|
dG = sG; \
|
||||||
|
dB = sB; \
|
||||||
|
dA = sA; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
surface_fill_blend (SDL_Surface *surface, SDL_Rect *rect, Uint32 color,
|
||||||
|
int blendargs);
|
||||||
|
|
||||||
|
void
|
||||||
|
surface_respect_clip_rect (SDL_Surface *surface, SDL_Rect *rect);
|
||||||
|
|
||||||
|
int
|
||||||
|
pygame_AlphaBlit (SDL_Surface * src, SDL_Rect * srcrect,
|
||||||
|
SDL_Surface * dst, SDL_Rect * dstrect, int the_args);
|
||||||
|
|
||||||
|
int
|
||||||
|
pygame_Blit (SDL_Surface * src, SDL_Rect * srcrect,
|
||||||
|
SDL_Surface * dst, SDL_Rect * dstrect, int the_args);
|
||||||
|
|
||||||
|
#endif /* SURFACE_H */
|
18
index.py
18
index.py
@ -1,6 +1,10 @@
|
|||||||
import firebase_admin
|
import firebase_admin
|
||||||
from firebase_admin import credentials
|
from firebase_admin import credentials
|
||||||
from firebase_admin import firestore
|
from firebase_admin import firestore
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
import camera
|
||||||
|
import image_tools
|
||||||
|
|
||||||
# Use a service account
|
# Use a service account
|
||||||
cred = credentials.Certificate('./hackku-272b6e79b2a9.json')
|
cred = credentials.Certificate('./hackku-272b6e79b2a9.json')
|
||||||
@ -10,7 +14,19 @@ db = firestore.client()
|
|||||||
|
|
||||||
doc_ref_lot1 = db.collection(u'Lot1')
|
doc_ref_lot1 = db.collection(u'Lot1')
|
||||||
|
|
||||||
|
# Take the picture
|
||||||
|
# img = Image.open(camera.capture()).load()
|
||||||
|
img = Image.open('./lib/test-images/lot-3-cars.jpg').load()
|
||||||
|
reference = Image.open('./lib/test-images/lot-empty.jpg').load()
|
||||||
|
|
||||||
stalls = doc_ref_lot1.get()
|
stalls = doc_ref_lot1.get()
|
||||||
|
|
||||||
for stall in stalls:
|
for stall in stalls:
|
||||||
print(u'{} => {}'.format(stall.id, stall.to_dict()))
|
#print(u'{} => {}'.format(stall.id, stall.to_dict()))
|
||||||
|
stall_obj = stall.to_dict()
|
||||||
|
color_reference = image_tools.average_color(stall_obj['locationX'], stall_obj['locationY'], stall_obj['sideN'], reference)
|
||||||
|
color_compare = image_tools.average_color(stall_obj['locationX'], stall_obj['locationY'], stall_obj['sideN'], img)
|
||||||
|
stall_occupied = image_tools.threshold(image_tools.differences(color_reference, color_compare))
|
||||||
|
stall_obj['open'] = not stall_occupied
|
||||||
|
|
||||||
|
db.collection(u'Lot1').document(stall.id).set( stall_obj )
|
||||||
|
Loading…
Reference in New Issue
Block a user