repo
string
commit
string
message
string
diff
string
jjk/XamhainII
2e868b9f4679f0615d655cceb32a2fe3fe66166a
Start work on configuration UI.
diff --git a/XamhainConfigureSheet.xib b/XamhainConfigureSheet.xib new file mode 100644 index 0000000..04de8b9 --- /dev/null +++ b/XamhainConfigureSheet.xib @@ -0,0 +1,981 @@ +<?xml version="1.0" encoding="UTF-8"?> +<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10"> + <data> + <int key="IBDocument.SystemTarget">1060</int> + <string key="IBDocument.SystemVersion">10B504</string> + <string key="IBDocument.InterfaceBuilderVersion">732</string> + <string key="IBDocument.AppKitVersion">1038.2</string> + <string key="IBDocument.HIToolboxVersion">437.00</string> + <object class="NSMutableDictionary" key="IBDocument.PluginVersions"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="NS.object.0">732</string> + </object> + <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> + <bool key="EncodedWithXMLCoder">YES</bool> + <integer value="1"/> + </object> + <object class="NSArray" key="IBDocument.PluginDependencies"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + </object> + <object class="NSMutableDictionary" key="IBDocument.Metadata"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys" id="0"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + </object> + <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSCustomObject" id="1001"> + <string key="NSClassName">XamhainUserDefaultsController</string> + </object> + <object class="NSCustomObject" id="1003"> + <string key="NSClassName">FirstResponder</string> + </object> + <object class="NSCustomObject" id="1004"> + <string key="NSClassName">NSApplication</string> + </object> + <object class="NSWindowTemplate" id="1005"> + <int key="NSWindowStyleMask">1</int> + <int key="NSWindowBacking">2</int> + <string key="NSWindowRect">{{0, 768}, {415, 110}}</string> + <int key="NSWTFlags">1618478080</int> + <string key="NSWindowTitle">ConfigurationSheet</string> + <string key="NSWindowClass">NSWindow</string> + <nil key="NSViewClass"/> + <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> + <object class="NSView" key="NSWindowView" id="1006"> + <reference key="NSNextResponder"/> + <int key="NSvFlags">256</int> + <object class="NSMutableArray" key="NSSubviews"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSTextField" id="415200325"> + <reference key="NSNextResponder" ref="1006"/> + <int key="NSvFlags">268</int> + <string key="NSFrame">{{17, 73}, {234, 17}}</string> + <reference key="NSSuperview" ref="1006"/> + <int key="NSViewLayerContentsRedrawPolicy">2</int> + <bool key="NSEnabled">YES</bool> + <object class="NSTextFieldCell" key="NSCell" id="759654285"> + <int key="NSCellFlags">67239424</int> + <int key="NSCellFlags2">272629760</int> + <string key="NSContents">Number of Knots</string> + <object class="NSFont" key="NSSupport"> + <string key="NSName">LucidaGrande</string> + <double key="NSSize">13</double> + <int key="NSfFlags">16</int> + </object> + <reference key="NSControlView" ref="415200325"/> + <object class="NSColor" key="NSBackgroundColor" id="586021249"> + <int key="NSColorSpace">6</int> + <string key="NSCatalogName">System</string> + <string key="NSColorName">controlColor</string> + <object class="NSColor" key="NSColor"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes> + </object> + </object> + <object class="NSColor" key="NSTextColor" id="671980879"> + <int key="NSColorSpace">6</int> + <string key="NSCatalogName">System</string> + <string key="NSColorName">controlTextColor</string> + <object class="NSColor" key="NSColor"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MAA</bytes> + </object> + </object> + </object> + </object> + <object class="NSButton" id="1013048762"> + <reference key="NSNextResponder" ref="1006"/> + <int key="NSvFlags">289</int> + <string key="NSFrame">{{305, 12}, {96, 32}}</string> + <reference key="NSSuperview" ref="1006"/> + <int key="NSViewLayerContentsRedrawPolicy">2</int> + <bool key="NSEnabled">YES</bool> + <object class="NSButtonCell" key="NSCell" id="328796931"> + <int key="NSCellFlags">67239424</int> + <int key="NSCellFlags2">134217728</int> + <string key="NSContents">OK</string> + <object class="NSFont" key="NSSupport" id="872788741"> + <string key="NSName">LucidaGrande</string> + <double key="NSSize">13</double> + <int key="NSfFlags">1044</int> + </object> + <reference key="NSControlView" ref="1013048762"/> + <int key="NSButtonFlags">-2037235457</int> + <int key="NSButtonFlags2">129</int> + <string key="NSAlternateContents"/> + <string type="base64-UTF8" key="NSKeyEquivalent">DQ</string> + <int key="NSPeriodicDelay">200</int> + <int key="NSPeriodicInterval">25</int> + </object> + </object> + <object class="NSButton" id="995501573"> + <reference key="NSNextResponder" ref="1006"/> + <int key="NSvFlags">289</int> + <string key="NSFrame">{{197, 12}, {96, 32}}</string> + <reference key="NSSuperview" ref="1006"/> + <int key="NSViewLayerContentsRedrawPolicy">2</int> + <bool key="NSEnabled">YES</bool> + <object class="NSButtonCell" key="NSCell" id="770782373"> + <int key="NSCellFlags">67239424</int> + <int key="NSCellFlags2">134217728</int> + <string key="NSContents">Cancel</string> + <reference key="NSSupport" ref="872788741"/> + <reference key="NSControlView" ref="995501573"/> + <int key="NSButtonFlags">-2038284033</int> + <int key="NSButtonFlags2">129</int> + <string key="NSAlternateContents"/> + <string type="base64-UTF8" key="NSKeyEquivalent">Gw</string> + <int key="NSPeriodicDelay">200</int> + <int key="NSPeriodicInterval">25</int> + </object> + </object> + <object class="NSButton" id="654791710"> + <reference key="NSNextResponder" ref="1006"/> + <int key="NSvFlags">292</int> + <string key="NSFrame">{{14, 12}, {148, 32}}</string> + <reference key="NSSuperview" ref="1006"/> + <int key="NSViewLayerContentsRedrawPolicy">2</int> + <bool key="NSEnabled">YES</bool> + <object class="NSButtonCell" key="NSCell" id="460152017"> + <int key="NSCellFlags">67239424</int> + <int key="NSCellFlags2">134217728</int> + <string key="NSContents">Reset to Defaults</string> + <reference key="NSSupport" ref="872788741"/> + <reference key="NSControlView" ref="654791710"/> + <int key="NSButtonFlags">-2038284033</int> + <int key="NSButtonFlags2">129</int> + <string key="NSAlternateContents"/> + <string key="NSKeyEquivalent"/> + <int key="NSPeriodicDelay">200</int> + <int key="NSPeriodicInterval">25</int> + </object> + </object> + <object class="NSStepper" id="392143892"> + <reference key="NSNextResponder" ref="1006"/> + <int key="NSvFlags">268</int> + <string key="NSFrame">{{186, 67}, {19, 27}}</string> + <reference key="NSSuperview" ref="1006"/> + <int key="NSViewLayerContentsRedrawPolicy">2</int> + <bool key="NSEnabled">YES</bool> + <object class="NSStepperCell" key="NSCell" id="154709998"> + <int key="NSCellFlags">917024</int> + <int key="NSCellFlags2">0</int> + <reference key="NSControlView" ref="392143892"/> + <double key="NSValue">8</double> + <double key="NSMinValue">1</double> + <double key="NSMaxValue">25</double> + <double key="NSIncrement">1</double> + <bool key="NSAutorepeat">YES</bool> + </object> + </object> + <object class="NSTextField" id="38819005"> + <reference key="NSNextResponder" ref="1006"/> + <int key="NSvFlags">268</int> + <string key="NSFrame">{{143, 73}, {38, 17}}</string> + <reference key="NSSuperview" ref="1006"/> + <bool key="NSEnabled">YES</bool> + <object class="NSTextFieldCell" key="NSCell" id="922564724"> + <int key="NSCellFlags">347209281</int> + <int key="NSCellFlags2">272700480</int> + <string key="NSContents">Label</string> + <reference key="NSSupport" ref="872788741"/> + <reference key="NSControlView" ref="38819005"/> + <bool key="NSDrawsBackground">YES</bool> + <reference key="NSBackgroundColor" ref="586021249"/> + <reference key="NSTextColor" ref="671980879"/> + </object> + </object> + </object> + <string key="NSFrameSize">{415, 110}</string> + <reference key="NSSuperview"/> + <int key="NSViewLayerContentsRedrawPolicy">2</int> + </object> + <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string> + <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> + </object> + </object> + <object class="IBObjectContainer" key="IBDocument.Objects"> + <object class="NSMutableArray" key="connectionRecords"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">mpConfigureSheet</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="1005"/> + </object> + <int key="connectionID">32</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">revertToInitialValues:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="654791710"/> + </object> + <int key="connectionID">36</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">save:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="1013048762"/> + </object> + <int key="connectionID">37</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">revert:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="995501573"/> + </object> + <int key="connectionID">39</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">value: values.NumberOfKnots</string> + <reference key="source" ref="38819005"/> + <reference key="destination" ref="1001"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="38819005"/> + <reference key="NSDestination" ref="1001"/> + <string key="NSLabel">value: values.NumberOfKnots</string> + <string key="NSBinding">value</string> + <string key="NSKeyPath">values.NumberOfKnots</string> + <object class="NSDictionary" key="NSOptions"> + <string key="NS.key.0">NSAllowsEditingMultipleValuesSelection</string> + <boolean value="NO" key="NS.object.0"/> + </object> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">49</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">value: values.NumberOfKnots</string> + <reference key="source" ref="392143892"/> + <reference key="destination" ref="1001"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="392143892"/> + <reference key="NSDestination" ref="1001"/> + <string key="NSLabel">value: values.NumberOfKnots</string> + <string key="NSBinding">value</string> + <string key="NSKeyPath">values.NumberOfKnots</string> + <object class="NSDictionary" key="NSOptions"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>NSAllowsEditingMultipleValuesSelection</string> + <string>NSConditionallySetsEnabled</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <boolean value="NO"/> + <boolean value="NO"/> + </object> + </object> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">50</int> + </object> + </object> + <object class="IBMutableOrderedSet" key="objectRecords"> + <object class="NSArray" key="orderedObjects"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBObjectRecord"> + <int key="objectID">0</int> + <reference key="object" ref="0"/> + <reference key="children" ref="1000"/> + <nil key="parent"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">-2</int> + <reference key="object" ref="1001"/> + <reference key="parent" ref="0"/> + <string key="objectName">File's Owner</string> + </object> + <object class="IBObjectRecord"> + <int key="objectID">-1</int> + <reference key="object" ref="1003"/> + <reference key="parent" ref="0"/> + <string key="objectName">First Responder</string> + </object> + <object class="IBObjectRecord"> + <int key="objectID">-3</int> + <reference key="object" ref="1004"/> + <reference key="parent" ref="0"/> + <string key="objectName">Application</string> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1</int> + <reference key="object" ref="1005"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="1006"/> + </object> + <reference key="parent" ref="0"/> + <string key="objectName">ConfigurationSheet</string> + </object> + <object class="IBObjectRecord"> + <int key="objectID">2</int> + <reference key="object" ref="1006"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="415200325"/> + <reference ref="392143892"/> + <reference ref="38819005"/> + <reference ref="654791710"/> + <reference ref="995501573"/> + <reference ref="1013048762"/> + </object> + <reference key="parent" ref="1005"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">5</int> + <reference key="object" ref="415200325"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="759654285"/> + </object> + <reference key="parent" ref="1006"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">6</int> + <reference key="object" ref="759654285"/> + <reference key="parent" ref="415200325"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">7</int> + <reference key="object" ref="1013048762"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="328796931"/> + </object> + <reference key="parent" ref="1006"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">8</int> + <reference key="object" ref="328796931"/> + <reference key="parent" ref="1013048762"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">9</int> + <reference key="object" ref="995501573"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="770782373"/> + </object> + <reference key="parent" ref="1006"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">10</int> + <reference key="object" ref="770782373"/> + <reference key="parent" ref="995501573"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">11</int> + <reference key="object" ref="654791710"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="460152017"/> + </object> + <reference key="parent" ref="1006"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">12</int> + <reference key="object" ref="460152017"/> + <reference key="parent" ref="654791710"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">21</int> + <reference key="object" ref="392143892"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="154709998"/> + </object> + <reference key="parent" ref="1006"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">22</int> + <reference key="object" ref="154709998"/> + <reference key="parent" ref="392143892"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">23</int> + <reference key="object" ref="38819005"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="922564724"/> + </object> + <reference key="parent" ref="1006"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">24</int> + <reference key="object" ref="922564724"/> + <reference key="parent" ref="38819005"/> + </object> + </object> + </object> + <object class="NSMutableDictionary" key="flattenedProperties"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>1.IBEditorWindowLastContentRect</string> + <string>1.IBPluginDependency</string> + <string>1.IBWindowTemplateEditedContentRect</string> + <string>1.NSWindowTemplate.visibleAtLaunch</string> + <string>1.WindowOrigin</string> + <string>1.editorWindowContentRectSynchronizationRect</string> + <string>1.windowTemplate.hasMinSize</string> + <string>1.windowTemplate.minSize</string> + <string>10.IBPluginDependency</string> + <string>11.IBPluginDependency</string> + <string>12.IBPluginDependency</string> + <string>2.IBPluginDependency</string> + <string>21.IBPluginDependency</string> + <string>22.IBPluginDependency</string> + <string>23.IBPluginDependency</string> + <string>24.IBPluginDependency</string> + <string>5.IBPluginDependency</string> + <string>6.IBPluginDependency</string> + <string>7.IBPluginDependency</string> + <string>8.IBPluginDependency</string> + <string>9.IBPluginDependency</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>{{665, 702}, {415, 110}}</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>{{665, 702}, {415, 110}}</string> + <boolean value="NO"/> + <string>{196, 240}</string> + <string>{{202, 428}, {480, 270}}</string> + <boolean value="NO"/> + <string>{368, 331}</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + </object> + </object> + <object class="NSMutableDictionary" key="unlocalizedProperties"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference key="dict.sortedKeys" ref="0"/> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + </object> + <nil key="activeLocalization"/> + <object class="NSMutableDictionary" key="localizations"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference key="dict.sortedKeys" ref="0"/> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + </object> + <nil key="sourceID"/> + <int key="maxID">52</int> + </object> + <object class="IBClassDescriber" key="IBDocument.Classes"> + <object class="NSMutableArray" key="referencedPartialClassDescriptions"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBPartialClassDescription"> + <string key="className">XamhainUserDefaultsController</string> + <string key="superclassName">NSUserDefaultsController</string> + <object class="NSMutableDictionary" key="outlets"> + <string key="NS.key.0">mpConfigureSheet</string> + <string key="NS.object.0">NSWindow</string> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">screen saving/XamhainUserDefaultsController.h</string> + </object> + </object> + </object> + <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBPartialClassDescription"> + <string key="className">NSActionCell</string> + <string key="superclassName">NSCell</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSActionCell.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <string key="superclassName">NSResponder</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="87276028"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSApplication.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="696164746"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSApplicationScripting.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="1054327803"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSColorPanel.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSHelpManager.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSPageLayout.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSUserInterfaceItemSearching.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSButton</string> + <string key="superclassName">NSControl</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSButton.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSButtonCell</string> + <string key="superclassName">NSActionCell</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSButtonCell.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSCell</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSCell.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSControl</string> + <string key="superclassName">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="476499260"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSControl.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSController</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSFormatter</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSFormatter.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSMenu</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="871101704"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSMenu.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSAccessibility.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="87276028"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="696164746"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="1054327803"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="476499260"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSDictionaryController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSDragging.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSFontManager.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSFontPanel.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSKeyValueBinding.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="871101704"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSNibLoading.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSOutlineView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSPasteboard.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSSavePanel.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSTableView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSToolbarItem.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="701233559"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSArchiver.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSClassDescription.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSError.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSFileManager.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSKeyValueCoding.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSKeyValueObserving.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSKeyedArchiver.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSObject.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSObjectScripting.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSPortCoder.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSRunLoop.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSScriptClassDescription.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSScriptKeyValueCoding.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSScriptObjectSpecifiers.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSScriptWhoseTests.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSThread.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSURL.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSURLConnection.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSURLDownload.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSResponder</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSInterfaceStyle.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSResponder</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSResponder.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSStepper</string> + <string key="superclassName">NSControl</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSStepper.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSStepperCell</string> + <string key="superclassName">NSActionCell</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSStepperCell.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSTextField</string> + <string key="superclassName">NSControl</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSTextField.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSTextFieldCell</string> + <string key="superclassName">NSActionCell</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSTextFieldCell.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSUserDefaultsController</string> + <string key="superclassName">NSController</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSUserDefaultsController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSClipView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSMenuItem.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSRulerView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSView</string> + <string key="superclassName">NSResponder</string> + <reference key="sourceIdentifier" ref="701233559"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSWindow</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSDrawer.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSWindow</string> + <string key="superclassName">NSResponder</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSWindow.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSWindow</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSWindowScripting.h</string> + </object> + </object> + </object> + </object> + <int key="IBDocument.localizationMode">0</int> + <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string> + <integer value="1060" key="NS.object.0"/> + </object> + <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string> + <integer value="3000" key="NS.object.0"/> + </object> + <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool> + <string key="IBDocument.LastKnownRelativeProjectPath">XamhainII.xcodeproj</string> + <int key="IBDocument.defaultPropertyAccessControl">3</int> + </data> +</archive> diff --git a/XamhainII.xcodeproj/project.pbxproj b/XamhainII.xcodeproj/project.pbxproj index 7065574..9e73d03 100644 --- a/XamhainII.xcodeproj/project.pbxproj +++ b/XamhainII.xcodeproj/project.pbxproj @@ -1,727 +1,743 @@ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 45; objects = { /* Begin PBXAggregateTarget section */ 000D03D61089C45F003F010E /* XamhainII.dmg */ = { isa = PBXAggregateTarget; buildConfigurationList = 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */; buildPhases = ( 000D03D51089C45F003F010E /* ShellScript */, ); dependencies = ( 000D03DA1089C465003F010E /* PBXTargetDependency */, ); name = XamhainII.dmg; productName = XamhainII.dmg; }; /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 00151B9A109A2BAA00CFFD7F /* XamhainConfigureSheet.xib in Resources */ = {isa = PBXBuildFile; fileRef = 00151B99109A2BAA00CFFD7F /* XamhainConfigureSheet.xib */; }; 002438561098D6E100E8A351 /* KnotStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 002438541098D6E100E8A351 /* KnotStyle.cpp */; }; 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0032D325108A30770033FA87 /* OpenGL.framework */; }; 00790DBF10996796007ABF04 /* COPYING in Resources */ = {isa = PBXBuildFile; fileRef = 00790DBE10996796007ABF04 /* COPYING */; }; 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00791842108B081B00156D67 /* XamhainPreferences.mm */; }; 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007C5127108A29BE00ED3242 /* RandomColor.cpp */; }; 007ED8661090CD6800B01235 /* CircularKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8581090CD6800B01235 /* CircularKnot.cpp */; }; 007ED8681090CD6800B01235 /* ClosedKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED85A1090CD6800B01235 /* ClosedKnot.cpp */; }; 007ED86A1090CD6800B01235 /* HorizontalKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED85C1090CD6800B01235 /* HorizontalKnot.cpp */; }; 007ED86C1090CD6800B01235 /* RandomKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED85E1090CD6800B01235 /* RandomKnot.cpp */; }; 007ED86E1090CD6800B01235 /* RectangularKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8601090CD6800B01235 /* RectangularKnot.cpp */; }; 007ED8701090CD6800B01235 /* TiledKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8621090CD6800B01235 /* TiledKnot.cpp */; }; 007ED8721090CD6800B01235 /* VerticalKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8641090CD6800B01235 /* VerticalKnot.cpp */; }; 00926762109A0BF600B2EF52 /* defaults.plist in Resources */ = {isa = PBXBuildFile; fileRef = 00926761109A0BF600B2EF52 /* defaults.plist */; }; + 0096345E109B5B6700B26FC2 /* XamhainUserDefaultsController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0096345C109B5B6700B26FC2 /* XamhainUserDefaultsController.mm */; }; 009D8964108E251800A416CF /* Stroke.mm in Sources */ = {isa = PBXBuildFile; fileRef = 009D8962108E251800A416CF /* Stroke.mm */; }; 009D897C108E28C800A416CF /* StrokeSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 009D897A108E28C800A416CF /* StrokeSet.cpp */; }; 00D188B11094BA31004E4496 /* XamhainGLView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 001EA1D6109365FC00D05EFB /* XamhainGLView.mm */; }; 00D7B656108F8E9A00432E90 /* KnotSection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00D7B654108F8E9A00432E90 /* KnotSection.cpp */; }; 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */; }; 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */; }; 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */; }; 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */; }; 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */; }; 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */; }; 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */; }; 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */; }; 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */; }; 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */; }; 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */; }; 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */; }; 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */; }; 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */; }; 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */; }; 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */; }; 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */; }; 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */; }; 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */; }; 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */; }; 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */; }; 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */; }; 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */; }; 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */; }; 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */; }; 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */; }; 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */; }; 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */; }; 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */; }; 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */; }; 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */; }; 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */; }; 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */; }; 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */; }; 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */; }; 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */; }; 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */; }; 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */; }; 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */; }; 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */; }; 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */; }; 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */; }; 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */; }; 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */; }; 00DA7838107A73320094FCAB /* XamhainView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00DA7836107A73320094FCAB /* XamhainView.mm */; }; 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 000D03D91089C465003F010E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 089C1669FE841209C02AAC07 /* Project object */; proxyType = 1; remoteGlobalIDString = 8D255AC50486D3F9007BF209; remoteInfo = XamhainII; }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 000AE53A109B577E00DCDFD0 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; }; + 000AE53D109B57FC00DCDFD0 /* CREDITS */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CREDITS; sourceTree = "<group>"; }; + 00151B99109A2BAA00CFFD7F /* XamhainConfigureSheet.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = XamhainConfigureSheet.xib; sourceTree = "<group>"; }; 001EA1D5109365FC00D05EFB /* XamhainGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainGLView.h; path = "screen saving/XamhainGLView.h"; sourceTree = "<group>"; }; 001EA1D6109365FC00D05EFB /* XamhainGLView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainGLView.mm; path = "screen saving/XamhainGLView.mm"; sourceTree = "<group>"; }; 002438531098D6E100E8A351 /* KnotStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KnotStyle.h; path = "knot engine/KnotStyle.h"; sourceTree = "<group>"; }; 002438541098D6E100E8A351 /* KnotStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KnotStyle.cpp; path = "knot engine/KnotStyle.cpp"; sourceTree = "<group>"; }; 0032D325108A30770033FA87 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; }; 00790DBE10996796007ABF04 /* COPYING */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; path = COPYING; sourceTree = "<group>"; }; 00791842108B081B00156D67 /* XamhainPreferences.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainPreferences.mm; path = "screen saving/XamhainPreferences.mm"; sourceTree = "<group>"; }; 00791843108B081B00156D67 /* XamhainPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainPreferences.h; path = "screen saving/XamhainPreferences.h"; sourceTree = "<group>"; }; 007C5126108A29BE00ED3242 /* Position.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Position.h; path = utility/Position.h; sourceTree = "<group>"; }; 007C5127108A29BE00ED3242 /* RandomColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RandomColor.cpp; path = utility/RandomColor.cpp; sourceTree = "<group>"; }; 007C5128108A29BE00ED3242 /* RandomColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomColor.h; path = utility/RandomColor.h; sourceTree = "<group>"; }; 007C5129108A29BE00ED3242 /* RandomNumbers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomNumbers.h; path = utility/RandomNumbers.h; sourceTree = "<group>"; }; 007ED8581090CD6800B01235 /* CircularKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CircularKnot.cpp; path = "knot engine/CircularKnot.cpp"; sourceTree = "<group>"; }; 007ED8591090CD6800B01235 /* CircularKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CircularKnot.h; path = "knot engine/CircularKnot.h"; sourceTree = "<group>"; }; 007ED85A1090CD6800B01235 /* ClosedKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClosedKnot.cpp; path = "knot engine/ClosedKnot.cpp"; sourceTree = "<group>"; }; 007ED85B1090CD6800B01235 /* ClosedKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClosedKnot.h; path = "knot engine/ClosedKnot.h"; sourceTree = "<group>"; }; 007ED85C1090CD6800B01235 /* HorizontalKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HorizontalKnot.cpp; path = "knot engine/HorizontalKnot.cpp"; sourceTree = "<group>"; }; 007ED85D1090CD6800B01235 /* HorizontalKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HorizontalKnot.h; path = "knot engine/HorizontalKnot.h"; sourceTree = "<group>"; }; 007ED85E1090CD6800B01235 /* RandomKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RandomKnot.cpp; path = "knot engine/RandomKnot.cpp"; sourceTree = "<group>"; }; 007ED85F1090CD6800B01235 /* RandomKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomKnot.h; path = "knot engine/RandomKnot.h"; sourceTree = "<group>"; }; 007ED8601090CD6800B01235 /* RectangularKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RectangularKnot.cpp; path = "knot engine/RectangularKnot.cpp"; sourceTree = "<group>"; }; 007ED8611090CD6800B01235 /* RectangularKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RectangularKnot.h; path = "knot engine/RectangularKnot.h"; sourceTree = "<group>"; }; 007ED8621090CD6800B01235 /* TiledKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TiledKnot.cpp; path = "knot engine/TiledKnot.cpp"; sourceTree = "<group>"; }; 007ED8631090CD6800B01235 /* TiledKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiledKnot.h; path = "knot engine/TiledKnot.h"; sourceTree = "<group>"; }; 007ED8641090CD6800B01235 /* VerticalKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VerticalKnot.cpp; path = "knot engine/VerticalKnot.cpp"; sourceTree = "<group>"; }; 007ED8651090CD6800B01235 /* VerticalKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VerticalKnot.h; path = "knot engine/VerticalKnot.h"; sourceTree = "<group>"; }; 00926761109A0BF600B2EF52 /* defaults.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = defaults.plist; sourceTree = "<group>"; }; + 0096345B109B5B6700B26FC2 /* XamhainUserDefaultsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainUserDefaultsController.h; path = "screen saving/XamhainUserDefaultsController.h"; sourceTree = "<group>"; }; + 0096345C109B5B6700B26FC2 /* XamhainUserDefaultsController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainUserDefaultsController.mm; path = "screen saving/XamhainUserDefaultsController.mm"; sourceTree = "<group>"; }; 009D8962108E251800A416CF /* Stroke.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Stroke.mm; path = "knot engine/Stroke.mm"; sourceTree = "<group>"; }; 009D8963108E251800A416CF /* Stroke.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Stroke.h; path = "knot engine/Stroke.h"; sourceTree = "<group>"; }; 009D897A108E28C800A416CF /* StrokeSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StrokeSet.cpp; path = "knot engine/StrokeSet.cpp"; sourceTree = "<group>"; }; 009D897B108E28C800A416CF /* StrokeSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StrokeSet.h; path = "knot engine/StrokeSet.h"; sourceTree = "<group>"; }; 00D7B654108F8E9A00432E90 /* KnotSection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KnotSection.cpp; path = "knot engine/KnotSection.cpp"; sourceTree = "<group>"; }; 00D7B655108F8E9A00432E90 /* KnotSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KnotSection.h; path = "knot engine/KnotSection.h"; sourceTree = "<group>"; }; 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA7835107A73320094FCAB /* XamhainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainView.h; path = "screen saving/XamhainView.h"; sourceTree = "<group>"; }; 00DA7836107A73320094FCAB /* XamhainView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainView.mm; path = "screen saving/XamhainView.mm"; sourceTree = "<group>"; }; 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ScreenSaver.framework; path = /System/Library/Frameworks/ScreenSaver.framework; sourceTree = "<absolute>"; }; 089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; 089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; }; 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; }; 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XamhainII_Prefix.pch; sourceTree = "<group>"; }; 8D255AD20486D3F9007BF209 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; 8D255AD30486D3F9007BF209 /* XamhainII.saver */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XamhainII.saver; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 8D255ACD0486D3F9007BF209 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */, 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */, 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 007C5125108A299800ED3242 /* Utility */ = { isa = PBXGroup; children = ( 007C5126108A29BE00ED3242 /* Position.h */, 007C5127108A29BE00ED3242 /* RandomColor.cpp */, 007C5128108A29BE00ED3242 /* RandomColor.h */, 007C5129108A29BE00ED3242 /* RandomNumbers.h */, ); name = Utility; sourceTree = "<group>"; }; 009D8961108E24ED00A416CF /* Knot Engine */ = { isa = PBXGroup; children = ( 002438531098D6E100E8A351 /* KnotStyle.h */, 002438541098D6E100E8A351 /* KnotStyle.cpp */, 007ED8581090CD6800B01235 /* CircularKnot.cpp */, 007ED8591090CD6800B01235 /* CircularKnot.h */, 007ED85A1090CD6800B01235 /* ClosedKnot.cpp */, 007ED85B1090CD6800B01235 /* ClosedKnot.h */, 007ED85C1090CD6800B01235 /* HorizontalKnot.cpp */, 007ED85D1090CD6800B01235 /* HorizontalKnot.h */, 007ED85E1090CD6800B01235 /* RandomKnot.cpp */, 007ED85F1090CD6800B01235 /* RandomKnot.h */, 007ED8601090CD6800B01235 /* RectangularKnot.cpp */, 007ED8611090CD6800B01235 /* RectangularKnot.h */, 007ED8621090CD6800B01235 /* TiledKnot.cpp */, 007ED8631090CD6800B01235 /* TiledKnot.h */, 007ED8641090CD6800B01235 /* VerticalKnot.cpp */, 007ED8651090CD6800B01235 /* VerticalKnot.h */, 00D7B654108F8E9A00432E90 /* KnotSection.cpp */, 00D7B655108F8E9A00432E90 /* KnotSection.h */, 009D897A108E28C800A416CF /* StrokeSet.cpp */, 009D897B108E28C800A416CF /* StrokeSet.h */, 009D8962108E251800A416CF /* Stroke.mm */, 009D8963108E251800A416CF /* Stroke.h */, ); name = "Knot Engine"; sourceTree = "<group>"; }; 00DA77D5107A728C0094FCAB /* Strokes */ = { isa = PBXGroup; children = ( 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */, 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */, 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */, 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */, 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */, 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */, 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */, 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */, 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */, 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */, 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */, 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */, 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */, 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */, 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */, 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */, 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */, 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */, 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */, 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */, 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */, 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */, 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */, 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */, 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */, 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */, 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */, 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */, 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */, 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */, 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */, 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */, 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */, 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */, 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */, 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */, 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */, 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */, 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */, 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */, 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */, 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */, 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */, 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */, ); name = Strokes; path = strokes; sourceTree = "<group>"; }; 00DA7833107A72F00094FCAB /* Screen Saving */ = { isa = PBXGroup; children = ( 001EA1D5109365FC00D05EFB /* XamhainGLView.h */, 001EA1D6109365FC00D05EFB /* XamhainGLView.mm */, 00791842108B081B00156D67 /* XamhainPreferences.mm */, 00791843108B081B00156D67 /* XamhainPreferences.h */, 00DA7835107A73320094FCAB /* XamhainView.h */, 00DA7836107A73320094FCAB /* XamhainView.mm */, + 0096345B109B5B6700B26FC2 /* XamhainUserDefaultsController.h */, + 0096345C109B5B6700B26FC2 /* XamhainUserDefaultsController.mm */, ); name = "Screen Saving"; sourceTree = "<group>"; }; 089C166AFE841209C02AAC07 /* XamhainII */ = { isa = PBXGroup; children = ( 009D8961108E24ED00A416CF /* Knot Engine */, 00DA7833107A72F00094FCAB /* Screen Saving */, 007C5125108A299800ED3242 /* Utility */, 32DBCFA70370C4F300C91783 /* Other Sources */, 089C167CFE841241C02AAC07 /* Resources */, 089C1671FE841209C02AAC07 /* Frameworks and Libraries */, 19C28FB8FE9D52D311CA2CBB /* Products */, ); name = XamhainII; sourceTree = "<group>"; }; 089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = { isa = PBXGroup; children = ( 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */, 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */, ); name = "Frameworks and Libraries"; sourceTree = "<group>"; }; 089C167CFE841241C02AAC07 /* Resources */ = { isa = PBXGroup; children = ( + 000AE53D109B57FC00DCDFD0 /* CREDITS */, 00926761109A0BF600B2EF52 /* defaults.plist */, 00790DBE10996796007ABF04 /* COPYING */, 00DA77D5107A728C0094FCAB /* Strokes */, 8D255AD20486D3F9007BF209 /* Info.plist */, 089C167DFE841241C02AAC07 /* InfoPlist.strings */, + 00151B99109A2BAA00CFFD7F /* XamhainConfigureSheet.xib */, + 000AE53A109B577E00DCDFD0 /* README */, ); name = Resources; sourceTree = "<group>"; }; 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = { isa = PBXGroup; children = ( 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, 0032D325108A30770033FA87 /* OpenGL.framework */, 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */, ); name = "Linked Frameworks"; sourceTree = "<group>"; }; 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = { isa = PBXGroup; children = ( 089C1672FE841209C02AAC07 /* Foundation.framework */, 089C167FFE841241C02AAC07 /* AppKit.framework */, ); name = "Other Frameworks"; sourceTree = "<group>"; }; 19C28FB8FE9D52D311CA2CBB /* Products */ = { isa = PBXGroup; children = ( 8D255AD30486D3F9007BF209 /* XamhainII.saver */, ); name = Products; sourceTree = "<group>"; }; 32DBCFA70370C4F300C91783 /* Other Sources */ = { isa = PBXGroup; children = ( 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */, ); name = "Other Sources"; sourceTree = "<group>"; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ 8D255AC60486D3F9007BF209 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ 8D255AC50486D3F9007BF209 /* XamhainII */ = { isa = PBXNativeTarget; buildConfigurationList = EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */; buildPhases = ( 8D255AC60486D3F9007BF209 /* Headers */, 8D255AC90486D3F9007BF209 /* Resources */, 8D255ACB0486D3F9007BF209 /* Sources */, 8D255ACD0486D3F9007BF209 /* Frameworks */, 8D255AD00486D3F9007BF209 /* Rez */, ); buildRules = ( ); dependencies = ( ); name = XamhainII; productInstallPath = "$(HOME)/Library/Screen Savers"; productName = XamhainII; productReference = 8D255AD30486D3F9007BF209 /* XamhainII.saver */; productType = "com.apple.product-type.bundle"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 089C1669FE841209C02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */; compatibilityVersion = "Xcode 3.1"; hasScannedForEncodings = 1; mainGroup = 089C166AFE841209C02AAC07 /* XamhainII */; projectDirPath = ""; projectRoot = ""; targets = ( 8D255AC50486D3F9007BF209 /* XamhainII */, 000D03D61089C45F003F010E /* XamhainII.dmg */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ 8D255AC90486D3F9007BF209 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */, 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */, 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */, 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */, 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */, 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */, 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */, 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */, 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */, 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */, 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */, 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */, 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */, 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */, 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */, 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */, 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */, 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */, 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */, 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */, 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */, 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */, 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */, 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */, 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */, 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */, 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */, 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */, 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */, 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */, 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */, 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */, 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */, 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */, 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */, 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */, 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */, 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */, 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */, 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */, 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */, 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */, 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */, 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */, 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */, 00790DBF10996796007ABF04 /* COPYING in Resources */, 00926762109A0BF600B2EF52 /* defaults.plist in Resources */, + 00151B9A109A2BAA00CFFD7F /* XamhainConfigureSheet.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXRezBuildPhase section */ 8D255AD00486D3F9007BF209 /* Rez */ = { isa = PBXRezBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXRezBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ 000D03D51089C45F003F010E /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.saver", "$(SRCROOT)/COPYING", + "$(SRCROOT)/CREDITS", + "$(SRCROOT)/README", ); outputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.dmg", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "# Thanks to Rob Mayoff for explaining how to do this.\n# See http://qwan.org/2007/05/22/using-xcode-to-build-a-disk-image-and-upload-a-web-site/\n\nset -ex\n\n[ \"$ACTION\" = build ] || exit 0\n[ \"$BUILD_VARIANTS\" = \"normal\" ] || exit 0\n\ndir=\"$TEMP_FILES_DIR/disk\"\ndmg=\"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.dmg\"\n\nrm -rf \"$dir\"\nmkdir \"$dir\"\ncp -R \"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.saver\" \"$dir\"\ncp -R \"$SRCROOT/COPYING\" \"$dir\"\nrm -f \"$dmg\"\nhdiutil create -srcfolder \"$dir\" -volname \"$PROJECT_NAME\" \"$dmg\"\nhdiutil internet-enable -yes \"$dmg\"\nrm -rf \"$dir\"\n"; + shellScript = "# Thanks to Rob Mayoff for explaining how to do this.\n# See http://qwan.org/2007/05/22/using-xcode-to-build-a-disk-image-and-upload-a-web-site/\n\nset -ex\n\n[ \"$ACTION\" = build ] || exit 0\n[ \"$BUILD_VARIANTS\" = \"normal\" ] || exit 0\n\ndir=\"$TEMP_FILES_DIR/disk\"\ndmg=\"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.dmg\"\n\nrm -rf \"$dir\"\nmkdir \"$dir\"\ncp -R \"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.saver\" \"$dir\"\ncp -R \"$SRCROOT/COPYING\" \"$dir\"\ncp -R \"$SRCROOT/CREDITS\" \"$dir\"\ncp -R \"$SRCROOT/README\" \"$dir\"\nrm -f \"$dmg\"\nhdiutil create -srcfolder \"$dir\" -volname \"$PROJECT_NAME\" \"$dmg\"\nhdiutil internet-enable -yes \"$dmg\"\nrm -rf \"$dir\"\n"; }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 8D255ACB0486D3F9007BF209 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 00DA7838107A73320094FCAB /* XamhainView.mm in Sources */, 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */, 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */, 009D8964108E251800A416CF /* Stroke.mm in Sources */, 009D897C108E28C800A416CF /* StrokeSet.cpp in Sources */, 00D7B656108F8E9A00432E90 /* KnotSection.cpp in Sources */, 007ED8661090CD6800B01235 /* CircularKnot.cpp in Sources */, 007ED8681090CD6800B01235 /* ClosedKnot.cpp in Sources */, 007ED86A1090CD6800B01235 /* HorizontalKnot.cpp in Sources */, 007ED86C1090CD6800B01235 /* RandomKnot.cpp in Sources */, 007ED86E1090CD6800B01235 /* RectangularKnot.cpp in Sources */, 007ED8701090CD6800B01235 /* TiledKnot.cpp in Sources */, 007ED8721090CD6800B01235 /* VerticalKnot.cpp in Sources */, 00D188B11094BA31004E4496 /* XamhainGLView.mm in Sources */, 002438561098D6E100E8A351 /* KnotStyle.cpp in Sources */, + 0096345E109B5B6700B26FC2 /* XamhainUserDefaultsController.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 000D03DA1089C465003F010E /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 8D255AC50486D3F9007BF209 /* XamhainII */; targetProxy = 000D03D91089C465003F010E /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ 089C167DFE841241C02AAC07 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 089C167EFE841241C02AAC07 /* English */, ); name = InfoPlist.strings; sourceTree = "<group>"; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 000D03D71089C45F003F010E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; PRODUCT_NAME = XamhainII.dmg; }; name = Debug; }; 000D03D81089C45F003F010E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = XamhainII.dmg; ZERO_LINK = NO; }; name = Release; }; EF7AD72E08BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_STRICT_ALIASING = NO; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = NO; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; ZERO_LINK = YES; }; name = Debug; }; EF7AD72F08BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; }; name = Release; }; EF7AD73208BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = NO; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Debug; }; EF7AD73308BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */ = { isa = XCConfigurationList; buildConfigurations = ( 000D03D71089C45F003F010E /* Debug */, 000D03D81089C45F003F010E /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD72E08BB986600CE4634 /* Debug */, EF7AD72F08BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD73208BB986600CE4634 /* Debug */, EF7AD73308BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 089C1669FE841209C02AAC07 /* Project object */; } diff --git a/screen saving/XamhainPreferences.mm b/screen saving/XamhainPreferences.mm index 45c2f47..58e11a5 100644 --- a/screen saving/XamhainPreferences.mm +++ b/screen saving/XamhainPreferences.mm @@ -1,249 +1,211 @@ // XamhainII screen saver preferences. // // Copyright © 2000-2009, Jens Kilian. // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "XamhainPreferences.h" #include <algorithm> using namespace ::std; -#import <ScreenSaver/ScreenSaverDefaults.h> +#import "XamhainUserDefaultsController.h" -@interface XamhainScreenSaverDefaults -{ - // empty -} - -+ (NSUserDefaults *) sharedDefaults; - -@end - -namespace -{ - NSUserDefaults *gInstance = nil; -} - -@implementation XamhainScreenSaverDefaults - -+ (void) initialize -{ - gInstance = [ScreenSaverDefaults defaultsForModuleWithName: @"de.earrame.XamhainII"]; - - // Load initial defaults and register them. - NSBundle *bundle = [NSBundle bundleWithIdentifier: @"de.earrame.XamhainII"]; - NSString *path = [bundle pathForResource: @"defaults" ofType: @"plist"]; - assert(path != nil); - - NSDictionary *factoryDefaults = [NSDictionary dictionaryWithContentsOfFile: path]; - assert(factoryDefaults != nil); - - [gInstance registerDefaults: factoryDefaults]; -} - -+ (NSUserDefaults *) sharedDefaults -{ - return gInstance; -} - -@end - // Construct a preferences object - which is actually just a wrapper. XamhainPreferences::XamhainPreferences(void) -: mDefaults([XamhainScreenSaverDefaults sharedDefaults]) +: mDefaults([[XamhainUserDefaultsController sharedUserDefaultsController] defaults]) { // empty } // Implementation of inquiry functions. int XamhainPreferences::numberOfKnots(void) const { return max((NSInteger)1, [mDefaults integerForKey: @"NumberOfKnots"]); } bool XamhainPreferences::technicolor(void) const { return [mDefaults boolForKey: @"Technicolor"]; } int XamhainPreferences::ticksPerSecond(void) const { return max((NSInteger)1, [mDefaults integerForKey: @"TicksPerSecond"]); } GLfloat XamhainPreferences::minSize(void) const { return min([mDefaults floatForKey: @"MinSize"], [mDefaults floatForKey: @"MaxSize"]); } GLfloat XamhainPreferences::maxSize(void) const { return max([mDefaults floatForKey: @"MinSize"], [mDefaults floatForKey: @"MaxSize"]); } GLfloat XamhainPreferences::minSpeed(void) const { return min([mDefaults floatForKey: @"MinSpeed"], [mDefaults floatForKey: @"MaxSpeed"]); } GLfloat XamhainPreferences::maxSpeed(void) const { return max([mDefaults floatForKey: @"MinSpeed"], [mDefaults floatForKey: @"MaxSpeed"]); } GLfloat XamhainPreferences::minSpin(void) const { return min([mDefaults floatForKey: @"MinSpin"], [mDefaults floatForKey: @"MaxSpin"]); } GLfloat XamhainPreferences::maxSpin(void) const { return max([mDefaults floatForKey: @"MinSpin"], [mDefaults floatForKey: @"MaxSpin"]); } GLfloat XamhainPreferences::skewProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"SkewProbability"]), 1.0f); } GLfloat XamhainPreferences::spinProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"SpinProbability"]), 1.0f); } int XamhainPreferences::knotSubdivisions(void) const { return max((NSInteger)1, [mDefaults integerForKey: @"KnotSubdivisions"]); } GLfloat XamhainPreferences::horizontalKnotProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"HorizontalKnotProbability"] / totalKnotProbability()), 1.0f); } GLfloat XamhainPreferences::verticalKnotProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"VerticalKnotProbability"] / totalKnotProbability()), 1.0f); } GLfloat XamhainPreferences::closedKnotProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"ClosedKnotProbability"] / totalKnotProbability()), 1.0f); } GLfloat XamhainPreferences::circularKnotProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"CircularKnotProbability"] / totalKnotProbability()), 1.0f); } GLfloat XamhainPreferences::sectionProbability1(void) const { return min(max(0.0f, [mDefaults floatForKey: @"SectionProbability1"]), 1.0f); } GLfloat XamhainPreferences::sectionProbability2(void) const { return min(max(0.0f, [mDefaults floatForKey: @"SectionProbability2"]), 1.0f); } GLfloat XamhainPreferences::cornerProbability1(void) const { return min(max(0.0f, [mDefaults floatForKey: @"CornerProbability1"]), 1.0f); } GLfloat XamhainPreferences::cornerProbability2(void) const { return min(max(0.0f, [mDefaults floatForKey: @"CornerProbability2"]), 1.0f); } GLfloat XamhainPreferences::broadKnotProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"BroadKnotProbability"]), 1.0f); } GLfloat XamhainPreferences::hollowKnotProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"HollowKnotProbability"]), 1.0f); } GLfloat XamhainPreferences::symmetricKnotProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"SymmetricKnotProbability"]), 1.0f); } GLfloat XamhainPreferences::horizontalMirrorProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"HorizontalMirrorProbability"]), 1.0f); } GLfloat XamhainPreferences::verticalMirrorProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"VerticalMirrorProbability"]), 1.0f); } GLfloat XamhainPreferences::totalKnotProbability(void) const { return [mDefaults floatForKey: @"HorizontalKnotProbability"] + [mDefaults floatForKey: @"VerticalKnotProbability"] + [mDefaults floatForKey: @"ClosedKnotProbability"] + [mDefaults floatForKey: @"CircularKnotProbability"]; } diff --git a/screen saving/XamhainUserDefaultsController.h b/screen saving/XamhainUserDefaultsController.h new file mode 100644 index 0000000..161b1c9 --- /dev/null +++ b/screen saving/XamhainUserDefaultsController.h @@ -0,0 +1,31 @@ +// XamhainII user defaults controller. +// +// Copyright © 2009, Jens Kilian. +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + + +@interface XamhainUserDefaultsController : NSUserDefaultsController +{ + NSNib *mpNib; + IBOutlet NSWindow *mpConfigureSheet; +} + ++ (id) sharedUserDefaultsController; + +- (NSWindow *) configureSheet; + +@end diff --git a/screen saving/XamhainUserDefaultsController.mm b/screen saving/XamhainUserDefaultsController.mm new file mode 100644 index 0000000..34ec3d2 --- /dev/null +++ b/screen saving/XamhainUserDefaultsController.mm @@ -0,0 +1,108 @@ +// XamhainII user defaults controller. +// +// Copyright © 2009, Jens Kilian. +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +// The only reason for defining our own version of the standard +// NSUserDefaultsController class is that we can't use an instance +// of the original one which is allocated in our nib file. It appears +// that Interface Builder only supports the standard (shared) user +// defaults, and not the weird individual ones that the screen saver +// framework deals out. So we need to create our own controller and +// pass it to the nib as the File's Owner. +// +// Alternatively we could have set up our bindings by hand. Meh. +// +// See also http://jwz.livejournal.com/756713.html?thread=14516713#t14516713 + +#import "XamhainUserDefaultsController.h" + +#import <ScreenSaver/ScreenSaverDefaults.h> + + +namespace +{ + const NSString *kBundleName = @"de.earrame.XamhainII"; + + XamhainUserDefaultsController *gpInstance = nil; +} + +@implementation XamhainUserDefaultsController + ++ (void) initialize +{ + // THIS is causing all the trouble. + NSUserDefaults *defaults = [ScreenSaverDefaults defaultsForModuleWithName: kBundleName]; + + // Load initial defaults and register them. + NSBundle *bundle = [NSBundle bundleWithIdentifier: kBundleName]; + NSString *path = [bundle pathForResource: @"defaults" ofType: @"plist"]; + assert(path != nil); + + NSDictionary *factoryDefaults = [NSDictionary dictionaryWithContentsOfFile: path]; + assert(factoryDefaults != nil); + + [defaults registerDefaults: factoryDefaults]; + + // Create the shared user defaults controller. + gpInstance = [[XamhainUserDefaultsController alloc] + initWithDefaults: defaults + initialValues: factoryDefaults]; + [gpInstance setAppliesImmediately: NO]; + + // Load our nib file. + gpInstance->mpNib = [[NSNib alloc] initWithNibNamed: @"XamhainConfigureSheet" + bundle: bundle]; +} + ++ (id) sharedUserDefaultsController +{ + return gpInstance; +} + +- (NSWindow *) configureSheet +{ + if (!mpConfigureSheet) { + if (![mpNib instantiateNibWithOwner: self topLevelObjects: nil]) { + NSLog(@"Could not load configuration sheet."); + } + } + + return mpConfigureSheet; +} + +- (IBAction) save: (id)sender +{ + [super save: sender]; + + if (mpConfigureSheet) { + [NSApp endSheet: mpConfigureSheet returnCode: NSOKButton]; + [mpConfigureSheet close]; + } +} + +- (IBAction) revert: (id)sender +{ + [super revert: sender]; + + if (mpConfigureSheet) { + [NSApp endSheet: mpConfigureSheet returnCode: NSCancelButton]; + [mpConfigureSheet close]; + } +} + +@end diff --git a/screen saving/XamhainView.mm b/screen saving/XamhainView.mm index c366db7..17eec14 100644 --- a/screen saving/XamhainView.mm +++ b/screen saving/XamhainView.mm @@ -1,78 +1,80 @@ // XamhainII screen saver view. // // Copyright © 2009, Jens Kilian. // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #import "XamhainView.h" #import "XamhainGLView.h" #include "XamhainPreferences.h" +#import "XamhainUserDefaultsController.h" @implementation XamhainView - (id) initWithFrame: (NSRect)frame isPreview: (BOOL)isPreview { self = [super initWithFrame: frame isPreview: isPreview]; if (self) { XamhainPreferences prefs; [self setAnimationTimeInterval: 1.0/prefs.ticksPerSecond()]; const NSRect childFrame = NSOffsetRect(frame, -frame.origin.x, -frame.origin.y); mpGLView = [[XamhainGLView alloc] initWithFrame: childFrame]; if (mpGLView) { [self addSubview: mpGLView]; } else { NSLog(@"Failed to create XamhainGLView."); } } else { NSLog(@"Failed to create XamhainView"); } return self; } - (void) startAnimation { [super startAnimation]; [mpGLView startAnimation]; } - (void) stopAnimation { [super stopAnimation]; [mpGLView stopAnimation]; } - (void) animateOneFrame { [mpGLView setNeedsDisplay: YES]; } - (BOOL) hasConfigureSheet { - return NO; + return YES; } - (NSWindow *) configureSheet { - return nil; + return [[XamhainUserDefaultsController sharedUserDefaultsController] + configureSheet]; } @end
jjk/XamhainII
e6e60736425dc26595c504eae1d2761c8d903b89
Add missing README file and credits.
diff --git a/CREDITS b/CREDITS new file mode 100644 index 0000000..4a5ade9 --- /dev/null +++ b/CREDITS @@ -0,0 +1,13 @@ +Traditionally, Celtic knotwork is drawn on a diagonal grid overlaid with +straight lines and circles. Xamhain uses a much simpler method devised +by Andy Sloss, which divides the knot into sections at every other grid point. + +If you want to know the details, you can find them in + + Andy Sloss + How to Draw Celtic Knotwork: A Practical Handbook + Cassell Illustrated, 2002 (New edition) + ISBN 0304361259 + +You may also be interested in the website http://www.proscribe.co.uk/, +which features more work by Andy Sloss. diff --git a/README b/README new file mode 100644 index 0000000..5774637 --- /dev/null +++ b/README @@ -0,0 +1,12 @@ +On a night in the lonesome October… + +In 1997 I wrote the first version of this screensaver for the BeOS. +It was called “Samhain” because of the Celtic theme, and because it was +released shortly before Halloween. + +In the twelve years since then, I ported it to X11 (renaming it “Xamhain”) +and later to OpenGL (involving a massive rewrite, and thus another renaming). +These versions were never released, mostly because of laziness. + +Halloween is near again, and to celebrate the acquisition of my first Mac, +I’m porting it yet another time. Enjoy.
jjk/XamhainII
73c3cf7e7f2fa3e5ce3144ec564d4258c71588e0
Fix texture seams.
diff --git a/knot engine/Stroke.mm b/knot engine/Stroke.mm index c95480b..8142b64 100644 --- a/knot engine/Stroke.mm +++ b/knot engine/Stroke.mm @@ -1,256 +1,256 @@ // A single primitive stroke, represented by a GL texture. // // Copyright © 2003-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "Stroke.h" #include <algorithm> #include <cassert> #include <cmath> using namespace ::std; #include <OpenGL/gl.h> #include <OpenGL/glu.h> #include "Position.h" #include "XamhainPreferences.h" namespace { // Nominal size of a texture. const GLsizei kTextureSize = 128; // Internal texture format. const GLenum kTextureFormat = GL_ALPHA4; // Cache for values of trigonometric functions. class TrigFunctionCache { public: TrigFunctionCache(const GLfloat arcLength) : mSubdivisions(XamhainPreferences().knotSubdivisions()), mpSin(new GLfloat[mSubdivisions]), mpCos(new GLfloat[mSubdivisions]) { for (int i = 0; i < mSubdivisions; ++i) { const GLfloat arg = (i+1) * arcLength * 0.5 / mSubdivisions; mpSin[i] = ::sin(arg); mpCos[i] = ::cos(arg); } } ~TrigFunctionCache(void) { delete [] mpSin; delete [] mpCos; mpSin = mpCos = 0; } GLfloat sin(const int index) const { if (index) { return (index < 0) ? -mpSin[-index-1] : mpSin[index-1]; } return 0.0; } GLfloat cos(const int index) const { if (index) { return (index < 0) ? mpCos[-index-1] : mpCos[index-1]; } return 1.0; } private: TrigFunctionCache(const TrigFunctionCache &); TrigFunctionCache &operator =(const TrigFunctionCache &); // Data members. const int mSubdivisions; GLfloat *mpSin; GLfloat *mpCos; }; // Load an image resource and convert it to a bitmap. NSBitmapImageRep * loadImage(const char *const name) { // Load the (PDF) image. NSBundle *bundle = [NSBundle bundleWithIdentifier: @"de.earrame.XamhainII"]; NSString *file =[NSString stringWithCString: name encoding: NSASCIIStringEncoding]; NSString *path = [bundle pathForResource: file ofType: @"pdf"]; assert(path != nil); NSImage *image = [[NSImage alloc] initWithContentsOfFile: path]; assert(image != nil); // Create a bitmap of the desired size. NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL pixelsWide: kTextureSize pixelsHigh: kTextureSize bitsPerSample: 8 samplesPerPixel: 4 hasAlpha: YES isPlanar: NO colorSpaceName: NSDeviceRGBColorSpace bytesPerRow: 0 bitsPerPixel: 0]; // Draw the image at the desired size. [NSGraphicsContext saveGraphicsState]; [NSGraphicsContext setCurrentContext: [NSGraphicsContext graphicsContextWithBitmapImageRep: bitmap]]; const NSSize size = [image size]; const NSRect srcRect = NSMakeRect(0.0, 0.0, size.width, size.height); const NSRect dstRect = NSMakeRect(0.0, 0.0, kTextureSize, kTextureSize); [image drawInRect: dstRect fromRect: srcRect operation: NSCompositeCopy fraction: 1.0]; [[NSGraphicsContext currentContext] flushGraphics]; [NSGraphicsContext restoreGraphicsState]; return bitmap; } } Stroke::Stroke(const char *const name) : mSubdivisions(XamhainPreferences().knotSubdivisions()) { // Load image resource. NSBitmapImageRep *bitmap = loadImage(name); // Create a texture object for the stroke. glGenTextures(1, &mTexture); glBindTexture(GL_TEXTURE_2D, mTexture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glPixelStorei(GL_UNPACK_ROW_LENGTH, [bitmap pixelsWide]); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gluBuild2DMipmaps(GL_TEXTURE_2D, kTextureFormat, kTextureSize, kTextureSize, GL_RGBA, GL_UNSIGNED_BYTE, [bitmap bitmapData]); } Stroke::~Stroke(void) { glDeleteTextures(1, &mTexture); mTexture = 0; } void Stroke::draw(Position where, GLfloat size, GLfloat radius, GLfloat angle, const GLint transform[4]) const { if (radius <= 0.0 || angle <= 0.0) { size *= 0.5f; const GLfloat t0 = size * transform[0]; const GLfloat t1 = size * transform[1]; const GLfloat t2 = size * transform[2]; const GLfloat t3 = size * transform[3]; const GLfloat r = 1.0f; const GLfloat b = -1.0f; glBindTexture(GL_TEXTURE_2D, mTexture); glBegin(GL_POLYGON); { glTexCoord2f(0.0f, 1.0f); glVertex2f(where.x - t0 + b * t1, where.y - t2 + b * t3); glTexCoord2f(1.0f, 1.0f); glVertex2f(where.x + r * t0 + b * t1, where.y + r * t2 + b * t3); glTexCoord2f(1.0f, 0.0f); glVertex2f(where.x + r * t0 + t1, where.y + r * t2 + t3); glTexCoord2f(0.0f, 0.0f); glVertex2f(where.x - t0 + t1, where.y - t2 + t3); } glEnd(); } else { size = size * 0.5 / mSubdivisions; const GLint r = mSubdivisions; const GLint b = -mSubdivisions; const TrigFunctionCache cache(angle); glBindTexture(GL_TEXTURE_2D, mTexture); glBegin(GL_QUADS); { for (GLint x = -mSubdivisions; x < r; ++x) { for (GLint y = b; y < mSubdivisions; ++y) { const GLint x0 = x * transform[0] + y * transform[1]; const GLint y0 = x * transform[2] + y * transform[3]; const GLint x1 = (x+1) * transform[0] + y * transform[1]; const GLint y1 = (x+1) * transform[2] + y * transform[3]; const GLint x2 = (x+1) * transform[0] + (y+1) * transform[1]; const GLint y2 = (x+1) * transform[2] + (y+1) * transform[3]; const GLint x3 = x * transform[0] + (y+1) * transform[1]; const GLint y3 = x * transform[2] + (y+1) * transform[3]; const GLfloat r0 = size * x0 + radius; const GLfloat r1 = size * x1 + radius; const GLfloat r2 = size * x2 + radius; const GLfloat r3 = size * x3 + radius; glTexCoord2f( (GLfloat)(x+mSubdivisions) / (GLfloat)(r+mSubdivisions), (GLfloat)(mSubdivisions-y) / (GLfloat)(mSubdivisions-b)); glVertex2f(where.x + r0 * cache.cos(y0) - radius, where.y + r0 * cache.sin(y0)); glTexCoord2f( (GLfloat)(x+1+mSubdivisions) / (GLfloat)(r+mSubdivisions), (GLfloat)(mSubdivisions-y) / (GLfloat)(mSubdivisions-b)); glVertex2f(where.x + r1 * cache.cos(y1) - radius, where.y + r1 * cache.sin(y1)); glTexCoord2f( (GLfloat)(x+1+mSubdivisions) / (GLfloat)(r+mSubdivisions), (GLfloat)(mSubdivisions-y-1) / (GLfloat)(mSubdivisions-b)); glVertex2f(where.x + r2 * cache.cos(y2) - radius, where.y + r2 * cache.sin(y2)); glTexCoord2f( (GLfloat)(x+mSubdivisions) / (GLfloat)(r+mSubdivisions), (GLfloat)(mSubdivisions-y-1) / (GLfloat)(mSubdivisions-b)); glVertex2f(where.x + r3 * cache.cos(y3) - radius, where.y + r3 * cache.sin(y3)); } } } glEnd(); } }
jjk/XamhainII
a7f56beae526ef72453383678a57bdff97f597d1
Load initial defaults from a property list file.
diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. diff --git a/English.lproj/InfoPlist.strings b/English.lproj/InfoPlist.strings index d247954..ea72d08 100644 Binary files a/English.lproj/InfoPlist.strings and b/English.lproj/InfoPlist.strings differ diff --git a/XamhainII.xcodeproj/project.pbxproj b/XamhainII.xcodeproj/project.pbxproj index 8f75bf7..7065574 100644 --- a/XamhainII.xcodeproj/project.pbxproj +++ b/XamhainII.xcodeproj/project.pbxproj @@ -1,718 +1,727 @@ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 45; objects = { /* Begin PBXAggregateTarget section */ 000D03D61089C45F003F010E /* XamhainII.dmg */ = { isa = PBXAggregateTarget; buildConfigurationList = 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */; buildPhases = ( 000D03D51089C45F003F010E /* ShellScript */, ); dependencies = ( 000D03DA1089C465003F010E /* PBXTargetDependency */, ); name = XamhainII.dmg; productName = XamhainII.dmg; }; /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ 002438561098D6E100E8A351 /* KnotStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 002438541098D6E100E8A351 /* KnotStyle.cpp */; }; 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0032D325108A30770033FA87 /* OpenGL.framework */; }; + 00790DBF10996796007ABF04 /* COPYING in Resources */ = {isa = PBXBuildFile; fileRef = 00790DBE10996796007ABF04 /* COPYING */; }; 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00791842108B081B00156D67 /* XamhainPreferences.mm */; }; 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007C5127108A29BE00ED3242 /* RandomColor.cpp */; }; 007ED8661090CD6800B01235 /* CircularKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8581090CD6800B01235 /* CircularKnot.cpp */; }; 007ED8681090CD6800B01235 /* ClosedKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED85A1090CD6800B01235 /* ClosedKnot.cpp */; }; 007ED86A1090CD6800B01235 /* HorizontalKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED85C1090CD6800B01235 /* HorizontalKnot.cpp */; }; 007ED86C1090CD6800B01235 /* RandomKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED85E1090CD6800B01235 /* RandomKnot.cpp */; }; 007ED86E1090CD6800B01235 /* RectangularKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8601090CD6800B01235 /* RectangularKnot.cpp */; }; 007ED8701090CD6800B01235 /* TiledKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8621090CD6800B01235 /* TiledKnot.cpp */; }; 007ED8721090CD6800B01235 /* VerticalKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8641090CD6800B01235 /* VerticalKnot.cpp */; }; + 00926762109A0BF600B2EF52 /* defaults.plist in Resources */ = {isa = PBXBuildFile; fileRef = 00926761109A0BF600B2EF52 /* defaults.plist */; }; 009D8964108E251800A416CF /* Stroke.mm in Sources */ = {isa = PBXBuildFile; fileRef = 009D8962108E251800A416CF /* Stroke.mm */; }; 009D897C108E28C800A416CF /* StrokeSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 009D897A108E28C800A416CF /* StrokeSet.cpp */; }; 00D188B11094BA31004E4496 /* XamhainGLView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 001EA1D6109365FC00D05EFB /* XamhainGLView.mm */; }; 00D7B656108F8E9A00432E90 /* KnotSection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00D7B654108F8E9A00432E90 /* KnotSection.cpp */; }; 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */; }; 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */; }; 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */; }; 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */; }; 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */; }; 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */; }; 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */; }; 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */; }; 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */; }; 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */; }; 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */; }; 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */; }; 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */; }; 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */; }; 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */; }; 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */; }; 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */; }; 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */; }; 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */; }; 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */; }; 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */; }; 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */; }; 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */; }; 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */; }; 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */; }; 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */; }; 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */; }; 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */; }; 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */; }; 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */; }; 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */; }; 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */; }; 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */; }; 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */; }; 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */; }; 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */; }; 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */; }; 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */; }; 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */; }; 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */; }; 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */; }; 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */; }; 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */; }; 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */; }; 00DA7838107A73320094FCAB /* XamhainView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00DA7836107A73320094FCAB /* XamhainView.mm */; }; 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 000D03D91089C465003F010E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 089C1669FE841209C02AAC07 /* Project object */; proxyType = 1; remoteGlobalIDString = 8D255AC50486D3F9007BF209; remoteInfo = XamhainII; }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ 001EA1D5109365FC00D05EFB /* XamhainGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainGLView.h; path = "screen saving/XamhainGLView.h"; sourceTree = "<group>"; }; 001EA1D6109365FC00D05EFB /* XamhainGLView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainGLView.mm; path = "screen saving/XamhainGLView.mm"; sourceTree = "<group>"; }; 002438531098D6E100E8A351 /* KnotStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KnotStyle.h; path = "knot engine/KnotStyle.h"; sourceTree = "<group>"; }; 002438541098D6E100E8A351 /* KnotStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KnotStyle.cpp; path = "knot engine/KnotStyle.cpp"; sourceTree = "<group>"; }; 0032D325108A30770033FA87 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; }; + 00790DBE10996796007ABF04 /* COPYING */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; path = COPYING; sourceTree = "<group>"; }; 00791842108B081B00156D67 /* XamhainPreferences.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainPreferences.mm; path = "screen saving/XamhainPreferences.mm"; sourceTree = "<group>"; }; 00791843108B081B00156D67 /* XamhainPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainPreferences.h; path = "screen saving/XamhainPreferences.h"; sourceTree = "<group>"; }; 007C5126108A29BE00ED3242 /* Position.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Position.h; path = utility/Position.h; sourceTree = "<group>"; }; 007C5127108A29BE00ED3242 /* RandomColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RandomColor.cpp; path = utility/RandomColor.cpp; sourceTree = "<group>"; }; 007C5128108A29BE00ED3242 /* RandomColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomColor.h; path = utility/RandomColor.h; sourceTree = "<group>"; }; 007C5129108A29BE00ED3242 /* RandomNumbers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomNumbers.h; path = utility/RandomNumbers.h; sourceTree = "<group>"; }; 007ED8581090CD6800B01235 /* CircularKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CircularKnot.cpp; path = "knot engine/CircularKnot.cpp"; sourceTree = "<group>"; }; 007ED8591090CD6800B01235 /* CircularKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CircularKnot.h; path = "knot engine/CircularKnot.h"; sourceTree = "<group>"; }; 007ED85A1090CD6800B01235 /* ClosedKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClosedKnot.cpp; path = "knot engine/ClosedKnot.cpp"; sourceTree = "<group>"; }; 007ED85B1090CD6800B01235 /* ClosedKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClosedKnot.h; path = "knot engine/ClosedKnot.h"; sourceTree = "<group>"; }; 007ED85C1090CD6800B01235 /* HorizontalKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HorizontalKnot.cpp; path = "knot engine/HorizontalKnot.cpp"; sourceTree = "<group>"; }; 007ED85D1090CD6800B01235 /* HorizontalKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HorizontalKnot.h; path = "knot engine/HorizontalKnot.h"; sourceTree = "<group>"; }; 007ED85E1090CD6800B01235 /* RandomKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RandomKnot.cpp; path = "knot engine/RandomKnot.cpp"; sourceTree = "<group>"; }; 007ED85F1090CD6800B01235 /* RandomKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomKnot.h; path = "knot engine/RandomKnot.h"; sourceTree = "<group>"; }; 007ED8601090CD6800B01235 /* RectangularKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RectangularKnot.cpp; path = "knot engine/RectangularKnot.cpp"; sourceTree = "<group>"; }; 007ED8611090CD6800B01235 /* RectangularKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RectangularKnot.h; path = "knot engine/RectangularKnot.h"; sourceTree = "<group>"; }; 007ED8621090CD6800B01235 /* TiledKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TiledKnot.cpp; path = "knot engine/TiledKnot.cpp"; sourceTree = "<group>"; }; 007ED8631090CD6800B01235 /* TiledKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiledKnot.h; path = "knot engine/TiledKnot.h"; sourceTree = "<group>"; }; 007ED8641090CD6800B01235 /* VerticalKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VerticalKnot.cpp; path = "knot engine/VerticalKnot.cpp"; sourceTree = "<group>"; }; 007ED8651090CD6800B01235 /* VerticalKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VerticalKnot.h; path = "knot engine/VerticalKnot.h"; sourceTree = "<group>"; }; + 00926761109A0BF600B2EF52 /* defaults.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = defaults.plist; sourceTree = "<group>"; }; 009D8962108E251800A416CF /* Stroke.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Stroke.mm; path = "knot engine/Stroke.mm"; sourceTree = "<group>"; }; 009D8963108E251800A416CF /* Stroke.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Stroke.h; path = "knot engine/Stroke.h"; sourceTree = "<group>"; }; 009D897A108E28C800A416CF /* StrokeSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StrokeSet.cpp; path = "knot engine/StrokeSet.cpp"; sourceTree = "<group>"; }; 009D897B108E28C800A416CF /* StrokeSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StrokeSet.h; path = "knot engine/StrokeSet.h"; sourceTree = "<group>"; }; 00D7B654108F8E9A00432E90 /* KnotSection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KnotSection.cpp; path = "knot engine/KnotSection.cpp"; sourceTree = "<group>"; }; 00D7B655108F8E9A00432E90 /* KnotSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KnotSection.h; path = "knot engine/KnotSection.h"; sourceTree = "<group>"; }; 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA7835107A73320094FCAB /* XamhainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainView.h; path = "screen saving/XamhainView.h"; sourceTree = "<group>"; }; 00DA7836107A73320094FCAB /* XamhainView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainView.mm; path = "screen saving/XamhainView.mm"; sourceTree = "<group>"; }; 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ScreenSaver.framework; path = /System/Library/Frameworks/ScreenSaver.framework; sourceTree = "<absolute>"; }; 089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; 089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; }; 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; }; 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XamhainII_Prefix.pch; sourceTree = "<group>"; }; 8D255AD20486D3F9007BF209 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; 8D255AD30486D3F9007BF209 /* XamhainII.saver */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XamhainII.saver; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 8D255ACD0486D3F9007BF209 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */, 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */, 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 007C5125108A299800ED3242 /* Utility */ = { isa = PBXGroup; children = ( 007C5126108A29BE00ED3242 /* Position.h */, 007C5127108A29BE00ED3242 /* RandomColor.cpp */, 007C5128108A29BE00ED3242 /* RandomColor.h */, 007C5129108A29BE00ED3242 /* RandomNumbers.h */, ); name = Utility; sourceTree = "<group>"; }; 009D8961108E24ED00A416CF /* Knot Engine */ = { isa = PBXGroup; children = ( 002438531098D6E100E8A351 /* KnotStyle.h */, 002438541098D6E100E8A351 /* KnotStyle.cpp */, 007ED8581090CD6800B01235 /* CircularKnot.cpp */, 007ED8591090CD6800B01235 /* CircularKnot.h */, 007ED85A1090CD6800B01235 /* ClosedKnot.cpp */, 007ED85B1090CD6800B01235 /* ClosedKnot.h */, 007ED85C1090CD6800B01235 /* HorizontalKnot.cpp */, 007ED85D1090CD6800B01235 /* HorizontalKnot.h */, 007ED85E1090CD6800B01235 /* RandomKnot.cpp */, 007ED85F1090CD6800B01235 /* RandomKnot.h */, 007ED8601090CD6800B01235 /* RectangularKnot.cpp */, 007ED8611090CD6800B01235 /* RectangularKnot.h */, 007ED8621090CD6800B01235 /* TiledKnot.cpp */, 007ED8631090CD6800B01235 /* TiledKnot.h */, 007ED8641090CD6800B01235 /* VerticalKnot.cpp */, 007ED8651090CD6800B01235 /* VerticalKnot.h */, 00D7B654108F8E9A00432E90 /* KnotSection.cpp */, 00D7B655108F8E9A00432E90 /* KnotSection.h */, 009D897A108E28C800A416CF /* StrokeSet.cpp */, 009D897B108E28C800A416CF /* StrokeSet.h */, 009D8962108E251800A416CF /* Stroke.mm */, 009D8963108E251800A416CF /* Stroke.h */, ); name = "Knot Engine"; sourceTree = "<group>"; }; 00DA77D5107A728C0094FCAB /* Strokes */ = { isa = PBXGroup; children = ( 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */, 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */, 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */, 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */, 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */, 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */, 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */, 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */, 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */, 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */, 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */, 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */, 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */, 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */, 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */, 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */, 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */, 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */, 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */, 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */, 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */, 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */, 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */, 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */, 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */, 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */, 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */, 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */, 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */, 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */, 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */, 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */, 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */, 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */, 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */, 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */, 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */, 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */, 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */, 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */, 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */, 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */, 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */, 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */, ); name = Strokes; path = strokes; sourceTree = "<group>"; }; 00DA7833107A72F00094FCAB /* Screen Saving */ = { isa = PBXGroup; children = ( 001EA1D5109365FC00D05EFB /* XamhainGLView.h */, 001EA1D6109365FC00D05EFB /* XamhainGLView.mm */, 00791842108B081B00156D67 /* XamhainPreferences.mm */, 00791843108B081B00156D67 /* XamhainPreferences.h */, 00DA7835107A73320094FCAB /* XamhainView.h */, 00DA7836107A73320094FCAB /* XamhainView.mm */, ); name = "Screen Saving"; sourceTree = "<group>"; }; 089C166AFE841209C02AAC07 /* XamhainII */ = { isa = PBXGroup; children = ( 009D8961108E24ED00A416CF /* Knot Engine */, 00DA7833107A72F00094FCAB /* Screen Saving */, 007C5125108A299800ED3242 /* Utility */, 32DBCFA70370C4F300C91783 /* Other Sources */, 089C167CFE841241C02AAC07 /* Resources */, 089C1671FE841209C02AAC07 /* Frameworks and Libraries */, 19C28FB8FE9D52D311CA2CBB /* Products */, ); name = XamhainII; sourceTree = "<group>"; }; 089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = { isa = PBXGroup; children = ( 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */, 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */, ); name = "Frameworks and Libraries"; sourceTree = "<group>"; }; 089C167CFE841241C02AAC07 /* Resources */ = { isa = PBXGroup; children = ( + 00926761109A0BF600B2EF52 /* defaults.plist */, + 00790DBE10996796007ABF04 /* COPYING */, 00DA77D5107A728C0094FCAB /* Strokes */, 8D255AD20486D3F9007BF209 /* Info.plist */, 089C167DFE841241C02AAC07 /* InfoPlist.strings */, ); name = Resources; sourceTree = "<group>"; }; 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = { isa = PBXGroup; children = ( 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, 0032D325108A30770033FA87 /* OpenGL.framework */, 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */, ); name = "Linked Frameworks"; sourceTree = "<group>"; }; 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = { isa = PBXGroup; children = ( 089C1672FE841209C02AAC07 /* Foundation.framework */, 089C167FFE841241C02AAC07 /* AppKit.framework */, ); name = "Other Frameworks"; sourceTree = "<group>"; }; 19C28FB8FE9D52D311CA2CBB /* Products */ = { isa = PBXGroup; children = ( 8D255AD30486D3F9007BF209 /* XamhainII.saver */, ); name = Products; sourceTree = "<group>"; }; 32DBCFA70370C4F300C91783 /* Other Sources */ = { isa = PBXGroup; children = ( 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */, ); name = "Other Sources"; sourceTree = "<group>"; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ 8D255AC60486D3F9007BF209 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ 8D255AC50486D3F9007BF209 /* XamhainII */ = { isa = PBXNativeTarget; buildConfigurationList = EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */; buildPhases = ( 8D255AC60486D3F9007BF209 /* Headers */, 8D255AC90486D3F9007BF209 /* Resources */, 8D255ACB0486D3F9007BF209 /* Sources */, 8D255ACD0486D3F9007BF209 /* Frameworks */, 8D255AD00486D3F9007BF209 /* Rez */, ); buildRules = ( ); dependencies = ( ); name = XamhainII; productInstallPath = "$(HOME)/Library/Screen Savers"; productName = XamhainII; productReference = 8D255AD30486D3F9007BF209 /* XamhainII.saver */; productType = "com.apple.product-type.bundle"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 089C1669FE841209C02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */; compatibilityVersion = "Xcode 3.1"; hasScannedForEncodings = 1; mainGroup = 089C166AFE841209C02AAC07 /* XamhainII */; projectDirPath = ""; projectRoot = ""; targets = ( 8D255AC50486D3F9007BF209 /* XamhainII */, 000D03D61089C45F003F010E /* XamhainII.dmg */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ 8D255AC90486D3F9007BF209 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */, 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */, 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */, 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */, 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */, 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */, 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */, 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */, 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */, 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */, 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */, 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */, 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */, 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */, 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */, 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */, 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */, 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */, 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */, 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */, 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */, 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */, 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */, 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */, 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */, 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */, 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */, 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */, 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */, 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */, 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */, 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */, 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */, 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */, 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */, 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */, 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */, 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */, 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */, 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */, 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */, 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */, 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */, 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */, 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */, + 00790DBF10996796007ABF04 /* COPYING in Resources */, + 00926762109A0BF600B2EF52 /* defaults.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXRezBuildPhase section */ 8D255AD00486D3F9007BF209 /* Rez */ = { isa = PBXRezBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXRezBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ 000D03D51089C45F003F010E /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.saver", + "$(SRCROOT)/COPYING", ); outputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.dmg", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "# Thanks to Rob Mayoff for explaining how to do this.\n# See http://qwan.org/2007/05/22/using-xcode-to-build-a-disk-image-and-upload-a-web-site/\n\nset -ex\n\n[ \"$ACTION\" = build ] || exit 0\n[ \"$BUILD_VARIANTS\" = \"normal\" ] || exit 0\n\ndir=\"$TEMP_FILES_DIR/disk\"\ndmg=\"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.dmg\"\n\nrm -rf \"$dir\"\nmkdir \"$dir\"\ncp -R \"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.saver\" \"$dir\"\nrm -f \"$dmg\"\nhdiutil create -srcfolder \"$dir\" -volname \"$PROJECT_NAME\" \"$dmg\"\nhdiutil internet-enable -yes \"$dmg\"\nrm -rf \"$dir\"\n"; + shellScript = "# Thanks to Rob Mayoff for explaining how to do this.\n# See http://qwan.org/2007/05/22/using-xcode-to-build-a-disk-image-and-upload-a-web-site/\n\nset -ex\n\n[ \"$ACTION\" = build ] || exit 0\n[ \"$BUILD_VARIANTS\" = \"normal\" ] || exit 0\n\ndir=\"$TEMP_FILES_DIR/disk\"\ndmg=\"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.dmg\"\n\nrm -rf \"$dir\"\nmkdir \"$dir\"\ncp -R \"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.saver\" \"$dir\"\ncp -R \"$SRCROOT/COPYING\" \"$dir\"\nrm -f \"$dmg\"\nhdiutil create -srcfolder \"$dir\" -volname \"$PROJECT_NAME\" \"$dmg\"\nhdiutil internet-enable -yes \"$dmg\"\nrm -rf \"$dir\"\n"; }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 8D255ACB0486D3F9007BF209 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 00DA7838107A73320094FCAB /* XamhainView.mm in Sources */, 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */, 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */, 009D8964108E251800A416CF /* Stroke.mm in Sources */, 009D897C108E28C800A416CF /* StrokeSet.cpp in Sources */, 00D7B656108F8E9A00432E90 /* KnotSection.cpp in Sources */, 007ED8661090CD6800B01235 /* CircularKnot.cpp in Sources */, 007ED8681090CD6800B01235 /* ClosedKnot.cpp in Sources */, 007ED86A1090CD6800B01235 /* HorizontalKnot.cpp in Sources */, 007ED86C1090CD6800B01235 /* RandomKnot.cpp in Sources */, 007ED86E1090CD6800B01235 /* RectangularKnot.cpp in Sources */, 007ED8701090CD6800B01235 /* TiledKnot.cpp in Sources */, 007ED8721090CD6800B01235 /* VerticalKnot.cpp in Sources */, 00D188B11094BA31004E4496 /* XamhainGLView.mm in Sources */, 002438561098D6E100E8A351 /* KnotStyle.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 000D03DA1089C465003F010E /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 8D255AC50486D3F9007BF209 /* XamhainII */; targetProxy = 000D03D91089C465003F010E /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ 089C167DFE841241C02AAC07 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 089C167EFE841241C02AAC07 /* English */, ); name = InfoPlist.strings; sourceTree = "<group>"; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 000D03D71089C45F003F010E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; PRODUCT_NAME = XamhainII.dmg; }; name = Debug; }; 000D03D81089C45F003F010E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = XamhainII.dmg; ZERO_LINK = NO; }; name = Release; }; EF7AD72E08BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_STRICT_ALIASING = NO; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = NO; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; ZERO_LINK = YES; }; name = Debug; }; EF7AD72F08BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; }; name = Release; }; EF7AD73208BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = NO; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Debug; }; EF7AD73308BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */ = { isa = XCConfigurationList; buildConfigurations = ( 000D03D71089C45F003F010E /* Debug */, 000D03D81089C45F003F010E /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD72E08BB986600CE4634 /* Debug */, EF7AD72F08BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD73208BB986600CE4634 /* Debug */, EF7AD73308BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 089C1669FE841209C02AAC07 /* Project object */; } diff --git a/defaults.plist b/defaults.plist new file mode 100644 index 0000000..611595f --- /dev/null +++ b/defaults.plist @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>BroadKnotProbability</key> + <real>0.5</real> + <key>CircularKnotProbability</key> + <real>0.5</real> + <key>ClosedKnotProbability</key> + <real>0.5</real> + <key>CornerProbability1</key> + <real>0.2</real> + <key>CornerProbability2</key> + <real>0.8</real> + <key>HollowKnotProbability</key> + <real>0.4</real> + <key>HorizontalKnotProbability</key> + <real>0.1</real> + <key>HorizontalMirrorProbability</key> + <real>0.9</real> + <key>KnotSubdivisions</key> + <integer>2</integer> + <key>MaxSize</key> + <real>0.5</real> + <key>MaxSpeed</key> + <real>6.0</real> + <key>MaxSpin</key> + <real>5.0</real> + <key>MinSize</key> + <real>0.2</real> + <key>MinSpeed</key> + <real>3.0</real> + <key>MinSpin</key> + <real>1.0</real> + <key>NumberOfKnots</key> + <integer>8</integer> + <key>SectionProbability1</key> + <real>0.06</real> + <key>SectionProbability2</key> + <real>0.94</real> + <key>SkewProbability</key> + <real>0.8</real> + <key>SpinProbability</key> + <real>0.8</real> + <key>SymmetricKnotProbability</key> + <real>0.8</real> + <key>Technicolor</key> + <true/> + <key>TicksPerSecond</key> + <integer>60</integer> + <key>VerticalKnotProbability</key> + <real>0.2</real> + <key>VerticalMirrorProbability</key> + <real>0.9</real> +</dict> +</plist> diff --git a/screen saving/XamhainPreferences.mm b/screen saving/XamhainPreferences.mm index ca15be6..45c2f47 100644 --- a/screen saving/XamhainPreferences.mm +++ b/screen saving/XamhainPreferences.mm @@ -1,271 +1,249 @@ // XamhainII screen saver preferences. // // Copyright © 2000-2009, Jens Kilian. // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "XamhainPreferences.h" #include <algorithm> using namespace ::std; #import <ScreenSaver/ScreenSaverDefaults.h> @interface XamhainScreenSaverDefaults { // empty } + (NSUserDefaults *) sharedDefaults; @end namespace { NSUserDefaults *gInstance = nil; } @implementation XamhainScreenSaverDefaults + (void) initialize { gInstance = [ScreenSaverDefaults defaultsForModuleWithName: @"de.earrame.XamhainII"]; - // Register initial defaults. - NSDictionary *factoryDefaults = - [NSDictionary dictionaryWithObjectsAndKeys: - @"8", @"NumberOfKnots", - @"YES", @"Technicolor", - @"60", @"TicksPerSecond", - @"0.2", @"MinSize", - @"0.5", @"MaxSize", - @"3.0", @"MinSpeed", - @"6.0", @"MaxSpeed", - @"1.0", @"MinSpin", - @"5.0", @"MaxSpin", - @"0.8", @"SkewProbability", - @"0.8", @"SpinProbability", - @"2", @"KnotSubdivisions", - @"0.1", @"HorizontalKnotProbability", - @"0.2", @"VerticalKnotProbability", - @"0.5", @"ClosedKnotProbability", - @"0.5", @"CircularKnotProbability", - @"0.06", @"SectionProbability1", - @"0.94", @"SectionProbability2", - @"0.2", @"CornerProbability1", - @"0.8", @"CornerProbability2", - @"0.5", @"BroadKnotProbability", - @"0.4", @"HollowKnotProbability", - @"0.8", @"SymmetricKnotProbability", - @"0.9", @"HorizontalMirrorProbability", - @"0.9", @"VerticalMirrorProbability", - NULL]; + // Load initial defaults and register them. + NSBundle *bundle = [NSBundle bundleWithIdentifier: @"de.earrame.XamhainII"]; + NSString *path = [bundle pathForResource: @"defaults" ofType: @"plist"]; + assert(path != nil); + + NSDictionary *factoryDefaults = [NSDictionary dictionaryWithContentsOfFile: path]; + assert(factoryDefaults != nil); [gInstance registerDefaults: factoryDefaults]; } + (NSUserDefaults *) sharedDefaults { return gInstance; } @end // Construct a preferences object - which is actually just a wrapper. XamhainPreferences::XamhainPreferences(void) : mDefaults([XamhainScreenSaverDefaults sharedDefaults]) { // empty } // Implementation of inquiry functions. int XamhainPreferences::numberOfKnots(void) const { return max((NSInteger)1, [mDefaults integerForKey: @"NumberOfKnots"]); } bool XamhainPreferences::technicolor(void) const { return [mDefaults boolForKey: @"Technicolor"]; } int XamhainPreferences::ticksPerSecond(void) const { return max((NSInteger)1, [mDefaults integerForKey: @"TicksPerSecond"]); } GLfloat XamhainPreferences::minSize(void) const { return min([mDefaults floatForKey: @"MinSize"], [mDefaults floatForKey: @"MaxSize"]); } GLfloat XamhainPreferences::maxSize(void) const { return max([mDefaults floatForKey: @"MinSize"], [mDefaults floatForKey: @"MaxSize"]); } GLfloat XamhainPreferences::minSpeed(void) const { return min([mDefaults floatForKey: @"MinSpeed"], [mDefaults floatForKey: @"MaxSpeed"]); } GLfloat XamhainPreferences::maxSpeed(void) const { return max([mDefaults floatForKey: @"MinSpeed"], [mDefaults floatForKey: @"MaxSpeed"]); } GLfloat XamhainPreferences::minSpin(void) const { return min([mDefaults floatForKey: @"MinSpin"], [mDefaults floatForKey: @"MaxSpin"]); } GLfloat XamhainPreferences::maxSpin(void) const { return max([mDefaults floatForKey: @"MinSpin"], [mDefaults floatForKey: @"MaxSpin"]); } GLfloat XamhainPreferences::skewProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"SkewProbability"]), 1.0f); } GLfloat XamhainPreferences::spinProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"SpinProbability"]), 1.0f); } int XamhainPreferences::knotSubdivisions(void) const { return max((NSInteger)1, [mDefaults integerForKey: @"KnotSubdivisions"]); } GLfloat XamhainPreferences::horizontalKnotProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"HorizontalKnotProbability"] / totalKnotProbability()), 1.0f); } GLfloat XamhainPreferences::verticalKnotProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"VerticalKnotProbability"] / totalKnotProbability()), 1.0f); } GLfloat XamhainPreferences::closedKnotProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"ClosedKnotProbability"] / totalKnotProbability()), 1.0f); } GLfloat XamhainPreferences::circularKnotProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"CircularKnotProbability"] / totalKnotProbability()), 1.0f); } GLfloat XamhainPreferences::sectionProbability1(void) const { return min(max(0.0f, [mDefaults floatForKey: @"SectionProbability1"]), 1.0f); } GLfloat XamhainPreferences::sectionProbability2(void) const { return min(max(0.0f, [mDefaults floatForKey: @"SectionProbability2"]), 1.0f); } GLfloat XamhainPreferences::cornerProbability1(void) const { return min(max(0.0f, [mDefaults floatForKey: @"CornerProbability1"]), 1.0f); } GLfloat XamhainPreferences::cornerProbability2(void) const { return min(max(0.0f, [mDefaults floatForKey: @"CornerProbability2"]), 1.0f); } GLfloat XamhainPreferences::broadKnotProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"BroadKnotProbability"]), 1.0f); } GLfloat XamhainPreferences::hollowKnotProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"HollowKnotProbability"]), 1.0f); } GLfloat XamhainPreferences::symmetricKnotProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"SymmetricKnotProbability"]), 1.0f); } GLfloat XamhainPreferences::horizontalMirrorProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"HorizontalMirrorProbability"]), 1.0f); } GLfloat XamhainPreferences::verticalMirrorProbability(void) const { return min(max(0.0f, [mDefaults floatForKey: @"VerticalMirrorProbability"]), 1.0f); } GLfloat XamhainPreferences::totalKnotProbability(void) const { return [mDefaults floatForKey: @"HorizontalKnotProbability"] + [mDefaults floatForKey: @"VerticalKnotProbability"] + [mDefaults floatForKey: @"ClosedKnotProbability"] + [mDefaults floatForKey: @"CircularKnotProbability"]; }
jjk/XamhainII
629e4dfeb25f29756df81d9629c097e9fc0dea91
Use separate sets of textures for each GL context.
diff --git a/XamhainII.xcodeproj/project.pbxproj b/XamhainII.xcodeproj/project.pbxproj index f60637f..8f75bf7 100644 --- a/XamhainII.xcodeproj/project.pbxproj +++ b/XamhainII.xcodeproj/project.pbxproj @@ -1,712 +1,718 @@ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 45; objects = { /* Begin PBXAggregateTarget section */ 000D03D61089C45F003F010E /* XamhainII.dmg */ = { isa = PBXAggregateTarget; buildConfigurationList = 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */; buildPhases = ( 000D03D51089C45F003F010E /* ShellScript */, ); dependencies = ( 000D03DA1089C465003F010E /* PBXTargetDependency */, ); name = XamhainII.dmg; productName = XamhainII.dmg; }; /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 002438561098D6E100E8A351 /* KnotStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 002438541098D6E100E8A351 /* KnotStyle.cpp */; }; 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0032D325108A30770033FA87 /* OpenGL.framework */; }; 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00791842108B081B00156D67 /* XamhainPreferences.mm */; }; 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007C5127108A29BE00ED3242 /* RandomColor.cpp */; }; 007ED8661090CD6800B01235 /* CircularKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8581090CD6800B01235 /* CircularKnot.cpp */; }; 007ED8681090CD6800B01235 /* ClosedKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED85A1090CD6800B01235 /* ClosedKnot.cpp */; }; 007ED86A1090CD6800B01235 /* HorizontalKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED85C1090CD6800B01235 /* HorizontalKnot.cpp */; }; 007ED86C1090CD6800B01235 /* RandomKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED85E1090CD6800B01235 /* RandomKnot.cpp */; }; 007ED86E1090CD6800B01235 /* RectangularKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8601090CD6800B01235 /* RectangularKnot.cpp */; }; 007ED8701090CD6800B01235 /* TiledKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8621090CD6800B01235 /* TiledKnot.cpp */; }; 007ED8721090CD6800B01235 /* VerticalKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8641090CD6800B01235 /* VerticalKnot.cpp */; }; 009D8964108E251800A416CF /* Stroke.mm in Sources */ = {isa = PBXBuildFile; fileRef = 009D8962108E251800A416CF /* Stroke.mm */; }; 009D897C108E28C800A416CF /* StrokeSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 009D897A108E28C800A416CF /* StrokeSet.cpp */; }; 00D188B11094BA31004E4496 /* XamhainGLView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 001EA1D6109365FC00D05EFB /* XamhainGLView.mm */; }; 00D7B656108F8E9A00432E90 /* KnotSection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00D7B654108F8E9A00432E90 /* KnotSection.cpp */; }; 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */; }; 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */; }; 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */; }; 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */; }; 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */; }; 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */; }; 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */; }; 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */; }; 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */; }; 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */; }; 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */; }; 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */; }; 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */; }; 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */; }; 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */; }; 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */; }; 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */; }; 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */; }; 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */; }; 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */; }; 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */; }; 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */; }; 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */; }; 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */; }; 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */; }; 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */; }; 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */; }; 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */; }; 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */; }; 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */; }; 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */; }; 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */; }; 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */; }; 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */; }; 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */; }; 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */; }; 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */; }; 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */; }; 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */; }; 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */; }; 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */; }; 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */; }; 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */; }; 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */; }; 00DA7838107A73320094FCAB /* XamhainView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00DA7836107A73320094FCAB /* XamhainView.mm */; }; 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 000D03D91089C465003F010E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 089C1669FE841209C02AAC07 /* Project object */; proxyType = 1; remoteGlobalIDString = 8D255AC50486D3F9007BF209; remoteInfo = XamhainII; }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ 001EA1D5109365FC00D05EFB /* XamhainGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainGLView.h; path = "screen saving/XamhainGLView.h"; sourceTree = "<group>"; }; 001EA1D6109365FC00D05EFB /* XamhainGLView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainGLView.mm; path = "screen saving/XamhainGLView.mm"; sourceTree = "<group>"; }; + 002438531098D6E100E8A351 /* KnotStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KnotStyle.h; path = "knot engine/KnotStyle.h"; sourceTree = "<group>"; }; + 002438541098D6E100E8A351 /* KnotStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KnotStyle.cpp; path = "knot engine/KnotStyle.cpp"; sourceTree = "<group>"; }; 0032D325108A30770033FA87 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; }; 00791842108B081B00156D67 /* XamhainPreferences.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainPreferences.mm; path = "screen saving/XamhainPreferences.mm"; sourceTree = "<group>"; }; 00791843108B081B00156D67 /* XamhainPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainPreferences.h; path = "screen saving/XamhainPreferences.h"; sourceTree = "<group>"; }; 007C5126108A29BE00ED3242 /* Position.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Position.h; path = utility/Position.h; sourceTree = "<group>"; }; 007C5127108A29BE00ED3242 /* RandomColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RandomColor.cpp; path = utility/RandomColor.cpp; sourceTree = "<group>"; }; 007C5128108A29BE00ED3242 /* RandomColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomColor.h; path = utility/RandomColor.h; sourceTree = "<group>"; }; 007C5129108A29BE00ED3242 /* RandomNumbers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomNumbers.h; path = utility/RandomNumbers.h; sourceTree = "<group>"; }; 007ED8581090CD6800B01235 /* CircularKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CircularKnot.cpp; path = "knot engine/CircularKnot.cpp"; sourceTree = "<group>"; }; 007ED8591090CD6800B01235 /* CircularKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CircularKnot.h; path = "knot engine/CircularKnot.h"; sourceTree = "<group>"; }; 007ED85A1090CD6800B01235 /* ClosedKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClosedKnot.cpp; path = "knot engine/ClosedKnot.cpp"; sourceTree = "<group>"; }; 007ED85B1090CD6800B01235 /* ClosedKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClosedKnot.h; path = "knot engine/ClosedKnot.h"; sourceTree = "<group>"; }; 007ED85C1090CD6800B01235 /* HorizontalKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HorizontalKnot.cpp; path = "knot engine/HorizontalKnot.cpp"; sourceTree = "<group>"; }; 007ED85D1090CD6800B01235 /* HorizontalKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HorizontalKnot.h; path = "knot engine/HorizontalKnot.h"; sourceTree = "<group>"; }; 007ED85E1090CD6800B01235 /* RandomKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RandomKnot.cpp; path = "knot engine/RandomKnot.cpp"; sourceTree = "<group>"; }; 007ED85F1090CD6800B01235 /* RandomKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomKnot.h; path = "knot engine/RandomKnot.h"; sourceTree = "<group>"; }; 007ED8601090CD6800B01235 /* RectangularKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RectangularKnot.cpp; path = "knot engine/RectangularKnot.cpp"; sourceTree = "<group>"; }; 007ED8611090CD6800B01235 /* RectangularKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RectangularKnot.h; path = "knot engine/RectangularKnot.h"; sourceTree = "<group>"; }; 007ED8621090CD6800B01235 /* TiledKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TiledKnot.cpp; path = "knot engine/TiledKnot.cpp"; sourceTree = "<group>"; }; 007ED8631090CD6800B01235 /* TiledKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiledKnot.h; path = "knot engine/TiledKnot.h"; sourceTree = "<group>"; }; 007ED8641090CD6800B01235 /* VerticalKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VerticalKnot.cpp; path = "knot engine/VerticalKnot.cpp"; sourceTree = "<group>"; }; 007ED8651090CD6800B01235 /* VerticalKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VerticalKnot.h; path = "knot engine/VerticalKnot.h"; sourceTree = "<group>"; }; 009D8962108E251800A416CF /* Stroke.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Stroke.mm; path = "knot engine/Stroke.mm"; sourceTree = "<group>"; }; 009D8963108E251800A416CF /* Stroke.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Stroke.h; path = "knot engine/Stroke.h"; sourceTree = "<group>"; }; 009D897A108E28C800A416CF /* StrokeSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StrokeSet.cpp; path = "knot engine/StrokeSet.cpp"; sourceTree = "<group>"; }; 009D897B108E28C800A416CF /* StrokeSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StrokeSet.h; path = "knot engine/StrokeSet.h"; sourceTree = "<group>"; }; 00D7B654108F8E9A00432E90 /* KnotSection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KnotSection.cpp; path = "knot engine/KnotSection.cpp"; sourceTree = "<group>"; }; 00D7B655108F8E9A00432E90 /* KnotSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KnotSection.h; path = "knot engine/KnotSection.h"; sourceTree = "<group>"; }; 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA7835107A73320094FCAB /* XamhainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainView.h; path = "screen saving/XamhainView.h"; sourceTree = "<group>"; }; 00DA7836107A73320094FCAB /* XamhainView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainView.mm; path = "screen saving/XamhainView.mm"; sourceTree = "<group>"; }; 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ScreenSaver.framework; path = /System/Library/Frameworks/ScreenSaver.framework; sourceTree = "<absolute>"; }; 089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; 089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; }; 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; }; 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XamhainII_Prefix.pch; sourceTree = "<group>"; }; 8D255AD20486D3F9007BF209 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; 8D255AD30486D3F9007BF209 /* XamhainII.saver */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XamhainII.saver; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 8D255ACD0486D3F9007BF209 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */, 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */, 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 007C5125108A299800ED3242 /* Utility */ = { isa = PBXGroup; children = ( 007C5126108A29BE00ED3242 /* Position.h */, 007C5127108A29BE00ED3242 /* RandomColor.cpp */, 007C5128108A29BE00ED3242 /* RandomColor.h */, 007C5129108A29BE00ED3242 /* RandomNumbers.h */, ); name = Utility; sourceTree = "<group>"; }; 009D8961108E24ED00A416CF /* Knot Engine */ = { isa = PBXGroup; children = ( + 002438531098D6E100E8A351 /* KnotStyle.h */, + 002438541098D6E100E8A351 /* KnotStyle.cpp */, 007ED8581090CD6800B01235 /* CircularKnot.cpp */, 007ED8591090CD6800B01235 /* CircularKnot.h */, 007ED85A1090CD6800B01235 /* ClosedKnot.cpp */, 007ED85B1090CD6800B01235 /* ClosedKnot.h */, 007ED85C1090CD6800B01235 /* HorizontalKnot.cpp */, 007ED85D1090CD6800B01235 /* HorizontalKnot.h */, 007ED85E1090CD6800B01235 /* RandomKnot.cpp */, 007ED85F1090CD6800B01235 /* RandomKnot.h */, 007ED8601090CD6800B01235 /* RectangularKnot.cpp */, 007ED8611090CD6800B01235 /* RectangularKnot.h */, 007ED8621090CD6800B01235 /* TiledKnot.cpp */, 007ED8631090CD6800B01235 /* TiledKnot.h */, 007ED8641090CD6800B01235 /* VerticalKnot.cpp */, 007ED8651090CD6800B01235 /* VerticalKnot.h */, 00D7B654108F8E9A00432E90 /* KnotSection.cpp */, 00D7B655108F8E9A00432E90 /* KnotSection.h */, 009D897A108E28C800A416CF /* StrokeSet.cpp */, 009D897B108E28C800A416CF /* StrokeSet.h */, 009D8962108E251800A416CF /* Stroke.mm */, 009D8963108E251800A416CF /* Stroke.h */, ); name = "Knot Engine"; sourceTree = "<group>"; }; 00DA77D5107A728C0094FCAB /* Strokes */ = { isa = PBXGroup; children = ( 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */, 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */, 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */, 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */, 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */, 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */, 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */, 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */, 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */, 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */, 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */, 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */, 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */, 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */, 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */, 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */, 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */, 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */, 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */, 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */, 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */, 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */, 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */, 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */, 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */, 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */, 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */, 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */, 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */, 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */, 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */, 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */, 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */, 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */, 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */, 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */, 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */, 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */, 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */, 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */, 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */, 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */, 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */, 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */, ); name = Strokes; path = strokes; sourceTree = "<group>"; }; 00DA7833107A72F00094FCAB /* Screen Saving */ = { isa = PBXGroup; children = ( 001EA1D5109365FC00D05EFB /* XamhainGLView.h */, 001EA1D6109365FC00D05EFB /* XamhainGLView.mm */, 00791842108B081B00156D67 /* XamhainPreferences.mm */, 00791843108B081B00156D67 /* XamhainPreferences.h */, 00DA7835107A73320094FCAB /* XamhainView.h */, 00DA7836107A73320094FCAB /* XamhainView.mm */, ); name = "Screen Saving"; sourceTree = "<group>"; }; 089C166AFE841209C02AAC07 /* XamhainII */ = { isa = PBXGroup; children = ( 009D8961108E24ED00A416CF /* Knot Engine */, 00DA7833107A72F00094FCAB /* Screen Saving */, 007C5125108A299800ED3242 /* Utility */, 32DBCFA70370C4F300C91783 /* Other Sources */, 089C167CFE841241C02AAC07 /* Resources */, 089C1671FE841209C02AAC07 /* Frameworks and Libraries */, 19C28FB8FE9D52D311CA2CBB /* Products */, ); name = XamhainII; sourceTree = "<group>"; }; 089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = { isa = PBXGroup; children = ( 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */, 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */, ); name = "Frameworks and Libraries"; sourceTree = "<group>"; }; 089C167CFE841241C02AAC07 /* Resources */ = { isa = PBXGroup; children = ( 00DA77D5107A728C0094FCAB /* Strokes */, 8D255AD20486D3F9007BF209 /* Info.plist */, 089C167DFE841241C02AAC07 /* InfoPlist.strings */, ); name = Resources; sourceTree = "<group>"; }; 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = { isa = PBXGroup; children = ( 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, 0032D325108A30770033FA87 /* OpenGL.framework */, 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */, ); name = "Linked Frameworks"; sourceTree = "<group>"; }; 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = { isa = PBXGroup; children = ( 089C1672FE841209C02AAC07 /* Foundation.framework */, 089C167FFE841241C02AAC07 /* AppKit.framework */, ); name = "Other Frameworks"; sourceTree = "<group>"; }; 19C28FB8FE9D52D311CA2CBB /* Products */ = { isa = PBXGroup; children = ( 8D255AD30486D3F9007BF209 /* XamhainII.saver */, ); name = Products; sourceTree = "<group>"; }; 32DBCFA70370C4F300C91783 /* Other Sources */ = { isa = PBXGroup; children = ( 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */, ); name = "Other Sources"; sourceTree = "<group>"; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ 8D255AC60486D3F9007BF209 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ 8D255AC50486D3F9007BF209 /* XamhainII */ = { isa = PBXNativeTarget; buildConfigurationList = EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */; buildPhases = ( 8D255AC60486D3F9007BF209 /* Headers */, 8D255AC90486D3F9007BF209 /* Resources */, 8D255ACB0486D3F9007BF209 /* Sources */, 8D255ACD0486D3F9007BF209 /* Frameworks */, 8D255AD00486D3F9007BF209 /* Rez */, ); buildRules = ( ); dependencies = ( ); name = XamhainII; productInstallPath = "$(HOME)/Library/Screen Savers"; productName = XamhainII; productReference = 8D255AD30486D3F9007BF209 /* XamhainII.saver */; productType = "com.apple.product-type.bundle"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 089C1669FE841209C02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */; compatibilityVersion = "Xcode 3.1"; hasScannedForEncodings = 1; mainGroup = 089C166AFE841209C02AAC07 /* XamhainII */; projectDirPath = ""; projectRoot = ""; targets = ( 8D255AC50486D3F9007BF209 /* XamhainII */, 000D03D61089C45F003F010E /* XamhainII.dmg */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ 8D255AC90486D3F9007BF209 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */, 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */, 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */, 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */, 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */, 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */, 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */, 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */, 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */, 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */, 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */, 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */, 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */, 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */, 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */, 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */, 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */, 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */, 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */, 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */, 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */, 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */, 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */, 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */, 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */, 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */, 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */, 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */, 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */, 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */, 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */, 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */, 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */, 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */, 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */, 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */, 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */, 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */, 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */, 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */, 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */, 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */, 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */, 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */, 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXRezBuildPhase section */ 8D255AD00486D3F9007BF209 /* Rez */ = { isa = PBXRezBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXRezBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ 000D03D51089C45F003F010E /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.saver", ); outputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.dmg", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "# Thanks to Rob Mayoff for explaining how to do this.\n# See http://qwan.org/2007/05/22/using-xcode-to-build-a-disk-image-and-upload-a-web-site/\n\nset -ex\n\n[ \"$ACTION\" = build ] || exit 0\n[ \"$BUILD_VARIANTS\" = \"normal\" ] || exit 0\n\ndir=\"$TEMP_FILES_DIR/disk\"\ndmg=\"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.dmg\"\n\nrm -rf \"$dir\"\nmkdir \"$dir\"\ncp -R \"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.saver\" \"$dir\"\nrm -f \"$dmg\"\nhdiutil create -srcfolder \"$dir\" -volname \"$PROJECT_NAME\" \"$dmg\"\nhdiutil internet-enable -yes \"$dmg\"\nrm -rf \"$dir\"\n"; }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 8D255ACB0486D3F9007BF209 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 00DA7838107A73320094FCAB /* XamhainView.mm in Sources */, 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */, 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */, 009D8964108E251800A416CF /* Stroke.mm in Sources */, 009D897C108E28C800A416CF /* StrokeSet.cpp in Sources */, 00D7B656108F8E9A00432E90 /* KnotSection.cpp in Sources */, 007ED8661090CD6800B01235 /* CircularKnot.cpp in Sources */, 007ED8681090CD6800B01235 /* ClosedKnot.cpp in Sources */, 007ED86A1090CD6800B01235 /* HorizontalKnot.cpp in Sources */, 007ED86C1090CD6800B01235 /* RandomKnot.cpp in Sources */, 007ED86E1090CD6800B01235 /* RectangularKnot.cpp in Sources */, 007ED8701090CD6800B01235 /* TiledKnot.cpp in Sources */, 007ED8721090CD6800B01235 /* VerticalKnot.cpp in Sources */, 00D188B11094BA31004E4496 /* XamhainGLView.mm in Sources */, + 002438561098D6E100E8A351 /* KnotStyle.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 000D03DA1089C465003F010E /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 8D255AC50486D3F9007BF209 /* XamhainII */; targetProxy = 000D03D91089C465003F010E /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ 089C167DFE841241C02AAC07 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 089C167EFE841241C02AAC07 /* English */, ); name = InfoPlist.strings; sourceTree = "<group>"; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 000D03D71089C45F003F010E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; PRODUCT_NAME = XamhainII.dmg; }; name = Debug; }; 000D03D81089C45F003F010E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = XamhainII.dmg; ZERO_LINK = NO; }; name = Release; }; EF7AD72E08BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_STRICT_ALIASING = NO; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = NO; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; ZERO_LINK = YES; }; name = Debug; }; EF7AD72F08BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; }; name = Release; }; EF7AD73208BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = NO; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Debug; }; EF7AD73308BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */ = { isa = XCConfigurationList; buildConfigurations = ( 000D03D71089C45F003F010E /* Debug */, 000D03D81089C45F003F010E /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD72E08BB986600CE4634 /* Debug */, EF7AD72F08BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD73208BB986600CE4634 /* Debug */, EF7AD73308BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 089C1669FE841209C02AAC07 /* Project object */; } diff --git a/knot engine/CircularKnot.cpp b/knot engine/CircularKnot.cpp index 16d941c..bd6a198 100644 --- a/knot engine/CircularKnot.cpp +++ b/knot engine/CircularKnot.cpp @@ -1,144 +1,146 @@ // A class representing a random circular knot. // // Copyright © 2004-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "CircularKnot.h" #include <cmath> #include <algorithm> using namespace ::std; #include <OpenGL/gl.h> #include "KnotSection.h" +class KnotStyle; #include "Position.h" #include "RandomKnot.h" #include "RandomNumbers.h" namespace { // Minimum size of knot sections. const int kMinEdgeLength = 10; } -CircularKnot::CircularKnot(int windowWidth, int windowHeight) -: inherited(windowWidth, windowHeight, 6), +CircularKnot::CircularKnot(const KnotStyle &knotStyle, + int windowWidth, int windowHeight) +: inherited(knotStyle, windowWidth, windowHeight, 6), mSectors(3 + randomInteger(5)) { // Set boundary conditions. // The left and right borders must have vertical corners. for (int i = 0; i <= mVSections; ++i) { sectionCorner(0, i) = sectionCorner(mHSections, i) = V; } // The top and bottom borders must match. for (int i = 1; i < mHSections; ++i) { sectionCorner(i, mVSections) = sectionCorner(i, 0); } // Calculate dimensions of the knot. const GLfloat fraction = randomFloat(mPrefs.minSize(), mPrefs.maxSize()); const GLfloat outRadius = 0.5 * fraction * min(mWindowWidth, mWindowHeight); const GLfloat inRadius = outRadius * randomFloat(0.25, 0.75); const GLfloat midRadius = (outRadius + inRadius) * 0.5; const int sectionWidth = (int)((outRadius - inRadius) / mHSections); const GLfloat angle = 2.0 * M_PI / mSectors; const int sectionHeight = (int)(angle * midRadius / mVSections); mEdgeLength = max(max(sectionWidth, sectionHeight), (mHollow ? 3 : 1) * kMinEdgeLength); mRadius = max(mVSections / angle, (mHSections+1) * 0.5f) * mEdgeLength; // Avoid infelicitous associations. if (mSectors == 4) { enforceVerticalSymmetry(false); } // Calculate the remaining properties. prepareAnimation( Position(1.0, 1.0) * (mRadius + mHSections * mEdgeLength * 0.5)); assignColors(); } CircularKnot::~CircularKnot(void) { // empty } void CircularKnot::drawBasicKnot(void) const { const GLfloat angle = 2.0 * M_PI / mSectors / mVSections; const GLfloat minRadius = mRadius - mEdgeLength * 0.5 * (mHSections-1); // Draw all the sections. for (int i = 0; i < mVSections; ++i) { const GLfloat phi = (0.5 * (mVSections-1) - i) * angle; for (int j = 0; j < mHSections; ++j) { const GLfloat radius = minRadius + j * mEdgeLength; glPushMatrix(); { glRotatef(phi * 180.0 / M_PI, 0.0, 0.0, 1.0); glTranslatef(radius, 0.0, 0.0); KnotSection section(sectionType(j, i), sectionCorner(j, i), sectionCorner(j+1, i), sectionCorner(j, i+1), sectionCorner(j+1, i+1)); const GLfloat *pTopColor = sectionColor(TOP, j, i); const GLfloat *pBotColor = sectionColor(BOT, j, i); const GLfloat *pLTColor = leftTopCornerColor(j, i); const GLfloat *pRBColor = rightBottomCornerColor(j, i); section.draw(Position(0.0, 0.0), mEdgeLength, radius, angle, - *mpOutlineStrokes, *mpFillStrokes, mHollow, + mOutlineStrokes, mFillStrokes, mHollow, pTopColor, pBotColor, pLTColor, pRBColor); } glPopMatrix(); } } } void CircularKnot::draw(Position where, GLfloat angle) const { glPushMatrix(); { glTranslatef(where.x, where.y, 0.0); glRotatef(angle * 180.0 / M_PI, 0.0, 0.0, 1.0); for (int i = 0; i < mSectors; ++i) { glCallList(displayList()); glRotatef(360.0 / mSectors, 0.0, 0.0, 1.0); } } glPopMatrix(); } diff --git a/knot engine/CircularKnot.h b/knot engine/CircularKnot.h index 0948771..0b4534e 100644 --- a/knot engine/CircularKnot.h +++ b/knot engine/CircularKnot.h @@ -1,52 +1,54 @@ // A class representing a random circular knot. // // Copyright © 2004-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #ifndef CIRCULARKNOT_H #define CIRCULARKNOT_H #include <OpenGL/gl.h> +class KnotStyle; #include "Position.h" #include "RandomKnot.h" class CircularKnot : public RandomKnot { typedef RandomKnot inherited; public: - CircularKnot(int windowWidth, int windowHeight); + CircularKnot(const KnotStyle &knotStyle, + int windowWidth, int windowHeight); virtual ~CircularKnot(void); private: CircularKnot(const CircularKnot &orig); CircularKnot &operator =(CircularKnot &orig); // Draw the basic knot at the origin. virtual void drawBasicKnot(void) const; virtual void draw(Position where, GLfloat angle) const; // Data members. int mSectors; GLfloat mEdgeLength; GLfloat mRadius; }; #endif // CIRCULARKNOT_H diff --git a/knot engine/ClosedKnot.cpp b/knot engine/ClosedKnot.cpp index 00ab974..c39d668 100644 --- a/knot engine/ClosedKnot.cpp +++ b/knot engine/ClosedKnot.cpp @@ -1,68 +1,70 @@ // A class representing a random closed knot. // // Copyright © 1997-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "ClosedKnot.h" #include <cmath> #include <OpenGL/gl.h> #include "KnotSection.h" +class KnotStyle; #include "Position.h" -ClosedKnot::ClosedKnot(int windowWidth, int windowHeight) -: inherited(windowWidth, windowHeight, 12) +ClosedKnot::ClosedKnot(const KnotStyle &knotStyle, + int windowWidth, int windowHeight) +: inherited(knotStyle, windowWidth, windowHeight, 12) { // Set boundary conditions for a closed knot. // The left and right border must consist of vertical... for (int i = 0; i < mVSections; ++i) { sectionType(0, i) = sectionType(mHSections-1, i) = V; } // ... half sections. for (int i = 0; i <= mVSections; ++i) { sectionCorner(0, i) = sectionCorner(mHSections, i) = N; } // The top and bottom border must have horizontal corners. for (int i = 1; i < mHSections; ++i) { sectionCorner(i, 0) = sectionCorner(i, mVSections) = H; } // Assign colors to the knot. assignColors(); } ClosedKnot::~ClosedKnot(void) { // empty } void ClosedKnot::draw(Position where, GLfloat angle) const { glPushMatrix(); { glTranslatef(where.x, where.y, 0.0); glRotatef(angle * 180.0 / M_PI, 0.0, 0.0, 1.0); glCallList(displayList()); } glPopMatrix(); } diff --git a/knot engine/ClosedKnot.h b/knot engine/ClosedKnot.h index 9991c84..6e6d6ff 100644 --- a/knot engine/ClosedKnot.h +++ b/knot engine/ClosedKnot.h @@ -1,43 +1,45 @@ // A class representing a random closed knot. // // Copyright © 1997-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #ifndef CLOSEDKNOT_H #define CLOSEDKNOT_H #include <OpenGL/gl.h> +class KnotStyle; #include "Position.h" #include "RectangularKnot.h" class ClosedKnot : public RectangularKnot { typedef RectangularKnot inherited; public: - ClosedKnot(int windowWidth, int windowHeight); + ClosedKnot(const KnotStyle &knotStyle, + int windowWidth, int windowHeight); virtual ~ClosedKnot(void); private: ClosedKnot(const ClosedKnot &orig); ClosedKnot &operator =(ClosedKnot &orig); virtual void draw(Position where, GLfloat angle) const; }; #endif // CLOSEDKNOT_H diff --git a/knot engine/HorizontalKnot.cpp b/knot engine/HorizontalKnot.cpp index 0dc3613..27be6ac 100644 --- a/knot engine/HorizontalKnot.cpp +++ b/knot engine/HorizontalKnot.cpp @@ -1,49 +1,51 @@ // A class representing a random horizontally tileable knot. // // Copyright © 1997-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "HorizontalKnot.h" #include "KnotSection.h" +class KnotStyle; #include "Position.h" #include "TiledKnot.h" #include "RandomNumbers.h" -HorizontalKnot::HorizontalKnot(int width, int height) -: inherited(width, height, Position(1.0, 0.0)) +HorizontalKnot::HorizontalKnot(const KnotStyle &knotStyle, + int width, int height) +: inherited(knotStyle, width, height, Position(1.0, 0.0)) { // Set boundary conditions for a horizontal knot. // The left and right borders must match. for (int i = 1; i < mVSections; ++i) { sectionCorner(mHSections, i) = sectionCorner(0, i); } // The top and bottom borders must have horizontal corners. for (int i = 0; i <= mHSections; ++i) { sectionCorner(i, 0) = sectionCorner(i, mVSections) = H; } // Assign colors to the knot. assignColors(); } HorizontalKnot::~HorizontalKnot(void) { // empty } diff --git a/knot engine/HorizontalKnot.h b/knot engine/HorizontalKnot.h index 98b73b8..4fa5949 100644 --- a/knot engine/HorizontalKnot.h +++ b/knot engine/HorizontalKnot.h @@ -1,37 +1,39 @@ // A class representing a random horizontally tileable knot. // // Copyright © 1997-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #ifndef HORIZONTALKNOT_H #define HORIZONTALKNOT_H +class KnotStyle; #include "TiledKnot.h" class HorizontalKnot : public TiledKnot { typedef TiledKnot inherited; public: - HorizontalKnot(int windowWidth, int windowHeight); + HorizontalKnot(const KnotStyle &knotStyle, + int windowWidth, int windowHeight); virtual ~HorizontalKnot(void); private: HorizontalKnot(const HorizontalKnot &orig); HorizontalKnot &operator =(HorizontalKnot &orig); }; #endif // HORIZONTALKNOT_H diff --git a/knot engine/KnotStyle.cpp b/knot engine/KnotStyle.cpp new file mode 100644 index 0000000..9fef7b2 --- /dev/null +++ b/knot engine/KnotStyle.cpp @@ -0,0 +1,29 @@ +// Drawing style for a knot, combining fill and outline strokes. +// +// Copyright © 2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#include "KnotStyle.h" + +#include "StrokeSet.h" + +KnotStyle::KnotStyle(const char *const pName) +: mOutline(pName, "outline"), + mFill(pName, "fill") +{ + // empty +} diff --git a/knot engine/KnotStyle.h b/knot engine/KnotStyle.h new file mode 100644 index 0000000..3c5d80f --- /dev/null +++ b/knot engine/KnotStyle.h @@ -0,0 +1,53 @@ +// Drawing style for a knot, combining fill and outline strokes. +// +// Copyright © 2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#ifndef KNOTSTYLE_H +#define KNOTSTYLE_H + +#include "StrokeSet.h" + +class KnotStyle +{ +public: + // Create a KnotStyle. + KnotStyle(const char *const pName); + + // Inquiry functions. + const StrokeSet & + outline(void) const + { + return mOutline; + } + + const StrokeSet & + fill(void) const + { + return mFill; + } + +private: + KnotStyle(const KnotStyle &); + KnotStyle &operator =(const KnotStyle &); + + // Data members; + const StrokeSet mOutline; + const StrokeSet mFill; +}; + +#endif // KNOTSTYLE_H diff --git a/knot engine/RandomKnot.cpp b/knot engine/RandomKnot.cpp index 7a6c6d9..0d7dac2 100644 --- a/knot engine/RandomKnot.cpp +++ b/knot engine/RandomKnot.cpp @@ -1,402 +1,392 @@ // Base class for creating random knots. // // Copyright © 1997-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "RandomKnot.h" #include <algorithm> #include <cmath> #include <cstdlib> #include <OpenGL/gl.h> #include "KnotSection.h" +#include "KnotStyle.h" #include "Position.h" #include "RandomColor.h" #include "RandomNumbers.h" #include "StrokeSet.h" namespace { // Generate an array of random direction values. Direction * randomDirectionArray(int width, int height, GLfloat min, GLfloat max) { Direction *pArray = new Direction[width * height]; for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) { GLfloat p = randomFloat(); if (p < min) { pArray[i*width + j] = H; } else if (p < max) { pArray[i*width + j] = D; } else { pArray[i*width + j] = V; } } } return pArray; } // Enforce symmetry in an array of random direction values. void enforceSymmetry(Direction *pArray, int width, int height, int widthLimit, int heightLimit, bool xMirror, bool yMirror) { for (int i0 = 0; i0 < heightLimit; ++i0) { const int i1 = yMirror ? height - i0 - 1 : i0; for (int j0 = 0; j0 < widthLimit; ++j0) { const int j1 = xMirror ? width - j0 - 1 : j0; pArray[i1*width + j1] = pArray[i0*width + j0]; } } } } -RandomKnot::RandomKnot(int windowWidth, int windowHeight, int maxSections) +RandomKnot::RandomKnot(const KnotStyle &knotStyle, + int windowWidth, int windowHeight, int maxSections) : mWindowWidth(windowWidth), mWindowHeight(windowHeight), mHSections(3 + randomInteger(maxSections - 3)), mVSections(3 + randomInteger(maxSections - 3)), - mpOutlineStrokes(0), - mpFillStrokes(0), + mOutlineStrokes(knotStyle.outline()), + mFillStrokes(knotStyle.fill()), + mHollow(randomFloat() < mPrefs.hollowKnotProbability()), mpSectionTypes(0), mpSectionCorners(0), mpColors(0), mDisplayList(0) { - // Determine knot style. - if (randomFloat() < mPrefs.broadKnotProbability()) { - mpOutlineStrokes = &StrokeSet::broadOutline(); - mpFillStrokes = &StrokeSet::broadFill(); - } else { - mpOutlineStrokes = &StrokeSet::slenderOutline(); - mpFillStrokes = &StrokeSet::slenderFill(); - } - - mHollow = randomFloat() < mPrefs.hollowKnotProbability(); - // Initialize the knot data. Derived classes have to establish // the proper boundary conditions. mpSectionTypes = randomDirectionArray(mHSections, mVSections, mPrefs.sectionProbability1(), mPrefs.sectionProbability2()); mpSectionCorners = randomDirectionArray(mHSections + 1, mVSections + 1, mPrefs.cornerProbability1(), mPrefs.cornerProbability2()); mpSectionColors[BOT] = new int[mHSections * mVSections]; mpSectionColors[TOP] = new int[mHSections * mVSections]; if (randomFloat() < mPrefs.symmetricKnotProbability()) { // Enforce symmetries. enforceHorizontalSymmetry( randomFloat() < mPrefs.horizontalMirrorProbability()); enforceVerticalSymmetry( randomFloat() < mPrefs.verticalMirrorProbability()); } } RandomKnot::~RandomKnot(void) { delete [] mpSectionTypes; mpSectionTypes = 0; delete [] mpSectionCorners; mpSectionCorners = 0; delete [] mpSectionColors[BOT]; mpSectionColors[BOT] = 0; delete [] mpSectionColors[TOP]; mpSectionColors[TOP] = 0; delete [] mpColors; mpColors = 0; - mpOutlineStrokes = mpFillStrokes = 0; - if (mDisplayList) { glDeleteLists(mDisplayList, 1); mDisplayList = 0; } } bool RandomKnot::animate(void) { if (mTime >= mMaxTime) { return false; } // Draw the knot in its current state. draw(mBasePosition + mTime * mDirection, mAngle); // Update the state. mTime += mSpeed; mAngle += mSpin; return true; } GLuint RandomKnot::displayList(void) const { if (!mDisplayList) { mDisplayList = glGenLists(1); // Generate the display list. glNewList(mDisplayList, GL_COMPILE); { drawBasicKnot(); } glEndList(); } return mDisplayList; } void RandomKnot::enforceHorizontalSymmetry(bool mirror) { enforceSymmetry(mpSectionTypes, mHSections, mVSections, mHSections / 2, mVSections, true, mirror); enforceSymmetry(mpSectionCorners, mHSections + 1, mVSections + 1, (mHSections + 1) / 2, mVSections + 1, true, mirror); } void RandomKnot::enforceVerticalSymmetry(bool mirror) { enforceSymmetry(mpSectionTypes, mHSections, mVSections, mHSections, mVSections / 2, mirror, true); enforceSymmetry(mpSectionCorners, mHSections + 1, mVSections + 1, mHSections + 1, (mVSections + 1) / 2, mirror, true); } void RandomKnot::prepareAnimation(Position extent, bool xRepeat, bool yRepeat) { // Find a random position within the window where the knot will be visible. const GLfloat knotWidth = 2.0 * extent.x; const GLfloat knotHeight = 2.0 * extent.y; if (knotWidth < mWindowWidth && knotHeight < mWindowHeight) { mBasePosition = Position(randomFloat(mWindowWidth - knotWidth), randomFloat(mWindowHeight - knotHeight)) + extent; } else { mBasePosition = Position(randomFloat() * mWindowWidth, randomFloat() * mWindowHeight); } // Give the knot a random speed, direction, angle and spin. mSpeed = randomFloat(mPrefs.minSpeed(), mPrefs.maxSpeed()); GLfloat dir; if (randomFloat() < mPrefs.skewProbability()) { dir = randomFloat(0.0, M_PI * 2.0); if (xRepeat) { mAngle = fmod(dir + M_PI_2, M_PI * 2.0); } else if (yRepeat) { mAngle = dir; } else { mAngle = randomFloat(0.0, M_PI * 2.0); } } else { int quad; if (xRepeat) { quad = 2 * randomInteger(2) + 1; } else if (yRepeat) { quad = 2 * randomInteger(2); } else { quad = randomInteger(4); } dir = quad * M_PI_2; mAngle = 0.0; } mDirection = Position(cos(dir), sin(dir)); if (randomFloat() < mPrefs.spinProbability()) { mSpin = randomFloat(mPrefs.minSpin(), mPrefs.maxSpin()) * ((randomFloat() < 0.5) ? 1.0 : -1.0) / 180.0 * M_PI; } else { mSpin = 0.0; } // Calculate the starting and stopping times, i.e., the time at which // the knot's bounding circle is tangent to the window's bounding circle. // // - project window midpoint to point P0 on line of movement at time T0. // - use Pythagoras to compute distance from P0 to center of knot // - calculate T0 - distance and T0 + distance const Position midPosition(mWindowWidth * 0.5, mWindowHeight * 0.5); const GLfloat t0 = (midPosition - mBasePosition) * mDirection; const Position p0 = mBasePosition + t0 * mDirection; const GLfloat hyp = norm(midPosition) + norm(extent); const GLfloat cat = norm(midPosition - p0); const GLfloat distance = sqrt(hyp * hyp - cat * cat); mTime = t0 - distance; mMaxTime = t0 + distance; // Adjust the spin rate so the angle is consistent at start and stop. GLfloat iterations = floor((mMaxTime - mTime) / mSpeed); mSpin = floor(mSpin / M_PI * iterations) * M_PI / iterations; } void RandomKnot::assignColors(void) { // Initialize the color indices; -1 indicates an as-yet-unknown color. int color = mPrefs.technicolor() ? -1 : 0; for (int y = 0; y < mVSections; ++y) { for (int x = 0; x < mHSections; ++x) { mpSectionColors[BOT][y * mHSections + x] = color; mpSectionColors[TOP][y * mHSections + x] = color; } } ++color; // Assign colors to the sections by tracing all the 'strands' in the knot. for (int y = 0; y < mVSections; ++y) { for (int x = 0; x < mHSections; ++x) { if (mpSectionColors[TOP][y * mHSections + x] < 0) { // Assign a color to the top strand. if (traceColor(color, TOP, x, y, 0, 0)) { ++color; } } if (mpSectionColors[BOT][y * mHSections + x] < 0) { // Assign a color to the bottom strand. switch (mpSectionTypes[y * mHSections + x]) { case D: case H: if (traceColor(color, BOT, x, y, 0, 1)) { ++color; } break; case V: if (traceColor(color, BOT, x, y, 1, 0)) { ++color; } break; case N: break; } } } } // Generate the random colors. mpColors = new RandomColor[color]; int hue = randomInteger(360); const int gamut = 90 + randomInteger(270); const int shift = gamut / color; for (int i = 0; i < color; ++i) { mpColors[i] = RandomColor(0.4, 0.9, 0.6, 1.0, 1.0, 1.0, hue); hue = (hue + shift) % 360; } } bool RandomKnot::traceColor(int color, int layer, int x, int y, int dx, int dy) { for (;;) { mpSectionColors[layer][y * mHSections + x] = color; // Hop across the corner indicated by dx/dy. switch (mpSectionCorners[(y+dy) * (mHSections+1) + x+dx]) { case D: x = (dx ? x+1 : x-1+mHSections) % mHSections; dx = 1-dx; y = (dy ? y+1 : y-1+mVSections) % mVSections; dy = 1-dy; break; case H: x = (dx ? x+1 : x-1+mHSections) % mHSections; dx = 1-dx; break; case V: y = (dy ? y+1 : y-1+mVSections) % mVSections; dy = 1-dy; break; case N: mpSectionColors[layer][y * mHSections + x] = 0; return false; } // Decide how to continue. switch (mpSectionTypes[y * mHSections + x]) { case D: dx = 1-dx; dy = 1-dy; layer = (dx + dy) % 2 ? BOT : TOP; break; case H: dx = 1-dx; layer = dy ? BOT : TOP; break; case V: dy = 1-dy; layer = dx ? BOT : TOP; break; case N: // This can't happen. abort(); } if (mpSectionColors[layer][y * mHSections + x] == color) { // We're done with this strand. break; } else if (mpSectionColors[layer][y * mHSections + x] >= 0) { // This can't happen. abort(); } } return true; } diff --git a/knot engine/RandomKnot.h b/knot engine/RandomKnot.h index d7749ef..70daa84 100644 --- a/knot engine/RandomKnot.h +++ b/knot engine/RandomKnot.h @@ -1,152 +1,152 @@ // Abstract base class for creating random knots. // // Copyright © 1997-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #ifndef RANDOMKNOT_H #define RANDOMKNOT_H #include <OpenGL/gl.h> #include "KnotSection.h" +class KnotStyle; #include "Position.h" #include "RandomColor.h" class StrokeSet; #include "XamhainPreferences.h" class RandomKnot { public: - RandomKnot(int windowWidth, int windowHeight, int maxSections); + RandomKnot(const KnotStyle &knotStyle, + int windowWidth, int windowHeight, int maxSections); virtual ~RandomKnot(void); // Perform a single animation cycle; return 'false' when finished. bool animate(void); protected: // Return display list for drawing the basic knot. GLuint displayList(void) const; // Draw the basic knot at the origin (to set up the display list). virtual void drawBasicKnot(void) const = 0; // Enforce symmetries in the random arrays. void enforceHorizontalSymmetry(bool mirror); void enforceVerticalSymmetry(bool mirror); // Calculate animation parameters given the knot's size. void prepareAnimation(Position extent, bool xRepeat = false, bool yRepeat = false); // Assign colors to the knot. void assignColors(void); // Inquire knot data. Direction sectionType(int x, int y) const { return mpSectionTypes[y * mHSections + x]; } Direction & sectionType(int x, int y) { return mpSectionTypes[y * mHSections + x]; } Direction sectionCorner(int x, int y) const { return mpSectionCorners[y * (mHSections + 1) + x]; } Direction & sectionCorner(int x, int y) { return mpSectionCorners[y * (mHSections + 1) + x]; } const GLfloat * sectionColor(int layer, int x, int y) const { return mpColors[mpSectionColors[layer][y * mHSections + x]]; } const GLfloat * leftTopCornerColor(int x, int y) const { y = (y - 1 + mVSections) % mVSections; if (sectionType(x, y) != V) { return sectionColor(BOT, x, y); } else { return sectionColor(TOP, x, y); } } const GLfloat * rightBottomCornerColor(int x, int y) const { y = (y + 1) % mVSections; if (sectionType(x, y) != H) { return sectionColor(BOT, x, y); } else { return sectionColor(TOP, x, y); } } // Data members. + XamhainPreferences mPrefs; // user preferences const int mWindowWidth; // window size const int mWindowHeight; const int mHSections; // horizontal #sections const int mVSections; // vertical #sections - const StrokeSet *mpOutlineStrokes; // knot properties - const StrokeSet *mpFillStrokes; + const StrokeSet &mOutlineStrokes; // knot properties + const StrokeSet &mFillStrokes; bool mHollow; -protected: - XamhainPreferences mPrefs; // user preferences - private: RandomKnot(const RandomKnot &orig); RandomKnot &operator =(RandomKnot &orig); // Draw the (possibly replicated) knot. virtual void draw(Position where, GLfloat angle) const = 0; // Trace a 'strand' of the knot and assign a color to it. bool traceColor(int color, int layer, int x, int y, int dx, int dy); // Data members. Direction *mpSectionTypes; // types of sections Direction *mpSectionCorners; // corner directions int *mpSectionColors[2]; // color indices (two per section) RandomColor *mpColors; // colors Position mBasePosition; // animation data Position mDirection; GLfloat mSpeed; GLfloat mAngle; GLfloat mSpin; GLfloat mTime; GLfloat mMaxTime; mutable GLuint mDisplayList; // display list caching the basic knot }; #endif // RANDOMKNOT_H diff --git a/knot engine/RectangularKnot.cpp b/knot engine/RectangularKnot.cpp index efbfa82..6bdd615 100644 --- a/knot engine/RectangularKnot.cpp +++ b/knot engine/RectangularKnot.cpp @@ -1,89 +1,91 @@ // A class representing a random rectangular knot. // // Copyright © 2004-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "RectangularKnot.h" #include <cmath> #include <algorithm> using namespace ::std; #include <OpenGL/gl.h> #include "KnotSection.h" +class KnotStyle; #include "Position.h" #include "RandomKnot.h" #include "RandomNumbers.h" namespace { // Minimum size of knot sections. const int kMinEdgeLength = 10; } -RectangularKnot::RectangularKnot(int windowWidth, int windowHeight, +RectangularKnot::RectangularKnot(const KnotStyle &knotStyle, + int windowWidth, int windowHeight, int maxSections, int xRepeat, int yRepeat) -: inherited(windowWidth, windowHeight, maxSections) +: inherited(knotStyle, windowWidth, windowHeight, maxSections) { // Calculate dimensions of the knot. const GLfloat fraction = randomFloat(mPrefs.minSize(), mPrefs.maxSize()); const int sectionWidth = (int)(fraction * mWindowWidth / mHSections / xRepeat); const int sectionHeight = (int)(fraction * mWindowHeight / mVSections / yRepeat); mEdgeLength = max(max(sectionWidth, sectionHeight), (mHollow ? 3 : 1) * kMinEdgeLength); // Calculate the remaining properties. prepareAnimation(Position(mHSections, mVSections) * mEdgeLength * 0.5, xRepeat > 1, yRepeat > 1); } RectangularKnot::~RectangularKnot(void) { // empty } void RectangularKnot::drawBasicKnot(void) const { const Position offset = - (mEdgeLength*0.5) * Position(mHSections-1, mVSections-1); // Draw all the sections. for (int i = 0; i < mVSections; ++i) { for (int j = 0; j < mHSections; ++j) { KnotSection section(sectionType(j, i), sectionCorner(j, i), sectionCorner(j+1, i), sectionCorner(j, i+1), sectionCorner(j+1, i+1)); const GLfloat *pTopColor = sectionColor(TOP, j, i); const GLfloat *pBotColor = sectionColor(BOT, j, i); const GLfloat *pLTColor = leftTopCornerColor(j, i); const GLfloat *pRBColor = rightBottomCornerColor(j, i); section.draw(offset + mEdgeLength*Position(j, (mVSections-1 - i)), mEdgeLength, 0.0, 0.0, - *mpOutlineStrokes, *mpFillStrokes, mHollow, + mOutlineStrokes, mFillStrokes, mHollow, pTopColor, pBotColor, pLTColor, pRBColor); } } } diff --git a/knot engine/RectangularKnot.h b/knot engine/RectangularKnot.h index fc50517..8f86b68 100644 --- a/knot engine/RectangularKnot.h +++ b/knot engine/RectangularKnot.h @@ -1,56 +1,58 @@ // A class representing a random rectangular knot. // // Copyright © 2004-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #ifndef RECTANGULARKNOT_H #define RECTANGULARKNOT_H #include <OpenGL/gl.h> +class KnotStyle; #include "Position.h" #include "RandomKnot.h" class RectangularKnot : public RandomKnot { typedef RandomKnot inherited; public: - RectangularKnot(int windowWidth, int windowHeight, - int maxSections, int xRepeat = 1, int yRepeat = 1); + RectangularKnot(const KnotStyle &knotStyle, + int windowWidth, int windowHeight, + int maxSections, int xRepeat = 1, int yRepeat = 1); virtual ~RectangularKnot(void); protected: // Return the size of the basic knot. Position Size(void) const { return mEdgeLength * Position(mHSections, mVSections); } // Draw the basic knot at the origin. virtual void drawBasicKnot(void) const; private: RectangularKnot(const RectangularKnot &orig); RectangularKnot &operator =(RectangularKnot &orig); // Data members. GLfloat mEdgeLength; }; #endif // RECTANGULARKNOT_H diff --git a/knot engine/Stroke.mm b/knot engine/Stroke.mm index 49bf931..c95480b 100644 --- a/knot engine/Stroke.mm +++ b/knot engine/Stroke.mm @@ -1,258 +1,256 @@ // A single primitive stroke, represented by a GL texture. // // Copyright © 2003-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "Stroke.h" #include <algorithm> #include <cassert> #include <cmath> using namespace ::std; #include <OpenGL/gl.h> #include <OpenGL/glu.h> #include "Position.h" #include "XamhainPreferences.h" namespace { // Nominal size of a texture. - const GLsizei kTextureSize = 64; + const GLsizei kTextureSize = 128; // Internal texture format. const GLenum kTextureFormat = GL_ALPHA4; // Cache for values of trigonometric functions. class TrigFunctionCache { public: TrigFunctionCache(const GLfloat arcLength) : mSubdivisions(XamhainPreferences().knotSubdivisions()), mpSin(new GLfloat[mSubdivisions]), mpCos(new GLfloat[mSubdivisions]) { for (int i = 0; i < mSubdivisions; ++i) { const GLfloat arg = (i+1) * arcLength * 0.5 / mSubdivisions; mpSin[i] = ::sin(arg); mpCos[i] = ::cos(arg); } } ~TrigFunctionCache(void) { delete [] mpSin; delete [] mpCos; mpSin = mpCos = 0; } GLfloat sin(const int index) const { if (index) { return (index < 0) ? -mpSin[-index-1] : mpSin[index-1]; } return 0.0; } GLfloat cos(const int index) const { if (index) { return (index < 0) ? mpCos[-index-1] : mpCos[index-1]; } return 1.0; } private: TrigFunctionCache(const TrigFunctionCache &); TrigFunctionCache &operator =(const TrigFunctionCache &); // Data members. const int mSubdivisions; GLfloat *mpSin; GLfloat *mpCos; }; // Load an image resource and convert it to a bitmap. NSBitmapImageRep * loadImage(const char *const name) { // Load the (PDF) image. NSBundle *bundle = [NSBundle bundleWithIdentifier: @"de.earrame.XamhainII"]; NSString *file =[NSString stringWithCString: name encoding: NSASCIIStringEncoding]; NSString *path = [bundle pathForResource: file ofType: @"pdf"]; assert(path != nil); NSImage *image = [[NSImage alloc] initWithContentsOfFile: path]; assert(image != nil); // Create a bitmap of the desired size. NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL pixelsWide: kTextureSize pixelsHigh: kTextureSize bitsPerSample: 8 samplesPerPixel: 4 hasAlpha: YES isPlanar: NO colorSpaceName: NSDeviceRGBColorSpace bytesPerRow: 0 bitsPerPixel: 0]; // Draw the image at the desired size. [NSGraphicsContext saveGraphicsState]; [NSGraphicsContext setCurrentContext: [NSGraphicsContext graphicsContextWithBitmapImageRep: bitmap]]; const NSSize size = [image size]; const NSRect srcRect = NSMakeRect(0.0, 0.0, size.width, size.height); const NSRect dstRect = NSMakeRect(0.0, 0.0, kTextureSize, kTextureSize); - [[NSColor whiteColor] setFill]; - [NSBezierPath fillRect: dstRect]; - [image drawInRect: dstRect fromRect: srcRect operation: NSCompositeCopy fraction: 1.0]; + [[NSGraphicsContext currentContext] flushGraphics]; [NSGraphicsContext restoreGraphicsState]; return bitmap; } } Stroke::Stroke(const char *const name) : mSubdivisions(XamhainPreferences().knotSubdivisions()) { // Load image resource. NSBitmapImageRep *bitmap = loadImage(name); // Create a texture object for the stroke. glGenTextures(1, &mTexture); glBindTexture(GL_TEXTURE_2D, mTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glPixelStorei(GL_UNPACK_ROW_LENGTH, [bitmap pixelsWide]); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gluBuild2DMipmaps(GL_TEXTURE_2D, kTextureFormat, kTextureSize, kTextureSize, GL_RGBA, GL_UNSIGNED_BYTE, [bitmap bitmapData]); } Stroke::~Stroke(void) { glDeleteTextures(1, &mTexture); mTexture = 0; } void Stroke::draw(Position where, GLfloat size, GLfloat radius, GLfloat angle, const GLint transform[4]) const { if (radius <= 0.0 || angle <= 0.0) { size *= 0.5f; const GLfloat t0 = size * transform[0]; const GLfloat t1 = size * transform[1]; const GLfloat t2 = size * transform[2]; const GLfloat t3 = size * transform[3]; const GLfloat r = 1.0f; const GLfloat b = -1.0f; glBindTexture(GL_TEXTURE_2D, mTexture); glBegin(GL_POLYGON); { glTexCoord2f(0.0f, 1.0f); glVertex2f(where.x - t0 + b * t1, where.y - t2 + b * t3); glTexCoord2f(1.0f, 1.0f); glVertex2f(where.x + r * t0 + b * t1, where.y + r * t2 + b * t3); glTexCoord2f(1.0f, 0.0f); glVertex2f(where.x + r * t0 + t1, where.y + r * t2 + t3); glTexCoord2f(0.0f, 0.0f); glVertex2f(where.x - t0 + t1, where.y - t2 + t3); } glEnd(); } else { size = size * 0.5 / mSubdivisions; const GLint r = mSubdivisions; const GLint b = -mSubdivisions; const TrigFunctionCache cache(angle); glBindTexture(GL_TEXTURE_2D, mTexture); glBegin(GL_QUADS); { for (GLint x = -mSubdivisions; x < r; ++x) { for (GLint y = b; y < mSubdivisions; ++y) { const GLint x0 = x * transform[0] + y * transform[1]; const GLint y0 = x * transform[2] + y * transform[3]; const GLint x1 = (x+1) * transform[0] + y * transform[1]; const GLint y1 = (x+1) * transform[2] + y * transform[3]; const GLint x2 = (x+1) * transform[0] + (y+1) * transform[1]; const GLint y2 = (x+1) * transform[2] + (y+1) * transform[3]; const GLint x3 = x * transform[0] + (y+1) * transform[1]; const GLint y3 = x * transform[2] + (y+1) * transform[3]; const GLfloat r0 = size * x0 + radius; const GLfloat r1 = size * x1 + radius; const GLfloat r2 = size * x2 + radius; const GLfloat r3 = size * x3 + radius; glTexCoord2f( (GLfloat)(x+mSubdivisions) / (GLfloat)(r+mSubdivisions), (GLfloat)(mSubdivisions-y) / (GLfloat)(mSubdivisions-b)); glVertex2f(where.x + r0 * cache.cos(y0) - radius, where.y + r0 * cache.sin(y0)); glTexCoord2f( (GLfloat)(x+1+mSubdivisions) / (GLfloat)(r+mSubdivisions), (GLfloat)(mSubdivisions-y) / (GLfloat)(mSubdivisions-b)); glVertex2f(where.x + r1 * cache.cos(y1) - radius, where.y + r1 * cache.sin(y1)); glTexCoord2f( (GLfloat)(x+1+mSubdivisions) / (GLfloat)(r+mSubdivisions), (GLfloat)(mSubdivisions-y-1) / (GLfloat)(mSubdivisions-b)); glVertex2f(where.x + r2 * cache.cos(y2) - radius, where.y + r2 * cache.sin(y2)); glTexCoord2f( (GLfloat)(x+mSubdivisions) / (GLfloat)(r+mSubdivisions), (GLfloat)(mSubdivisions-y-1) / (GLfloat)(mSubdivisions-b)); glVertex2f(where.x + r3 * cache.cos(y3) - radius, where.y + r3 * cache.sin(y3)); } } } glEnd(); } } diff --git a/knot engine/StrokeSet.cpp b/knot engine/StrokeSet.cpp index 963720e..af12715 100644 --- a/knot engine/StrokeSet.cpp +++ b/knot engine/StrokeSet.cpp @@ -1,57 +1,63 @@ // A StrokeSet contains the 10 basic strokes from which knots are built, // plus an additional stroke used in filling in corners. // // Copyright © 2003-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "StrokeSet.h" +#include <cassert> +#include <string> +using namespace ::std; + #include "Stroke.h" -#define StaticStroke(stroke, shape, type) \ - static const Stroke Stroke_##stroke(#shape "_" #type "_" #stroke); +namespace +{ + static const string kShape[StrokeSet::NumStrokes] = + { + "DDD", "DHD", "DHH", "DHV", + "HDD", "HDH", "HDV", "HHH", "HHV", "HVV", + "corner" + }; +} + +StrokeSet::StrokeSet(const char *const pStyle, const char *const pType) +: mPrefix(string(pStyle) + string("_") + string(pType) + string("_")) +{ + for (int i = 0; i < NumStrokes; ++i) { + mpStrokes[i] = 0; + } +} -#define StaticStrokeSet(name, shape, type) \ - const StrokeSet & \ - StrokeSet::name(void) \ - { \ - StaticStroke(DDD, shape, type); \ - StaticStroke(DHD, shape, type); \ - StaticStroke(DHH, shape, type); \ - StaticStroke(DHV, shape, type); \ - StaticStroke(HDD, shape, type); \ - StaticStroke(HDH, shape, type); \ - StaticStroke(HDV, shape, type); \ - StaticStroke(HHH, shape, type); \ - StaticStroke(HHV, shape, type); \ - StaticStroke(HVV, shape, type); \ - StaticStroke(corner, shape, type); \ - \ - static const Stroke *const pStrokes[NumStrokes] = { \ - &Stroke_DDD, &Stroke_DHD, &Stroke_DHH, &Stroke_DHV, &Stroke_HDD, \ - &Stroke_HDH, &Stroke_HDV, &Stroke_HHH, &Stroke_HHV, &Stroke_HVV, \ - &Stroke_corner, \ - }; \ - static const StrokeSet theSet(pStrokes); \ - \ - return theSet; \ +StrokeSet::~StrokeSet(void) +{ + for (int i = 0; i < NumStrokes; ++i) { + delete mpStrokes[i]; } +} -StaticStrokeSet(broadFill, broad, fill) -StaticStrokeSet(broadOutline, broad, outline) -StaticStrokeSet(slenderFill, slender, fill) -StaticStrokeSet(slenderOutline, slender, outline) +const Stroke & +StrokeSet::operator [](unsigned int index) const +{ + assert(index < NumStrokes); + if (!mpStrokes[index]) { + const string name = mPrefix + kShape[index]; + mpStrokes[index] = new Stroke(name.c_str()); + } + return *mpStrokes[index]; +} diff --git a/knot engine/StrokeSet.h b/knot engine/StrokeSet.h index f7bd061..9e6a483 100644 --- a/knot engine/StrokeSet.h +++ b/knot engine/StrokeSet.h @@ -1,72 +1,57 @@ // A StrokeSet contains the 10 basic strokes from which knots are built, // plus an additional stroke used in filling in corners. // // Copyright © 2003-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #ifndef STROKESET_H #define STROKESET_H -#include <cassert> +#include <string> -#include "Stroke.h" +class Stroke; class StrokeSet { public: // Stroke types. enum { DDD, DHD, DHH, DHV, HDD, HDH, HDV, HHH, HHV, HVV, Corner, NumStrokes }; - // Singleton objects which contain strokes for different knot styles. - static const StrokeSet & - broadFill(void); - static const StrokeSet & - broadOutline(void); + // Construct a set of strokes of a given style and type. + StrokeSet(const char *const pStyle, const char *const pType); - static const StrokeSet & - slenderFill(void); - static const StrokeSet & - slenderOutline(void); + // Destroy the StrokeSet. + ~StrokeSet(void); // Return a Stroke of the given type. const Stroke & - operator [](unsigned int index) const - { - assert(index < NumStrokes); - return *mppStrokes[index]; - } + operator [](unsigned int index) const; private: - // Construct from an array of Stroke objects. - StrokeSet(const Stroke *const pStrokes[NumStrokes]) - : mppStrokes(pStrokes) - { - // empty - } - StrokeSet(const StrokeSet &); StrokeSet &operator =(const StrokeSet &); // Data members. - const Stroke *const *const mppStrokes; + const ::std::string mPrefix; + mutable const Stroke *mpStrokes[NumStrokes]; }; #endif // STROKESET_H diff --git a/knot engine/TiledKnot.cpp b/knot engine/TiledKnot.cpp index 7ce0127..654ee61 100644 --- a/knot engine/TiledKnot.cpp +++ b/knot engine/TiledKnot.cpp @@ -1,150 +1,153 @@ // A class representing a random tiled knot. // // Copyright © 2004-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "TiledKnot.h" #include <algorithm> #include <cmath> using namespace ::std; #include <OpenGL/gl.h> #include "KnotSection.h" +class KnotStyle; #include "Position.h" #include "RandomNumbers.h" namespace { int kMaxSections = 6; } -TiledKnot::TiledKnot(int windowWidth, int windowHeight, Position tilingDirection) -: inherited(windowWidth, windowHeight, +TiledKnot::TiledKnot(const KnotStyle &knotStyle, + int windowWidth, int windowHeight, Position tilingDirection) +: inherited(knotStyle, + windowWidth, windowHeight, kMaxSections, tilingDirection.x ? 4 + randomInteger(4) : 1, tilingDirection.y ? 4 + randomInteger(4) : 1), mTilingDirection(tilingDirection) { // empty } TiledKnot::~TiledKnot(void) { // empty } // Find the intersection of the line (p0 + t*d) with the line through pe // with normal n. If no such intersection exists, return 'false'; // otherwise set t to the parameter value at the intersection point // and return 'true'. bool TiledKnot::clipLine(Position p0, Position d, Position pe, Position n, GLfloat &t) const { const GLfloat dot = n * d; if (fabs(dot) < 0.00001) { // Near parallel lines. return false; } // See Foley et.al. t = (n * (p0 - pe)) / -dot; return true; } // Find two values of the parameter t bounding the visible part of the line // (p0 + t*d). (We don't care about the case that the line is completely // invisible.) void TiledKnot::findBounds(Position p0, Position d, GLfloat t[2]) const { const GLfloat diag = norm(Size()); bool clipH, clipV; GLfloat tt[4]; // Clip against lower and upper borders of window. clipH = clipLine(p0, d, Position(-mWindowWidth, -diag), Position(0.0, -1.0), tt[0]) && clipLine(p0, d, Position(-mWindowWidth, mWindowHeight+diag), Position(0.0, 1.0), tt[1]); // Clip against left and right borders of window. clipV = clipLine(p0, d, Position(-diag, -mWindowHeight), Position(-1.0, 0.0), tt[2]) && clipLine(p0, d, Position(mWindowWidth+diag, -mWindowHeight), Position(1.0, 0.0), tt[3]); // Sort the intersections. sort(clipH ? (tt + 0) : (tt + 2), clipV ? (tt + 4) : (tt + 2)); if (clipH && clipV) { // Find two intersections on opposite sides of the window. const Position midPosition(mWindowWidth * 0.5, mWindowHeight * 0.5); const GLfloat tm = (midPosition - p0) * d; const GLfloat *const p = lower_bound(tt + 0, tt + 4, tm); if (p > tt + 0 && p < tt + 4) { t[0] = p[-1]; t[1] = p[0]; } else { // This shouldn't hapen, but... t[0] = t[1] = 0; } } else if (!clipH) { t[0] = tt[2]; t[1] = tt[3]; } else { t[0] = tt[0]; t[1] = tt[1]; } } void TiledKnot::draw(Position where, GLfloat angle) const { const Position size(Size()); const GLfloat step = size * mTilingDirection; const GLfloat rot[4] = { mTilingDirection.x, -mTilingDirection.y, mTilingDirection.y, mTilingDirection.x }; const Position d = rot * Position(cos(angle), sin(angle)); // Find the limits of visibility. GLfloat t[2]; findBounds(where, d, t); const int minI = (int)floor(t[0] / step); const int maxI = (int)ceil(t[1] / step); // Draw the knot. for (int i = minI; i <= maxI; ++i) { const Position pos = where + i * step * d; glPushMatrix(); { glTranslatef(pos.x, pos.y, 0.0); glRotatef(angle * 180.0 / M_PI, 0.0, 0.0, 1.0); glCallList(displayList()); } glPopMatrix(); } } diff --git a/knot engine/TiledKnot.h b/knot engine/TiledKnot.h index 9fbf5e0..48fcef7 100644 --- a/knot engine/TiledKnot.h +++ b/knot engine/TiledKnot.h @@ -1,54 +1,56 @@ // A class representing a random tiled knot. // // Copyright © 2004-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #ifndef TILEDKNOT_H #define TILEDKNOT_H #include <OpenGL/gl.h> +class KnotStyle; #include "Position.h" #include "RectangularKnot.h" class TiledKnot : public RectangularKnot { typedef RectangularKnot inherited; public: - TiledKnot(int windowWidth, int windowHeight, Position tilingDirection); + TiledKnot(const KnotStyle &knotStyle, + int windowWidth, int windowHeight, Position tilingDirection); virtual ~TiledKnot(void); private: TiledKnot(const TiledKnot &orig); TiledKnot &operator =(TiledKnot &orig); // Clip line (p0 + t*d) at a window boundary. bool clipLine(Position p0, Position d, Position pe, Position n, GLfloat &t) const; // Find two parameter values between which the knot will be visible. void findBounds(Position p0, Position d, GLfloat t[2]) const; // Draw the (replicated) knot. virtual void draw(Position where, GLfloat angle) const; // Data members. const Position mTilingDirection; }; #endif // TILEDKNOT_H diff --git a/knot engine/VerticalKnot.cpp b/knot engine/VerticalKnot.cpp index edf93d4..a616921 100644 --- a/knot engine/VerticalKnot.cpp +++ b/knot engine/VerticalKnot.cpp @@ -1,49 +1,51 @@ // A class representing a random vertically tileable knot. // // Copyright © 1997-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "VerticalKnot.h" #include "KnotSection.h" +class KnotStyle; #include "Position.h" #include "TiledKnot.h" #include "RandomNumbers.h" -VerticalKnot::VerticalKnot(int width, int height) -: inherited(width, height, Position(0.0, 1.0)) +VerticalKnot::VerticalKnot(const KnotStyle &knotStyle, + int width, int height) +: inherited(knotStyle, width, height, Position(0.0, 1.0)) { // Set boundary conditions for a vertical knot. // The left and right borders must have vertical corners. for (int i = 0; i <= mVSections; ++i) { sectionCorner(0, i) = sectionCorner(mHSections, i) = V; } // The top and bottom borders must match. for (int i = 1; i < mHSections; ++i) { sectionCorner(i, mVSections) = sectionCorner(i, 0); } // Assign colors to the knot. assignColors(); } VerticalKnot::~VerticalKnot(void) { // empty } diff --git a/knot engine/VerticalKnot.h b/knot engine/VerticalKnot.h index dc7a411..0a23382 100644 --- a/knot engine/VerticalKnot.h +++ b/knot engine/VerticalKnot.h @@ -1,37 +1,39 @@ // A class representing a random vertically tileable knot. // // Copyright © 1997-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #ifndef VERTICALKNOT_H #define VERTICALKNOT_H +class KnotStyle; #include "TiledKnot.h" class VerticalKnot : public TiledKnot { typedef TiledKnot inherited; public: - VerticalKnot(int windowWidth, int windowHeight); + VerticalKnot(const KnotStyle &knotStyle, + int windowWidth, int windowHeight); virtual ~VerticalKnot(void); private: VerticalKnot(const VerticalKnot &orig); VerticalKnot &operator =(VerticalKnot &orig); }; #endif // VERTICALKNOT_H diff --git a/screen saving/XamhainGLView.h b/screen saving/XamhainGLView.h index f74c67f..4665705 100644 --- a/screen saving/XamhainGLView.h +++ b/screen saving/XamhainGLView.h @@ -1,32 +1,41 @@ // XamhainII OpenGL view. // // Copyright © 2009, Jens Kilian. // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #import <AppKit/NSOpenGLView.h> +class KnotStyle; class RandomKnot; class XamhainPreferences; @interface XamhainGLView : NSOpenGLView { XamhainPreferences *mpPrefs; // user defaults - RandomKnot **mppKnots; // knots being animated + + KnotStyle *mpBroadStyle; // knot styles + KnotStyle *mpSlenderStyle; + + int mNumberOfKnots; // knots being animated + RandomKnot **mppKnots; } +- (void) startAnimation; +- (void) stopAnimation; + @end diff --git a/screen saving/XamhainGLView.mm b/screen saving/XamhainGLView.mm index 56aa15f..2090c83 100644 --- a/screen saving/XamhainGLView.mm +++ b/screen saving/XamhainGLView.mm @@ -1,153 +1,196 @@ // XamhainII OpenGL view. // // Copyright © 2009, Jens Kilian. // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #import "XamhainGLView.h" #include <algorithm> using namespace ::std; #include <OpenGL/gl.h> #include "CircularKnot.h" #include "ClosedKnot.h" #include "HorizontalKnot.h" +#include "KnotStyle.h" #include "RandomNumbers.h" #include "VerticalKnot.h" namespace { // Knot types. enum KnotType { kClosed, kCircular, kHorizontal, kVertical }; } @implementation XamhainGLView + (NSOpenGLPixelFormat *) defaultPixelFormat { static const NSOpenGLPixelFormatAttribute attributes[] = { NSOpenGLPFADoubleBuffer, 0 }; return [[NSOpenGLPixelFormat alloc] initWithAttributes: attributes]; } -- (XamhainGLView *) initWithFrame: (NSRect)frame +- (id) initWithFrame: (NSRect)frame { self = [super initWithFrame: frame]; if (self) { mpPrefs = new XamhainPreferences; - mppKnots = new RandomKnot *[mpPrefs->numberOfKnots()]; - fill(mppKnots, mppKnots + mpPrefs->numberOfKnots(), (RandomKnot *)0); + + mpSlenderStyle = mpBroadStyle = 0; + + mppKnots = 0; } return self; } -- (void) finalize +- (void) startAnimation +{ + mpBroadStyle = new KnotStyle("broad"); + mpSlenderStyle = new KnotStyle("slender"); + + mNumberOfKnots = mpPrefs->numberOfKnots(); + mppKnots = new RandomKnot *[mNumberOfKnots]; + fill(mppKnots, mppKnots + mNumberOfKnots, (RandomKnot *)0); +} + +- (void) stopAnimation { if (mppKnots) { - for (int i = 0; i < mpPrefs->numberOfKnots(); ++i) { + for (int i = 0; i < mNumberOfKnots; ++i) { delete mppKnots[i]; } delete [] mppKnots; + mppKnots = 0; } + + delete mpSlenderStyle; + delete mpBroadStyle; + mpSlenderStyle = mpBroadStyle = 0; +} + +- (void) finalize +{ delete mpPrefs; [super finalize]; } - (void) prepareOpenGL { + const GLint one = 1; + [[self openGLContext] setValues: &one forParameter: NSOpenGLCPSwapInterval]; + glClearColor(0.0, 0.0, 0.0, 1.0); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_TEXTURE_2D); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } -- (void) drawRect: (NSRect)bounds +- (void) reshape { - const int width = bounds.size.width; - const int height = bounds.size.height; + const NSSize size = [self bounds].size; + const int width = size.width; + const int height = size.height; glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, width, 0.0, height, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); +} + +- (void) drawRect: (NSRect)dirtyRect +{ + (void)dirtyRect; glClear(GL_COLOR_BUFFER_BIT); - for (int i = 0; i < mpPrefs->numberOfKnots(); ++i) { - if (!mppKnots[i]) { - // Determine knot type. - KnotType type = kCircular; - GLfloat p = randomFloat(); - - if ((p -= mpPrefs->horizontalKnotProbability()) < 0.0) { - type = kHorizontal; - } else if ((p -= mpPrefs->verticalKnotProbability()) < 0.0) { - type = kVertical; - } else if ((p -= mpPrefs->closedKnotProbability()) < 0.0) { - type = kClosed; + if (mppKnots) { + const NSSize size = [self bounds].size; + const int width = size.width; + const int height = size.height; + + for (int i = 0; i < mNumberOfKnots; ++i) { + if (!mppKnots[i]) { + // Determine knot style. + const KnotStyle &style = + randomFloat() < mpPrefs->broadKnotProbability() + ? *mpBroadStyle + : *mpSlenderStyle; + + // Determine knot type. + KnotType type = kCircular; + GLfloat p = randomFloat(); + + if ((p -= mpPrefs->horizontalKnotProbability()) < 0.0) { + type = kHorizontal; + } else if ((p -= mpPrefs->verticalKnotProbability()) < 0.0) { + type = kVertical; + } else if ((p -= mpPrefs->closedKnotProbability()) < 0.0) { + type = kClosed; + } + + switch (type) { + + case kClosed: + mppKnots[i] = new ClosedKnot(style, width, height); + break; + + case kCircular: + mppKnots[i] = new CircularKnot(style, width, height); + break; + + case kHorizontal: + mppKnots[i] = new HorizontalKnot(style, width, height); + break; + + case kVertical: + mppKnots[i] = new VerticalKnot(style, width, height); + break; + } } - switch (type) { - - case kClosed: - mppKnots[i] = new ClosedKnot(width, height); - break; - - case kCircular: - mppKnots[i] = new CircularKnot(width, height); - break; - - case kHorizontal: - mppKnots[i] = new HorizontalKnot(width, height); - break; - - case kVertical: - mppKnots[i] = new VerticalKnot(width, height); - break; + if (!mppKnots[i]->animate()) { + delete mppKnots[i]; + mppKnots[i] = 0; } } - - if (!mppKnots[i]->animate()) { - delete mppKnots[i]; - mppKnots[i] = 0; - } } [[self openGLContext] flushBuffer]; } @end diff --git a/screen saving/XamhainView.mm b/screen saving/XamhainView.mm index 3ac7ad7..c366db7 100644 --- a/screen saving/XamhainView.mm +++ b/screen saving/XamhainView.mm @@ -1,66 +1,78 @@ // XamhainII screen saver view. // // Copyright © 2009, Jens Kilian. // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #import "XamhainView.h" #import "XamhainGLView.h" #include "XamhainPreferences.h" @implementation XamhainView - (id) initWithFrame: (NSRect)frame isPreview: (BOOL)isPreview { self = [super initWithFrame: frame isPreview: isPreview]; if (self) { XamhainPreferences prefs; [self setAnimationTimeInterval: 1.0/prefs.ticksPerSecond()]; const NSRect childFrame = NSOffsetRect(frame, -frame.origin.x, -frame.origin.y); mpGLView = [[XamhainGLView alloc] initWithFrame: childFrame]; if (mpGLView) { [self addSubview: mpGLView]; } else { NSLog(@"Failed to create XamhainGLView."); } } else { NSLog(@"Failed to create XamhainView"); } return self; } +- (void) startAnimation +{ + [super startAnimation]; + [mpGLView startAnimation]; +} + +- (void) stopAnimation +{ + [super stopAnimation]; + [mpGLView stopAnimation]; +} + - (void) animateOneFrame { [mpGLView setNeedsDisplay: YES]; } -- (BOOL)hasConfigureSheet +- (BOOL) hasConfigureSheet { return NO; } - (NSWindow *) configureSheet { return nil; } @end
jjk/XamhainII
b384dbfa0406c4b0f2b9cd765fad8d0ded2caaf7
First working version.
diff --git a/XamhainII.xcodeproj/project.pbxproj b/XamhainII.xcodeproj/project.pbxproj index 41413ec..f60637f 100644 --- a/XamhainII.xcodeproj/project.pbxproj +++ b/XamhainII.xcodeproj/project.pbxproj @@ -1,728 +1,712 @@ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 45; objects = { /* Begin PBXAggregateTarget section */ 000D03D61089C45F003F010E /* XamhainII.dmg */ = { isa = PBXAggregateTarget; buildConfigurationList = 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */; buildPhases = ( 000D03D51089C45F003F010E /* ShellScript */, ); dependencies = ( 000D03DA1089C465003F010E /* PBXTargetDependency */, ); name = XamhainII.dmg; productName = XamhainII.dmg; }; /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ - 001EA1D7109365FC00D05EFB /* XamhainGLView.h in Headers */ = {isa = PBXBuildFile; fileRef = 001EA1D5109365FC00D05EFB /* XamhainGLView.h */; }; - 001EA1D8109365FC00D05EFB /* XamhainGLView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 001EA1D6109365FC00D05EFB /* XamhainGLView.mm */; }; 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0032D325108A30770033FA87 /* OpenGL.framework */; }; 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00791842108B081B00156D67 /* XamhainPreferences.mm */; }; 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007C5127108A29BE00ED3242 /* RandomColor.cpp */; }; 007ED8661090CD6800B01235 /* CircularKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8581090CD6800B01235 /* CircularKnot.cpp */; }; - 007ED8671090CD6800B01235 /* CircularKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED8591090CD6800B01235 /* CircularKnot.h */; }; 007ED8681090CD6800B01235 /* ClosedKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED85A1090CD6800B01235 /* ClosedKnot.cpp */; }; - 007ED8691090CD6800B01235 /* ClosedKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED85B1090CD6800B01235 /* ClosedKnot.h */; }; 007ED86A1090CD6800B01235 /* HorizontalKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED85C1090CD6800B01235 /* HorizontalKnot.cpp */; }; - 007ED86B1090CD6800B01235 /* HorizontalKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED85D1090CD6800B01235 /* HorizontalKnot.h */; }; 007ED86C1090CD6800B01235 /* RandomKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED85E1090CD6800B01235 /* RandomKnot.cpp */; }; - 007ED86D1090CD6800B01235 /* RandomKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED85F1090CD6800B01235 /* RandomKnot.h */; }; 007ED86E1090CD6800B01235 /* RectangularKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8601090CD6800B01235 /* RectangularKnot.cpp */; }; - 007ED86F1090CD6800B01235 /* RectangularKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED8611090CD6800B01235 /* RectangularKnot.h */; }; 007ED8701090CD6800B01235 /* TiledKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8621090CD6800B01235 /* TiledKnot.cpp */; }; - 007ED8711090CD6800B01235 /* TiledKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED8631090CD6800B01235 /* TiledKnot.h */; }; 007ED8721090CD6800B01235 /* VerticalKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8641090CD6800B01235 /* VerticalKnot.cpp */; }; - 007ED8731090CD6800B01235 /* VerticalKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED8651090CD6800B01235 /* VerticalKnot.h */; }; 009D8964108E251800A416CF /* Stroke.mm in Sources */ = {isa = PBXBuildFile; fileRef = 009D8962108E251800A416CF /* Stroke.mm */; }; 009D897C108E28C800A416CF /* StrokeSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 009D897A108E28C800A416CF /* StrokeSet.cpp */; }; + 00D188B11094BA31004E4496 /* XamhainGLView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 001EA1D6109365FC00D05EFB /* XamhainGLView.mm */; }; 00D7B656108F8E9A00432E90 /* KnotSection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00D7B654108F8E9A00432E90 /* KnotSection.cpp */; }; 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */; }; 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */; }; 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */; }; 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */; }; 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */; }; 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */; }; 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */; }; 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */; }; 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */; }; 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */; }; 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */; }; 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */; }; 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */; }; 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */; }; 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */; }; 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */; }; 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */; }; 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */; }; 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */; }; 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */; }; 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */; }; 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */; }; 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */; }; 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */; }; 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */; }; 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */; }; 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */; }; 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */; }; 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */; }; 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */; }; 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */; }; 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */; }; 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */; }; 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */; }; 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */; }; 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */; }; 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */; }; 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */; }; 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */; }; 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */; }; 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */; }; 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */; }; 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */; }; 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */; }; 00DA7838107A73320094FCAB /* XamhainView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00DA7836107A73320094FCAB /* XamhainView.mm */; }; 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 000D03D91089C465003F010E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 089C1669FE841209C02AAC07 /* Project object */; proxyType = 1; remoteGlobalIDString = 8D255AC50486D3F9007BF209; remoteInfo = XamhainII; }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ 001EA1D5109365FC00D05EFB /* XamhainGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainGLView.h; path = "screen saving/XamhainGLView.h"; sourceTree = "<group>"; }; 001EA1D6109365FC00D05EFB /* XamhainGLView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainGLView.mm; path = "screen saving/XamhainGLView.mm"; sourceTree = "<group>"; }; 0032D325108A30770033FA87 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; }; 00791842108B081B00156D67 /* XamhainPreferences.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainPreferences.mm; path = "screen saving/XamhainPreferences.mm"; sourceTree = "<group>"; }; 00791843108B081B00156D67 /* XamhainPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainPreferences.h; path = "screen saving/XamhainPreferences.h"; sourceTree = "<group>"; }; 007C5126108A29BE00ED3242 /* Position.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Position.h; path = utility/Position.h; sourceTree = "<group>"; }; 007C5127108A29BE00ED3242 /* RandomColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RandomColor.cpp; path = utility/RandomColor.cpp; sourceTree = "<group>"; }; 007C5128108A29BE00ED3242 /* RandomColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomColor.h; path = utility/RandomColor.h; sourceTree = "<group>"; }; 007C5129108A29BE00ED3242 /* RandomNumbers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomNumbers.h; path = utility/RandomNumbers.h; sourceTree = "<group>"; }; 007ED8581090CD6800B01235 /* CircularKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CircularKnot.cpp; path = "knot engine/CircularKnot.cpp"; sourceTree = "<group>"; }; 007ED8591090CD6800B01235 /* CircularKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CircularKnot.h; path = "knot engine/CircularKnot.h"; sourceTree = "<group>"; }; 007ED85A1090CD6800B01235 /* ClosedKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClosedKnot.cpp; path = "knot engine/ClosedKnot.cpp"; sourceTree = "<group>"; }; 007ED85B1090CD6800B01235 /* ClosedKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClosedKnot.h; path = "knot engine/ClosedKnot.h"; sourceTree = "<group>"; }; 007ED85C1090CD6800B01235 /* HorizontalKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HorizontalKnot.cpp; path = "knot engine/HorizontalKnot.cpp"; sourceTree = "<group>"; }; 007ED85D1090CD6800B01235 /* HorizontalKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HorizontalKnot.h; path = "knot engine/HorizontalKnot.h"; sourceTree = "<group>"; }; 007ED85E1090CD6800B01235 /* RandomKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RandomKnot.cpp; path = "knot engine/RandomKnot.cpp"; sourceTree = "<group>"; }; 007ED85F1090CD6800B01235 /* RandomKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomKnot.h; path = "knot engine/RandomKnot.h"; sourceTree = "<group>"; }; 007ED8601090CD6800B01235 /* RectangularKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RectangularKnot.cpp; path = "knot engine/RectangularKnot.cpp"; sourceTree = "<group>"; }; 007ED8611090CD6800B01235 /* RectangularKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RectangularKnot.h; path = "knot engine/RectangularKnot.h"; sourceTree = "<group>"; }; 007ED8621090CD6800B01235 /* TiledKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TiledKnot.cpp; path = "knot engine/TiledKnot.cpp"; sourceTree = "<group>"; }; 007ED8631090CD6800B01235 /* TiledKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiledKnot.h; path = "knot engine/TiledKnot.h"; sourceTree = "<group>"; }; 007ED8641090CD6800B01235 /* VerticalKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VerticalKnot.cpp; path = "knot engine/VerticalKnot.cpp"; sourceTree = "<group>"; }; 007ED8651090CD6800B01235 /* VerticalKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VerticalKnot.h; path = "knot engine/VerticalKnot.h"; sourceTree = "<group>"; }; 009D8962108E251800A416CF /* Stroke.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Stroke.mm; path = "knot engine/Stroke.mm"; sourceTree = "<group>"; }; 009D8963108E251800A416CF /* Stroke.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Stroke.h; path = "knot engine/Stroke.h"; sourceTree = "<group>"; }; 009D897A108E28C800A416CF /* StrokeSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StrokeSet.cpp; path = "knot engine/StrokeSet.cpp"; sourceTree = "<group>"; }; 009D897B108E28C800A416CF /* StrokeSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StrokeSet.h; path = "knot engine/StrokeSet.h"; sourceTree = "<group>"; }; 00D7B654108F8E9A00432E90 /* KnotSection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KnotSection.cpp; path = "knot engine/KnotSection.cpp"; sourceTree = "<group>"; }; 00D7B655108F8E9A00432E90 /* KnotSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KnotSection.h; path = "knot engine/KnotSection.h"; sourceTree = "<group>"; }; 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA7835107A73320094FCAB /* XamhainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainView.h; path = "screen saving/XamhainView.h"; sourceTree = "<group>"; }; 00DA7836107A73320094FCAB /* XamhainView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainView.mm; path = "screen saving/XamhainView.mm"; sourceTree = "<group>"; }; 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ScreenSaver.framework; path = /System/Library/Frameworks/ScreenSaver.framework; sourceTree = "<absolute>"; }; 089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; 089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; }; 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; }; 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XamhainII_Prefix.pch; sourceTree = "<group>"; }; 8D255AD20486D3F9007BF209 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; 8D255AD30486D3F9007BF209 /* XamhainII.saver */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XamhainII.saver; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 8D255ACD0486D3F9007BF209 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */, 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */, 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 007C5125108A299800ED3242 /* Utility */ = { isa = PBXGroup; children = ( 007C5126108A29BE00ED3242 /* Position.h */, 007C5127108A29BE00ED3242 /* RandomColor.cpp */, 007C5128108A29BE00ED3242 /* RandomColor.h */, 007C5129108A29BE00ED3242 /* RandomNumbers.h */, ); name = Utility; sourceTree = "<group>"; }; 009D8961108E24ED00A416CF /* Knot Engine */ = { isa = PBXGroup; children = ( 007ED8581090CD6800B01235 /* CircularKnot.cpp */, 007ED8591090CD6800B01235 /* CircularKnot.h */, 007ED85A1090CD6800B01235 /* ClosedKnot.cpp */, 007ED85B1090CD6800B01235 /* ClosedKnot.h */, 007ED85C1090CD6800B01235 /* HorizontalKnot.cpp */, 007ED85D1090CD6800B01235 /* HorizontalKnot.h */, 007ED85E1090CD6800B01235 /* RandomKnot.cpp */, 007ED85F1090CD6800B01235 /* RandomKnot.h */, 007ED8601090CD6800B01235 /* RectangularKnot.cpp */, 007ED8611090CD6800B01235 /* RectangularKnot.h */, 007ED8621090CD6800B01235 /* TiledKnot.cpp */, 007ED8631090CD6800B01235 /* TiledKnot.h */, 007ED8641090CD6800B01235 /* VerticalKnot.cpp */, 007ED8651090CD6800B01235 /* VerticalKnot.h */, 00D7B654108F8E9A00432E90 /* KnotSection.cpp */, 00D7B655108F8E9A00432E90 /* KnotSection.h */, 009D897A108E28C800A416CF /* StrokeSet.cpp */, 009D897B108E28C800A416CF /* StrokeSet.h */, 009D8962108E251800A416CF /* Stroke.mm */, 009D8963108E251800A416CF /* Stroke.h */, ); name = "Knot Engine"; sourceTree = "<group>"; }; 00DA77D5107A728C0094FCAB /* Strokes */ = { isa = PBXGroup; children = ( 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */, 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */, 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */, 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */, 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */, 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */, 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */, 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */, 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */, 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */, 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */, 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */, 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */, 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */, 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */, 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */, 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */, 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */, 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */, 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */, 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */, 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */, 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */, 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */, 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */, 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */, 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */, 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */, 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */, 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */, 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */, 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */, 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */, 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */, 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */, 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */, 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */, 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */, 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */, 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */, 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */, 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */, 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */, 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */, ); name = Strokes; path = strokes; sourceTree = "<group>"; }; 00DA7833107A72F00094FCAB /* Screen Saving */ = { isa = PBXGroup; children = ( 001EA1D5109365FC00D05EFB /* XamhainGLView.h */, 001EA1D6109365FC00D05EFB /* XamhainGLView.mm */, 00791842108B081B00156D67 /* XamhainPreferences.mm */, 00791843108B081B00156D67 /* XamhainPreferences.h */, 00DA7835107A73320094FCAB /* XamhainView.h */, 00DA7836107A73320094FCAB /* XamhainView.mm */, ); name = "Screen Saving"; sourceTree = "<group>"; }; 089C166AFE841209C02AAC07 /* XamhainII */ = { isa = PBXGroup; children = ( 009D8961108E24ED00A416CF /* Knot Engine */, 00DA7833107A72F00094FCAB /* Screen Saving */, 007C5125108A299800ED3242 /* Utility */, 32DBCFA70370C4F300C91783 /* Other Sources */, 089C167CFE841241C02AAC07 /* Resources */, 089C1671FE841209C02AAC07 /* Frameworks and Libraries */, 19C28FB8FE9D52D311CA2CBB /* Products */, ); name = XamhainII; sourceTree = "<group>"; }; 089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = { isa = PBXGroup; children = ( 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */, 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */, ); name = "Frameworks and Libraries"; sourceTree = "<group>"; }; 089C167CFE841241C02AAC07 /* Resources */ = { isa = PBXGroup; children = ( 00DA77D5107A728C0094FCAB /* Strokes */, 8D255AD20486D3F9007BF209 /* Info.plist */, 089C167DFE841241C02AAC07 /* InfoPlist.strings */, ); name = Resources; sourceTree = "<group>"; }; 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = { isa = PBXGroup; children = ( 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, 0032D325108A30770033FA87 /* OpenGL.framework */, 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */, ); name = "Linked Frameworks"; sourceTree = "<group>"; }; 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = { isa = PBXGroup; children = ( 089C1672FE841209C02AAC07 /* Foundation.framework */, 089C167FFE841241C02AAC07 /* AppKit.framework */, ); name = "Other Frameworks"; sourceTree = "<group>"; }; 19C28FB8FE9D52D311CA2CBB /* Products */ = { isa = PBXGroup; children = ( 8D255AD30486D3F9007BF209 /* XamhainII.saver */, ); name = Products; sourceTree = "<group>"; }; 32DBCFA70370C4F300C91783 /* Other Sources */ = { isa = PBXGroup; children = ( 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */, ); name = "Other Sources"; sourceTree = "<group>"; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ 8D255AC60486D3F9007BF209 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 007ED8671090CD6800B01235 /* CircularKnot.h in Headers */, - 007ED8691090CD6800B01235 /* ClosedKnot.h in Headers */, - 007ED86B1090CD6800B01235 /* HorizontalKnot.h in Headers */, - 007ED86D1090CD6800B01235 /* RandomKnot.h in Headers */, - 007ED86F1090CD6800B01235 /* RectangularKnot.h in Headers */, - 007ED8711090CD6800B01235 /* TiledKnot.h in Headers */, - 007ED8731090CD6800B01235 /* VerticalKnot.h in Headers */, - 001EA1D7109365FC00D05EFB /* XamhainGLView.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ 8D255AC50486D3F9007BF209 /* XamhainII */ = { isa = PBXNativeTarget; buildConfigurationList = EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */; buildPhases = ( 8D255AC60486D3F9007BF209 /* Headers */, 8D255AC90486D3F9007BF209 /* Resources */, 8D255ACB0486D3F9007BF209 /* Sources */, 8D255ACD0486D3F9007BF209 /* Frameworks */, 8D255AD00486D3F9007BF209 /* Rez */, ); buildRules = ( ); dependencies = ( ); name = XamhainII; productInstallPath = "$(HOME)/Library/Screen Savers"; productName = XamhainII; productReference = 8D255AD30486D3F9007BF209 /* XamhainII.saver */; productType = "com.apple.product-type.bundle"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 089C1669FE841209C02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */; compatibilityVersion = "Xcode 3.1"; hasScannedForEncodings = 1; mainGroup = 089C166AFE841209C02AAC07 /* XamhainII */; projectDirPath = ""; projectRoot = ""; targets = ( 8D255AC50486D3F9007BF209 /* XamhainII */, 000D03D61089C45F003F010E /* XamhainII.dmg */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ 8D255AC90486D3F9007BF209 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */, 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */, 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */, 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */, 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */, 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */, 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */, 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */, 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */, 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */, 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */, 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */, 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */, 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */, 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */, 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */, 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */, 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */, 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */, 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */, 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */, 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */, 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */, 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */, 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */, 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */, 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */, 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */, 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */, 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */, 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */, 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */, 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */, 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */, 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */, 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */, 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */, 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */, 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */, 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */, 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */, 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */, 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */, 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */, 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXRezBuildPhase section */ 8D255AD00486D3F9007BF209 /* Rez */ = { isa = PBXRezBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXRezBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ 000D03D51089C45F003F010E /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.saver", ); outputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.dmg", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "# Thanks to Rob Mayoff for explaining how to do this.\n# See http://qwan.org/2007/05/22/using-xcode-to-build-a-disk-image-and-upload-a-web-site/\n\nset -ex\n\n[ \"$ACTION\" = build ] || exit 0\n[ \"$BUILD_VARIANTS\" = \"normal\" ] || exit 0\n\ndir=\"$TEMP_FILES_DIR/disk\"\ndmg=\"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.dmg\"\n\nrm -rf \"$dir\"\nmkdir \"$dir\"\ncp -R \"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.saver\" \"$dir\"\nrm -f \"$dmg\"\nhdiutil create -srcfolder \"$dir\" -volname \"$PROJECT_NAME\" \"$dmg\"\nhdiutil internet-enable -yes \"$dmg\"\nrm -rf \"$dir\"\n"; }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 8D255ACB0486D3F9007BF209 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 00DA7838107A73320094FCAB /* XamhainView.mm in Sources */, 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */, 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */, 009D8964108E251800A416CF /* Stroke.mm in Sources */, 009D897C108E28C800A416CF /* StrokeSet.cpp in Sources */, 00D7B656108F8E9A00432E90 /* KnotSection.cpp in Sources */, 007ED8661090CD6800B01235 /* CircularKnot.cpp in Sources */, 007ED8681090CD6800B01235 /* ClosedKnot.cpp in Sources */, 007ED86A1090CD6800B01235 /* HorizontalKnot.cpp in Sources */, 007ED86C1090CD6800B01235 /* RandomKnot.cpp in Sources */, 007ED86E1090CD6800B01235 /* RectangularKnot.cpp in Sources */, 007ED8701090CD6800B01235 /* TiledKnot.cpp in Sources */, 007ED8721090CD6800B01235 /* VerticalKnot.cpp in Sources */, - 001EA1D8109365FC00D05EFB /* XamhainGLView.mm in Sources */, + 00D188B11094BA31004E4496 /* XamhainGLView.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 000D03DA1089C465003F010E /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 8D255AC50486D3F9007BF209 /* XamhainII */; targetProxy = 000D03D91089C465003F010E /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ 089C167DFE841241C02AAC07 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 089C167EFE841241C02AAC07 /* English */, ); name = InfoPlist.strings; sourceTree = "<group>"; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 000D03D71089C45F003F010E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; PRODUCT_NAME = XamhainII.dmg; }; name = Debug; }; 000D03D81089C45F003F010E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = XamhainII.dmg; ZERO_LINK = NO; }; name = Release; }; EF7AD72E08BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_STRICT_ALIASING = NO; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = NO; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; ZERO_LINK = YES; }; name = Debug; }; EF7AD72F08BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; }; name = Release; }; EF7AD73208BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = NO; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Debug; }; EF7AD73308BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */ = { isa = XCConfigurationList; buildConfigurations = ( 000D03D71089C45F003F010E /* Debug */, 000D03D81089C45F003F010E /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD72E08BB986600CE4634 /* Debug */, EF7AD72F08BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD73208BB986600CE4634 /* Debug */, EF7AD73308BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 089C1669FE841209C02AAC07 /* Project object */; } diff --git a/knot engine/CircularKnot.cpp b/knot engine/CircularKnot.cpp index 4e0fc9d..16d941c 100644 --- a/knot engine/CircularKnot.cpp +++ b/knot engine/CircularKnot.cpp @@ -1,142 +1,144 @@ // A class representing a random circular knot. // // Copyright © 2004-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "CircularKnot.h" #include <cmath> #include <algorithm> +using namespace ::std; + #include <OpenGL/gl.h> #include "KnotSection.h" #include "Position.h" #include "RandomKnot.h" #include "RandomNumbers.h" namespace { // Minimum size of knot sections. const int kMinEdgeLength = 10; } CircularKnot::CircularKnot(int windowWidth, int windowHeight) : inherited(windowWidth, windowHeight, 6), mSectors(3 + randomInteger(5)) { // Set boundary conditions. // The left and right borders must have vertical corners. for (int i = 0; i <= mVSections; ++i) { sectionCorner(0, i) = sectionCorner(mHSections, i) = V; } // The top and bottom borders must match. for (int i = 1; i < mHSections; ++i) { sectionCorner(i, mVSections) = sectionCorner(i, 0); } // Calculate dimensions of the knot. const GLfloat fraction = randomFloat(mPrefs.minSize(), mPrefs.maxSize()); const GLfloat outRadius = - 0.5 * fraction * ::std::min(mWindowWidth, mWindowHeight); + 0.5 * fraction * min(mWindowWidth, mWindowHeight); const GLfloat inRadius = outRadius * randomFloat(0.25, 0.75); const GLfloat midRadius = (outRadius + inRadius) * 0.5; const int sectionWidth = (int)((outRadius - inRadius) / mHSections); const GLfloat angle = 2.0 * M_PI / mSectors; const int sectionHeight = (int)(angle * midRadius / mVSections); mEdgeLength = - ::std::max(::std::max(sectionWidth, sectionHeight), - (mHollow ? 3 : 1) * kMinEdgeLength); + max(max(sectionWidth, sectionHeight), + (mHollow ? 3 : 1) * kMinEdgeLength); mRadius = - ::std::max(mVSections / angle, (mHSections+1) * 0.5f) * mEdgeLength; + max(mVSections / angle, (mHSections+1) * 0.5f) * mEdgeLength; // Avoid infelicitous associations. if (mSectors == 4) { enforceVerticalSymmetry(false); } // Calculate the remaining properties. prepareAnimation( Position(1.0, 1.0) * (mRadius + mHSections * mEdgeLength * 0.5)); assignColors(); } CircularKnot::~CircularKnot(void) { // empty } void CircularKnot::drawBasicKnot(void) const { const GLfloat angle = 2.0 * M_PI / mSectors / mVSections; const GLfloat minRadius = mRadius - mEdgeLength * 0.5 * (mHSections-1); // Draw all the sections. for (int i = 0; i < mVSections; ++i) { const GLfloat phi = (0.5 * (mVSections-1) - i) * angle; for (int j = 0; j < mHSections; ++j) { const GLfloat radius = minRadius + j * mEdgeLength; glPushMatrix(); { glRotatef(phi * 180.0 / M_PI, 0.0, 0.0, 1.0); glTranslatef(radius, 0.0, 0.0); KnotSection section(sectionType(j, i), sectionCorner(j, i), sectionCorner(j+1, i), sectionCorner(j, i+1), sectionCorner(j+1, i+1)); const GLfloat *pTopColor = sectionColor(TOP, j, i); const GLfloat *pBotColor = sectionColor(BOT, j, i); const GLfloat *pLTColor = leftTopCornerColor(j, i); const GLfloat *pRBColor = rightBottomCornerColor(j, i); section.draw(Position(0.0, 0.0), mEdgeLength, radius, angle, *mpOutlineStrokes, *mpFillStrokes, mHollow, pTopColor, pBotColor, pLTColor, pRBColor); } glPopMatrix(); } } } void CircularKnot::draw(Position where, GLfloat angle) const { glPushMatrix(); { glTranslatef(where.x, where.y, 0.0); glRotatef(angle * 180.0 / M_PI, 0.0, 0.0, 1.0); for (int i = 0; i < mSectors; ++i) { glCallList(displayList()); glRotatef(360.0 / mSectors, 0.0, 0.0, 1.0); } } glPopMatrix(); } diff --git a/knot engine/RectangularKnot.cpp b/knot engine/RectangularKnot.cpp index 7e0b469..efbfa82 100644 --- a/knot engine/RectangularKnot.cpp +++ b/knot engine/RectangularKnot.cpp @@ -1,87 +1,89 @@ // A class representing a random rectangular knot. // // Copyright © 2004-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "RectangularKnot.h" #include <cmath> #include <algorithm> +using namespace ::std; + #include <OpenGL/gl.h> #include "KnotSection.h" #include "Position.h" #include "RandomKnot.h" #include "RandomNumbers.h" namespace { // Minimum size of knot sections. const int kMinEdgeLength = 10; } RectangularKnot::RectangularKnot(int windowWidth, int windowHeight, int maxSections, int xRepeat, int yRepeat) : inherited(windowWidth, windowHeight, maxSections) { // Calculate dimensions of the knot. const GLfloat fraction = randomFloat(mPrefs.minSize(), mPrefs.maxSize()); const int sectionWidth = (int)(fraction * mWindowWidth / mHSections / xRepeat); const int sectionHeight = (int)(fraction * mWindowHeight / mVSections / yRepeat); mEdgeLength = - ::std::max(::std::max(sectionWidth, sectionHeight), - (mHollow ? 3 : 1) * kMinEdgeLength); + max(max(sectionWidth, sectionHeight), + (mHollow ? 3 : 1) * kMinEdgeLength); // Calculate the remaining properties. prepareAnimation(Position(mHSections, mVSections) * mEdgeLength * 0.5, xRepeat > 1, yRepeat > 1); } RectangularKnot::~RectangularKnot(void) { // empty } void RectangularKnot::drawBasicKnot(void) const { const Position offset = - (mEdgeLength*0.5) * Position(mHSections-1, mVSections-1); // Draw all the sections. for (int i = 0; i < mVSections; ++i) { for (int j = 0; j < mHSections; ++j) { KnotSection section(sectionType(j, i), sectionCorner(j, i), sectionCorner(j+1, i), sectionCorner(j, i+1), sectionCorner(j+1, i+1)); const GLfloat *pTopColor = sectionColor(TOP, j, i); const GLfloat *pBotColor = sectionColor(BOT, j, i); const GLfloat *pLTColor = leftTopCornerColor(j, i); const GLfloat *pRBColor = rightBottomCornerColor(j, i); section.draw(offset + mEdgeLength*Position(j, (mVSections-1 - i)), mEdgeLength, 0.0, 0.0, *mpOutlineStrokes, *mpFillStrokes, mHollow, pTopColor, pBotColor, pLTColor, pRBColor); } } } diff --git a/knot engine/Stroke.mm b/knot engine/Stroke.mm index 708269a..49bf931 100644 --- a/knot engine/Stroke.mm +++ b/knot engine/Stroke.mm @@ -1,246 +1,258 @@ // A single primitive stroke, represented by a GL texture. // // Copyright © 2003-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "Stroke.h" #include <algorithm> #include <cassert> #include <cmath> +using namespace ::std; #include <OpenGL/gl.h> #include <OpenGL/glu.h> #include "Position.h" #include "XamhainPreferences.h" namespace { // Nominal size of a texture. const GLsizei kTextureSize = 64; // Internal texture format. const GLenum kTextureFormat = GL_ALPHA4; // Cache for values of trigonometric functions. class TrigFunctionCache { public: TrigFunctionCache(const GLfloat arcLength) : mSubdivisions(XamhainPreferences().knotSubdivisions()), mpSin(new GLfloat[mSubdivisions]), mpCos(new GLfloat[mSubdivisions]) { for (int i = 0; i < mSubdivisions; ++i) { const GLfloat arg = (i+1) * arcLength * 0.5 / mSubdivisions; mpSin[i] = ::sin(arg); mpCos[i] = ::cos(arg); } } ~TrigFunctionCache(void) { delete [] mpSin; delete [] mpCos; mpSin = mpCos = 0; } GLfloat sin(const int index) const { if (index) { return (index < 0) ? -mpSin[-index-1] : mpSin[index-1]; } return 0.0; } GLfloat cos(const int index) const { if (index) { return (index < 0) ? mpCos[-index-1] : mpCos[index-1]; } return 1.0; } private: TrigFunctionCache(const TrigFunctionCache &); TrigFunctionCache &operator =(const TrigFunctionCache &); // Data members. const int mSubdivisions; GLfloat *mpSin; GLfloat *mpCos; }; // Load an image resource and convert it to a bitmap. NSBitmapImageRep * loadImage(const char *const name) { // Load the (PDF) image. - NSImage *image = [NSImage imageNamed: - [NSString stringWithCString: name - encoding: NSASCIIStringEncoding]]; + NSBundle *bundle = [NSBundle bundleWithIdentifier: @"de.earrame.XamhainII"]; + NSString *file =[NSString stringWithCString: name + encoding: NSASCIIStringEncoding]; + NSString *path = [bundle pathForResource: file ofType: @"pdf"]; + assert(path != nil); + + NSImage *image = [[NSImage alloc] initWithContentsOfFile: path]; assert(image != nil); // Create a bitmap of the desired size. NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL pixelsWide: kTextureSize pixelsHigh: kTextureSize bitsPerSample: 8 - samplesPerPixel: 1 - hasAlpha: NO + samplesPerPixel: 4 + hasAlpha: YES isPlanar: NO - colorSpaceName: NSDeviceWhiteColorSpace + colorSpaceName: NSDeviceRGBColorSpace bytesPerRow: 0 bitsPerPixel: 0]; // Draw the image at the desired size. [NSGraphicsContext saveGraphicsState]; [NSGraphicsContext setCurrentContext: [NSGraphicsContext graphicsContextWithBitmapImageRep: bitmap]]; const NSSize size = [image size]; - [image drawInRect: NSMakeRect(0.0, 0.0, kTextureSize, kTextureSize) - fromRect: NSMakeRect(0.0, 0.0, size.width, size.height) + const NSRect srcRect = NSMakeRect(0.0, 0.0, size.width, size.height); + const NSRect dstRect = NSMakeRect(0.0, 0.0, kTextureSize, kTextureSize); + + [[NSColor whiteColor] setFill]; + [NSBezierPath fillRect: dstRect]; + + [image drawInRect: dstRect + fromRect: srcRect operation: NSCompositeCopy fraction: 1.0]; [NSGraphicsContext restoreGraphicsState]; return bitmap; } } Stroke::Stroke(const char *const name) -: mSubdivisions(XamhainPreferences().knotSubdivisions()){ +: mSubdivisions(XamhainPreferences().knotSubdivisions()) +{ // Load image resource. NSBitmapImageRep *bitmap = loadImage(name); // Create a texture object for the stroke. glGenTextures(1, &mTexture); glBindTexture(GL_TEXTURE_2D, mTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glPixelStorei(GL_UNPACK_ROW_LENGTH, [bitmap pixelsWide]); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gluBuild2DMipmaps(GL_TEXTURE_2D, kTextureFormat, kTextureSize, kTextureSize, - GL_ALPHA, GL_UNSIGNED_BYTE, [bitmap bitmapData]); + GL_RGBA, GL_UNSIGNED_BYTE, [bitmap bitmapData]); } Stroke::~Stroke(void) { glDeleteTextures(1, &mTexture); mTexture = 0; } void Stroke::draw(Position where, GLfloat size, GLfloat radius, GLfloat angle, const GLint transform[4]) const { if (radius <= 0.0 || angle <= 0.0) { size *= 0.5f; const GLfloat t0 = size * transform[0]; const GLfloat t1 = size * transform[1]; const GLfloat t2 = size * transform[2]; const GLfloat t3 = size * transform[3]; const GLfloat r = 1.0f; const GLfloat b = -1.0f; glBindTexture(GL_TEXTURE_2D, mTexture); glBegin(GL_POLYGON); { glTexCoord2f(0.0f, 1.0f); glVertex2f(where.x - t0 + b * t1, where.y - t2 + b * t3); glTexCoord2f(1.0f, 1.0f); glVertex2f(where.x + r * t0 + b * t1, where.y + r * t2 + b * t3); glTexCoord2f(1.0f, 0.0f); glVertex2f(where.x + r * t0 + t1, where.y + r * t2 + t3); glTexCoord2f(0.0f, 0.0f); glVertex2f(where.x - t0 + t1, where.y - t2 + t3); } glEnd(); } else { size = size * 0.5 / mSubdivisions; const GLint r = mSubdivisions; const GLint b = -mSubdivisions; const TrigFunctionCache cache(angle); glBindTexture(GL_TEXTURE_2D, mTexture); glBegin(GL_QUADS); { for (GLint x = -mSubdivisions; x < r; ++x) { for (GLint y = b; y < mSubdivisions; ++y) { const GLint x0 = x * transform[0] + y * transform[1]; const GLint y0 = x * transform[2] + y * transform[3]; const GLint x1 = (x+1) * transform[0] + y * transform[1]; const GLint y1 = (x+1) * transform[2] + y * transform[3]; const GLint x2 = (x+1) * transform[0] + (y+1) * transform[1]; const GLint y2 = (x+1) * transform[2] + (y+1) * transform[3]; const GLint x3 = x * transform[0] + (y+1) * transform[1]; const GLint y3 = x * transform[2] + (y+1) * transform[3]; const GLfloat r0 = size * x0 + radius; const GLfloat r1 = size * x1 + radius; const GLfloat r2 = size * x2 + radius; const GLfloat r3 = size * x3 + radius; glTexCoord2f( (GLfloat)(x+mSubdivisions) / (GLfloat)(r+mSubdivisions), (GLfloat)(mSubdivisions-y) / (GLfloat)(mSubdivisions-b)); glVertex2f(where.x + r0 * cache.cos(y0) - radius, where.y + r0 * cache.sin(y0)); glTexCoord2f( (GLfloat)(x+1+mSubdivisions) / (GLfloat)(r+mSubdivisions), (GLfloat)(mSubdivisions-y) / (GLfloat)(mSubdivisions-b)); glVertex2f(where.x + r1 * cache.cos(y1) - radius, where.y + r1 * cache.sin(y1)); glTexCoord2f( (GLfloat)(x+1+mSubdivisions) / (GLfloat)(r+mSubdivisions), (GLfloat)(mSubdivisions-y-1) / (GLfloat)(mSubdivisions-b)); glVertex2f(where.x + r2 * cache.cos(y2) - radius, where.y + r2 * cache.sin(y2)); glTexCoord2f( (GLfloat)(x+mSubdivisions) / (GLfloat)(r+mSubdivisions), (GLfloat)(mSubdivisions-y-1) / (GLfloat)(mSubdivisions-b)); glVertex2f(where.x + r3 * cache.cos(y3) - radius, where.y + r3 * cache.sin(y3)); } } } glEnd(); } } diff --git a/knot engine/StrokeSet.cpp b/knot engine/StrokeSet.cpp index 89564de..963720e 100644 --- a/knot engine/StrokeSet.cpp +++ b/knot engine/StrokeSet.cpp @@ -1,57 +1,57 @@ // A StrokeSet contains the 10 basic strokes from which knots are built, // plus an additional stroke used in filling in corners. // // Copyright © 2003-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "StrokeSet.h" #include "Stroke.h" #define StaticStroke(stroke, shape, type) \ - static const Stroke Stroke_##stroke(#shape "_" #type "_" #stroke ".pdf"); + static const Stroke Stroke_##stroke(#shape "_" #type "_" #stroke); #define StaticStrokeSet(name, shape, type) \ const StrokeSet & \ StrokeSet::name(void) \ { \ StaticStroke(DDD, shape, type); \ StaticStroke(DHD, shape, type); \ StaticStroke(DHH, shape, type); \ StaticStroke(DHV, shape, type); \ StaticStroke(HDD, shape, type); \ StaticStroke(HDH, shape, type); \ StaticStroke(HDV, shape, type); \ StaticStroke(HHH, shape, type); \ StaticStroke(HHV, shape, type); \ StaticStroke(HVV, shape, type); \ StaticStroke(corner, shape, type); \ \ static const Stroke *const pStrokes[NumStrokes] = { \ &Stroke_DDD, &Stroke_DHD, &Stroke_DHH, &Stroke_DHV, &Stroke_HDD, \ &Stroke_HDH, &Stroke_HDV, &Stroke_HHH, &Stroke_HHV, &Stroke_HVV, \ &Stroke_corner, \ }; \ static const StrokeSet theSet(pStrokes); \ \ return theSet; \ } StaticStrokeSet(broadFill, broad, fill) StaticStrokeSet(broadOutline, broad, outline) StaticStrokeSet(slenderFill, slender, fill) StaticStrokeSet(slenderOutline, slender, outline) diff --git a/knot engine/TiledKnot.cpp b/knot engine/TiledKnot.cpp index e30db1e..7ce0127 100644 --- a/knot engine/TiledKnot.cpp +++ b/knot engine/TiledKnot.cpp @@ -1,149 +1,150 @@ // A class representing a random tiled knot. // // Copyright © 2004-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. +#include "TiledKnot.h" + #include <algorithm> #include <cmath> +using namespace ::std; #include <OpenGL/gl.h> -#include "TiledKnot.h" - #include "KnotSection.h" #include "Position.h" #include "RandomNumbers.h" namespace { int kMaxSections = 6; } TiledKnot::TiledKnot(int windowWidth, int windowHeight, Position tilingDirection) : inherited(windowWidth, windowHeight, kMaxSections, tilingDirection.x ? 4 + randomInteger(4) : 1, tilingDirection.y ? 4 + randomInteger(4) : 1), mTilingDirection(tilingDirection) { // empty } TiledKnot::~TiledKnot(void) { // empty } // Find the intersection of the line (p0 + t*d) with the line through pe // with normal n. If no such intersection exists, return 'false'; // otherwise set t to the parameter value at the intersection point // and return 'true'. bool TiledKnot::clipLine(Position p0, Position d, Position pe, Position n, GLfloat &t) const { const GLfloat dot = n * d; if (fabs(dot) < 0.00001) { // Near parallel lines. return false; } // See Foley et.al. t = (n * (p0 - pe)) / -dot; return true; } // Find two values of the parameter t bounding the visible part of the line // (p0 + t*d). (We don't care about the case that the line is completely // invisible.) void TiledKnot::findBounds(Position p0, Position d, GLfloat t[2]) const { const GLfloat diag = norm(Size()); bool clipH, clipV; GLfloat tt[4]; // Clip against lower and upper borders of window. clipH = clipLine(p0, d, Position(-mWindowWidth, -diag), Position(0.0, -1.0), tt[0]) && clipLine(p0, d, Position(-mWindowWidth, mWindowHeight+diag), Position(0.0, 1.0), tt[1]); // Clip against left and right borders of window. clipV = clipLine(p0, d, Position(-diag, -mWindowHeight), Position(-1.0, 0.0), tt[2]) && clipLine(p0, d, Position(mWindowWidth+diag, -mWindowHeight), Position(1.0, 0.0), tt[3]); // Sort the intersections. - ::std::sort(clipH ? (tt + 0) : (tt + 2), clipV ? (tt + 4) : (tt + 2)); + sort(clipH ? (tt + 0) : (tt + 2), clipV ? (tt + 4) : (tt + 2)); if (clipH && clipV) { // Find two intersections on opposite sides of the window. const Position midPosition(mWindowWidth * 0.5, mWindowHeight * 0.5); const GLfloat tm = (midPosition - p0) * d; - const GLfloat *const p = ::std::lower_bound(tt + 0, tt + 4, tm); + const GLfloat *const p = lower_bound(tt + 0, tt + 4, tm); if (p > tt + 0 && p < tt + 4) { t[0] = p[-1]; t[1] = p[0]; } else { // This shouldn't hapen, but... t[0] = t[1] = 0; } } else if (!clipH) { t[0] = tt[2]; t[1] = tt[3]; } else { t[0] = tt[0]; t[1] = tt[1]; } } void TiledKnot::draw(Position where, GLfloat angle) const { const Position size(Size()); const GLfloat step = size * mTilingDirection; const GLfloat rot[4] = { mTilingDirection.x, -mTilingDirection.y, mTilingDirection.y, mTilingDirection.x }; const Position d = rot * Position(cos(angle), sin(angle)); // Find the limits of visibility. GLfloat t[2]; findBounds(where, d, t); const int minI = (int)floor(t[0] / step); const int maxI = (int)ceil(t[1] / step); // Draw the knot. for (int i = minI; i <= maxI; ++i) { const Position pos = where + i * step * d; glPushMatrix(); { glTranslatef(pos.x, pos.y, 0.0); glRotatef(angle * 180.0 / M_PI, 0.0, 0.0, 1.0); glCallList(displayList()); } glPopMatrix(); } } diff --git a/screen saving/XamhainGLView.h b/screen saving/XamhainGLView.h index 48e537b..f74c67f 100644 --- a/screen saving/XamhainGLView.h +++ b/screen saving/XamhainGLView.h @@ -1,30 +1,32 @@ // XamhainII OpenGL view. // // Copyright © 2009, Jens Kilian. // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #import <AppKit/NSOpenGLView.h> +class RandomKnot; +class XamhainPreferences; + @interface XamhainGLView : NSOpenGLView { - int removethis; + XamhainPreferences *mpPrefs; // user defaults + RandomKnot **mppKnots; // knots being animated } -- (void) drawRect: (NSRect)bounds; - @end diff --git a/screen saving/XamhainGLView.mm b/screen saving/XamhainGLView.mm index d7d2108..56aa15f 100644 --- a/screen saving/XamhainGLView.mm +++ b/screen saving/XamhainGLView.mm @@ -1,58 +1,153 @@ // XamhainII OpenGL view. // // Copyright © 2009, Jens Kilian. // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #import "XamhainGLView.h" +#include <algorithm> +using namespace ::std; + #include <OpenGL/gl.h> +#include "CircularKnot.h" +#include "ClosedKnot.h" +#include "HorizontalKnot.h" +#include "RandomNumbers.h" +#include "VerticalKnot.h" + + +namespace +{ + // Knot types. + enum KnotType { + kClosed, + kCircular, + kHorizontal, + kVertical + }; +} @implementation XamhainGLView + (NSOpenGLPixelFormat *) defaultPixelFormat { static const NSOpenGLPixelFormatAttribute attributes[] = { NSOpenGLPFADoubleBuffer, - NSOpenGLPFADepthSize, 32, 0 }; return [[NSOpenGLPixelFormat alloc] initWithAttributes: attributes]; } +- (XamhainGLView *) initWithFrame: (NSRect)frame +{ + self = [super initWithFrame: frame]; + if (self) { + mpPrefs = new XamhainPreferences; + mppKnots = new RandomKnot *[mpPrefs->numberOfKnots()]; + fill(mppKnots, mppKnots + mpPrefs->numberOfKnots(), (RandomKnot *)0); + } + + return self; +} + +- (void) finalize +{ + if (mppKnots) { + for (int i = 0; i < mpPrefs->numberOfKnots(); ++i) { + delete mppKnots[i]; + } + delete [] mppKnots; + } + delete mpPrefs; + + [super finalize]; +} + +- (void) prepareOpenGL +{ + glClearColor(0.0, 0.0, 0.0, 1.0); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glEnable(GL_TEXTURE_2D); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); +} + - (void) drawRect: (NSRect)bounds { - (void)bounds; + const int width = bounds.size.width; + const int height = bounds.size.height; + + glViewport(0, 0, width, height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0.0, width, 0.0, height, -1.0, 1.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); - glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); - glColor3f(1.0f, 0.85f, 0.35f); - glBegin(GL_TRIANGLES); - { - glVertex3f( 0.0, 0.6, 0.0); - glVertex3f( -0.2, -0.3, 0.0); - glVertex3f( 0.2, -0.3 ,0.0); + for (int i = 0; i < mpPrefs->numberOfKnots(); ++i) { + if (!mppKnots[i]) { + // Determine knot type. + KnotType type = kCircular; + GLfloat p = randomFloat(); + + if ((p -= mpPrefs->horizontalKnotProbability()) < 0.0) { + type = kHorizontal; + } else if ((p -= mpPrefs->verticalKnotProbability()) < 0.0) { + type = kVertical; + } else if ((p -= mpPrefs->closedKnotProbability()) < 0.0) { + type = kClosed; + } + + switch (type) { + + case kClosed: + mppKnots[i] = new ClosedKnot(width, height); + break; + + case kCircular: + mppKnots[i] = new CircularKnot(width, height); + break; + + case kHorizontal: + mppKnots[i] = new HorizontalKnot(width, height); + break; + + case kVertical: + mppKnots[i] = new VerticalKnot(width, height); + break; + } + } + + if (!mppKnots[i]->animate()) { + delete mppKnots[i]; + mppKnots[i] = 0; + } } - glEnd(); - glFlush(); + [[self openGLContext] flushBuffer]; } @end diff --git a/screen saving/XamhainPreferences.h b/screen saving/XamhainPreferences.h index e5307a8..44c6e6c 100644 --- a/screen saving/XamhainPreferences.h +++ b/screen saving/XamhainPreferences.h @@ -1,99 +1,102 @@ // XamhainII screen saver preferences. // // Copyright © 2000-2009, Jens Kilian. // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #ifndef XAMHAINPREFERENCES_H #define XAMHAINPREFERENCES_H #include <objc/objc.h> #include <OpenGL/gl.h> class XamhainPreferences { public: XamhainPreferences(void); // Screen saving preferences. int numberOfKnots(void) const; bool technicolor(void) const; int ticksPerSecond(void) const; GLfloat minSize(void) const; GLfloat maxSize(void) const; GLfloat minSpeed(void) const; GLfloat maxSpeed(void) const; GLfloat minSpin(void) const; GLfloat maxSpin(void) const; GLfloat skewProbability(void) const; GLfloat spinProbability(void) const; // Knot engine preferences. int knotSubdivisions(void) const; GLfloat horizontalKnotProbability(void) const; GLfloat verticalKnotProbability(void) const; GLfloat closedKnotProbability(void) const; GLfloat circularKnotProbability(void) const; GLfloat sectionProbability1(void) const; GLfloat sectionProbability2(void) const; GLfloat cornerProbability1(void) const; GLfloat cornerProbability2(void) const; GLfloat broadKnotProbability(void) const; GLfloat hollowKnotProbability(void) const; GLfloat symmetricKnotProbability(void) const; GLfloat horizontalMirrorProbability(void) const; GLfloat verticalMirrorProbability(void) const; // ### TODO: colors private: + GLfloat + totalKnotProbability(void) const; + id mDefaults; // actual screen saver defaults }; #endif // XAMHAINPREFERENCES_H diff --git a/screen saving/XamhainPreferences.mm b/screen saving/XamhainPreferences.mm index 9b0117c..ca15be6 100644 --- a/screen saving/XamhainPreferences.mm +++ b/screen saving/XamhainPreferences.mm @@ -1,240 +1,271 @@ // XamhainII screen saver preferences. // // Copyright © 2000-2009, Jens Kilian. // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "XamhainPreferences.h" -#import "ScreenSaver/ScreenSaverDefaults.h" +#include <algorithm> +using namespace ::std; + +#import <ScreenSaver/ScreenSaverDefaults.h> + @interface XamhainScreenSaverDefaults { // empty } + (NSUserDefaults *) sharedDefaults; @end namespace { - NSUserDefaults *gpInstance = nil; + NSUserDefaults *gInstance = nil; } @implementation XamhainScreenSaverDefaults + (void) initialize { - gpInstance = [ScreenSaverDefaults defaultsForModuleWithName: @"de.earrame.XamhainII"]; + gInstance = [ScreenSaverDefaults defaultsForModuleWithName: @"de.earrame.XamhainII"]; // Register initial defaults. NSDictionary *factoryDefaults = [NSDictionary dictionaryWithObjectsAndKeys: - @"NumberOfKnots", @"8", - @"Technicolor", @"YES", - @"TicksPerSecond", @"60", - @"MinSize", @"0.2", - @"MaxSize", @"0.5", - @"MinSpeed", @"3.0", - @"MaxSpeed", @"6.0", - @"MinSpin", @"1.0", - @"MaxSpin", @"5.0", - @"SkewProbability", @"0.8", - @"SpinProbability", @"0.8", - @"KnotSubdivisions", @"2", - @"HorizontalKnotProbability", @"0.1", - @"VerticalKnotProbability", @"0.2", - @"ClosedKnotProbability", @"0.5", - @"CircularKnotProbability", @"0.5", - @"SectionProbability1", @"0.06", - @"SectionProbability2", @"0.94", - @"CornerProbability1", @"0.2", - @"CornerProbability2", @"0.8", - @"BroadKnotProbability", @"0.5", - @"HollowKnotProbability", @"0.4", - @"SymmetricKnotProbability", @"0.8", - @"HorizontalMirrorProbability", @"0.9", - @"VerticalMirrorProbability", @"0.9", + @"8", @"NumberOfKnots", + @"YES", @"Technicolor", + @"60", @"TicksPerSecond", + @"0.2", @"MinSize", + @"0.5", @"MaxSize", + @"3.0", @"MinSpeed", + @"6.0", @"MaxSpeed", + @"1.0", @"MinSpin", + @"5.0", @"MaxSpin", + @"0.8", @"SkewProbability", + @"0.8", @"SpinProbability", + @"2", @"KnotSubdivisions", + @"0.1", @"HorizontalKnotProbability", + @"0.2", @"VerticalKnotProbability", + @"0.5", @"ClosedKnotProbability", + @"0.5", @"CircularKnotProbability", + @"0.06", @"SectionProbability1", + @"0.94", @"SectionProbability2", + @"0.2", @"CornerProbability1", + @"0.8", @"CornerProbability2", + @"0.5", @"BroadKnotProbability", + @"0.4", @"HollowKnotProbability", + @"0.8", @"SymmetricKnotProbability", + @"0.9", @"HorizontalMirrorProbability", + @"0.9", @"VerticalMirrorProbability", NULL]; - [gpInstance registerDefaults: factoryDefaults]; + [gInstance registerDefaults: factoryDefaults]; } + (NSUserDefaults *) sharedDefaults { - return gpInstance; + return gInstance; } @end // Construct a preferences object - which is actually just a wrapper. XamhainPreferences::XamhainPreferences(void) : mDefaults([XamhainScreenSaverDefaults sharedDefaults]) { // empty } // Implementation of inquiry functions. int XamhainPreferences::numberOfKnots(void) const { - return [mDefaults integerForKey: @"NumberOfKnots"]; + return max((NSInteger)1, [mDefaults integerForKey: @"NumberOfKnots"]); } bool XamhainPreferences::technicolor(void) const { return [mDefaults boolForKey: @"Technicolor"]; } int XamhainPreferences::ticksPerSecond(void) const { - return [mDefaults integerForKey: @"TicksPerSecond"]; + return max((NSInteger)1, [mDefaults integerForKey: @"TicksPerSecond"]); } GLfloat XamhainPreferences::minSize(void) const { - return [mDefaults floatForKey: @"MinSize"]; + return min([mDefaults floatForKey: @"MinSize"], + [mDefaults floatForKey: @"MaxSize"]); } GLfloat XamhainPreferences::maxSize(void) const { - return [mDefaults floatForKey: @"MaxSize"]; + return max([mDefaults floatForKey: @"MinSize"], + [mDefaults floatForKey: @"MaxSize"]); } GLfloat XamhainPreferences::minSpeed(void) const { - return [mDefaults floatForKey: @"MinSpeed"]; + return min([mDefaults floatForKey: @"MinSpeed"], + [mDefaults floatForKey: @"MaxSpeed"]); } GLfloat XamhainPreferences::maxSpeed(void) const { - return [mDefaults floatForKey: @"MaxSpeed"]; + return max([mDefaults floatForKey: @"MinSpeed"], + [mDefaults floatForKey: @"MaxSpeed"]); } GLfloat XamhainPreferences::minSpin(void) const { - return [mDefaults floatForKey: @"MinSpin"]; + return min([mDefaults floatForKey: @"MinSpin"], + [mDefaults floatForKey: @"MaxSpin"]); } GLfloat XamhainPreferences::maxSpin(void) const { - return [mDefaults floatForKey: @"MaxSpin"]; + return max([mDefaults floatForKey: @"MinSpin"], + [mDefaults floatForKey: @"MaxSpin"]); } GLfloat XamhainPreferences::skewProbability(void) const { - return [mDefaults floatForKey: @"SkewProbability"]; + return min(max(0.0f, [mDefaults floatForKey: @"SkewProbability"]), 1.0f); } GLfloat XamhainPreferences::spinProbability(void) const { - return [mDefaults floatForKey: @"SpinProbability"]; + return min(max(0.0f, [mDefaults floatForKey: @"SpinProbability"]), 1.0f); } int XamhainPreferences::knotSubdivisions(void) const { - return [mDefaults integerForKey: @"KnotSubdivisions"]; + return max((NSInteger)1, [mDefaults integerForKey: @"KnotSubdivisions"]); } GLfloat XamhainPreferences::horizontalKnotProbability(void) const { - return [mDefaults floatForKey: @"HorizontalKnotProbability"]; + return min(max(0.0f, + [mDefaults floatForKey: @"HorizontalKnotProbability"] + / totalKnotProbability()), + 1.0f); } GLfloat XamhainPreferences::verticalKnotProbability(void) const { - return [mDefaults floatForKey: @"VerticalKnotProbability"]; + return min(max(0.0f, + [mDefaults floatForKey: @"VerticalKnotProbability"] + / totalKnotProbability()), + 1.0f); } GLfloat XamhainPreferences::closedKnotProbability(void) const { - return [mDefaults floatForKey: @"ClosedKnotProbability"]; + return min(max(0.0f, + [mDefaults floatForKey: @"ClosedKnotProbability"] + / totalKnotProbability()), + 1.0f); } GLfloat XamhainPreferences::circularKnotProbability(void) const { - return [mDefaults floatForKey: @"CircularKnotProbability"]; + return min(max(0.0f, + [mDefaults floatForKey: @"CircularKnotProbability"] + / totalKnotProbability()), + 1.0f); } GLfloat XamhainPreferences::sectionProbability1(void) const { - return [mDefaults floatForKey: @"SectionProbability1"]; + return min(max(0.0f, [mDefaults floatForKey: @"SectionProbability1"]), 1.0f); } GLfloat XamhainPreferences::sectionProbability2(void) const { - return [mDefaults floatForKey: @"SectionProbability2"]; + return min(max(0.0f, [mDefaults floatForKey: @"SectionProbability2"]), 1.0f); } GLfloat XamhainPreferences::cornerProbability1(void) const { - return [mDefaults floatForKey: @"CornerProbability1"]; + return min(max(0.0f, [mDefaults floatForKey: @"CornerProbability1"]), 1.0f); } GLfloat XamhainPreferences::cornerProbability2(void) const { - return [mDefaults floatForKey: @"CornerProbability2"]; + return min(max(0.0f, [mDefaults floatForKey: @"CornerProbability2"]), 1.0f); } GLfloat XamhainPreferences::broadKnotProbability(void) const { - return [mDefaults floatForKey: @"BroadKnotProbability"]; + return min(max(0.0f, [mDefaults floatForKey: @"BroadKnotProbability"]), 1.0f); } GLfloat XamhainPreferences::hollowKnotProbability(void) const { - return [mDefaults floatForKey: @"HollowKnotProbability"]; + return min(max(0.0f, [mDefaults floatForKey: @"HollowKnotProbability"]), 1.0f); } GLfloat XamhainPreferences::symmetricKnotProbability(void) const { - return [mDefaults floatForKey: @"SymmetricKnotProbability"]; + return min(max(0.0f, [mDefaults floatForKey: @"SymmetricKnotProbability"]), 1.0f); } GLfloat XamhainPreferences::horizontalMirrorProbability(void) const { - return [mDefaults floatForKey: @"HorizontalKnotProbability"]; + return min(max(0.0f, [mDefaults floatForKey: @"HorizontalMirrorProbability"]), 1.0f); } GLfloat XamhainPreferences::verticalMirrorProbability(void) const { - return [mDefaults floatForKey: @"VerticalKnotProbability"]; + return min(max(0.0f, [mDefaults floatForKey: @"VerticalMirrorProbability"]), 1.0f); +} + +GLfloat +XamhainPreferences::totalKnotProbability(void) const +{ + return [mDefaults floatForKey: @"HorizontalKnotProbability"] + + [mDefaults floatForKey: @"VerticalKnotProbability"] + + [mDefaults floatForKey: @"ClosedKnotProbability"] + + [mDefaults floatForKey: @"CircularKnotProbability"]; } diff --git a/screen saving/XamhainView.mm b/screen saving/XamhainView.mm index 3e1439b..3ac7ad7 100644 --- a/screen saving/XamhainView.mm +++ b/screen saving/XamhainView.mm @@ -1,64 +1,66 @@ // XamhainII screen saver view. // // Copyright © 2009, Jens Kilian. // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #import "XamhainView.h" #import "XamhainGLView.h" #include "XamhainPreferences.h" @implementation XamhainView - (id) initWithFrame: (NSRect)frame isPreview: (BOOL)isPreview { self = [super initWithFrame: frame isPreview: isPreview]; if (self) { XamhainPreferences prefs; [self setAnimationTimeInterval: 1.0/prefs.ticksPerSecond()]; - mpGLView = [[XamhainGLView alloc] initWithFrame: frame]; + const NSRect childFrame = + NSOffsetRect(frame, -frame.origin.x, -frame.origin.y); + mpGLView = [[XamhainGLView alloc] initWithFrame: childFrame]; if (mpGLView) { [self addSubview: mpGLView]; } else { NSLog(@"Failed to create XamhainGLView."); } } else { NSLog(@"Failed to create XamhainView"); } return self; } - (void) animateOneFrame { [mpGLView setNeedsDisplay: YES]; } - (BOOL)hasConfigureSheet { return NO; } - (NSWindow *) configureSheet { return nil; } @end
jjk/XamhainII
21c0588a6227648863ef6e99e067d720bcc0e7e8
Start actual screen saver implementation.
diff --git a/XamhainII.xcodeproj/project.pbxproj b/XamhainII.xcodeproj/project.pbxproj index 882095a..41413ec 100644 --- a/XamhainII.xcodeproj/project.pbxproj +++ b/XamhainII.xcodeproj/project.pbxproj @@ -1,720 +1,728 @@ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 45; objects = { /* Begin PBXAggregateTarget section */ 000D03D61089C45F003F010E /* XamhainII.dmg */ = { isa = PBXAggregateTarget; buildConfigurationList = 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */; buildPhases = ( 000D03D51089C45F003F010E /* ShellScript */, ); dependencies = ( 000D03DA1089C465003F010E /* PBXTargetDependency */, ); name = XamhainII.dmg; productName = XamhainII.dmg; }; /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 001EA1D7109365FC00D05EFB /* XamhainGLView.h in Headers */ = {isa = PBXBuildFile; fileRef = 001EA1D5109365FC00D05EFB /* XamhainGLView.h */; }; + 001EA1D8109365FC00D05EFB /* XamhainGLView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 001EA1D6109365FC00D05EFB /* XamhainGLView.mm */; }; 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0032D325108A30770033FA87 /* OpenGL.framework */; }; 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00791842108B081B00156D67 /* XamhainPreferences.mm */; }; 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007C5127108A29BE00ED3242 /* RandomColor.cpp */; }; 007ED8661090CD6800B01235 /* CircularKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8581090CD6800B01235 /* CircularKnot.cpp */; }; 007ED8671090CD6800B01235 /* CircularKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED8591090CD6800B01235 /* CircularKnot.h */; }; 007ED8681090CD6800B01235 /* ClosedKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED85A1090CD6800B01235 /* ClosedKnot.cpp */; }; 007ED8691090CD6800B01235 /* ClosedKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED85B1090CD6800B01235 /* ClosedKnot.h */; }; 007ED86A1090CD6800B01235 /* HorizontalKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED85C1090CD6800B01235 /* HorizontalKnot.cpp */; }; 007ED86B1090CD6800B01235 /* HorizontalKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED85D1090CD6800B01235 /* HorizontalKnot.h */; }; 007ED86C1090CD6800B01235 /* RandomKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED85E1090CD6800B01235 /* RandomKnot.cpp */; }; 007ED86D1090CD6800B01235 /* RandomKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED85F1090CD6800B01235 /* RandomKnot.h */; }; 007ED86E1090CD6800B01235 /* RectangularKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8601090CD6800B01235 /* RectangularKnot.cpp */; }; 007ED86F1090CD6800B01235 /* RectangularKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED8611090CD6800B01235 /* RectangularKnot.h */; }; 007ED8701090CD6800B01235 /* TiledKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8621090CD6800B01235 /* TiledKnot.cpp */; }; 007ED8711090CD6800B01235 /* TiledKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED8631090CD6800B01235 /* TiledKnot.h */; }; 007ED8721090CD6800B01235 /* VerticalKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8641090CD6800B01235 /* VerticalKnot.cpp */; }; 007ED8731090CD6800B01235 /* VerticalKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED8651090CD6800B01235 /* VerticalKnot.h */; }; 009D8964108E251800A416CF /* Stroke.mm in Sources */ = {isa = PBXBuildFile; fileRef = 009D8962108E251800A416CF /* Stroke.mm */; }; 009D897C108E28C800A416CF /* StrokeSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 009D897A108E28C800A416CF /* StrokeSet.cpp */; }; 00D7B656108F8E9A00432E90 /* KnotSection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00D7B654108F8E9A00432E90 /* KnotSection.cpp */; }; 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */; }; 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */; }; 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */; }; 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */; }; 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */; }; 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */; }; 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */; }; 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */; }; 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */; }; 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */; }; 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */; }; 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */; }; 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */; }; 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */; }; 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */; }; 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */; }; 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */; }; 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */; }; 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */; }; 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */; }; 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */; }; 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */; }; 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */; }; 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */; }; 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */; }; 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */; }; 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */; }; 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */; }; 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */; }; 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */; }; 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */; }; 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */; }; 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */; }; 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */; }; 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */; }; 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */; }; 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */; }; 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */; }; 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */; }; 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */; }; 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */; }; 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */; }; 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */; }; 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */; }; - 00DA7838107A73320094FCAB /* XamhainView.m in Sources */ = {isa = PBXBuildFile; fileRef = 00DA7836107A73320094FCAB /* XamhainView.m */; }; + 00DA7838107A73320094FCAB /* XamhainView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00DA7836107A73320094FCAB /* XamhainView.mm */; }; 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 000D03D91089C465003F010E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 089C1669FE841209C02AAC07 /* Project object */; proxyType = 1; remoteGlobalIDString = 8D255AC50486D3F9007BF209; remoteInfo = XamhainII; }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 001EA1D5109365FC00D05EFB /* XamhainGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainGLView.h; path = "screen saving/XamhainGLView.h"; sourceTree = "<group>"; }; + 001EA1D6109365FC00D05EFB /* XamhainGLView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainGLView.mm; path = "screen saving/XamhainGLView.mm"; sourceTree = "<group>"; }; 0032D325108A30770033FA87 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; }; 00791842108B081B00156D67 /* XamhainPreferences.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainPreferences.mm; path = "screen saving/XamhainPreferences.mm"; sourceTree = "<group>"; }; 00791843108B081B00156D67 /* XamhainPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainPreferences.h; path = "screen saving/XamhainPreferences.h"; sourceTree = "<group>"; }; 007C5126108A29BE00ED3242 /* Position.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Position.h; path = utility/Position.h; sourceTree = "<group>"; }; 007C5127108A29BE00ED3242 /* RandomColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RandomColor.cpp; path = utility/RandomColor.cpp; sourceTree = "<group>"; }; 007C5128108A29BE00ED3242 /* RandomColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomColor.h; path = utility/RandomColor.h; sourceTree = "<group>"; }; 007C5129108A29BE00ED3242 /* RandomNumbers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomNumbers.h; path = utility/RandomNumbers.h; sourceTree = "<group>"; }; 007ED8581090CD6800B01235 /* CircularKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CircularKnot.cpp; path = "knot engine/CircularKnot.cpp"; sourceTree = "<group>"; }; 007ED8591090CD6800B01235 /* CircularKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CircularKnot.h; path = "knot engine/CircularKnot.h"; sourceTree = "<group>"; }; 007ED85A1090CD6800B01235 /* ClosedKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClosedKnot.cpp; path = "knot engine/ClosedKnot.cpp"; sourceTree = "<group>"; }; 007ED85B1090CD6800B01235 /* ClosedKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClosedKnot.h; path = "knot engine/ClosedKnot.h"; sourceTree = "<group>"; }; 007ED85C1090CD6800B01235 /* HorizontalKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HorizontalKnot.cpp; path = "knot engine/HorizontalKnot.cpp"; sourceTree = "<group>"; }; 007ED85D1090CD6800B01235 /* HorizontalKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HorizontalKnot.h; path = "knot engine/HorizontalKnot.h"; sourceTree = "<group>"; }; 007ED85E1090CD6800B01235 /* RandomKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RandomKnot.cpp; path = "knot engine/RandomKnot.cpp"; sourceTree = "<group>"; }; 007ED85F1090CD6800B01235 /* RandomKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomKnot.h; path = "knot engine/RandomKnot.h"; sourceTree = "<group>"; }; 007ED8601090CD6800B01235 /* RectangularKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RectangularKnot.cpp; path = "knot engine/RectangularKnot.cpp"; sourceTree = "<group>"; }; 007ED8611090CD6800B01235 /* RectangularKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RectangularKnot.h; path = "knot engine/RectangularKnot.h"; sourceTree = "<group>"; }; 007ED8621090CD6800B01235 /* TiledKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TiledKnot.cpp; path = "knot engine/TiledKnot.cpp"; sourceTree = "<group>"; }; 007ED8631090CD6800B01235 /* TiledKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiledKnot.h; path = "knot engine/TiledKnot.h"; sourceTree = "<group>"; }; 007ED8641090CD6800B01235 /* VerticalKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VerticalKnot.cpp; path = "knot engine/VerticalKnot.cpp"; sourceTree = "<group>"; }; 007ED8651090CD6800B01235 /* VerticalKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VerticalKnot.h; path = "knot engine/VerticalKnot.h"; sourceTree = "<group>"; }; 009D8962108E251800A416CF /* Stroke.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Stroke.mm; path = "knot engine/Stroke.mm"; sourceTree = "<group>"; }; 009D8963108E251800A416CF /* Stroke.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Stroke.h; path = "knot engine/Stroke.h"; sourceTree = "<group>"; }; 009D897A108E28C800A416CF /* StrokeSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StrokeSet.cpp; path = "knot engine/StrokeSet.cpp"; sourceTree = "<group>"; }; 009D897B108E28C800A416CF /* StrokeSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StrokeSet.h; path = "knot engine/StrokeSet.h"; sourceTree = "<group>"; }; 00D7B654108F8E9A00432E90 /* KnotSection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KnotSection.cpp; path = "knot engine/KnotSection.cpp"; sourceTree = "<group>"; }; 00D7B655108F8E9A00432E90 /* KnotSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KnotSection.h; path = "knot engine/KnotSection.h"; sourceTree = "<group>"; }; 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA7835107A73320094FCAB /* XamhainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainView.h; path = "screen saving/XamhainView.h"; sourceTree = "<group>"; }; - 00DA7836107A73320094FCAB /* XamhainView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XamhainView.m; path = "screen saving/XamhainView.m"; sourceTree = "<group>"; }; + 00DA7836107A73320094FCAB /* XamhainView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainView.mm; path = "screen saving/XamhainView.mm"; sourceTree = "<group>"; }; 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ScreenSaver.framework; path = /System/Library/Frameworks/ScreenSaver.framework; sourceTree = "<absolute>"; }; 089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; 089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; }; 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; }; 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XamhainII_Prefix.pch; sourceTree = "<group>"; }; 8D255AD20486D3F9007BF209 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; 8D255AD30486D3F9007BF209 /* XamhainII.saver */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XamhainII.saver; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 8D255ACD0486D3F9007BF209 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */, 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */, 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 007C5125108A299800ED3242 /* Utility */ = { isa = PBXGroup; children = ( 007C5126108A29BE00ED3242 /* Position.h */, 007C5127108A29BE00ED3242 /* RandomColor.cpp */, 007C5128108A29BE00ED3242 /* RandomColor.h */, 007C5129108A29BE00ED3242 /* RandomNumbers.h */, ); name = Utility; sourceTree = "<group>"; }; 009D8961108E24ED00A416CF /* Knot Engine */ = { isa = PBXGroup; children = ( 007ED8581090CD6800B01235 /* CircularKnot.cpp */, 007ED8591090CD6800B01235 /* CircularKnot.h */, 007ED85A1090CD6800B01235 /* ClosedKnot.cpp */, 007ED85B1090CD6800B01235 /* ClosedKnot.h */, 007ED85C1090CD6800B01235 /* HorizontalKnot.cpp */, 007ED85D1090CD6800B01235 /* HorizontalKnot.h */, 007ED85E1090CD6800B01235 /* RandomKnot.cpp */, 007ED85F1090CD6800B01235 /* RandomKnot.h */, 007ED8601090CD6800B01235 /* RectangularKnot.cpp */, 007ED8611090CD6800B01235 /* RectangularKnot.h */, 007ED8621090CD6800B01235 /* TiledKnot.cpp */, 007ED8631090CD6800B01235 /* TiledKnot.h */, 007ED8641090CD6800B01235 /* VerticalKnot.cpp */, 007ED8651090CD6800B01235 /* VerticalKnot.h */, 00D7B654108F8E9A00432E90 /* KnotSection.cpp */, 00D7B655108F8E9A00432E90 /* KnotSection.h */, 009D897A108E28C800A416CF /* StrokeSet.cpp */, 009D897B108E28C800A416CF /* StrokeSet.h */, 009D8962108E251800A416CF /* Stroke.mm */, 009D8963108E251800A416CF /* Stroke.h */, ); name = "Knot Engine"; sourceTree = "<group>"; }; 00DA77D5107A728C0094FCAB /* Strokes */ = { isa = PBXGroup; children = ( 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */, 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */, 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */, 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */, 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */, 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */, 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */, 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */, 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */, 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */, 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */, 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */, 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */, 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */, 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */, 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */, 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */, 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */, 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */, 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */, 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */, 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */, 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */, 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */, 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */, 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */, 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */, 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */, 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */, 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */, 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */, 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */, 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */, 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */, 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */, 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */, 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */, 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */, 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */, 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */, 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */, 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */, 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */, 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */, ); name = Strokes; path = strokes; sourceTree = "<group>"; }; 00DA7833107A72F00094FCAB /* Screen Saving */ = { isa = PBXGroup; children = ( + 001EA1D5109365FC00D05EFB /* XamhainGLView.h */, + 001EA1D6109365FC00D05EFB /* XamhainGLView.mm */, 00791842108B081B00156D67 /* XamhainPreferences.mm */, 00791843108B081B00156D67 /* XamhainPreferences.h */, 00DA7835107A73320094FCAB /* XamhainView.h */, - 00DA7836107A73320094FCAB /* XamhainView.m */, + 00DA7836107A73320094FCAB /* XamhainView.mm */, ); name = "Screen Saving"; sourceTree = "<group>"; }; 089C166AFE841209C02AAC07 /* XamhainII */ = { isa = PBXGroup; children = ( 009D8961108E24ED00A416CF /* Knot Engine */, 00DA7833107A72F00094FCAB /* Screen Saving */, 007C5125108A299800ED3242 /* Utility */, 32DBCFA70370C4F300C91783 /* Other Sources */, 089C167CFE841241C02AAC07 /* Resources */, 089C1671FE841209C02AAC07 /* Frameworks and Libraries */, 19C28FB8FE9D52D311CA2CBB /* Products */, ); name = XamhainII; sourceTree = "<group>"; }; 089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = { isa = PBXGroup; children = ( 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */, 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */, ); name = "Frameworks and Libraries"; sourceTree = "<group>"; }; 089C167CFE841241C02AAC07 /* Resources */ = { isa = PBXGroup; children = ( 00DA77D5107A728C0094FCAB /* Strokes */, 8D255AD20486D3F9007BF209 /* Info.plist */, 089C167DFE841241C02AAC07 /* InfoPlist.strings */, ); name = Resources; sourceTree = "<group>"; }; 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = { isa = PBXGroup; children = ( 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, 0032D325108A30770033FA87 /* OpenGL.framework */, 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */, ); name = "Linked Frameworks"; sourceTree = "<group>"; }; 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = { isa = PBXGroup; children = ( 089C1672FE841209C02AAC07 /* Foundation.framework */, 089C167FFE841241C02AAC07 /* AppKit.framework */, ); name = "Other Frameworks"; sourceTree = "<group>"; }; 19C28FB8FE9D52D311CA2CBB /* Products */ = { isa = PBXGroup; children = ( 8D255AD30486D3F9007BF209 /* XamhainII.saver */, ); name = Products; sourceTree = "<group>"; }; 32DBCFA70370C4F300C91783 /* Other Sources */ = { isa = PBXGroup; children = ( 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */, ); name = "Other Sources"; sourceTree = "<group>"; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ 8D255AC60486D3F9007BF209 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 007ED8671090CD6800B01235 /* CircularKnot.h in Headers */, 007ED8691090CD6800B01235 /* ClosedKnot.h in Headers */, 007ED86B1090CD6800B01235 /* HorizontalKnot.h in Headers */, 007ED86D1090CD6800B01235 /* RandomKnot.h in Headers */, 007ED86F1090CD6800B01235 /* RectangularKnot.h in Headers */, 007ED8711090CD6800B01235 /* TiledKnot.h in Headers */, 007ED8731090CD6800B01235 /* VerticalKnot.h in Headers */, + 001EA1D7109365FC00D05EFB /* XamhainGLView.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ 8D255AC50486D3F9007BF209 /* XamhainII */ = { isa = PBXNativeTarget; buildConfigurationList = EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */; buildPhases = ( 8D255AC60486D3F9007BF209 /* Headers */, 8D255AC90486D3F9007BF209 /* Resources */, 8D255ACB0486D3F9007BF209 /* Sources */, 8D255ACD0486D3F9007BF209 /* Frameworks */, 8D255AD00486D3F9007BF209 /* Rez */, ); buildRules = ( ); dependencies = ( ); name = XamhainII; productInstallPath = "$(HOME)/Library/Screen Savers"; productName = XamhainII; productReference = 8D255AD30486D3F9007BF209 /* XamhainII.saver */; productType = "com.apple.product-type.bundle"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 089C1669FE841209C02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */; compatibilityVersion = "Xcode 3.1"; hasScannedForEncodings = 1; mainGroup = 089C166AFE841209C02AAC07 /* XamhainII */; projectDirPath = ""; projectRoot = ""; targets = ( 8D255AC50486D3F9007BF209 /* XamhainII */, 000D03D61089C45F003F010E /* XamhainII.dmg */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ 8D255AC90486D3F9007BF209 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */, 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */, 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */, 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */, 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */, 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */, 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */, 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */, 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */, 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */, 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */, 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */, 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */, 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */, 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */, 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */, 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */, 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */, 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */, 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */, 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */, 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */, 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */, 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */, 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */, 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */, 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */, 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */, 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */, 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */, 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */, 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */, 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */, 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */, 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */, 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */, 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */, 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */, 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */, 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */, 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */, 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */, 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */, 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */, 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXRezBuildPhase section */ 8D255AD00486D3F9007BF209 /* Rez */ = { isa = PBXRezBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXRezBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ 000D03D51089C45F003F010E /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.saver", ); outputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.dmg", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "# Thanks to Rob Mayoff for explaining how to do this.\n# See http://qwan.org/2007/05/22/using-xcode-to-build-a-disk-image-and-upload-a-web-site/\n\nset -ex\n\n[ \"$ACTION\" = build ] || exit 0\n[ \"$BUILD_VARIANTS\" = \"normal\" ] || exit 0\n\ndir=\"$TEMP_FILES_DIR/disk\"\ndmg=\"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.dmg\"\n\nrm -rf \"$dir\"\nmkdir \"$dir\"\ncp -R \"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.saver\" \"$dir\"\nrm -f \"$dmg\"\nhdiutil create -srcfolder \"$dir\" -volname \"$PROJECT_NAME\" \"$dmg\"\nhdiutil internet-enable -yes \"$dmg\"\nrm -rf \"$dir\"\n"; }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 8D255ACB0486D3F9007BF209 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 00DA7838107A73320094FCAB /* XamhainView.m in Sources */, + 00DA7838107A73320094FCAB /* XamhainView.mm in Sources */, 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */, 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */, 009D8964108E251800A416CF /* Stroke.mm in Sources */, 009D897C108E28C800A416CF /* StrokeSet.cpp in Sources */, 00D7B656108F8E9A00432E90 /* KnotSection.cpp in Sources */, 007ED8661090CD6800B01235 /* CircularKnot.cpp in Sources */, 007ED8681090CD6800B01235 /* ClosedKnot.cpp in Sources */, 007ED86A1090CD6800B01235 /* HorizontalKnot.cpp in Sources */, 007ED86C1090CD6800B01235 /* RandomKnot.cpp in Sources */, 007ED86E1090CD6800B01235 /* RectangularKnot.cpp in Sources */, 007ED8701090CD6800B01235 /* TiledKnot.cpp in Sources */, 007ED8721090CD6800B01235 /* VerticalKnot.cpp in Sources */, + 001EA1D8109365FC00D05EFB /* XamhainGLView.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 000D03DA1089C465003F010E /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 8D255AC50486D3F9007BF209 /* XamhainII */; targetProxy = 000D03D91089C465003F010E /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ 089C167DFE841241C02AAC07 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 089C167EFE841241C02AAC07 /* English */, ); name = InfoPlist.strings; sourceTree = "<group>"; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 000D03D71089C45F003F010E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; PRODUCT_NAME = XamhainII.dmg; }; name = Debug; }; 000D03D81089C45F003F010E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = XamhainII.dmg; ZERO_LINK = NO; }; name = Release; }; EF7AD72E08BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_STRICT_ALIASING = NO; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = NO; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; ZERO_LINK = YES; }; name = Debug; }; EF7AD72F08BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; }; name = Release; }; EF7AD73208BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = NO; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Debug; }; EF7AD73308BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */ = { isa = XCConfigurationList; buildConfigurations = ( 000D03D71089C45F003F010E /* Debug */, 000D03D81089C45F003F010E /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD72E08BB986600CE4634 /* Debug */, EF7AD72F08BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD73208BB986600CE4634 /* Debug */, EF7AD73308BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 089C1669FE841209C02AAC07 /* Project object */; } diff --git a/screen saving/XamhainGLView.h b/screen saving/XamhainGLView.h new file mode 100644 index 0000000..48e537b --- /dev/null +++ b/screen saving/XamhainGLView.h @@ -0,0 +1,30 @@ +// XamhainII OpenGL view. +// +// Copyright © 2009, Jens Kilian. +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#import <AppKit/NSOpenGLView.h> + + +@interface XamhainGLView : NSOpenGLView +{ + int removethis; +} + +- (void) drawRect: (NSRect)bounds; + +@end diff --git a/screen saving/XamhainGLView.mm b/screen saving/XamhainGLView.mm new file mode 100644 index 0000000..d7d2108 --- /dev/null +++ b/screen saving/XamhainGLView.mm @@ -0,0 +1,58 @@ +// XamhainII OpenGL view. +// +// Copyright © 2009, Jens Kilian. +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#import "XamhainGLView.h" + +#include <OpenGL/gl.h> + + +@implementation XamhainGLView + ++ (NSOpenGLPixelFormat *) defaultPixelFormat +{ + static const NSOpenGLPixelFormatAttribute attributes[] = + { + NSOpenGLPFADoubleBuffer, + NSOpenGLPFADepthSize, 32, + 0 + }; + + return [[NSOpenGLPixelFormat alloc] initWithAttributes: attributes]; +} + +- (void) drawRect: (NSRect)bounds +{ + (void)bounds; + + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); + + glColor3f(1.0f, 0.85f, 0.35f); + glBegin(GL_TRIANGLES); + { + glVertex3f( 0.0, 0.6, 0.0); + glVertex3f( -0.2, -0.3, 0.0); + glVertex3f( 0.2, -0.3 ,0.0); + } + glEnd(); + + glFlush(); +} + +@end diff --git a/screen saving/XamhainPreferences.h b/screen saving/XamhainPreferences.h index f3b8688..e5307a8 100644 --- a/screen saving/XamhainPreferences.h +++ b/screen saving/XamhainPreferences.h @@ -1,97 +1,99 @@ // XamhainII screen saver preferences. // // Copyright © 2000-2009, Jens Kilian. // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #ifndef XAMHAINPREFERENCES_H #define XAMHAINPREFERENCES_H #include <objc/objc.h> #include <OpenGL/gl.h> class XamhainPreferences { public: XamhainPreferences(void); // Screen saving preferences. int numberOfKnots(void) const; bool technicolor(void) const; + int + ticksPerSecond(void) const; GLfloat minSize(void) const; GLfloat maxSize(void) const; GLfloat minSpeed(void) const; GLfloat maxSpeed(void) const; GLfloat minSpin(void) const; GLfloat maxSpin(void) const; GLfloat skewProbability(void) const; GLfloat spinProbability(void) const; // Knot engine preferences. int knotSubdivisions(void) const; GLfloat horizontalKnotProbability(void) const; GLfloat verticalKnotProbability(void) const; GLfloat closedKnotProbability(void) const; GLfloat circularKnotProbability(void) const; GLfloat sectionProbability1(void) const; GLfloat sectionProbability2(void) const; GLfloat cornerProbability1(void) const; GLfloat cornerProbability2(void) const; GLfloat broadKnotProbability(void) const; GLfloat hollowKnotProbability(void) const; GLfloat symmetricKnotProbability(void) const; GLfloat horizontalMirrorProbability(void) const; GLfloat verticalMirrorProbability(void) const; // ### TODO: colors private: id mDefaults; // actual screen saver defaults }; #endif // XAMHAINPREFERENCES_H diff --git a/screen saving/XamhainPreferences.mm b/screen saving/XamhainPreferences.mm index f5763e9..9b0117c 100644 --- a/screen saving/XamhainPreferences.mm +++ b/screen saving/XamhainPreferences.mm @@ -1,234 +1,240 @@ // XamhainII screen saver preferences. // // Copyright © 2000-2009, Jens Kilian. // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "XamhainPreferences.h" #import "ScreenSaver/ScreenSaverDefaults.h" @interface XamhainScreenSaverDefaults { // empty } -+ (NSUserDefaults *)sharedDefaults; ++ (NSUserDefaults *) sharedDefaults; @end namespace { NSUserDefaults *gpInstance = nil; } @implementation XamhainScreenSaverDefaults -+ (NSUserDefaults *)sharedDefaults -{ - @synchronized(self) { - if (gpInstance == nil) { - gpInstance = [ScreenSaverDefaults defaultsForModuleWithName: @"de.earrame.XamhainII"]; - - // Register initial defaults. - NSDictionary *factoryDefaults = - [NSDictionary dictionaryWithObjectsAndKeys: - @"NumberOfKnots", @"8", - @"Technicolor", @"YES", - @"MinSize", @"0.2", - @"MaxSize", @"0.5", - @"MinSpeed", @"3.0", - @"MaxSpeed", @"6.0", - @"MinSpin", @"1.0", - @"MaxSpin", @"5.0", - @"SkewProbability", @"0.8", - @"SpinProbability", @"0.8", - @"KnotSubdivisions", @"2", - @"HorizontalKnotProbability", @"0.1", - @"VerticalKnotProbability", @"0.2", - @"ClosedKnotProbability", @"0.5", - @"CircularKnotProbability", @"0.5", - @"SectionProbability1", @"0.06", - @"SectionProbability2", @"0.94", - @"CornerProbability1", @"0.2", - @"CornerProbability2", @"0.8", - @"BroadKnotProbability", @"0.5", - @"HollowKnotProbability", @"0.4", - @"SymmetricKnotProbability", @"0.8", - @"HorizontalMirrorProbability", @"0.9", - @"VerticalMirrorProbability", @"0.9", - NULL]; - - [gpInstance registerDefaults: factoryDefaults]; - } - } - ++ (void) initialize +{ + gpInstance = [ScreenSaverDefaults defaultsForModuleWithName: @"de.earrame.XamhainII"]; + + // Register initial defaults. + NSDictionary *factoryDefaults = + [NSDictionary dictionaryWithObjectsAndKeys: + @"NumberOfKnots", @"8", + @"Technicolor", @"YES", + @"TicksPerSecond", @"60", + @"MinSize", @"0.2", + @"MaxSize", @"0.5", + @"MinSpeed", @"3.0", + @"MaxSpeed", @"6.0", + @"MinSpin", @"1.0", + @"MaxSpin", @"5.0", + @"SkewProbability", @"0.8", + @"SpinProbability", @"0.8", + @"KnotSubdivisions", @"2", + @"HorizontalKnotProbability", @"0.1", + @"VerticalKnotProbability", @"0.2", + @"ClosedKnotProbability", @"0.5", + @"CircularKnotProbability", @"0.5", + @"SectionProbability1", @"0.06", + @"SectionProbability2", @"0.94", + @"CornerProbability1", @"0.2", + @"CornerProbability2", @"0.8", + @"BroadKnotProbability", @"0.5", + @"HollowKnotProbability", @"0.4", + @"SymmetricKnotProbability", @"0.8", + @"HorizontalMirrorProbability", @"0.9", + @"VerticalMirrorProbability", @"0.9", + NULL]; + + [gpInstance registerDefaults: factoryDefaults]; +} + ++ (NSUserDefaults *) sharedDefaults +{ return gpInstance; } @end // Construct a preferences object - which is actually just a wrapper. XamhainPreferences::XamhainPreferences(void) : mDefaults([XamhainScreenSaverDefaults sharedDefaults]) { // empty } // Implementation of inquiry functions. int XamhainPreferences::numberOfKnots(void) const { return [mDefaults integerForKey: @"NumberOfKnots"]; } bool XamhainPreferences::technicolor(void) const { return [mDefaults boolForKey: @"Technicolor"]; } +int +XamhainPreferences::ticksPerSecond(void) const +{ + return [mDefaults integerForKey: @"TicksPerSecond"]; +} + GLfloat XamhainPreferences::minSize(void) const { return [mDefaults floatForKey: @"MinSize"]; } GLfloat XamhainPreferences::maxSize(void) const { return [mDefaults floatForKey: @"MaxSize"]; } GLfloat XamhainPreferences::minSpeed(void) const { return [mDefaults floatForKey: @"MinSpeed"]; } GLfloat XamhainPreferences::maxSpeed(void) const { return [mDefaults floatForKey: @"MaxSpeed"]; } GLfloat XamhainPreferences::minSpin(void) const { return [mDefaults floatForKey: @"MinSpin"]; } GLfloat XamhainPreferences::maxSpin(void) const { return [mDefaults floatForKey: @"MaxSpin"]; } GLfloat XamhainPreferences::skewProbability(void) const { return [mDefaults floatForKey: @"SkewProbability"]; } GLfloat XamhainPreferences::spinProbability(void) const { return [mDefaults floatForKey: @"SpinProbability"]; } int XamhainPreferences::knotSubdivisions(void) const { return [mDefaults integerForKey: @"KnotSubdivisions"]; } GLfloat XamhainPreferences::horizontalKnotProbability(void) const { return [mDefaults floatForKey: @"HorizontalKnotProbability"]; } GLfloat XamhainPreferences::verticalKnotProbability(void) const { return [mDefaults floatForKey: @"VerticalKnotProbability"]; } GLfloat XamhainPreferences::closedKnotProbability(void) const { return [mDefaults floatForKey: @"ClosedKnotProbability"]; } GLfloat XamhainPreferences::circularKnotProbability(void) const { return [mDefaults floatForKey: @"CircularKnotProbability"]; } GLfloat XamhainPreferences::sectionProbability1(void) const { return [mDefaults floatForKey: @"SectionProbability1"]; } GLfloat XamhainPreferences::sectionProbability2(void) const { return [mDefaults floatForKey: @"SectionProbability2"]; } GLfloat XamhainPreferences::cornerProbability1(void) const { return [mDefaults floatForKey: @"CornerProbability1"]; } GLfloat XamhainPreferences::cornerProbability2(void) const { return [mDefaults floatForKey: @"CornerProbability2"]; } GLfloat XamhainPreferences::broadKnotProbability(void) const { return [mDefaults floatForKey: @"BroadKnotProbability"]; } GLfloat XamhainPreferences::hollowKnotProbability(void) const { return [mDefaults floatForKey: @"HollowKnotProbability"]; } GLfloat XamhainPreferences::symmetricKnotProbability(void) const { return [mDefaults floatForKey: @"SymmetricKnotProbability"]; } GLfloat XamhainPreferences::horizontalMirrorProbability(void) const { return [mDefaults floatForKey: @"HorizontalKnotProbability"]; } GLfloat XamhainPreferences::verticalMirrorProbability(void) const { return [mDefaults floatForKey: @"VerticalKnotProbability"]; } diff --git a/screen saving/XamhainView.h b/screen saving/XamhainView.h index 497e3da..d57bb89 100644 --- a/screen saving/XamhainView.h +++ b/screen saving/XamhainView.h @@ -1,28 +1,30 @@ // XamhainII screen saver view. // // Copyright © 2009, Jens Kilian. // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #import <ScreenSaver/ScreenSaver.h> +#import "XamhainGLView.h" -@interface XamhainView : ScreenSaverView + +@interface XamhainView : ScreenSaverView { - int phase; + XamhainGLView *mpGLView; } @end diff --git a/screen saving/XamhainView.m b/screen saving/XamhainView.mm similarity index 54% rename from screen saving/XamhainView.m rename to screen saving/XamhainView.mm index 28a4712..3e1439b 100644 --- a/screen saving/XamhainView.m +++ b/screen saving/XamhainView.mm @@ -1,77 +1,64 @@ // XamhainII screen saver view. // // Copyright © 2009, Jens Kilian. // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #import "XamhainView.h" +#import "XamhainGLView.h" +#include "XamhainPreferences.h" + @implementation XamhainView -- (id)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview +- (id) initWithFrame: (NSRect)frame isPreview: (BOOL)isPreview { - self = [super initWithFrame:frame isPreview:isPreview]; + self = [super initWithFrame: frame isPreview: isPreview]; if (self) { - [self setAnimationTimeInterval:1/30.0]; - } - - phase = 0; - - return self; -} + XamhainPreferences prefs; + [self setAnimationTimeInterval: 1.0/prefs.ticksPerSecond()]; -- (void)startAnimation -{ - [super startAnimation]; -} + mpGLView = [[XamhainGLView alloc] initWithFrame: frame]; + if (mpGLView) { + [self addSubview: mpGLView]; -- (void)stopAnimation -{ - [super stopAnimation]; -} + } else { + NSLog(@"Failed to create XamhainGLView."); + } + } else { + NSLog(@"Failed to create XamhainView"); + } -- (void)drawRect:(NSRect)rect -{ - [super drawRect:rect]; + return self; } -- (void)animateOneFrame +- (void) animateOneFrame { - ++phase; - - [[NSColor colorWithCalibratedHue:(phase % 500) / 500.0 - saturation:1.0 - brightness:1.0 - alpha:1.0] setFill]; - - NSRect bounds = [self bounds]; - CGFloat d = NSWidth(bounds) / 25.0; - bounds = NSInsetRect(bounds, d, d); - NSFrameRectWithWidth(bounds, d); + [mpGLView setNeedsDisplay: YES]; } - (BOOL)hasConfigureSheet { return NO; } -- (NSWindow*)configureSheet +- (NSWindow *) configureSheet { return nil; } @end
jjk/XamhainII
630e4fde972b031785b2734d278f0a49216a0942
Port knot engine.
diff --git a/XamhainII.xcodeproj/project.pbxproj b/XamhainII.xcodeproj/project.pbxproj index c9ac6a6..882095a 100644 --- a/XamhainII.xcodeproj/project.pbxproj +++ b/XamhainII.xcodeproj/project.pbxproj @@ -1,664 +1,720 @@ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 45; objects = { /* Begin PBXAggregateTarget section */ 000D03D61089C45F003F010E /* XamhainII.dmg */ = { isa = PBXAggregateTarget; buildConfigurationList = 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */; buildPhases = ( 000D03D51089C45F003F010E /* ShellScript */, ); dependencies = ( 000D03DA1089C465003F010E /* PBXTargetDependency */, ); name = XamhainII.dmg; productName = XamhainII.dmg; }; /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0032D325108A30770033FA87 /* OpenGL.framework */; }; 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00791842108B081B00156D67 /* XamhainPreferences.mm */; }; 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007C5127108A29BE00ED3242 /* RandomColor.cpp */; }; + 007ED8661090CD6800B01235 /* CircularKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8581090CD6800B01235 /* CircularKnot.cpp */; }; + 007ED8671090CD6800B01235 /* CircularKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED8591090CD6800B01235 /* CircularKnot.h */; }; + 007ED8681090CD6800B01235 /* ClosedKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED85A1090CD6800B01235 /* ClosedKnot.cpp */; }; + 007ED8691090CD6800B01235 /* ClosedKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED85B1090CD6800B01235 /* ClosedKnot.h */; }; + 007ED86A1090CD6800B01235 /* HorizontalKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED85C1090CD6800B01235 /* HorizontalKnot.cpp */; }; + 007ED86B1090CD6800B01235 /* HorizontalKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED85D1090CD6800B01235 /* HorizontalKnot.h */; }; + 007ED86C1090CD6800B01235 /* RandomKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED85E1090CD6800B01235 /* RandomKnot.cpp */; }; + 007ED86D1090CD6800B01235 /* RandomKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED85F1090CD6800B01235 /* RandomKnot.h */; }; + 007ED86E1090CD6800B01235 /* RectangularKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8601090CD6800B01235 /* RectangularKnot.cpp */; }; + 007ED86F1090CD6800B01235 /* RectangularKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED8611090CD6800B01235 /* RectangularKnot.h */; }; + 007ED8701090CD6800B01235 /* TiledKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8621090CD6800B01235 /* TiledKnot.cpp */; }; + 007ED8711090CD6800B01235 /* TiledKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED8631090CD6800B01235 /* TiledKnot.h */; }; + 007ED8721090CD6800B01235 /* VerticalKnot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007ED8641090CD6800B01235 /* VerticalKnot.cpp */; }; + 007ED8731090CD6800B01235 /* VerticalKnot.h in Headers */ = {isa = PBXBuildFile; fileRef = 007ED8651090CD6800B01235 /* VerticalKnot.h */; }; 009D8964108E251800A416CF /* Stroke.mm in Sources */ = {isa = PBXBuildFile; fileRef = 009D8962108E251800A416CF /* Stroke.mm */; }; 009D897C108E28C800A416CF /* StrokeSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 009D897A108E28C800A416CF /* StrokeSet.cpp */; }; 00D7B656108F8E9A00432E90 /* KnotSection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00D7B654108F8E9A00432E90 /* KnotSection.cpp */; }; 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */; }; 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */; }; 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */; }; 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */; }; 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */; }; 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */; }; 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */; }; 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */; }; 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */; }; 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */; }; 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */; }; 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */; }; 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */; }; 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */; }; 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */; }; 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */; }; 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */; }; 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */; }; 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */; }; 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */; }; 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */; }; 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */; }; 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */; }; 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */; }; 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */; }; 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */; }; 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */; }; 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */; }; 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */; }; 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */; }; 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */; }; 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */; }; 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */; }; 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */; }; 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */; }; 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */; }; 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */; }; 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */; }; 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */; }; 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */; }; 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */; }; 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */; }; 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */; }; 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */; }; 00DA7838107A73320094FCAB /* XamhainView.m in Sources */ = {isa = PBXBuildFile; fileRef = 00DA7836107A73320094FCAB /* XamhainView.m */; }; 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 000D03D91089C465003F010E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 089C1669FE841209C02AAC07 /* Project object */; proxyType = 1; remoteGlobalIDString = 8D255AC50486D3F9007BF209; remoteInfo = XamhainII; }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ 0032D325108A30770033FA87 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; }; 00791842108B081B00156D67 /* XamhainPreferences.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainPreferences.mm; path = "screen saving/XamhainPreferences.mm"; sourceTree = "<group>"; }; 00791843108B081B00156D67 /* XamhainPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainPreferences.h; path = "screen saving/XamhainPreferences.h"; sourceTree = "<group>"; }; 007C5126108A29BE00ED3242 /* Position.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Position.h; path = utility/Position.h; sourceTree = "<group>"; }; 007C5127108A29BE00ED3242 /* RandomColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RandomColor.cpp; path = utility/RandomColor.cpp; sourceTree = "<group>"; }; 007C5128108A29BE00ED3242 /* RandomColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomColor.h; path = utility/RandomColor.h; sourceTree = "<group>"; }; 007C5129108A29BE00ED3242 /* RandomNumbers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomNumbers.h; path = utility/RandomNumbers.h; sourceTree = "<group>"; }; + 007ED8581090CD6800B01235 /* CircularKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CircularKnot.cpp; path = "knot engine/CircularKnot.cpp"; sourceTree = "<group>"; }; + 007ED8591090CD6800B01235 /* CircularKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CircularKnot.h; path = "knot engine/CircularKnot.h"; sourceTree = "<group>"; }; + 007ED85A1090CD6800B01235 /* ClosedKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClosedKnot.cpp; path = "knot engine/ClosedKnot.cpp"; sourceTree = "<group>"; }; + 007ED85B1090CD6800B01235 /* ClosedKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClosedKnot.h; path = "knot engine/ClosedKnot.h"; sourceTree = "<group>"; }; + 007ED85C1090CD6800B01235 /* HorizontalKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HorizontalKnot.cpp; path = "knot engine/HorizontalKnot.cpp"; sourceTree = "<group>"; }; + 007ED85D1090CD6800B01235 /* HorizontalKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HorizontalKnot.h; path = "knot engine/HorizontalKnot.h"; sourceTree = "<group>"; }; + 007ED85E1090CD6800B01235 /* RandomKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RandomKnot.cpp; path = "knot engine/RandomKnot.cpp"; sourceTree = "<group>"; }; + 007ED85F1090CD6800B01235 /* RandomKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomKnot.h; path = "knot engine/RandomKnot.h"; sourceTree = "<group>"; }; + 007ED8601090CD6800B01235 /* RectangularKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RectangularKnot.cpp; path = "knot engine/RectangularKnot.cpp"; sourceTree = "<group>"; }; + 007ED8611090CD6800B01235 /* RectangularKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RectangularKnot.h; path = "knot engine/RectangularKnot.h"; sourceTree = "<group>"; }; + 007ED8621090CD6800B01235 /* TiledKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TiledKnot.cpp; path = "knot engine/TiledKnot.cpp"; sourceTree = "<group>"; }; + 007ED8631090CD6800B01235 /* TiledKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiledKnot.h; path = "knot engine/TiledKnot.h"; sourceTree = "<group>"; }; + 007ED8641090CD6800B01235 /* VerticalKnot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VerticalKnot.cpp; path = "knot engine/VerticalKnot.cpp"; sourceTree = "<group>"; }; + 007ED8651090CD6800B01235 /* VerticalKnot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VerticalKnot.h; path = "knot engine/VerticalKnot.h"; sourceTree = "<group>"; }; 009D8962108E251800A416CF /* Stroke.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Stroke.mm; path = "knot engine/Stroke.mm"; sourceTree = "<group>"; }; 009D8963108E251800A416CF /* Stroke.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Stroke.h; path = "knot engine/Stroke.h"; sourceTree = "<group>"; }; 009D897A108E28C800A416CF /* StrokeSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StrokeSet.cpp; path = "knot engine/StrokeSet.cpp"; sourceTree = "<group>"; }; 009D897B108E28C800A416CF /* StrokeSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StrokeSet.h; path = "knot engine/StrokeSet.h"; sourceTree = "<group>"; }; 00D7B654108F8E9A00432E90 /* KnotSection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KnotSection.cpp; path = "knot engine/KnotSection.cpp"; sourceTree = "<group>"; }; 00D7B655108F8E9A00432E90 /* KnotSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KnotSection.h; path = "knot engine/KnotSection.h"; sourceTree = "<group>"; }; 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA7835107A73320094FCAB /* XamhainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainView.h; path = "screen saving/XamhainView.h"; sourceTree = "<group>"; }; 00DA7836107A73320094FCAB /* XamhainView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XamhainView.m; path = "screen saving/XamhainView.m"; sourceTree = "<group>"; }; 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ScreenSaver.framework; path = /System/Library/Frameworks/ScreenSaver.framework; sourceTree = "<absolute>"; }; 089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; 089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; }; 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; }; 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XamhainII_Prefix.pch; sourceTree = "<group>"; }; 8D255AD20486D3F9007BF209 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; 8D255AD30486D3F9007BF209 /* XamhainII.saver */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XamhainII.saver; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 8D255ACD0486D3F9007BF209 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */, 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */, 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 007C5125108A299800ED3242 /* Utility */ = { isa = PBXGroup; children = ( 007C5126108A29BE00ED3242 /* Position.h */, 007C5127108A29BE00ED3242 /* RandomColor.cpp */, 007C5128108A29BE00ED3242 /* RandomColor.h */, 007C5129108A29BE00ED3242 /* RandomNumbers.h */, ); name = Utility; sourceTree = "<group>"; }; 009D8961108E24ED00A416CF /* Knot Engine */ = { isa = PBXGroup; children = ( + 007ED8581090CD6800B01235 /* CircularKnot.cpp */, + 007ED8591090CD6800B01235 /* CircularKnot.h */, + 007ED85A1090CD6800B01235 /* ClosedKnot.cpp */, + 007ED85B1090CD6800B01235 /* ClosedKnot.h */, + 007ED85C1090CD6800B01235 /* HorizontalKnot.cpp */, + 007ED85D1090CD6800B01235 /* HorizontalKnot.h */, + 007ED85E1090CD6800B01235 /* RandomKnot.cpp */, + 007ED85F1090CD6800B01235 /* RandomKnot.h */, + 007ED8601090CD6800B01235 /* RectangularKnot.cpp */, + 007ED8611090CD6800B01235 /* RectangularKnot.h */, + 007ED8621090CD6800B01235 /* TiledKnot.cpp */, + 007ED8631090CD6800B01235 /* TiledKnot.h */, + 007ED8641090CD6800B01235 /* VerticalKnot.cpp */, + 007ED8651090CD6800B01235 /* VerticalKnot.h */, 00D7B654108F8E9A00432E90 /* KnotSection.cpp */, 00D7B655108F8E9A00432E90 /* KnotSection.h */, 009D897A108E28C800A416CF /* StrokeSet.cpp */, 009D897B108E28C800A416CF /* StrokeSet.h */, 009D8962108E251800A416CF /* Stroke.mm */, 009D8963108E251800A416CF /* Stroke.h */, ); name = "Knot Engine"; sourceTree = "<group>"; }; 00DA77D5107A728C0094FCAB /* Strokes */ = { isa = PBXGroup; children = ( 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */, 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */, 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */, 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */, 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */, 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */, 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */, 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */, 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */, 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */, 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */, 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */, 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */, 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */, 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */, 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */, 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */, 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */, 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */, 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */, 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */, 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */, 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */, 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */, 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */, 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */, 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */, 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */, 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */, 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */, 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */, 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */, 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */, 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */, 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */, 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */, 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */, 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */, 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */, 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */, 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */, 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */, 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */, 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */, ); name = Strokes; path = strokes; sourceTree = "<group>"; }; 00DA7833107A72F00094FCAB /* Screen Saving */ = { isa = PBXGroup; children = ( 00791842108B081B00156D67 /* XamhainPreferences.mm */, 00791843108B081B00156D67 /* XamhainPreferences.h */, 00DA7835107A73320094FCAB /* XamhainView.h */, 00DA7836107A73320094FCAB /* XamhainView.m */, ); name = "Screen Saving"; sourceTree = "<group>"; }; 089C166AFE841209C02AAC07 /* XamhainII */ = { isa = PBXGroup; children = ( 009D8961108E24ED00A416CF /* Knot Engine */, 00DA7833107A72F00094FCAB /* Screen Saving */, 007C5125108A299800ED3242 /* Utility */, 32DBCFA70370C4F300C91783 /* Other Sources */, 089C167CFE841241C02AAC07 /* Resources */, 089C1671FE841209C02AAC07 /* Frameworks and Libraries */, 19C28FB8FE9D52D311CA2CBB /* Products */, ); name = XamhainII; sourceTree = "<group>"; }; 089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = { isa = PBXGroup; children = ( 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */, 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */, ); name = "Frameworks and Libraries"; sourceTree = "<group>"; }; 089C167CFE841241C02AAC07 /* Resources */ = { isa = PBXGroup; children = ( 00DA77D5107A728C0094FCAB /* Strokes */, 8D255AD20486D3F9007BF209 /* Info.plist */, 089C167DFE841241C02AAC07 /* InfoPlist.strings */, ); name = Resources; sourceTree = "<group>"; }; 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = { isa = PBXGroup; children = ( 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, 0032D325108A30770033FA87 /* OpenGL.framework */, 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */, ); name = "Linked Frameworks"; sourceTree = "<group>"; }; 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = { isa = PBXGroup; children = ( 089C1672FE841209C02AAC07 /* Foundation.framework */, 089C167FFE841241C02AAC07 /* AppKit.framework */, ); name = "Other Frameworks"; sourceTree = "<group>"; }; 19C28FB8FE9D52D311CA2CBB /* Products */ = { isa = PBXGroup; children = ( 8D255AD30486D3F9007BF209 /* XamhainII.saver */, ); name = Products; sourceTree = "<group>"; }; 32DBCFA70370C4F300C91783 /* Other Sources */ = { isa = PBXGroup; children = ( 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */, ); name = "Other Sources"; sourceTree = "<group>"; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ 8D255AC60486D3F9007BF209 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 007ED8671090CD6800B01235 /* CircularKnot.h in Headers */, + 007ED8691090CD6800B01235 /* ClosedKnot.h in Headers */, + 007ED86B1090CD6800B01235 /* HorizontalKnot.h in Headers */, + 007ED86D1090CD6800B01235 /* RandomKnot.h in Headers */, + 007ED86F1090CD6800B01235 /* RectangularKnot.h in Headers */, + 007ED8711090CD6800B01235 /* TiledKnot.h in Headers */, + 007ED8731090CD6800B01235 /* VerticalKnot.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ 8D255AC50486D3F9007BF209 /* XamhainII */ = { isa = PBXNativeTarget; buildConfigurationList = EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */; buildPhases = ( 8D255AC60486D3F9007BF209 /* Headers */, 8D255AC90486D3F9007BF209 /* Resources */, 8D255ACB0486D3F9007BF209 /* Sources */, 8D255ACD0486D3F9007BF209 /* Frameworks */, 8D255AD00486D3F9007BF209 /* Rez */, ); buildRules = ( ); dependencies = ( ); name = XamhainII; productInstallPath = "$(HOME)/Library/Screen Savers"; productName = XamhainII; productReference = 8D255AD30486D3F9007BF209 /* XamhainII.saver */; productType = "com.apple.product-type.bundle"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 089C1669FE841209C02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */; compatibilityVersion = "Xcode 3.1"; hasScannedForEncodings = 1; mainGroup = 089C166AFE841209C02AAC07 /* XamhainII */; projectDirPath = ""; projectRoot = ""; targets = ( 8D255AC50486D3F9007BF209 /* XamhainII */, 000D03D61089C45F003F010E /* XamhainII.dmg */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ 8D255AC90486D3F9007BF209 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */, 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */, 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */, 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */, 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */, 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */, 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */, 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */, 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */, 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */, 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */, 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */, 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */, 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */, 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */, 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */, 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */, 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */, 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */, 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */, 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */, 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */, 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */, 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */, 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */, 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */, 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */, 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */, 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */, 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */, 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */, 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */, 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */, 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */, 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */, 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */, 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */, 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */, 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */, 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */, 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */, 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */, 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */, 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */, 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXRezBuildPhase section */ 8D255AD00486D3F9007BF209 /* Rez */ = { isa = PBXRezBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXRezBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ 000D03D51089C45F003F010E /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.saver", ); outputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.dmg", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "# Thanks to Rob Mayoff for explaining how to do this.\n# See http://qwan.org/2007/05/22/using-xcode-to-build-a-disk-image-and-upload-a-web-site/\n\nset -ex\n\n[ \"$ACTION\" = build ] || exit 0\n[ \"$BUILD_VARIANTS\" = \"normal\" ] || exit 0\n\ndir=\"$TEMP_FILES_DIR/disk\"\ndmg=\"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.dmg\"\n\nrm -rf \"$dir\"\nmkdir \"$dir\"\ncp -R \"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.saver\" \"$dir\"\nrm -f \"$dmg\"\nhdiutil create -srcfolder \"$dir\" -volname \"$PROJECT_NAME\" \"$dmg\"\nhdiutil internet-enable -yes \"$dmg\"\nrm -rf \"$dir\"\n"; }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 8D255ACB0486D3F9007BF209 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 00DA7838107A73320094FCAB /* XamhainView.m in Sources */, 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */, 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */, 009D8964108E251800A416CF /* Stroke.mm in Sources */, 009D897C108E28C800A416CF /* StrokeSet.cpp in Sources */, 00D7B656108F8E9A00432E90 /* KnotSection.cpp in Sources */, + 007ED8661090CD6800B01235 /* CircularKnot.cpp in Sources */, + 007ED8681090CD6800B01235 /* ClosedKnot.cpp in Sources */, + 007ED86A1090CD6800B01235 /* HorizontalKnot.cpp in Sources */, + 007ED86C1090CD6800B01235 /* RandomKnot.cpp in Sources */, + 007ED86E1090CD6800B01235 /* RectangularKnot.cpp in Sources */, + 007ED8701090CD6800B01235 /* TiledKnot.cpp in Sources */, + 007ED8721090CD6800B01235 /* VerticalKnot.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 000D03DA1089C465003F010E /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 8D255AC50486D3F9007BF209 /* XamhainII */; targetProxy = 000D03D91089C465003F010E /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ 089C167DFE841241C02AAC07 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 089C167EFE841241C02AAC07 /* English */, ); name = InfoPlist.strings; sourceTree = "<group>"; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 000D03D71089C45F003F010E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; PRODUCT_NAME = XamhainII.dmg; }; name = Debug; }; 000D03D81089C45F003F010E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = XamhainII.dmg; ZERO_LINK = NO; }; name = Release; }; EF7AD72E08BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_STRICT_ALIASING = NO; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = NO; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; ZERO_LINK = YES; }; name = Debug; }; EF7AD72F08BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; }; name = Release; }; EF7AD73208BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = NO; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Debug; }; EF7AD73308BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */ = { isa = XCConfigurationList; buildConfigurations = ( 000D03D71089C45F003F010E /* Debug */, 000D03D81089C45F003F010E /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD72E08BB986600CE4634 /* Debug */, EF7AD72F08BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD73208BB986600CE4634 /* Debug */, EF7AD73308BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 089C1669FE841209C02AAC07 /* Project object */; } diff --git a/knot engine/CircularKnot.cpp b/knot engine/CircularKnot.cpp new file mode 100644 index 0000000..4e0fc9d --- /dev/null +++ b/knot engine/CircularKnot.cpp @@ -0,0 +1,142 @@ +// A class representing a random circular knot. +// +// Copyright © 2004-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#include "CircularKnot.h" + +#include <cmath> +#include <algorithm> +#include <OpenGL/gl.h> + +#include "KnotSection.h" +#include "Position.h" +#include "RandomKnot.h" +#include "RandomNumbers.h" + +namespace +{ + // Minimum size of knot sections. + const int kMinEdgeLength = 10; +} + +CircularKnot::CircularKnot(int windowWidth, int windowHeight) +: inherited(windowWidth, windowHeight, 6), + mSectors(3 + randomInteger(5)) +{ + // Set boundary conditions. + + // The left and right borders must have vertical corners. + for (int i = 0; i <= mVSections; ++i) { + sectionCorner(0, i) = sectionCorner(mHSections, i) = V; + } + + // The top and bottom borders must match. + for (int i = 1; i < mHSections; ++i) { + sectionCorner(i, mVSections) = sectionCorner(i, 0); + } + + // Calculate dimensions of the knot. + const GLfloat fraction = randomFloat(mPrefs.minSize(), mPrefs.maxSize()); + + const GLfloat outRadius = + 0.5 * fraction * ::std::min(mWindowWidth, mWindowHeight); + const GLfloat inRadius = + outRadius * randomFloat(0.25, 0.75); + const GLfloat midRadius = + (outRadius + inRadius) * 0.5; + const int sectionWidth = + (int)((outRadius - inRadius) / mHSections); + + const GLfloat angle = 2.0 * M_PI / mSectors; + const int sectionHeight = + (int)(angle * midRadius / mVSections); + + mEdgeLength = + ::std::max(::std::max(sectionWidth, sectionHeight), + (mHollow ? 3 : 1) * kMinEdgeLength); + mRadius = + ::std::max(mVSections / angle, (mHSections+1) * 0.5f) * mEdgeLength; + + // Avoid infelicitous associations. + if (mSectors == 4) { + enforceVerticalSymmetry(false); + } + + // Calculate the remaining properties. + prepareAnimation( + Position(1.0, 1.0) * (mRadius + mHSections * mEdgeLength * 0.5)); + assignColors(); +} + +CircularKnot::~CircularKnot(void) +{ + // empty +} + +void +CircularKnot::drawBasicKnot(void) const +{ + const GLfloat angle = 2.0 * M_PI / mSectors / mVSections; + const GLfloat minRadius = mRadius - mEdgeLength * 0.5 * (mHSections-1); + + // Draw all the sections. + for (int i = 0; i < mVSections; ++i) { + const GLfloat phi = (0.5 * (mVSections-1) - i) * angle; + + for (int j = 0; j < mHSections; ++j) { + const GLfloat radius = minRadius + j * mEdgeLength; + + glPushMatrix(); + { + glRotatef(phi * 180.0 / M_PI, 0.0, 0.0, 1.0); + glTranslatef(radius, 0.0, 0.0); + + KnotSection section(sectionType(j, i), + sectionCorner(j, i), + sectionCorner(j+1, i), + sectionCorner(j, i+1), + sectionCorner(j+1, i+1)); + const GLfloat *pTopColor = sectionColor(TOP, j, i); + const GLfloat *pBotColor = sectionColor(BOT, j, i); + const GLfloat *pLTColor = leftTopCornerColor(j, i); + const GLfloat *pRBColor = rightBottomCornerColor(j, i); + + section.draw(Position(0.0, 0.0), mEdgeLength, radius, angle, + *mpOutlineStrokes, *mpFillStrokes, mHollow, + pTopColor, pBotColor, pLTColor, pRBColor); + } + glPopMatrix(); + } + } +} + +void +CircularKnot::draw(Position where, GLfloat angle) const +{ + glPushMatrix(); + { + glTranslatef(where.x, where.y, 0.0); + glRotatef(angle * 180.0 / M_PI, 0.0, 0.0, 1.0); + + for (int i = 0; i < mSectors; ++i) { + glCallList(displayList()); + glRotatef(360.0 / mSectors, 0.0, 0.0, 1.0); + } + } + glPopMatrix(); +} diff --git a/knot engine/CircularKnot.h b/knot engine/CircularKnot.h new file mode 100644 index 0000000..0948771 --- /dev/null +++ b/knot engine/CircularKnot.h @@ -0,0 +1,52 @@ +// A class representing a random circular knot. +// +// Copyright © 2004-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#ifndef CIRCULARKNOT_H +#define CIRCULARKNOT_H + +#include <OpenGL/gl.h> + +#include "Position.h" +#include "RandomKnot.h" + +class CircularKnot : public RandomKnot +{ + typedef RandomKnot inherited; +public: + CircularKnot(int windowWidth, int windowHeight); + virtual ~CircularKnot(void); + +private: + CircularKnot(const CircularKnot &orig); + CircularKnot &operator =(CircularKnot &orig); + + // Draw the basic knot at the origin. + virtual void + drawBasicKnot(void) const; + + virtual void + draw(Position where, GLfloat angle) const; + + // Data members. + int mSectors; + GLfloat mEdgeLength; + GLfloat mRadius; +}; + +#endif // CIRCULARKNOT_H diff --git a/knot engine/ClosedKnot.cpp b/knot engine/ClosedKnot.cpp new file mode 100644 index 0000000..00ab974 --- /dev/null +++ b/knot engine/ClosedKnot.cpp @@ -0,0 +1,68 @@ +// A class representing a random closed knot. +// +// Copyright © 1997-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#include "ClosedKnot.h" + +#include <cmath> + +#include <OpenGL/gl.h> + +#include "KnotSection.h" +#include "Position.h" + +ClosedKnot::ClosedKnot(int windowWidth, int windowHeight) +: inherited(windowWidth, windowHeight, 12) +{ + // Set boundary conditions for a closed knot. + + // The left and right border must consist of vertical... + for (int i = 0; i < mVSections; ++i) { + sectionType(0, i) = sectionType(mHSections-1, i) = V; + } + + // ... half sections. + for (int i = 0; i <= mVSections; ++i) { + sectionCorner(0, i) = sectionCorner(mHSections, i) = N; + } + + // The top and bottom border must have horizontal corners. + for (int i = 1; i < mHSections; ++i) { + sectionCorner(i, 0) = sectionCorner(i, mVSections) = H; + } + + // Assign colors to the knot. + assignColors(); +} + +ClosedKnot::~ClosedKnot(void) +{ + // empty +} + +void +ClosedKnot::draw(Position where, GLfloat angle) const +{ + glPushMatrix(); + { + glTranslatef(where.x, where.y, 0.0); + glRotatef(angle * 180.0 / M_PI, 0.0, 0.0, 1.0); + glCallList(displayList()); + } + glPopMatrix(); +} diff --git a/knot engine/ClosedKnot.h b/knot engine/ClosedKnot.h new file mode 100644 index 0000000..9991c84 --- /dev/null +++ b/knot engine/ClosedKnot.h @@ -0,0 +1,43 @@ +// A class representing a random closed knot. +// +// Copyright © 1997-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#ifndef CLOSEDKNOT_H +#define CLOSEDKNOT_H + +#include <OpenGL/gl.h> + +#include "Position.h" +#include "RectangularKnot.h" + +class ClosedKnot : public RectangularKnot +{ + typedef RectangularKnot inherited; +public: + ClosedKnot(int windowWidth, int windowHeight); + virtual ~ClosedKnot(void); + +private: + ClosedKnot(const ClosedKnot &orig); + ClosedKnot &operator =(ClosedKnot &orig); + + virtual void + draw(Position where, GLfloat angle) const; +}; + +#endif // CLOSEDKNOT_H diff --git a/knot engine/HorizontalKnot.cpp b/knot engine/HorizontalKnot.cpp new file mode 100644 index 0000000..0dc3613 --- /dev/null +++ b/knot engine/HorizontalKnot.cpp @@ -0,0 +1,49 @@ +// A class representing a random horizontally tileable knot. +// +// Copyright © 1997-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#include "HorizontalKnot.h" + +#include "KnotSection.h" +#include "Position.h" +#include "TiledKnot.h" +#include "RandomNumbers.h" + +HorizontalKnot::HorizontalKnot(int width, int height) +: inherited(width, height, Position(1.0, 0.0)) +{ + // Set boundary conditions for a horizontal knot. + + // The left and right borders must match. + for (int i = 1; i < mVSections; ++i) { + sectionCorner(mHSections, i) = sectionCorner(0, i); + } + + // The top and bottom borders must have horizontal corners. + for (int i = 0; i <= mHSections; ++i) { + sectionCorner(i, 0) = sectionCorner(i, mVSections) = H; + } + + // Assign colors to the knot. + assignColors(); +} + +HorizontalKnot::~HorizontalKnot(void) +{ + // empty +} diff --git a/knot engine/HorizontalKnot.h b/knot engine/HorizontalKnot.h new file mode 100644 index 0000000..98b73b8 --- /dev/null +++ b/knot engine/HorizontalKnot.h @@ -0,0 +1,37 @@ +// A class representing a random horizontally tileable knot. +// +// Copyright © 1997-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#ifndef HORIZONTALKNOT_H +#define HORIZONTALKNOT_H + +#include "TiledKnot.h" + +class HorizontalKnot : public TiledKnot +{ + typedef TiledKnot inherited; +public: + HorizontalKnot(int windowWidth, int windowHeight); + virtual ~HorizontalKnot(void); + +private: + HorizontalKnot(const HorizontalKnot &orig); + HorizontalKnot &operator =(HorizontalKnot &orig); +}; + +#endif // HORIZONTALKNOT_H diff --git a/knot engine/KnotSection.cpp b/knot engine/KnotSection.cpp index 85497a9..f6132c0 100644 --- a/knot engine/KnotSection.cpp +++ b/knot engine/KnotSection.cpp @@ -1,391 +1,391 @@ // Description of knot strokes and sections. // // Copyright © 1997-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "KnotSection.h" #include <OpenGL/gl.h> #include "Position.h" #include "Stroke.h" #include "StrokeSet.h" namespace { static const GLint t0[4] = { 1, 0, 0, 1 }; static const GLint t1[4] = { 0, -1, 1, 0 }; static const GLint t2[4] = { -1, 0, 0, -1 }; static const GLint t3[4] = { 0, 1, -1, 0 }; static const GLint t4[4] = { -1, 0, 0, 1 }; static const GLint t5[4] = { 0, -1, -1, 0 }; static const GLint t6[4] = { 1, 0, 0, -1 }; static const GLint t7[4] = { 0, 1, 1, 0 }; static const GLfloat black[4] = { 0.0, 0.0, 0.0, 1.0 }; void strokeCorners( const KnotSection &section, Position center, GLfloat size, GLfloat radius, GLfloat angle, const StrokeSet &strokes, const GLfloat ltCornerColor[4], const GLfloat rbCornerColor[4]) { // Draw corners of the section if needed. if (section.leftTop() == D) { glColor4fv(ltCornerColor); strokes[StrokeSet::Corner].draw(center, size, radius, angle, t0); } if (section.rightBottom() == D) { glColor4fv(rbCornerColor); strokes[StrokeSet::Corner].draw(center, size, radius, angle, t2); } } void diagonalStroke( - direction from, direction to, bool mirror, + Direction from, Direction to, bool mirror, Position center, GLfloat size, GLfloat radius, GLfloat angle, const StrokeSet &strokes, const GLfloat color[4]) { glColor4fv(color); switch (4*from + to) { case 4*D + D: strokes[StrokeSet::DDD].draw(center, size, radius, angle, mirror ? t4 : t0); break; case 4*D + H: strokes[StrokeSet::DHD].draw(center, size, radius, angle, mirror ? t6 : t2); break; case 4*D + V: strokes[StrokeSet::DHD].draw(center, size, radius, angle, mirror ? t1 : t7); break; case 4*H + D: strokes[StrokeSet::DHD].draw(center, size, radius, angle, mirror ? t4 : t0); break; case 4*H + H: strokes[StrokeSet::DHH].draw(center, size, radius, angle, mirror ? t4 : t0); break; case 4*H + V: strokes[StrokeSet::DHV].draw(center, size, radius, angle, mirror ? t4 : t0); break; case 4*V + D: strokes[StrokeSet::DHD].draw(center, size, radius, angle, mirror ? t3 : t5); break; case 4*V + H: strokes[StrokeSet::DHV].draw(center, size, radius, angle, mirror ? t6 : t2); break; case 4*V + V: strokes[StrokeSet::DHH].draw(center, size, radius, angle, mirror ? t1 : t5); break; default: // Just ignore illegal diagonal strokes. break; } } void diagonalSection( const KnotSection &section, Position center, GLfloat size, GLfloat radius, GLfloat angle, const StrokeSet &outlineStrokes, const StrokeSet &fillStrokes, bool hollow, const GLfloat topColor[4], const GLfloat botColor[4], const GLfloat ltCornerColor[4], const GLfloat rbCornerColor[4]) { // Draw bottom stroke. diagonalStroke(section.rightTop(), section.leftBottom(), true, center, size, radius, angle, outlineStrokes, hollow ? botColor : black); diagonalStroke(section.rightTop(), section.leftBottom(), true, center, size, radius, angle, fillStrokes, hollow ? black : botColor); // Draw top stroke. diagonalStroke(section.leftTop(), section.rightBottom(), false, center, size, radius, angle, outlineStrokes, hollow ? topColor : black); diagonalStroke(section.leftTop(), section.rightBottom(), false, center, size, radius, angle, fillStrokes, hollow ? black : topColor); // Draw corners if needed. strokeCorners(section, center, size, radius, angle, outlineStrokes, hollow ? ltCornerColor : black, hollow ? rbCornerColor : black); strokeCorners(section, center, size, radius, angle, fillStrokes, hollow ? black : ltCornerColor, hollow ? black : rbCornerColor); } void horizontalStroke( - direction from, direction to, bool mirror, + Direction from, Direction to, bool mirror, Position center, GLfloat size, GLfloat radius, GLfloat angle, const StrokeSet &strokes, const GLfloat color[4]) { glColor4fv(color); switch (4*from + to) { case 4*D + D: strokes[StrokeSet::HDD].draw(center, size, radius, angle, mirror ? t2 : t0); break; case 4*D + H: strokes[StrokeSet::HDH].draw(center, size, radius, angle, mirror ? t6 : t0); break; case 4*D + V: strokes[StrokeSet::HDV].draw(center, size, radius, angle, mirror ? t6 : t0); break; case 4*H + D: strokes[StrokeSet::HDH].draw(center, size, radius, angle, mirror ? t2 : t4); break; case 4*H + H: strokes[StrokeSet::HHH].draw(center, size, radius, angle, mirror ? t2 : t0); break; case 4*H + V: strokes[StrokeSet::HHV].draw(center, size, radius, angle, mirror ? t6 : t0); break; case 4*V + D: strokes[StrokeSet::HDV].draw(center, size, radius, angle, mirror ? t2 : t4); break; case 4*V + H: strokes[StrokeSet::HHV].draw(center, size, radius, angle, mirror ? t2 : t4); break; case 4*V + V: strokes[StrokeSet::HVV].draw(center, size, radius, angle, mirror ? t2 : t0); break; case 4*N + N: // Stroke omitted (edge section). break; default: // Just ignore illegal horizontal strokes. break; } } void horizontalSection( const KnotSection &section, Position center, GLfloat size, GLfloat radius, GLfloat angle, const StrokeSet &outlineStrokes, const StrokeSet &fillStrokes, bool hollow, const GLfloat topColor[4], const GLfloat botColor[4], const GLfloat ltCornerColor[4], const GLfloat rbCornerColor[4]) { // Draw bottom stroke. horizontalStroke(section.leftBottom(), section.rightBottom(), true, center, size, radius, angle, outlineStrokes, hollow ? botColor : black); horizontalStroke(section.leftBottom(), section.rightBottom(), true, center, size, radius, angle, fillStrokes, hollow ? black : botColor); // Draw top stroke. horizontalStroke(section.leftTop(), section.rightTop(), false, center, size, radius, angle, outlineStrokes, hollow ? topColor : black); horizontalStroke(section.leftTop(), section.rightTop(), false, center, size, radius, angle, fillStrokes, hollow ? black : topColor); // Draw corners if needed. strokeCorners(section, center, size, radius, angle, outlineStrokes, hollow ? ltCornerColor : black, hollow ? rbCornerColor : black); strokeCorners(section, center, size, radius, angle, fillStrokes, hollow ? black : ltCornerColor, hollow ? black : rbCornerColor); } void verticalStroke( - direction from, direction to, bool mirror, + Direction from, Direction to, bool mirror, Position center, GLfloat size, GLfloat radius, GLfloat angle, const StrokeSet &strokes, const GLfloat color[4]) { glColor4fv(color); switch (4*from + to) { case 4*D + D: strokes[StrokeSet::HDD].draw(center, size, radius, angle, mirror ? t3 : t1); break; case 4*D + H: strokes[StrokeSet::HDV].draw(center, size, radius, angle, mirror ? t3 : t5); break; case 4*D + V: strokes[StrokeSet::HDH].draw(center, size, radius, angle, mirror ? t3 : t5); break; case 4*H + D: strokes[StrokeSet::HDV].draw(center, size, radius, angle, mirror ? t7 : t1); break; case 4*H + H: strokes[StrokeSet::HVV].draw(center, size, radius, angle, mirror ? t3 : t1); break; case 4*H + V: strokes[StrokeSet::HHV].draw(center, size, radius, angle, mirror ? t7 : t1); break; case 4*V + D: strokes[StrokeSet::HDH].draw(center, size, radius, angle, mirror ? t7 : t1); break; case 4*V + H: strokes[StrokeSet::HHV].draw(center, size, radius, angle, mirror ? t3 : t5); break; case 4*V + V: strokes[StrokeSet::HHH].draw(center, size, radius, angle, mirror ? t3 : t1); break; case 4*N + N: // Stroke omitted (edge section). break; default: // Just ignore illegal vertical strokes. break; } } void verticalSection( const KnotSection &section, Position center, GLfloat size, GLfloat radius, GLfloat angle, const StrokeSet &outlineStrokes, const StrokeSet &fillStrokes, bool hollow, const GLfloat topColor[4], const GLfloat botColor[4], const GLfloat ltCornerColor[4], const GLfloat rbCornerColor[4]) { // Draw right stroke. verticalStroke(section.rightTop(), section.rightBottom(), true, center, size, radius, angle, outlineStrokes, hollow ? botColor : black); verticalStroke(section.rightTop(), section.rightBottom(), true, center, size, radius, angle, fillStrokes, hollow ? black : botColor); // Draw left stroke. verticalStroke(section.leftTop(), section.leftBottom(), false, center, size, radius, angle, outlineStrokes, hollow ? topColor : black); verticalStroke(section.leftTop(), section.leftBottom(), false, center, size, radius, angle, fillStrokes, hollow ? black : topColor); // Draw corners if needed. strokeCorners(section, center, size, radius, angle, outlineStrokes, hollow ? ltCornerColor : black, hollow ? rbCornerColor : black); strokeCorners(section, center, size, radius, angle, fillStrokes, hollow ? black : ltCornerColor, hollow ? black : rbCornerColor); } } void KnotSection::draw( Position center, GLfloat size, GLfloat radius, GLfloat angle, const StrokeSet &outlineStrokes, const StrokeSet &fillStrokes, bool hollow, const GLfloat topColor[4], const GLfloat botColor[4], const GLfloat ltCornerColor[4], const GLfloat rbCornerColor[4]) const { switch (mType) { case D: diagonalSection(*this, center, size, radius, angle, outlineStrokes, fillStrokes, hollow, topColor, botColor, ltCornerColor, rbCornerColor); break; case H: horizontalSection(*this, center, size, radius, angle, outlineStrokes, fillStrokes, hollow, topColor, botColor, ltCornerColor, rbCornerColor); break; case V: verticalSection(*this, center, size, radius, angle, outlineStrokes, fillStrokes, hollow, topColor, botColor, ltCornerColor, rbCornerColor); break; default: // Just ignore illegal section types. break; } } diff --git a/knot engine/KnotSection.h b/knot engine/KnotSection.h index 1f70e1c..1a56ee2 100644 --- a/knot engine/KnotSection.h +++ b/knot engine/KnotSection.h @@ -1,82 +1,82 @@ // Description of knot strokes and sections. // // Copyright © 1997-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. // Traditionally, Celtic knotwork is drawn on a diagonal grid // overlaid with straight lines and circles. Xamhain uses // a simpler method devised by Andy Sloss, which divides the knot // into sections at every other grid point. Each section can be // uniquely described by the directions in which the knot passes // through the section's corners, plus the directions the two lines // take in the interior of the section. // There are three possible directions (diagonal, horizontal and // vertical), so there are 3^5 = 243 basic sections. The horizontal // and vertical sections can be split in half for closing up the edges // of a knot, yielding another 36 shapes. These are represented // as a section with two corners that have "no" direction. // // Because of symmetries, the 279 different sections can be drawn // using only 10 basic strokes - see class StrokeSet. #ifndef KNOTSECTION_H #define KNOTSECTION_H #include <OpenGL/gl.h> #include "Position.h" class StrokeSet; -enum direction { // Directions of strokes and sections. +enum Direction { // Directions of strokes and sections. D = 0, // diagonal H = 1, // horizontal V = 2, // vertical N = 3 // none (edge sections only) }; // Identify the two 'strands' in a section. enum { BOT, TOP }; class KnotSection { - const direction mType, mLT, mRT, mLB, mRB; + const Direction mType, mLT, mRT, mLB, mRB; public: - KnotSection(direction tp, - direction lt, direction rt, direction lb, direction rb) + KnotSection(Direction tp, + Direction lt, Direction rt, Direction lb, Direction rb) : mType(tp), mLT(lt), mRT(rt), mLB(lb), mRB(rb) { // empty } - direction type(void) const { return mType; } - direction leftTop(void) const { return mLT; } - direction rightTop(void) const { return mRT; } - direction leftBottom(void) const { return mLB; } - direction rightBottom(void) const { return mRB; } + Direction type(void) const { return mType; } + Direction leftTop(void) const { return mLT; } + Direction rightTop(void) const { return mRT; } + Direction leftBottom(void) const { return mLB; } + Direction rightBottom(void) const { return mRB; } // Draw the section at the given location and size, using the strokes // and colors to determine how it will look. If radius and angle, // are non-zero, the stroke is warped into a segment of an annulus. void draw(Position center, GLfloat size, GLfloat radius, GLfloat angle, const StrokeSet &outlineStrokes, const StrokeSet &fillStrokes, bool hollow, const GLfloat topColor[4], const GLfloat botColor[4], const GLfloat ltCornerColor[4], const GLfloat rbCornerColor[4]) const; }; #endif // KNOTSECTION_H diff --git a/knot engine/RandomKnot.cpp b/knot engine/RandomKnot.cpp new file mode 100644 index 0000000..7a6c6d9 --- /dev/null +++ b/knot engine/RandomKnot.cpp @@ -0,0 +1,402 @@ +// Base class for creating random knots. +// +// Copyright © 1997-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#include "RandomKnot.h" + +#include <algorithm> +#include <cmath> +#include <cstdlib> +#include <OpenGL/gl.h> + +#include "KnotSection.h" +#include "Position.h" +#include "RandomColor.h" +#include "RandomNumbers.h" +#include "StrokeSet.h" + +namespace +{ + // Generate an array of random direction values. + Direction * + randomDirectionArray(int width, int height, GLfloat min, GLfloat max) + { + Direction *pArray = new Direction[width * height]; + for (int i = 0; i < height; ++i) { + for (int j = 0; j < width; ++j) { + GLfloat p = randomFloat(); + if (p < min) { + pArray[i*width + j] = H; + + } else if (p < max) { + pArray[i*width + j] = D; + + } else { + pArray[i*width + j] = V; + } + } + } + + return pArray; + } + + // Enforce symmetry in an array of random direction values. + void + enforceSymmetry(Direction *pArray, + int width, int height, + int widthLimit, int heightLimit, + bool xMirror, bool yMirror) + { + for (int i0 = 0; i0 < heightLimit; ++i0) { + const int i1 = yMirror ? height - i0 - 1 : i0; + for (int j0 = 0; j0 < widthLimit; ++j0) { + const int j1 = xMirror ? width - j0 - 1 : j0; + + pArray[i1*width + j1] = pArray[i0*width + j0]; + } + } + } +} + +RandomKnot::RandomKnot(int windowWidth, int windowHeight, int maxSections) +: mWindowWidth(windowWidth), + mWindowHeight(windowHeight), + mHSections(3 + randomInteger(maxSections - 3)), + mVSections(3 + randomInteger(maxSections - 3)), + mpOutlineStrokes(0), + mpFillStrokes(0), + mpSectionTypes(0), + mpSectionCorners(0), + mpColors(0), + mDisplayList(0) +{ + // Determine knot style. + if (randomFloat() < mPrefs.broadKnotProbability()) { + mpOutlineStrokes = &StrokeSet::broadOutline(); + mpFillStrokes = &StrokeSet::broadFill(); + } else { + mpOutlineStrokes = &StrokeSet::slenderOutline(); + mpFillStrokes = &StrokeSet::slenderFill(); + } + + mHollow = randomFloat() < mPrefs.hollowKnotProbability(); + + // Initialize the knot data. Derived classes have to establish + // the proper boundary conditions. + mpSectionTypes = + randomDirectionArray(mHSections, mVSections, + mPrefs.sectionProbability1(), + mPrefs.sectionProbability2()); + mpSectionCorners = + randomDirectionArray(mHSections + 1, mVSections + 1, + mPrefs.cornerProbability1(), + mPrefs.cornerProbability2()); + + mpSectionColors[BOT] = new int[mHSections * mVSections]; + mpSectionColors[TOP] = new int[mHSections * mVSections]; + + if (randomFloat() < mPrefs.symmetricKnotProbability()) { + // Enforce symmetries. + enforceHorizontalSymmetry( + randomFloat() < mPrefs.horizontalMirrorProbability()); + enforceVerticalSymmetry( + randomFloat() < mPrefs.verticalMirrorProbability()); + } +} + +RandomKnot::~RandomKnot(void) +{ + delete [] mpSectionTypes; + mpSectionTypes = 0; + delete [] mpSectionCorners; + mpSectionCorners = 0; + delete [] mpSectionColors[BOT]; + mpSectionColors[BOT] = 0; + delete [] mpSectionColors[TOP]; + mpSectionColors[TOP] = 0; + delete [] mpColors; + mpColors = 0; + + mpOutlineStrokes = mpFillStrokes = 0; + + if (mDisplayList) { + glDeleteLists(mDisplayList, 1); + mDisplayList = 0; + } +} + +bool +RandomKnot::animate(void) +{ + if (mTime >= mMaxTime) { + return false; + } + + // Draw the knot in its current state. + draw(mBasePosition + mTime * mDirection, mAngle); + + // Update the state. + mTime += mSpeed; + mAngle += mSpin; + + return true; +} + +GLuint +RandomKnot::displayList(void) const +{ + if (!mDisplayList) { + mDisplayList = glGenLists(1); + + // Generate the display list. + glNewList(mDisplayList, GL_COMPILE); + { + drawBasicKnot(); + } + glEndList(); + } + + return mDisplayList; +} + +void +RandomKnot::enforceHorizontalSymmetry(bool mirror) +{ + enforceSymmetry(mpSectionTypes, + mHSections, mVSections, + mHSections / 2, mVSections, + true, mirror); + enforceSymmetry(mpSectionCorners, + mHSections + 1, mVSections + 1, + (mHSections + 1) / 2, mVSections + 1, + true, mirror); +} + +void +RandomKnot::enforceVerticalSymmetry(bool mirror) +{ + enforceSymmetry(mpSectionTypes, + mHSections, mVSections, + mHSections, mVSections / 2, + mirror, true); + enforceSymmetry(mpSectionCorners, + mHSections + 1, mVSections + 1, + mHSections + 1, (mVSections + 1) / 2, + mirror, true); +} + +void +RandomKnot::prepareAnimation(Position extent, bool xRepeat, bool yRepeat) +{ + // Find a random position within the window where the knot will be visible. + const GLfloat knotWidth = 2.0 * extent.x; + const GLfloat knotHeight = 2.0 * extent.y; + if (knotWidth < mWindowWidth && knotHeight < mWindowHeight) { + mBasePosition = + Position(randomFloat(mWindowWidth - knotWidth), + randomFloat(mWindowHeight - knotHeight)) + + extent; + } else { + mBasePosition = Position(randomFloat() * mWindowWidth, + randomFloat() * mWindowHeight); + } + + // Give the knot a random speed, direction, angle and spin. + mSpeed = randomFloat(mPrefs.minSpeed(), mPrefs.maxSpeed()); + + GLfloat dir; + if (randomFloat() < mPrefs.skewProbability()) { + dir = randomFloat(0.0, M_PI * 2.0); + + if (xRepeat) { + mAngle = fmod(dir + M_PI_2, M_PI * 2.0); + } else if (yRepeat) { + mAngle = dir; + } else { + mAngle = randomFloat(0.0, M_PI * 2.0); + } + + } else { + int quad; + if (xRepeat) { + quad = 2 * randomInteger(2) + 1; + } else if (yRepeat) { + quad = 2 * randomInteger(2); + } else { + quad = randomInteger(4); + } + dir = quad * M_PI_2; + mAngle = 0.0; + } + mDirection = Position(cos(dir), sin(dir)); + + if (randomFloat() < mPrefs.spinProbability()) { + mSpin = randomFloat(mPrefs.minSpin(), mPrefs.maxSpin()) + * ((randomFloat() < 0.5) ? 1.0 : -1.0) + / 180.0 * M_PI; + } else { + mSpin = 0.0; + } + + // Calculate the starting and stopping times, i.e., the time at which + // the knot's bounding circle is tangent to the window's bounding circle. + // + // - project window midpoint to point P0 on line of movement at time T0. + // - use Pythagoras to compute distance from P0 to center of knot + // - calculate T0 - distance and T0 + distance + const Position midPosition(mWindowWidth * 0.5, mWindowHeight * 0.5); + const GLfloat t0 = (midPosition - mBasePosition) * mDirection; + const Position p0 = mBasePosition + t0 * mDirection; + + const GLfloat hyp = norm(midPosition) + norm(extent); + const GLfloat cat = norm(midPosition - p0); + const GLfloat distance = sqrt(hyp * hyp - cat * cat); + + mTime = t0 - distance; + mMaxTime = t0 + distance; + + // Adjust the spin rate so the angle is consistent at start and stop. + GLfloat iterations = floor((mMaxTime - mTime) / mSpeed); + mSpin = floor(mSpin / M_PI * iterations) * M_PI / iterations; +} + +void +RandomKnot::assignColors(void) +{ + // Initialize the color indices; -1 indicates an as-yet-unknown color. + int color = mPrefs.technicolor() ? -1 : 0; + for (int y = 0; y < mVSections; ++y) { + for (int x = 0; x < mHSections; ++x) { + mpSectionColors[BOT][y * mHSections + x] = color; + mpSectionColors[TOP][y * mHSections + x] = color; + } + } + ++color; + + // Assign colors to the sections by tracing all the 'strands' in the knot. + for (int y = 0; y < mVSections; ++y) { + for (int x = 0; x < mHSections; ++x) { + if (mpSectionColors[TOP][y * mHSections + x] < 0) { + // Assign a color to the top strand. + if (traceColor(color, TOP, x, y, 0, 0)) { + ++color; + } + } + + if (mpSectionColors[BOT][y * mHSections + x] < 0) { + // Assign a color to the bottom strand. + switch (mpSectionTypes[y * mHSections + x]) { + + case D: + case H: + if (traceColor(color, BOT, x, y, 0, 1)) { + ++color; + } + break; + + case V: + if (traceColor(color, BOT, x, y, 1, 0)) { + ++color; + } + break; + + case N: + break; + } + } + } + } + + // Generate the random colors. + mpColors = new RandomColor[color]; + int hue = randomInteger(360); + const int gamut = 90 + randomInteger(270); + const int shift = gamut / color; + for (int i = 0; i < color; ++i) { + mpColors[i] = RandomColor(0.4, 0.9, 0.6, 1.0, 1.0, 1.0, hue); + hue = (hue + shift) % 360; + } +} + +bool +RandomKnot::traceColor(int color, int layer, int x, int y, int dx, int dy) +{ + for (;;) { + mpSectionColors[layer][y * mHSections + x] = color; + + // Hop across the corner indicated by dx/dy. + switch (mpSectionCorners[(y+dy) * (mHSections+1) + x+dx]) { + + case D: + x = (dx ? x+1 : x-1+mHSections) % mHSections; + dx = 1-dx; + y = (dy ? y+1 : y-1+mVSections) % mVSections; + dy = 1-dy; + break; + + case H: + x = (dx ? x+1 : x-1+mHSections) % mHSections; + dx = 1-dx; + break; + + case V: + y = (dy ? y+1 : y-1+mVSections) % mVSections; + dy = 1-dy; + break; + + case N: + mpSectionColors[layer][y * mHSections + x] = 0; + return false; + } + + // Decide how to continue. + switch (mpSectionTypes[y * mHSections + x]) { + + case D: + dx = 1-dx; + dy = 1-dy; + layer = (dx + dy) % 2 ? BOT : TOP; + break; + + case H: + dx = 1-dx; + layer = dy ? BOT : TOP; + break; + + case V: + dy = 1-dy; + layer = dx ? BOT : TOP; + break; + + case N: + // This can't happen. + abort(); + } + + if (mpSectionColors[layer][y * mHSections + x] == color) { + // We're done with this strand. + break; + + } else if (mpSectionColors[layer][y * mHSections + x] >= 0) { + // This can't happen. + abort(); + } + } + + return true; +} diff --git a/knot engine/RandomKnot.h b/knot engine/RandomKnot.h new file mode 100644 index 0000000..d7749ef --- /dev/null +++ b/knot engine/RandomKnot.h @@ -0,0 +1,152 @@ +// Abstract base class for creating random knots. +// +// Copyright © 1997-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#ifndef RANDOMKNOT_H +#define RANDOMKNOT_H + +#include <OpenGL/gl.h> + +#include "KnotSection.h" +#include "Position.h" +#include "RandomColor.h" +class StrokeSet; +#include "XamhainPreferences.h" + +class RandomKnot +{ +public: + RandomKnot(int windowWidth, int windowHeight, int maxSections); + virtual ~RandomKnot(void); + + // Perform a single animation cycle; return 'false' when finished. + bool + animate(void); + +protected: + // Return display list for drawing the basic knot. + GLuint + displayList(void) const; + + // Draw the basic knot at the origin (to set up the display list). + virtual void + drawBasicKnot(void) const = 0; + + // Enforce symmetries in the random arrays. + void + enforceHorizontalSymmetry(bool mirror); + void + enforceVerticalSymmetry(bool mirror); + + // Calculate animation parameters given the knot's size. + void + prepareAnimation(Position extent, bool xRepeat = false, bool yRepeat = false); + + // Assign colors to the knot. + void + assignColors(void); + + // Inquire knot data. + Direction + sectionType(int x, int y) const + { + return mpSectionTypes[y * mHSections + x]; + } + Direction & + sectionType(int x, int y) + { + return mpSectionTypes[y * mHSections + x]; + } + + Direction + sectionCorner(int x, int y) const + { + return mpSectionCorners[y * (mHSections + 1) + x]; + } + Direction & + sectionCorner(int x, int y) + { + return mpSectionCorners[y * (mHSections + 1) + x]; + } + + const GLfloat * + sectionColor(int layer, int x, int y) const + { + return mpColors[mpSectionColors[layer][y * mHSections + x]]; + } + const GLfloat * + leftTopCornerColor(int x, int y) const + { + y = (y - 1 + mVSections) % mVSections; + if (sectionType(x, y) != V) { + return sectionColor(BOT, x, y); + } else { + return sectionColor(TOP, x, y); + } + } + const GLfloat * + rightBottomCornerColor(int x, int y) const + { + y = (y + 1) % mVSections; + if (sectionType(x, y) != H) { + return sectionColor(BOT, x, y); + } else { + return sectionColor(TOP, x, y); + } + } + + // Data members. + const int mWindowWidth; // window size + const int mWindowHeight; + const int mHSections; // horizontal #sections + const int mVSections; // vertical #sections + const StrokeSet *mpOutlineStrokes; // knot properties + const StrokeSet *mpFillStrokes; + bool mHollow; + +protected: + XamhainPreferences mPrefs; // user preferences + +private: + RandomKnot(const RandomKnot &orig); + RandomKnot &operator =(RandomKnot &orig); + + // Draw the (possibly replicated) knot. + virtual void + draw(Position where, GLfloat angle) const = 0; + + // Trace a 'strand' of the knot and assign a color to it. + bool + traceColor(int color, int layer, int x, int y, int dx, int dy); + + // Data members. + Direction *mpSectionTypes; // types of sections + Direction *mpSectionCorners; // corner directions + int *mpSectionColors[2]; // color indices (two per section) + RandomColor *mpColors; // colors + Position mBasePosition; // animation data + Position mDirection; + GLfloat mSpeed; + GLfloat mAngle; + GLfloat mSpin; + GLfloat mTime; + GLfloat mMaxTime; + mutable GLuint mDisplayList; // display list caching the basic knot +}; + +#endif // RANDOMKNOT_H diff --git a/knot engine/RectangularKnot.cpp b/knot engine/RectangularKnot.cpp new file mode 100644 index 0000000..7e0b469 --- /dev/null +++ b/knot engine/RectangularKnot.cpp @@ -0,0 +1,87 @@ +// A class representing a random rectangular knot. +// +// Copyright © 2004-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#include "RectangularKnot.h" + +#include <cmath> +#include <algorithm> +#include <OpenGL/gl.h> + +#include "KnotSection.h" +#include "Position.h" +#include "RandomKnot.h" +#include "RandomNumbers.h" + +namespace +{ + // Minimum size of knot sections. + const int kMinEdgeLength = 10; +} + +RectangularKnot::RectangularKnot(int windowWidth, int windowHeight, + int maxSections, int xRepeat, int yRepeat) +: inherited(windowWidth, windowHeight, maxSections) +{ + // Calculate dimensions of the knot. + const GLfloat fraction = randomFloat(mPrefs.minSize(), mPrefs.maxSize()); + const int sectionWidth = + (int)(fraction * mWindowWidth / mHSections / xRepeat); + const int sectionHeight = + (int)(fraction * mWindowHeight / mVSections / yRepeat); + mEdgeLength = + ::std::max(::std::max(sectionWidth, sectionHeight), + (mHollow ? 3 : 1) * kMinEdgeLength); + + // Calculate the remaining properties. + prepareAnimation(Position(mHSections, mVSections) * mEdgeLength * 0.5, + xRepeat > 1, + yRepeat > 1); +} + +RectangularKnot::~RectangularKnot(void) +{ + // empty +} + +void +RectangularKnot::drawBasicKnot(void) const +{ + const Position offset = + - (mEdgeLength*0.5) * Position(mHSections-1, mVSections-1); + + // Draw all the sections. + for (int i = 0; i < mVSections; ++i) { + for (int j = 0; j < mHSections; ++j) { + KnotSection section(sectionType(j, i), + sectionCorner(j, i), + sectionCorner(j+1, i), + sectionCorner(j, i+1), + sectionCorner(j+1, i+1)); + const GLfloat *pTopColor = sectionColor(TOP, j, i); + const GLfloat *pBotColor = sectionColor(BOT, j, i); + const GLfloat *pLTColor = leftTopCornerColor(j, i); + const GLfloat *pRBColor = rightBottomCornerColor(j, i); + + section.draw(offset + mEdgeLength*Position(j, (mVSections-1 - i)), + mEdgeLength, 0.0, 0.0, + *mpOutlineStrokes, *mpFillStrokes, mHollow, + pTopColor, pBotColor, pLTColor, pRBColor); + } + } +} diff --git a/knot engine/RectangularKnot.h b/knot engine/RectangularKnot.h new file mode 100644 index 0000000..fc50517 --- /dev/null +++ b/knot engine/RectangularKnot.h @@ -0,0 +1,56 @@ +// A class representing a random rectangular knot. +// +// Copyright © 2004-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#ifndef RECTANGULARKNOT_H +#define RECTANGULARKNOT_H + +#include <OpenGL/gl.h> + +#include "Position.h" +#include "RandomKnot.h" + +class RectangularKnot : public RandomKnot +{ + typedef RandomKnot inherited; +public: + RectangularKnot(int windowWidth, int windowHeight, + int maxSections, int xRepeat = 1, int yRepeat = 1); + virtual ~RectangularKnot(void); + +protected: + // Return the size of the basic knot. + Position + Size(void) const + { + return mEdgeLength * Position(mHSections, mVSections); + } + + // Draw the basic knot at the origin. + virtual void + drawBasicKnot(void) const; + +private: + RectangularKnot(const RectangularKnot &orig); + RectangularKnot &operator =(RectangularKnot &orig); + + // Data members. + GLfloat mEdgeLength; +}; + +#endif // RECTANGULARKNOT_H diff --git a/knot engine/TiledKnot.cpp b/knot engine/TiledKnot.cpp new file mode 100644 index 0000000..e30db1e --- /dev/null +++ b/knot engine/TiledKnot.cpp @@ -0,0 +1,149 @@ +// A class representing a random tiled knot. +// +// Copyright © 2004-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#include <algorithm> +#include <cmath> + +#include <OpenGL/gl.h> + +#include "TiledKnot.h" + +#include "KnotSection.h" +#include "Position.h" +#include "RandomNumbers.h" + +namespace +{ + int kMaxSections = 6; +} + +TiledKnot::TiledKnot(int windowWidth, int windowHeight, Position tilingDirection) +: inherited(windowWidth, windowHeight, + kMaxSections, + tilingDirection.x ? 4 + randomInteger(4) : 1, + tilingDirection.y ? 4 + randomInteger(4) : 1), + mTilingDirection(tilingDirection) +{ + // empty +} + +TiledKnot::~TiledKnot(void) +{ + // empty +} + +// Find the intersection of the line (p0 + t*d) with the line through pe +// with normal n. If no such intersection exists, return 'false'; +// otherwise set t to the parameter value at the intersection point +// and return 'true'. +bool +TiledKnot::clipLine(Position p0, Position d, Position pe, Position n, GLfloat &t) const +{ + const GLfloat dot = n * d; + if (fabs(dot) < 0.00001) { + // Near parallel lines. + return false; + } + + // See Foley et.al. + t = (n * (p0 - pe)) / -dot; + return true; +} + +// Find two values of the parameter t bounding the visible part of the line +// (p0 + t*d). (We don't care about the case that the line is completely +// invisible.) +void +TiledKnot::findBounds(Position p0, Position d, GLfloat t[2]) const +{ + const GLfloat diag = norm(Size()); + bool clipH, clipV; + GLfloat tt[4]; + + // Clip against lower and upper borders of window. + clipH = clipLine(p0, d, + Position(-mWindowWidth, -diag), Position(0.0, -1.0), + tt[0]) + && clipLine(p0, d, + Position(-mWindowWidth, mWindowHeight+diag), Position(0.0, 1.0), + tt[1]); + + // Clip against left and right borders of window. + clipV = clipLine(p0, d, + Position(-diag, -mWindowHeight), Position(-1.0, 0.0), + tt[2]) + && clipLine(p0, d, + Position(mWindowWidth+diag, -mWindowHeight), Position(1.0, 0.0), + tt[3]); + + // Sort the intersections. + ::std::sort(clipH ? (tt + 0) : (tt + 2), clipV ? (tt + 4) : (tt + 2)); + + if (clipH && clipV) { + // Find two intersections on opposite sides of the window. + const Position midPosition(mWindowWidth * 0.5, mWindowHeight * 0.5); + const GLfloat tm = (midPosition - p0) * d; + + const GLfloat *const p = ::std::lower_bound(tt + 0, tt + 4, tm); + + if (p > tt + 0 && p < tt + 4) { + t[0] = p[-1]; + t[1] = p[0]; + } else { + // This shouldn't hapen, but... + t[0] = t[1] = 0; + } + } else if (!clipH) { + t[0] = tt[2]; + t[1] = tt[3]; + } else { + t[0] = tt[0]; + t[1] = tt[1]; + } +} + +void +TiledKnot::draw(Position where, GLfloat angle) const +{ + const Position size(Size()); + const GLfloat step = size * mTilingDirection; + + const GLfloat rot[4] = { mTilingDirection.x, -mTilingDirection.y, + mTilingDirection.y, mTilingDirection.x }; + const Position d = rot * Position(cos(angle), sin(angle)); + + // Find the limits of visibility. + GLfloat t[2]; + findBounds(where, d, t); + const int minI = (int)floor(t[0] / step); + const int maxI = (int)ceil(t[1] / step); + + // Draw the knot. + for (int i = minI; i <= maxI; ++i) { + const Position pos = where + i * step * d; + + glPushMatrix(); + { + glTranslatef(pos.x, pos.y, 0.0); + glRotatef(angle * 180.0 / M_PI, 0.0, 0.0, 1.0); + glCallList(displayList()); + } + glPopMatrix(); + } +} diff --git a/knot engine/TiledKnot.h b/knot engine/TiledKnot.h new file mode 100644 index 0000000..9fbf5e0 --- /dev/null +++ b/knot engine/TiledKnot.h @@ -0,0 +1,54 @@ +// A class representing a random tiled knot. +// +// Copyright © 2004-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#ifndef TILEDKNOT_H +#define TILEDKNOT_H + +#include <OpenGL/gl.h> + +#include "Position.h" +#include "RectangularKnot.h" + +class TiledKnot : public RectangularKnot +{ + typedef RectangularKnot inherited; +public: + TiledKnot(int windowWidth, int windowHeight, Position tilingDirection); + virtual ~TiledKnot(void); + +private: + TiledKnot(const TiledKnot &orig); + TiledKnot &operator =(TiledKnot &orig); + + // Clip line (p0 + t*d) at a window boundary. + bool + clipLine(Position p0, Position d, Position pe, Position n, GLfloat &t) const; + // Find two parameter values between which the knot will be visible. + void + findBounds(Position p0, Position d, GLfloat t[2]) const; + + // Draw the (replicated) knot. + virtual void + draw(Position where, GLfloat angle) const; + + // Data members. + const Position mTilingDirection; +}; + +#endif // TILEDKNOT_H diff --git a/knot engine/VerticalKnot.cpp b/knot engine/VerticalKnot.cpp new file mode 100644 index 0000000..edf93d4 --- /dev/null +++ b/knot engine/VerticalKnot.cpp @@ -0,0 +1,49 @@ +// A class representing a random vertically tileable knot. +// +// Copyright © 1997-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#include "VerticalKnot.h" + +#include "KnotSection.h" +#include "Position.h" +#include "TiledKnot.h" +#include "RandomNumbers.h" + +VerticalKnot::VerticalKnot(int width, int height) +: inherited(width, height, Position(0.0, 1.0)) +{ + // Set boundary conditions for a vertical knot. + + // The left and right borders must have vertical corners. + for (int i = 0; i <= mVSections; ++i) { + sectionCorner(0, i) = sectionCorner(mHSections, i) = V; + } + + // The top and bottom borders must match. + for (int i = 1; i < mHSections; ++i) { + sectionCorner(i, mVSections) = sectionCorner(i, 0); + } + + // Assign colors to the knot. + assignColors(); +} + +VerticalKnot::~VerticalKnot(void) +{ + // empty +} diff --git a/knot engine/VerticalKnot.h b/knot engine/VerticalKnot.h new file mode 100644 index 0000000..dc7a411 --- /dev/null +++ b/knot engine/VerticalKnot.h @@ -0,0 +1,37 @@ +// A class representing a random vertically tileable knot. +// +// Copyright © 1997-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#ifndef VERTICALKNOT_H +#define VERTICALKNOT_H + +#include "TiledKnot.h" + +class VerticalKnot : public TiledKnot +{ + typedef TiledKnot inherited; +public: + VerticalKnot(int windowWidth, int windowHeight); + virtual ~VerticalKnot(void); + +private: + VerticalKnot(const VerticalKnot &orig); + VerticalKnot &operator =(VerticalKnot &orig); +}; + +#endif // VERTICALKNOT_H
jjk/XamhainII
e556031141f4efb6158459ebda87847708cd0c6e
Port the section drawing class.
diff --git a/XamhainII.xcodeproj/project.pbxproj b/XamhainII.xcodeproj/project.pbxproj index 7e4706f..c9ac6a6 100644 --- a/XamhainII.xcodeproj/project.pbxproj +++ b/XamhainII.xcodeproj/project.pbxproj @@ -1,658 +1,664 @@ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 45; objects = { /* Begin PBXAggregateTarget section */ 000D03D61089C45F003F010E /* XamhainII.dmg */ = { isa = PBXAggregateTarget; buildConfigurationList = 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */; buildPhases = ( 000D03D51089C45F003F010E /* ShellScript */, ); dependencies = ( 000D03DA1089C465003F010E /* PBXTargetDependency */, ); name = XamhainII.dmg; productName = XamhainII.dmg; }; /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0032D325108A30770033FA87 /* OpenGL.framework */; }; 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00791842108B081B00156D67 /* XamhainPreferences.mm */; }; 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007C5127108A29BE00ED3242 /* RandomColor.cpp */; }; 009D8964108E251800A416CF /* Stroke.mm in Sources */ = {isa = PBXBuildFile; fileRef = 009D8962108E251800A416CF /* Stroke.mm */; }; 009D897C108E28C800A416CF /* StrokeSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 009D897A108E28C800A416CF /* StrokeSet.cpp */; }; + 00D7B656108F8E9A00432E90 /* KnotSection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00D7B654108F8E9A00432E90 /* KnotSection.cpp */; }; 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */; }; 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */; }; 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */; }; 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */; }; 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */; }; 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */; }; 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */; }; 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */; }; 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */; }; 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */; }; 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */; }; 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */; }; 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */; }; 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */; }; 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */; }; 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */; }; 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */; }; 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */; }; 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */; }; 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */; }; 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */; }; 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */; }; 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */; }; 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */; }; 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */; }; 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */; }; 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */; }; 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */; }; 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */; }; 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */; }; 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */; }; 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */; }; 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */; }; 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */; }; 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */; }; 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */; }; 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */; }; 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */; }; 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */; }; 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */; }; 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */; }; 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */; }; 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */; }; 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */; }; 00DA7838107A73320094FCAB /* XamhainView.m in Sources */ = {isa = PBXBuildFile; fileRef = 00DA7836107A73320094FCAB /* XamhainView.m */; }; 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 000D03D91089C465003F010E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 089C1669FE841209C02AAC07 /* Project object */; proxyType = 1; remoteGlobalIDString = 8D255AC50486D3F9007BF209; remoteInfo = XamhainII; }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ 0032D325108A30770033FA87 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; }; 00791842108B081B00156D67 /* XamhainPreferences.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainPreferences.mm; path = "screen saving/XamhainPreferences.mm"; sourceTree = "<group>"; }; 00791843108B081B00156D67 /* XamhainPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainPreferences.h; path = "screen saving/XamhainPreferences.h"; sourceTree = "<group>"; }; 007C5126108A29BE00ED3242 /* Position.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Position.h; path = utility/Position.h; sourceTree = "<group>"; }; 007C5127108A29BE00ED3242 /* RandomColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RandomColor.cpp; path = utility/RandomColor.cpp; sourceTree = "<group>"; }; 007C5128108A29BE00ED3242 /* RandomColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomColor.h; path = utility/RandomColor.h; sourceTree = "<group>"; }; 007C5129108A29BE00ED3242 /* RandomNumbers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomNumbers.h; path = utility/RandomNumbers.h; sourceTree = "<group>"; }; 009D8962108E251800A416CF /* Stroke.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Stroke.mm; path = "knot engine/Stroke.mm"; sourceTree = "<group>"; }; 009D8963108E251800A416CF /* Stroke.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Stroke.h; path = "knot engine/Stroke.h"; sourceTree = "<group>"; }; 009D897A108E28C800A416CF /* StrokeSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StrokeSet.cpp; path = "knot engine/StrokeSet.cpp"; sourceTree = "<group>"; }; 009D897B108E28C800A416CF /* StrokeSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StrokeSet.h; path = "knot engine/StrokeSet.h"; sourceTree = "<group>"; }; + 00D7B654108F8E9A00432E90 /* KnotSection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KnotSection.cpp; path = "knot engine/KnotSection.cpp"; sourceTree = "<group>"; }; + 00D7B655108F8E9A00432E90 /* KnotSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KnotSection.h; path = "knot engine/KnotSection.h"; sourceTree = "<group>"; }; 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA7835107A73320094FCAB /* XamhainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainView.h; path = "screen saving/XamhainView.h"; sourceTree = "<group>"; }; 00DA7836107A73320094FCAB /* XamhainView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XamhainView.m; path = "screen saving/XamhainView.m"; sourceTree = "<group>"; }; 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ScreenSaver.framework; path = /System/Library/Frameworks/ScreenSaver.framework; sourceTree = "<absolute>"; }; 089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; 089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; }; 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; }; 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XamhainII_Prefix.pch; sourceTree = "<group>"; }; 8D255AD20486D3F9007BF209 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; 8D255AD30486D3F9007BF209 /* XamhainII.saver */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XamhainII.saver; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 8D255ACD0486D3F9007BF209 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */, 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */, 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 007C5125108A299800ED3242 /* Utility */ = { isa = PBXGroup; children = ( 007C5126108A29BE00ED3242 /* Position.h */, 007C5127108A29BE00ED3242 /* RandomColor.cpp */, 007C5128108A29BE00ED3242 /* RandomColor.h */, 007C5129108A29BE00ED3242 /* RandomNumbers.h */, ); name = Utility; sourceTree = "<group>"; }; 009D8961108E24ED00A416CF /* Knot Engine */ = { isa = PBXGroup; children = ( + 00D7B654108F8E9A00432E90 /* KnotSection.cpp */, + 00D7B655108F8E9A00432E90 /* KnotSection.h */, 009D897A108E28C800A416CF /* StrokeSet.cpp */, 009D897B108E28C800A416CF /* StrokeSet.h */, 009D8962108E251800A416CF /* Stroke.mm */, 009D8963108E251800A416CF /* Stroke.h */, ); name = "Knot Engine"; sourceTree = "<group>"; }; 00DA77D5107A728C0094FCAB /* Strokes */ = { isa = PBXGroup; children = ( 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */, 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */, 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */, 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */, 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */, 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */, 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */, 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */, 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */, 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */, 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */, 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */, 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */, 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */, 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */, 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */, 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */, 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */, 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */, 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */, 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */, 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */, 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */, 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */, 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */, 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */, 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */, 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */, 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */, 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */, 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */, 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */, 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */, 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */, 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */, 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */, 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */, 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */, 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */, 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */, 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */, 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */, 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */, 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */, ); name = Strokes; path = strokes; sourceTree = "<group>"; }; 00DA7833107A72F00094FCAB /* Screen Saving */ = { isa = PBXGroup; children = ( 00791842108B081B00156D67 /* XamhainPreferences.mm */, 00791843108B081B00156D67 /* XamhainPreferences.h */, 00DA7835107A73320094FCAB /* XamhainView.h */, 00DA7836107A73320094FCAB /* XamhainView.m */, ); name = "Screen Saving"; sourceTree = "<group>"; }; 089C166AFE841209C02AAC07 /* XamhainII */ = { isa = PBXGroup; children = ( 009D8961108E24ED00A416CF /* Knot Engine */, 00DA7833107A72F00094FCAB /* Screen Saving */, 007C5125108A299800ED3242 /* Utility */, 32DBCFA70370C4F300C91783 /* Other Sources */, 089C167CFE841241C02AAC07 /* Resources */, 089C1671FE841209C02AAC07 /* Frameworks and Libraries */, 19C28FB8FE9D52D311CA2CBB /* Products */, ); name = XamhainII; sourceTree = "<group>"; }; 089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = { isa = PBXGroup; children = ( 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */, 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */, ); name = "Frameworks and Libraries"; sourceTree = "<group>"; }; 089C167CFE841241C02AAC07 /* Resources */ = { isa = PBXGroup; children = ( 00DA77D5107A728C0094FCAB /* Strokes */, 8D255AD20486D3F9007BF209 /* Info.plist */, 089C167DFE841241C02AAC07 /* InfoPlist.strings */, ); name = Resources; sourceTree = "<group>"; }; 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = { isa = PBXGroup; children = ( 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, 0032D325108A30770033FA87 /* OpenGL.framework */, 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */, ); name = "Linked Frameworks"; sourceTree = "<group>"; }; 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = { isa = PBXGroup; children = ( 089C1672FE841209C02AAC07 /* Foundation.framework */, 089C167FFE841241C02AAC07 /* AppKit.framework */, ); name = "Other Frameworks"; sourceTree = "<group>"; }; 19C28FB8FE9D52D311CA2CBB /* Products */ = { isa = PBXGroup; children = ( 8D255AD30486D3F9007BF209 /* XamhainII.saver */, ); name = Products; sourceTree = "<group>"; }; 32DBCFA70370C4F300C91783 /* Other Sources */ = { isa = PBXGroup; children = ( 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */, ); name = "Other Sources"; sourceTree = "<group>"; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ 8D255AC60486D3F9007BF209 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ 8D255AC50486D3F9007BF209 /* XamhainII */ = { isa = PBXNativeTarget; buildConfigurationList = EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */; buildPhases = ( 8D255AC60486D3F9007BF209 /* Headers */, 8D255AC90486D3F9007BF209 /* Resources */, 8D255ACB0486D3F9007BF209 /* Sources */, 8D255ACD0486D3F9007BF209 /* Frameworks */, 8D255AD00486D3F9007BF209 /* Rez */, ); buildRules = ( ); dependencies = ( ); name = XamhainII; productInstallPath = "$(HOME)/Library/Screen Savers"; productName = XamhainII; productReference = 8D255AD30486D3F9007BF209 /* XamhainII.saver */; productType = "com.apple.product-type.bundle"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 089C1669FE841209C02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */; compatibilityVersion = "Xcode 3.1"; hasScannedForEncodings = 1; mainGroup = 089C166AFE841209C02AAC07 /* XamhainII */; projectDirPath = ""; projectRoot = ""; targets = ( 8D255AC50486D3F9007BF209 /* XamhainII */, 000D03D61089C45F003F010E /* XamhainII.dmg */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ 8D255AC90486D3F9007BF209 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */, 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */, 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */, 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */, 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */, 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */, 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */, 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */, 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */, 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */, 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */, 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */, 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */, 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */, 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */, 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */, 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */, 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */, 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */, 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */, 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */, 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */, 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */, 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */, 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */, 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */, 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */, 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */, 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */, 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */, 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */, 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */, 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */, 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */, 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */, 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */, 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */, 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */, 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */, 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */, 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */, 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */, 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */, 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */, 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXRezBuildPhase section */ 8D255AD00486D3F9007BF209 /* Rez */ = { isa = PBXRezBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXRezBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ 000D03D51089C45F003F010E /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.saver", ); outputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.dmg", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "# Thanks to Rob Mayoff for explaining how to do this.\n# See http://qwan.org/2007/05/22/using-xcode-to-build-a-disk-image-and-upload-a-web-site/\n\nset -ex\n\n[ \"$ACTION\" = build ] || exit 0\n[ \"$BUILD_VARIANTS\" = \"normal\" ] || exit 0\n\ndir=\"$TEMP_FILES_DIR/disk\"\ndmg=\"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.dmg\"\n\nrm -rf \"$dir\"\nmkdir \"$dir\"\ncp -R \"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.saver\" \"$dir\"\nrm -f \"$dmg\"\nhdiutil create -srcfolder \"$dir\" -volname \"$PROJECT_NAME\" \"$dmg\"\nhdiutil internet-enable -yes \"$dmg\"\nrm -rf \"$dir\"\n"; }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 8D255ACB0486D3F9007BF209 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 00DA7838107A73320094FCAB /* XamhainView.m in Sources */, 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */, 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */, 009D8964108E251800A416CF /* Stroke.mm in Sources */, 009D897C108E28C800A416CF /* StrokeSet.cpp in Sources */, + 00D7B656108F8E9A00432E90 /* KnotSection.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 000D03DA1089C465003F010E /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 8D255AC50486D3F9007BF209 /* XamhainII */; targetProxy = 000D03D91089C465003F010E /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ 089C167DFE841241C02AAC07 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 089C167EFE841241C02AAC07 /* English */, ); name = InfoPlist.strings; sourceTree = "<group>"; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 000D03D71089C45F003F010E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; PRODUCT_NAME = XamhainII.dmg; }; name = Debug; }; 000D03D81089C45F003F010E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = XamhainII.dmg; ZERO_LINK = NO; }; name = Release; }; EF7AD72E08BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_STRICT_ALIASING = NO; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = NO; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; ZERO_LINK = YES; }; name = Debug; }; EF7AD72F08BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; }; name = Release; }; EF7AD73208BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = NO; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Debug; }; EF7AD73308BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */ = { isa = XCConfigurationList; buildConfigurations = ( 000D03D71089C45F003F010E /* Debug */, 000D03D81089C45F003F010E /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD72E08BB986600CE4634 /* Debug */, EF7AD72F08BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD73208BB986600CE4634 /* Debug */, EF7AD73308BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 089C1669FE841209C02AAC07 /* Project object */; } diff --git a/knot engine/KnotSection.cpp b/knot engine/KnotSection.cpp new file mode 100644 index 0000000..85497a9 --- /dev/null +++ b/knot engine/KnotSection.cpp @@ -0,0 +1,391 @@ +// Description of knot strokes and sections. +// +// Copyright © 1997-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#include "KnotSection.h" + +#include <OpenGL/gl.h> + +#include "Position.h" +#include "Stroke.h" +#include "StrokeSet.h" + +namespace +{ + static const GLint t0[4] = { 1, 0, 0, 1 }; + static const GLint t1[4] = { 0, -1, 1, 0 }; + static const GLint t2[4] = { -1, 0, 0, -1 }; + static const GLint t3[4] = { 0, 1, -1, 0 }; + static const GLint t4[4] = { -1, 0, 0, 1 }; + static const GLint t5[4] = { 0, -1, -1, 0 }; + static const GLint t6[4] = { 1, 0, 0, -1 }; + static const GLint t7[4] = { 0, 1, 1, 0 }; + + static const GLfloat black[4] = { 0.0, 0.0, 0.0, 1.0 }; + + void + strokeCorners( + const KnotSection &section, + Position center, GLfloat size, GLfloat radius, GLfloat angle, + const StrokeSet &strokes, + const GLfloat ltCornerColor[4], const GLfloat rbCornerColor[4]) + { + // Draw corners of the section if needed. + if (section.leftTop() == D) { + glColor4fv(ltCornerColor); + strokes[StrokeSet::Corner].draw(center, size, radius, angle, t0); + } + if (section.rightBottom() == D) { + glColor4fv(rbCornerColor); + strokes[StrokeSet::Corner].draw(center, size, radius, angle, t2); + } + } + + void + diagonalStroke( + direction from, direction to, bool mirror, + Position center, GLfloat size, GLfloat radius, GLfloat angle, + const StrokeSet &strokes, const GLfloat color[4]) + { + glColor4fv(color); + + switch (4*from + to) { + + case 4*D + D: + strokes[StrokeSet::DDD].draw(center, size, radius, angle, + mirror ? t4 : t0); + break; + + case 4*D + H: + strokes[StrokeSet::DHD].draw(center, size, radius, angle, + mirror ? t6 : t2); + break; + + case 4*D + V: + strokes[StrokeSet::DHD].draw(center, size, radius, angle, + mirror ? t1 : t7); + break; + + case 4*H + D: + strokes[StrokeSet::DHD].draw(center, size, radius, angle, + mirror ? t4 : t0); + break; + + case 4*H + H: + strokes[StrokeSet::DHH].draw(center, size, radius, angle, + mirror ? t4 : t0); + break; + + case 4*H + V: + strokes[StrokeSet::DHV].draw(center, size, radius, angle, + mirror ? t4 : t0); + break; + + case 4*V + D: + strokes[StrokeSet::DHD].draw(center, size, radius, angle, + mirror ? t3 : t5); + break; + + case 4*V + H: + strokes[StrokeSet::DHV].draw(center, size, radius, angle, + mirror ? t6 : t2); + break; + + case 4*V + V: + strokes[StrokeSet::DHH].draw(center, size, radius, angle, + mirror ? t1 : t5); + break; + + default: + // Just ignore illegal diagonal strokes. + break; + } + } + + void + diagonalSection( + const KnotSection &section, + Position center, GLfloat size, GLfloat radius, GLfloat angle, + const StrokeSet &outlineStrokes, const StrokeSet &fillStrokes, + bool hollow, + const GLfloat topColor[4], const GLfloat botColor[4], + const GLfloat ltCornerColor[4], const GLfloat rbCornerColor[4]) + { + // Draw bottom stroke. + diagonalStroke(section.rightTop(), section.leftBottom(), true, + center, size, radius, angle, + outlineStrokes, hollow ? botColor : black); + diagonalStroke(section.rightTop(), section.leftBottom(), true, + center, size, radius, angle, + fillStrokes, hollow ? black : botColor); + + // Draw top stroke. + diagonalStroke(section.leftTop(), section.rightBottom(), false, + center, size, radius, angle, + outlineStrokes, hollow ? topColor : black); + diagonalStroke(section.leftTop(), section.rightBottom(), false, + center, size, radius, angle, + fillStrokes, hollow ? black : topColor); + + // Draw corners if needed. + strokeCorners(section, center, size, radius, angle, + outlineStrokes, + hollow ? ltCornerColor : black, + hollow ? rbCornerColor : black); + strokeCorners(section, center, size, radius, angle, + fillStrokes, + hollow ? black : ltCornerColor, + hollow ? black : rbCornerColor); + } + + void + horizontalStroke( + direction from, direction to, bool mirror, + Position center, GLfloat size, GLfloat radius, GLfloat angle, + const StrokeSet &strokes, const GLfloat color[4]) + { + glColor4fv(color); + + switch (4*from + to) { + + case 4*D + D: + strokes[StrokeSet::HDD].draw(center, size, radius, angle, + mirror ? t2 : t0); + break; + + case 4*D + H: + strokes[StrokeSet::HDH].draw(center, size, radius, angle, + mirror ? t6 : t0); + break; + + case 4*D + V: + strokes[StrokeSet::HDV].draw(center, size, radius, angle, + mirror ? t6 : t0); + break; + + case 4*H + D: + strokes[StrokeSet::HDH].draw(center, size, radius, angle, + mirror ? t2 : t4); + break; + + case 4*H + H: + strokes[StrokeSet::HHH].draw(center, size, radius, angle, + mirror ? t2 : t0); + break; + + case 4*H + V: + strokes[StrokeSet::HHV].draw(center, size, radius, angle, + mirror ? t6 : t0); + break; + + case 4*V + D: + strokes[StrokeSet::HDV].draw(center, size, radius, angle, + mirror ? t2 : t4); + break; + + case 4*V + H: + strokes[StrokeSet::HHV].draw(center, size, radius, angle, + mirror ? t2 : t4); + break; + + case 4*V + V: + strokes[StrokeSet::HVV].draw(center, size, radius, angle, + mirror ? t2 : t0); + break; + + case 4*N + N: + // Stroke omitted (edge section). + break; + + default: + // Just ignore illegal horizontal strokes. + break; + } + } + + void + horizontalSection( + const KnotSection &section, + Position center, GLfloat size, GLfloat radius, GLfloat angle, + const StrokeSet &outlineStrokes, const StrokeSet &fillStrokes, + bool hollow, + const GLfloat topColor[4], const GLfloat botColor[4], + const GLfloat ltCornerColor[4], const GLfloat rbCornerColor[4]) + { + // Draw bottom stroke. + horizontalStroke(section.leftBottom(), section.rightBottom(), true, + center, size, radius, angle, + outlineStrokes, hollow ? botColor : black); + horizontalStroke(section.leftBottom(), section.rightBottom(), true, + center, size, radius, angle, + fillStrokes, hollow ? black : botColor); + + // Draw top stroke. + horizontalStroke(section.leftTop(), section.rightTop(), false, + center, size, radius, angle, + outlineStrokes, hollow ? topColor : black); + horizontalStroke(section.leftTop(), section.rightTop(), false, + center, size, radius, angle, + fillStrokes, hollow ? black : topColor); + + // Draw corners if needed. + strokeCorners(section, center, size, radius, angle, + outlineStrokes, + hollow ? ltCornerColor : black, + hollow ? rbCornerColor : black); + strokeCorners(section, center, size, radius, angle, + fillStrokes, + hollow ? black : ltCornerColor, + hollow ? black : rbCornerColor); + } + + void + verticalStroke( + direction from, direction to, bool mirror, + Position center, GLfloat size, GLfloat radius, GLfloat angle, + const StrokeSet &strokes, const GLfloat color[4]) + { + glColor4fv(color); + + switch (4*from + to) { + + case 4*D + D: + strokes[StrokeSet::HDD].draw(center, size, radius, angle, + mirror ? t3 : t1); + break; + + case 4*D + H: + strokes[StrokeSet::HDV].draw(center, size, radius, angle, + mirror ? t3 : t5); + break; + + case 4*D + V: + strokes[StrokeSet::HDH].draw(center, size, radius, angle, + mirror ? t3 : t5); + break; + + case 4*H + D: + strokes[StrokeSet::HDV].draw(center, size, radius, angle, + mirror ? t7 : t1); + break; + + case 4*H + H: + strokes[StrokeSet::HVV].draw(center, size, radius, angle, + mirror ? t3 : t1); + break; + + case 4*H + V: + strokes[StrokeSet::HHV].draw(center, size, radius, angle, + mirror ? t7 : t1); + break; + + case 4*V + D: + strokes[StrokeSet::HDH].draw(center, size, radius, angle, + mirror ? t7 : t1); + break; + + case 4*V + H: + strokes[StrokeSet::HHV].draw(center, size, radius, angle, + mirror ? t3 : t5); + break; + + case 4*V + V: + strokes[StrokeSet::HHH].draw(center, size, radius, angle, + mirror ? t3 : t1); + break; + + case 4*N + N: + // Stroke omitted (edge section). + break; + + default: + // Just ignore illegal vertical strokes. + break; + } + } + + void + verticalSection( + const KnotSection &section, + Position center, GLfloat size, GLfloat radius, GLfloat angle, + const StrokeSet &outlineStrokes, const StrokeSet &fillStrokes, + bool hollow, + const GLfloat topColor[4], const GLfloat botColor[4], + const GLfloat ltCornerColor[4], const GLfloat rbCornerColor[4]) + { + // Draw right stroke. + verticalStroke(section.rightTop(), section.rightBottom(), true, + center, size, radius, angle, + outlineStrokes, hollow ? botColor : black); + verticalStroke(section.rightTop(), section.rightBottom(), true, + center, size, radius, angle, + fillStrokes, hollow ? black : botColor); + + // Draw left stroke. + verticalStroke(section.leftTop(), section.leftBottom(), false, + center, size, radius, angle, + outlineStrokes, hollow ? topColor : black); + verticalStroke(section.leftTop(), section.leftBottom(), false, + center, size, radius, angle, + fillStrokes, hollow ? black : topColor); + + // Draw corners if needed. + strokeCorners(section, center, size, radius, angle, + outlineStrokes, + hollow ? ltCornerColor : black, + hollow ? rbCornerColor : black); + strokeCorners(section, center, size, radius, angle, + fillStrokes, + hollow ? black : ltCornerColor, + hollow ? black : rbCornerColor); + } +} + +void +KnotSection::draw( + Position center, GLfloat size, GLfloat radius, GLfloat angle, + const StrokeSet &outlineStrokes, const StrokeSet &fillStrokes, + bool hollow, + const GLfloat topColor[4], const GLfloat botColor[4], + const GLfloat ltCornerColor[4], const GLfloat rbCornerColor[4]) const +{ + switch (mType) { + + case D: + diagonalSection(*this, center, size, radius, angle, + outlineStrokes, fillStrokes, hollow, + topColor, botColor, ltCornerColor, rbCornerColor); + break; + + case H: + horizontalSection(*this, center, size, radius, angle, + outlineStrokes, fillStrokes, hollow, + topColor, botColor, ltCornerColor, rbCornerColor); + break; + + case V: + verticalSection(*this, center, size, radius, angle, + outlineStrokes, fillStrokes, hollow, + topColor, botColor, ltCornerColor, rbCornerColor); + break; + + default: + // Just ignore illegal section types. + break; + } +} diff --git a/knot engine/KnotSection.h b/knot engine/KnotSection.h new file mode 100644 index 0000000..1f70e1c --- /dev/null +++ b/knot engine/KnotSection.h @@ -0,0 +1,82 @@ +// Description of knot strokes and sections. +// +// Copyright © 1997-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +// Traditionally, Celtic knotwork is drawn on a diagonal grid +// overlaid with straight lines and circles. Xamhain uses +// a simpler method devised by Andy Sloss, which divides the knot +// into sections at every other grid point. Each section can be +// uniquely described by the directions in which the knot passes +// through the section's corners, plus the directions the two lines +// take in the interior of the section. +// There are three possible directions (diagonal, horizontal and +// vertical), so there are 3^5 = 243 basic sections. The horizontal +// and vertical sections can be split in half for closing up the edges +// of a knot, yielding another 36 shapes. These are represented +// as a section with two corners that have "no" direction. +// +// Because of symmetries, the 279 different sections can be drawn +// using only 10 basic strokes - see class StrokeSet. + +#ifndef KNOTSECTION_H +#define KNOTSECTION_H + +#include <OpenGL/gl.h> + +#include "Position.h" +class StrokeSet; + +enum direction { // Directions of strokes and sections. + D = 0, // diagonal + H = 1, // horizontal + V = 2, // vertical + N = 3 // none (edge sections only) +}; + +// Identify the two 'strands' in a section. +enum { BOT, TOP }; + +class KnotSection { + const direction mType, mLT, mRT, mLB, mRB; + +public: + KnotSection(direction tp, + direction lt, direction rt, direction lb, direction rb) + : mType(tp), mLT(lt), mRT(rt), mLB(lb), mRB(rb) + { + // empty + } + + direction type(void) const { return mType; } + direction leftTop(void) const { return mLT; } + direction rightTop(void) const { return mRT; } + direction leftBottom(void) const { return mLB; } + direction rightBottom(void) const { return mRB; } + + // Draw the section at the given location and size, using the strokes + // and colors to determine how it will look. If radius and angle, + // are non-zero, the stroke is warped into a segment of an annulus. + void + draw(Position center, GLfloat size, GLfloat radius, GLfloat angle, + const StrokeSet &outlineStrokes, const StrokeSet &fillStrokes, + bool hollow, + const GLfloat topColor[4], const GLfloat botColor[4], + const GLfloat ltCornerColor[4], const GLfloat rbCornerColor[4]) const; +}; + +#endif // KNOTSECTION_H diff --git a/knot engine/Stroke.h b/knot engine/Stroke.h index 19a3fe7..5533f18 100644 --- a/knot engine/Stroke.h +++ b/knot engine/Stroke.h @@ -1,53 +1,53 @@ // A single primitive stroke, represented by a GL texture. // // Copyright © 2003-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #ifndef STROKE_H #define STROKE_H #include <OpenGL/gl.h> #include "Position.h" class Stroke { public: // Create a Stroke from one of our image files. Stroke(const char *name); // Destroy the associated texture. ~Stroke(void); // Draw the Stroke at the given location and size, transforming it // via the given matrix. If the radius and angle are non-zero, the stroke // is warped into a segment of an annulus with the given midradius and // spanning the given angle; the center of the annulus is assumed to lie // at (where.x - radius, where.y). void - Draw(Position where, GLfloat size, GLfloat radius, GLfloat angle, + draw(Position where, GLfloat size, GLfloat radius, GLfloat angle, const GLint transform[4]) const; private: Stroke(const Stroke &); Stroke &operator =(const Stroke &); // Data members. const int mSubdivisions; // subdivisions for warping GLuint mTexture; // ID of stroke texture }; #endif // STROKE_H diff --git a/knot engine/Stroke.mm b/knot engine/Stroke.mm index 8eee8cf..708269a 100644 --- a/knot engine/Stroke.mm +++ b/knot engine/Stroke.mm @@ -1,246 +1,246 @@ // A single primitive stroke, represented by a GL texture. // // Copyright © 2003-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "Stroke.h" #include <algorithm> #include <cassert> #include <cmath> #include <OpenGL/gl.h> #include <OpenGL/glu.h> #include "Position.h" #include "XamhainPreferences.h" namespace { // Nominal size of a texture. const GLsizei kTextureSize = 64; // Internal texture format. const GLenum kTextureFormat = GL_ALPHA4; // Cache for values of trigonometric functions. class TrigFunctionCache { public: TrigFunctionCache(const GLfloat arcLength) : mSubdivisions(XamhainPreferences().knotSubdivisions()), mpSin(new GLfloat[mSubdivisions]), mpCos(new GLfloat[mSubdivisions]) { for (int i = 0; i < mSubdivisions; ++i) { const GLfloat arg = (i+1) * arcLength * 0.5 / mSubdivisions; mpSin[i] = ::sin(arg); mpCos[i] = ::cos(arg); } } ~TrigFunctionCache(void) { delete [] mpSin; delete [] mpCos; mpSin = mpCos = 0; } GLfloat sin(const int index) const { if (index) { return (index < 0) ? -mpSin[-index-1] : mpSin[index-1]; } return 0.0; } GLfloat cos(const int index) const { if (index) { return (index < 0) ? mpCos[-index-1] : mpCos[index-1]; } return 1.0; } private: TrigFunctionCache(const TrigFunctionCache &); TrigFunctionCache &operator =(const TrigFunctionCache &); // Data members. const int mSubdivisions; GLfloat *mpSin; GLfloat *mpCos; }; // Load an image resource and convert it to a bitmap. NSBitmapImageRep * loadImage(const char *const name) { // Load the (PDF) image. NSImage *image = [NSImage imageNamed: [NSString stringWithCString: name encoding: NSASCIIStringEncoding]]; assert(image != nil); // Create a bitmap of the desired size. NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL pixelsWide: kTextureSize pixelsHigh: kTextureSize bitsPerSample: 8 samplesPerPixel: 1 hasAlpha: NO isPlanar: NO colorSpaceName: NSDeviceWhiteColorSpace bytesPerRow: 0 bitsPerPixel: 0]; // Draw the image at the desired size. [NSGraphicsContext saveGraphicsState]; [NSGraphicsContext setCurrentContext: [NSGraphicsContext graphicsContextWithBitmapImageRep: bitmap]]; const NSSize size = [image size]; [image drawInRect: NSMakeRect(0.0, 0.0, kTextureSize, kTextureSize) fromRect: NSMakeRect(0.0, 0.0, size.width, size.height) operation: NSCompositeCopy fraction: 1.0]; [NSGraphicsContext restoreGraphicsState]; return bitmap; } } Stroke::Stroke(const char *const name) : mSubdivisions(XamhainPreferences().knotSubdivisions()){ // Load image resource. NSBitmapImageRep *bitmap = loadImage(name); // Create a texture object for the stroke. glGenTextures(1, &mTexture); glBindTexture(GL_TEXTURE_2D, mTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glPixelStorei(GL_UNPACK_ROW_LENGTH, [bitmap pixelsWide]); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gluBuild2DMipmaps(GL_TEXTURE_2D, kTextureFormat, kTextureSize, kTextureSize, GL_ALPHA, GL_UNSIGNED_BYTE, [bitmap bitmapData]); } Stroke::~Stroke(void) { glDeleteTextures(1, &mTexture); mTexture = 0; } void -Stroke::Draw(Position where, GLfloat size, GLfloat radius, GLfloat angle, +Stroke::draw(Position where, GLfloat size, GLfloat radius, GLfloat angle, const GLint transform[4]) const { if (radius <= 0.0 || angle <= 0.0) { size *= 0.5f; const GLfloat t0 = size * transform[0]; const GLfloat t1 = size * transform[1]; const GLfloat t2 = size * transform[2]; const GLfloat t3 = size * transform[3]; const GLfloat r = 1.0f; const GLfloat b = -1.0f; glBindTexture(GL_TEXTURE_2D, mTexture); glBegin(GL_POLYGON); { glTexCoord2f(0.0f, 1.0f); glVertex2f(where.x - t0 + b * t1, where.y - t2 + b * t3); glTexCoord2f(1.0f, 1.0f); glVertex2f(where.x + r * t0 + b * t1, where.y + r * t2 + b * t3); glTexCoord2f(1.0f, 0.0f); glVertex2f(where.x + r * t0 + t1, where.y + r * t2 + t3); glTexCoord2f(0.0f, 0.0f); glVertex2f(where.x - t0 + t1, where.y - t2 + t3); } glEnd(); } else { size = size * 0.5 / mSubdivisions; const GLint r = mSubdivisions; const GLint b = -mSubdivisions; const TrigFunctionCache cache(angle); glBindTexture(GL_TEXTURE_2D, mTexture); glBegin(GL_QUADS); { for (GLint x = -mSubdivisions; x < r; ++x) { for (GLint y = b; y < mSubdivisions; ++y) { const GLint x0 = x * transform[0] + y * transform[1]; const GLint y0 = x * transform[2] + y * transform[3]; const GLint x1 = (x+1) * transform[0] + y * transform[1]; const GLint y1 = (x+1) * transform[2] + y * transform[3]; const GLint x2 = (x+1) * transform[0] + (y+1) * transform[1]; const GLint y2 = (x+1) * transform[2] + (y+1) * transform[3]; const GLint x3 = x * transform[0] + (y+1) * transform[1]; const GLint y3 = x * transform[2] + (y+1) * transform[3]; const GLfloat r0 = size * x0 + radius; const GLfloat r1 = size * x1 + radius; const GLfloat r2 = size * x2 + radius; const GLfloat r3 = size * x3 + radius; glTexCoord2f( (GLfloat)(x+mSubdivisions) / (GLfloat)(r+mSubdivisions), (GLfloat)(mSubdivisions-y) / (GLfloat)(mSubdivisions-b)); glVertex2f(where.x + r0 * cache.cos(y0) - radius, where.y + r0 * cache.sin(y0)); glTexCoord2f( (GLfloat)(x+1+mSubdivisions) / (GLfloat)(r+mSubdivisions), (GLfloat)(mSubdivisions-y) / (GLfloat)(mSubdivisions-b)); glVertex2f(where.x + r1 * cache.cos(y1) - radius, where.y + r1 * cache.sin(y1)); glTexCoord2f( (GLfloat)(x+1+mSubdivisions) / (GLfloat)(r+mSubdivisions), (GLfloat)(mSubdivisions-y-1) / (GLfloat)(mSubdivisions-b)); glVertex2f(where.x + r2 * cache.cos(y2) - radius, where.y + r2 * cache.sin(y2)); glTexCoord2f( (GLfloat)(x+mSubdivisions) / (GLfloat)(r+mSubdivisions), (GLfloat)(mSubdivisions-y-1) / (GLfloat)(mSubdivisions-b)); glVertex2f(where.x + r3 * cache.cos(y3) - radius, where.y + r3 * cache.sin(y3)); } } } glEnd(); } } diff --git a/knot engine/StrokeSet.cpp b/knot engine/StrokeSet.cpp index 358aa64..89564de 100644 --- a/knot engine/StrokeSet.cpp +++ b/knot engine/StrokeSet.cpp @@ -1,57 +1,57 @@ // A StrokeSet contains the 10 basic strokes from which knots are built, // plus an additional stroke used in filling in corners. // // Copyright © 2003-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "StrokeSet.h" #include "Stroke.h" #define StaticStroke(stroke, shape, type) \ static const Stroke Stroke_##stroke(#shape "_" #type "_" #stroke ".pdf"); #define StaticStrokeSet(name, shape, type) \ const StrokeSet & \ StrokeSet::name(void) \ { \ StaticStroke(DDD, shape, type); \ StaticStroke(DHD, shape, type); \ StaticStroke(DHH, shape, type); \ StaticStroke(DHV, shape, type); \ StaticStroke(HDD, shape, type); \ StaticStroke(HDH, shape, type); \ StaticStroke(HDV, shape, type); \ StaticStroke(HHH, shape, type); \ StaticStroke(HHV, shape, type); \ StaticStroke(HVV, shape, type); \ StaticStroke(corner, shape, type); \ \ static const Stroke *const pStrokes[NumStrokes] = { \ &Stroke_DDD, &Stroke_DHD, &Stroke_DHH, &Stroke_DHV, &Stroke_HDD, \ &Stroke_HDH, &Stroke_HDV, &Stroke_HHH, &Stroke_HHV, &Stroke_HVV, \ &Stroke_corner, \ }; \ static const StrokeSet theSet(pStrokes); \ \ return theSet; \ } -StaticStrokeSet(BroadFill, broad, fill) -StaticStrokeSet(BroadOutline, broad, outline) -StaticStrokeSet(SlenderFill, slender, fill) -StaticStrokeSet(SlenderOutline, slender, outline) +StaticStrokeSet(broadFill, broad, fill) +StaticStrokeSet(broadOutline, broad, outline) +StaticStrokeSet(slenderFill, slender, fill) +StaticStrokeSet(slenderOutline, slender, outline) diff --git a/knot engine/StrokeSet.h b/knot engine/StrokeSet.h index 50c2b2d..f7bd061 100644 --- a/knot engine/StrokeSet.h +++ b/knot engine/StrokeSet.h @@ -1,72 +1,72 @@ // A StrokeSet contains the 10 basic strokes from which knots are built, // plus an additional stroke used in filling in corners. // // Copyright © 2003-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #ifndef STROKESET_H #define STROKESET_H #include <cassert> #include "Stroke.h" class StrokeSet { public: // Stroke types. enum { DDD, DHD, DHH, DHV, HDD, HDH, HDV, HHH, HHV, HVV, Corner, NumStrokes }; // Singleton objects which contain strokes for different knot styles. static const StrokeSet & - BroadFill(void); + broadFill(void); static const StrokeSet & - BroadOutline(void); + broadOutline(void); static const StrokeSet & - SlenderFill(void); + slenderFill(void); static const StrokeSet & - SlenderOutline(void); + slenderOutline(void); // Return a Stroke of the given type. const Stroke & operator [](unsigned int index) const { assert(index < NumStrokes); return *mppStrokes[index]; } private: // Construct from an array of Stroke objects. StrokeSet(const Stroke *const pStrokes[NumStrokes]) : mppStrokes(pStrokes) { // empty } StrokeSet(const StrokeSet &); StrokeSet &operator =(const StrokeSet &); // Data members. const Stroke *const *const mppStrokes; }; #endif // STROKESET_H
jjk/XamhainII
d73ec410f6f6d1792d176a3a2725749a42bb86fb
Port basic stroke drawing classes.
diff --git a/XamhainII.xcodeproj/project.pbxproj b/XamhainII.xcodeproj/project.pbxproj index 7d31461..7e4706f 100644 --- a/XamhainII.xcodeproj/project.pbxproj +++ b/XamhainII.xcodeproj/project.pbxproj @@ -1,638 +1,658 @@ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 45; objects = { /* Begin PBXAggregateTarget section */ 000D03D61089C45F003F010E /* XamhainII.dmg */ = { isa = PBXAggregateTarget; buildConfigurationList = 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */; buildPhases = ( 000D03D51089C45F003F010E /* ShellScript */, ); dependencies = ( 000D03DA1089C465003F010E /* PBXTargetDependency */, ); name = XamhainII.dmg; productName = XamhainII.dmg; }; /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0032D325108A30770033FA87 /* OpenGL.framework */; }; 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00791842108B081B00156D67 /* XamhainPreferences.mm */; }; 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007C5127108A29BE00ED3242 /* RandomColor.cpp */; }; + 009D8964108E251800A416CF /* Stroke.mm in Sources */ = {isa = PBXBuildFile; fileRef = 009D8962108E251800A416CF /* Stroke.mm */; }; + 009D897C108E28C800A416CF /* StrokeSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 009D897A108E28C800A416CF /* StrokeSet.cpp */; }; 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */; }; 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */; }; 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */; }; 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */; }; 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */; }; 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */; }; 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */; }; 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */; }; 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */; }; 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */; }; 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */; }; 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */; }; 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */; }; 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */; }; 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */; }; 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */; }; 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */; }; 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */; }; 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */; }; 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */; }; 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */; }; 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */; }; 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */; }; 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */; }; 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */; }; 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */; }; 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */; }; 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */; }; 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */; }; 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */; }; 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */; }; 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */; }; 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */; }; 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */; }; 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */; }; 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */; }; 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */; }; 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */; }; 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */; }; 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */; }; 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */; }; 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */; }; 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */; }; 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */; }; 00DA7838107A73320094FCAB /* XamhainView.m in Sources */ = {isa = PBXBuildFile; fileRef = 00DA7836107A73320094FCAB /* XamhainView.m */; }; 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 000D03D91089C465003F010E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 089C1669FE841209C02AAC07 /* Project object */; proxyType = 1; remoteGlobalIDString = 8D255AC50486D3F9007BF209; remoteInfo = XamhainII; }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ 0032D325108A30770033FA87 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; }; 00791842108B081B00156D67 /* XamhainPreferences.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainPreferences.mm; path = "screen saving/XamhainPreferences.mm"; sourceTree = "<group>"; }; 00791843108B081B00156D67 /* XamhainPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainPreferences.h; path = "screen saving/XamhainPreferences.h"; sourceTree = "<group>"; }; - 007C5126108A29BE00ED3242 /* Point.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Point.h; path = utility/Point.h; sourceTree = "<group>"; }; + 007C5126108A29BE00ED3242 /* Position.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Position.h; path = utility/Position.h; sourceTree = "<group>"; }; 007C5127108A29BE00ED3242 /* RandomColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RandomColor.cpp; path = utility/RandomColor.cpp; sourceTree = "<group>"; }; 007C5128108A29BE00ED3242 /* RandomColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomColor.h; path = utility/RandomColor.h; sourceTree = "<group>"; }; 007C5129108A29BE00ED3242 /* RandomNumbers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomNumbers.h; path = utility/RandomNumbers.h; sourceTree = "<group>"; }; + 009D8962108E251800A416CF /* Stroke.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Stroke.mm; path = "knot engine/Stroke.mm"; sourceTree = "<group>"; }; + 009D8963108E251800A416CF /* Stroke.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Stroke.h; path = "knot engine/Stroke.h"; sourceTree = "<group>"; }; + 009D897A108E28C800A416CF /* StrokeSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StrokeSet.cpp; path = "knot engine/StrokeSet.cpp"; sourceTree = "<group>"; }; + 009D897B108E28C800A416CF /* StrokeSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StrokeSet.h; path = "knot engine/StrokeSet.h"; sourceTree = "<group>"; }; 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA7835107A73320094FCAB /* XamhainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainView.h; path = "screen saving/XamhainView.h"; sourceTree = "<group>"; }; 00DA7836107A73320094FCAB /* XamhainView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XamhainView.m; path = "screen saving/XamhainView.m"; sourceTree = "<group>"; }; 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ScreenSaver.framework; path = /System/Library/Frameworks/ScreenSaver.framework; sourceTree = "<absolute>"; }; 089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; 089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; }; 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; }; 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XamhainII_Prefix.pch; sourceTree = "<group>"; }; 8D255AD20486D3F9007BF209 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; 8D255AD30486D3F9007BF209 /* XamhainII.saver */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XamhainII.saver; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 8D255ACD0486D3F9007BF209 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */, 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */, 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 007C5125108A299800ED3242 /* Utility */ = { isa = PBXGroup; children = ( - 007C5126108A29BE00ED3242 /* Point.h */, + 007C5126108A29BE00ED3242 /* Position.h */, 007C5127108A29BE00ED3242 /* RandomColor.cpp */, 007C5128108A29BE00ED3242 /* RandomColor.h */, 007C5129108A29BE00ED3242 /* RandomNumbers.h */, ); name = Utility; sourceTree = "<group>"; }; + 009D8961108E24ED00A416CF /* Knot Engine */ = { + isa = PBXGroup; + children = ( + 009D897A108E28C800A416CF /* StrokeSet.cpp */, + 009D897B108E28C800A416CF /* StrokeSet.h */, + 009D8962108E251800A416CF /* Stroke.mm */, + 009D8963108E251800A416CF /* Stroke.h */, + ); + name = "Knot Engine"; + sourceTree = "<group>"; + }; 00DA77D5107A728C0094FCAB /* Strokes */ = { isa = PBXGroup; children = ( 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */, 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */, 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */, 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */, 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */, 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */, 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */, 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */, 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */, 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */, 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */, 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */, 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */, 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */, 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */, 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */, 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */, 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */, 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */, 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */, 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */, 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */, 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */, 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */, 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */, 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */, 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */, 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */, 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */, 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */, 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */, 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */, 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */, 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */, 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */, 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */, 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */, 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */, 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */, 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */, 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */, 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */, 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */, 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */, ); name = Strokes; path = strokes; sourceTree = "<group>"; }; 00DA7833107A72F00094FCAB /* Screen Saving */ = { isa = PBXGroup; children = ( 00791842108B081B00156D67 /* XamhainPreferences.mm */, 00791843108B081B00156D67 /* XamhainPreferences.h */, 00DA7835107A73320094FCAB /* XamhainView.h */, 00DA7836107A73320094FCAB /* XamhainView.m */, ); name = "Screen Saving"; sourceTree = "<group>"; }; 089C166AFE841209C02AAC07 /* XamhainII */ = { isa = PBXGroup; children = ( + 009D8961108E24ED00A416CF /* Knot Engine */, 00DA7833107A72F00094FCAB /* Screen Saving */, 007C5125108A299800ED3242 /* Utility */, 32DBCFA70370C4F300C91783 /* Other Sources */, 089C167CFE841241C02AAC07 /* Resources */, 089C1671FE841209C02AAC07 /* Frameworks and Libraries */, 19C28FB8FE9D52D311CA2CBB /* Products */, ); name = XamhainII; sourceTree = "<group>"; }; 089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = { isa = PBXGroup; children = ( 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */, 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */, ); name = "Frameworks and Libraries"; sourceTree = "<group>"; }; 089C167CFE841241C02AAC07 /* Resources */ = { isa = PBXGroup; children = ( 00DA77D5107A728C0094FCAB /* Strokes */, 8D255AD20486D3F9007BF209 /* Info.plist */, 089C167DFE841241C02AAC07 /* InfoPlist.strings */, ); name = Resources; sourceTree = "<group>"; }; 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = { isa = PBXGroup; children = ( 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, 0032D325108A30770033FA87 /* OpenGL.framework */, 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */, ); name = "Linked Frameworks"; sourceTree = "<group>"; }; 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = { isa = PBXGroup; children = ( 089C1672FE841209C02AAC07 /* Foundation.framework */, 089C167FFE841241C02AAC07 /* AppKit.framework */, ); name = "Other Frameworks"; sourceTree = "<group>"; }; 19C28FB8FE9D52D311CA2CBB /* Products */ = { isa = PBXGroup; children = ( 8D255AD30486D3F9007BF209 /* XamhainII.saver */, ); name = Products; sourceTree = "<group>"; }; 32DBCFA70370C4F300C91783 /* Other Sources */ = { isa = PBXGroup; children = ( 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */, ); name = "Other Sources"; sourceTree = "<group>"; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ 8D255AC60486D3F9007BF209 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ 8D255AC50486D3F9007BF209 /* XamhainII */ = { isa = PBXNativeTarget; buildConfigurationList = EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */; buildPhases = ( 8D255AC60486D3F9007BF209 /* Headers */, 8D255AC90486D3F9007BF209 /* Resources */, 8D255ACB0486D3F9007BF209 /* Sources */, 8D255ACD0486D3F9007BF209 /* Frameworks */, 8D255AD00486D3F9007BF209 /* Rez */, ); buildRules = ( ); dependencies = ( ); name = XamhainII; productInstallPath = "$(HOME)/Library/Screen Savers"; productName = XamhainII; productReference = 8D255AD30486D3F9007BF209 /* XamhainII.saver */; productType = "com.apple.product-type.bundle"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 089C1669FE841209C02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */; compatibilityVersion = "Xcode 3.1"; hasScannedForEncodings = 1; mainGroup = 089C166AFE841209C02AAC07 /* XamhainII */; projectDirPath = ""; projectRoot = ""; targets = ( 8D255AC50486D3F9007BF209 /* XamhainII */, 000D03D61089C45F003F010E /* XamhainII.dmg */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ 8D255AC90486D3F9007BF209 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */, 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */, 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */, 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */, 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */, 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */, 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */, 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */, 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */, 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */, 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */, 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */, 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */, 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */, 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */, 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */, 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */, 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */, 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */, 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */, 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */, 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */, 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */, 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */, 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */, 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */, 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */, 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */, 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */, 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */, 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */, 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */, 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */, 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */, 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */, 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */, 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */, 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */, 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */, 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */, 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */, 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */, 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */, 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */, 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXRezBuildPhase section */ 8D255AD00486D3F9007BF209 /* Rez */ = { isa = PBXRezBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXRezBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ 000D03D51089C45F003F010E /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.saver", ); outputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.dmg", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "# Thanks to Rob Mayoff for explaining how to do this.\n# See http://qwan.org/2007/05/22/using-xcode-to-build-a-disk-image-and-upload-a-web-site/\n\nset -ex\n\n[ \"$ACTION\" = build ] || exit 0\n[ \"$BUILD_VARIANTS\" = \"normal\" ] || exit 0\n\ndir=\"$TEMP_FILES_DIR/disk\"\ndmg=\"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.dmg\"\n\nrm -rf \"$dir\"\nmkdir \"$dir\"\ncp -R \"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.saver\" \"$dir\"\nrm -f \"$dmg\"\nhdiutil create -srcfolder \"$dir\" -volname \"$PROJECT_NAME\" \"$dmg\"\nhdiutil internet-enable -yes \"$dmg\"\nrm -rf \"$dir\"\n"; }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 8D255ACB0486D3F9007BF209 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 00DA7838107A73320094FCAB /* XamhainView.m in Sources */, 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */, 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */, + 009D8964108E251800A416CF /* Stroke.mm in Sources */, + 009D897C108E28C800A416CF /* StrokeSet.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 000D03DA1089C465003F010E /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 8D255AC50486D3F9007BF209 /* XamhainII */; targetProxy = 000D03D91089C465003F010E /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ 089C167DFE841241C02AAC07 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 089C167EFE841241C02AAC07 /* English */, ); name = InfoPlist.strings; sourceTree = "<group>"; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 000D03D71089C45F003F010E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; PRODUCT_NAME = XamhainII.dmg; }; name = Debug; }; 000D03D81089C45F003F010E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = XamhainII.dmg; ZERO_LINK = NO; }; name = Release; }; EF7AD72E08BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_STRICT_ALIASING = NO; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = NO; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; ZERO_LINK = YES; }; name = Debug; }; EF7AD72F08BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; }; name = Release; }; EF7AD73208BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = NO; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Debug; }; EF7AD73308BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */ = { isa = XCConfigurationList; buildConfigurations = ( 000D03D71089C45F003F010E /* Debug */, 000D03D81089C45F003F010E /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD72E08BB986600CE4634 /* Debug */, EF7AD72F08BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD73208BB986600CE4634 /* Debug */, EF7AD73308BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 089C1669FE841209C02AAC07 /* Project object */; } diff --git a/knot engine/Stroke.h b/knot engine/Stroke.h new file mode 100644 index 0000000..19a3fe7 --- /dev/null +++ b/knot engine/Stroke.h @@ -0,0 +1,53 @@ +// A single primitive stroke, represented by a GL texture. +// +// Copyright © 2003-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#ifndef STROKE_H +#define STROKE_H + +#include <OpenGL/gl.h> + +#include "Position.h" + +class Stroke { +public: + // Create a Stroke from one of our image files. + Stroke(const char *name); + + // Destroy the associated texture. + ~Stroke(void); + + // Draw the Stroke at the given location and size, transforming it + // via the given matrix. If the radius and angle are non-zero, the stroke + // is warped into a segment of an annulus with the given midradius and + // spanning the given angle; the center of the annulus is assumed to lie + // at (where.x - radius, where.y). + void + Draw(Position where, GLfloat size, GLfloat radius, GLfloat angle, + const GLint transform[4]) const; + +private: + Stroke(const Stroke &); + Stroke &operator =(const Stroke &); + + // Data members. + const int mSubdivisions; // subdivisions for warping + GLuint mTexture; // ID of stroke texture +}; + +#endif // STROKE_H diff --git a/knot engine/Stroke.mm b/knot engine/Stroke.mm new file mode 100644 index 0000000..8eee8cf --- /dev/null +++ b/knot engine/Stroke.mm @@ -0,0 +1,246 @@ +// A single primitive stroke, represented by a GL texture. +// +// Copyright © 2003-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#include "Stroke.h" + +#include <algorithm> +#include <cassert> +#include <cmath> + +#include <OpenGL/gl.h> +#include <OpenGL/glu.h> + +#include "Position.h" +#include "XamhainPreferences.h" + +namespace +{ + // Nominal size of a texture. + const GLsizei kTextureSize = 64; + + // Internal texture format. + const GLenum kTextureFormat = GL_ALPHA4; + + // Cache for values of trigonometric functions. + class TrigFunctionCache + { + public: + TrigFunctionCache(const GLfloat arcLength) + : mSubdivisions(XamhainPreferences().knotSubdivisions()), + mpSin(new GLfloat[mSubdivisions]), + mpCos(new GLfloat[mSubdivisions]) + { + for (int i = 0; i < mSubdivisions; ++i) { + const GLfloat arg = (i+1) * arcLength * 0.5 / mSubdivisions; + mpSin[i] = ::sin(arg); + mpCos[i] = ::cos(arg); + } + } + ~TrigFunctionCache(void) + { + delete [] mpSin; + delete [] mpCos; + mpSin = mpCos = 0; + } + + GLfloat + sin(const int index) const + { + if (index) { + return (index < 0) ? -mpSin[-index-1] : mpSin[index-1]; + } + return 0.0; + } + + GLfloat + cos(const int index) const + { + if (index) { + return (index < 0) ? mpCos[-index-1] : mpCos[index-1]; + } + return 1.0; + } + + private: + TrigFunctionCache(const TrigFunctionCache &); + TrigFunctionCache &operator =(const TrigFunctionCache &); + + // Data members. + const int mSubdivisions; + GLfloat *mpSin; + GLfloat *mpCos; + }; + + // Load an image resource and convert it to a bitmap. + NSBitmapImageRep * + loadImage(const char *const name) + { + // Load the (PDF) image. + NSImage *image = [NSImage imageNamed: + [NSString stringWithCString: name + encoding: NSASCIIStringEncoding]]; + assert(image != nil); + + // Create a bitmap of the desired size. + NSBitmapImageRep *bitmap = + [[NSBitmapImageRep alloc] + initWithBitmapDataPlanes: NULL + pixelsWide: kTextureSize + pixelsHigh: kTextureSize + bitsPerSample: 8 + samplesPerPixel: 1 + hasAlpha: NO + isPlanar: NO + colorSpaceName: NSDeviceWhiteColorSpace + bytesPerRow: 0 + bitsPerPixel: 0]; + + // Draw the image at the desired size. + [NSGraphicsContext saveGraphicsState]; + [NSGraphicsContext setCurrentContext: + [NSGraphicsContext graphicsContextWithBitmapImageRep: bitmap]]; + + const NSSize size = [image size]; + [image drawInRect: NSMakeRect(0.0, 0.0, kTextureSize, kTextureSize) + fromRect: NSMakeRect(0.0, 0.0, size.width, size.height) + operation: NSCompositeCopy + fraction: 1.0]; + + [NSGraphicsContext restoreGraphicsState]; + + return bitmap; + } +} + +Stroke::Stroke(const char *const name) +: mSubdivisions(XamhainPreferences().knotSubdivisions()){ + // Load image resource. + NSBitmapImageRep *bitmap = loadImage(name); + + // Create a texture object for the stroke. + glGenTextures(1, &mTexture); + glBindTexture(GL_TEXTURE_2D, mTexture); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + + glPixelStorei(GL_UNPACK_ROW_LENGTH, [bitmap pixelsWide]); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + gluBuild2DMipmaps(GL_TEXTURE_2D, kTextureFormat, + kTextureSize, kTextureSize, + GL_ALPHA, GL_UNSIGNED_BYTE, [bitmap bitmapData]); +} + +Stroke::~Stroke(void) +{ + glDeleteTextures(1, &mTexture); + mTexture = 0; +} + +void +Stroke::Draw(Position where, GLfloat size, GLfloat radius, GLfloat angle, + const GLint transform[4]) const +{ + if (radius <= 0.0 || angle <= 0.0) { + size *= 0.5f; + + const GLfloat t0 = size * transform[0]; + const GLfloat t1 = size * transform[1]; + const GLfloat t2 = size * transform[2]; + const GLfloat t3 = size * transform[3]; + + const GLfloat r = 1.0f; + const GLfloat b = -1.0f; + + glBindTexture(GL_TEXTURE_2D, mTexture); + glBegin(GL_POLYGON); + { + glTexCoord2f(0.0f, 1.0f); + glVertex2f(where.x - t0 + b * t1, where.y - t2 + b * t3); + + glTexCoord2f(1.0f, 1.0f); + glVertex2f(where.x + r * t0 + b * t1, where.y + r * t2 + b * t3); + + glTexCoord2f(1.0f, 0.0f); + glVertex2f(where.x + r * t0 + t1, where.y + r * t2 + t3); + + glTexCoord2f(0.0f, 0.0f); + glVertex2f(where.x - t0 + t1, where.y - t2 + t3); + } + glEnd(); + + } else { + size = size * 0.5 / mSubdivisions; + + const GLint r = mSubdivisions; + const GLint b = -mSubdivisions; + + const TrigFunctionCache cache(angle); + + glBindTexture(GL_TEXTURE_2D, mTexture); + glBegin(GL_QUADS); + { + for (GLint x = -mSubdivisions; x < r; ++x) { + for (GLint y = b; y < mSubdivisions; ++y) { + const GLint x0 = x * transform[0] + y * transform[1]; + const GLint y0 = x * transform[2] + y * transform[3]; + const GLint x1 = (x+1) * transform[0] + y * transform[1]; + const GLint y1 = (x+1) * transform[2] + y * transform[3]; + const GLint x2 = (x+1) * transform[0] + (y+1) * transform[1]; + const GLint y2 = (x+1) * transform[2] + (y+1) * transform[3]; + const GLint x3 = x * transform[0] + (y+1) * transform[1]; + const GLint y3 = x * transform[2] + (y+1) * transform[3]; + + const GLfloat r0 = size * x0 + radius; + const GLfloat r1 = size * x1 + radius; + const GLfloat r2 = size * x2 + radius; + const GLfloat r3 = size * x3 + radius; + + glTexCoord2f( + (GLfloat)(x+mSubdivisions) / (GLfloat)(r+mSubdivisions), + (GLfloat)(mSubdivisions-y) / (GLfloat)(mSubdivisions-b)); + glVertex2f(where.x + r0 * cache.cos(y0) - radius, + where.y + r0 * cache.sin(y0)); + + glTexCoord2f( + (GLfloat)(x+1+mSubdivisions) / (GLfloat)(r+mSubdivisions), + (GLfloat)(mSubdivisions-y) / (GLfloat)(mSubdivisions-b)); + glVertex2f(where.x + r1 * cache.cos(y1) - radius, + where.y + r1 * cache.sin(y1)); + + glTexCoord2f( + (GLfloat)(x+1+mSubdivisions) / (GLfloat)(r+mSubdivisions), + (GLfloat)(mSubdivisions-y-1) / (GLfloat)(mSubdivisions-b)); + glVertex2f(where.x + r2 * cache.cos(y2) - radius, + where.y + r2 * cache.sin(y2)); + + glTexCoord2f( + (GLfloat)(x+mSubdivisions) / (GLfloat)(r+mSubdivisions), + (GLfloat)(mSubdivisions-y-1) / (GLfloat)(mSubdivisions-b)); + glVertex2f(where.x + r3 * cache.cos(y3) - radius, + where.y + r3 * cache.sin(y3)); + } + } + } + glEnd(); + } +} diff --git a/knot engine/StrokeSet.cpp b/knot engine/StrokeSet.cpp new file mode 100644 index 0000000..358aa64 --- /dev/null +++ b/knot engine/StrokeSet.cpp @@ -0,0 +1,57 @@ +// A StrokeSet contains the 10 basic strokes from which knots are built, +// plus an additional stroke used in filling in corners. +// +// Copyright © 2003-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#include "StrokeSet.h" + +#include "Stroke.h" + +#define StaticStroke(stroke, shape, type) \ + static const Stroke Stroke_##stroke(#shape "_" #type "_" #stroke ".pdf"); + +#define StaticStrokeSet(name, shape, type) \ + const StrokeSet & \ + StrokeSet::name(void) \ + { \ + StaticStroke(DDD, shape, type); \ + StaticStroke(DHD, shape, type); \ + StaticStroke(DHH, shape, type); \ + StaticStroke(DHV, shape, type); \ + StaticStroke(HDD, shape, type); \ + StaticStroke(HDH, shape, type); \ + StaticStroke(HDV, shape, type); \ + StaticStroke(HHH, shape, type); \ + StaticStroke(HHV, shape, type); \ + StaticStroke(HVV, shape, type); \ + StaticStroke(corner, shape, type); \ + \ + static const Stroke *const pStrokes[NumStrokes] = { \ + &Stroke_DDD, &Stroke_DHD, &Stroke_DHH, &Stroke_DHV, &Stroke_HDD, \ + &Stroke_HDH, &Stroke_HDV, &Stroke_HHH, &Stroke_HHV, &Stroke_HVV, \ + &Stroke_corner, \ + }; \ + static const StrokeSet theSet(pStrokes); \ + \ + return theSet; \ + } + +StaticStrokeSet(BroadFill, broad, fill) +StaticStrokeSet(BroadOutline, broad, outline) +StaticStrokeSet(SlenderFill, slender, fill) +StaticStrokeSet(SlenderOutline, slender, outline) diff --git a/knot engine/StrokeSet.h b/knot engine/StrokeSet.h new file mode 100644 index 0000000..50c2b2d --- /dev/null +++ b/knot engine/StrokeSet.h @@ -0,0 +1,72 @@ +// A StrokeSet contains the 10 basic strokes from which knots are built, +// plus an additional stroke used in filling in corners. +// +// Copyright © 2003-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#ifndef STROKESET_H +#define STROKESET_H + +#include <cassert> + +#include "Stroke.h" + +class StrokeSet { +public: + // Stroke types. + enum { + DDD, DHD, DHH, DHV, + HDD, HDH, HDV, HHH, HHV, HVV, + Corner, + NumStrokes + }; + + // Singleton objects which contain strokes for different knot styles. + static const StrokeSet & + BroadFill(void); + static const StrokeSet & + BroadOutline(void); + + static const StrokeSet & + SlenderFill(void); + static const StrokeSet & + SlenderOutline(void); + + // Return a Stroke of the given type. + const Stroke & + operator [](unsigned int index) const + { + assert(index < NumStrokes); + return *mppStrokes[index]; + } + +private: + // Construct from an array of Stroke objects. + StrokeSet(const Stroke *const pStrokes[NumStrokes]) + : mppStrokes(pStrokes) + { + // empty + } + + StrokeSet(const StrokeSet &); + StrokeSet &operator =(const StrokeSet &); + + // Data members. + const Stroke *const *const mppStrokes; +}; + +#endif // STROKESET_H diff --git a/utility/Point.h b/utility/Position.h similarity index 59% rename from utility/Point.h rename to utility/Position.h index d62f1c4..aa67f01 100644 --- a/utility/Point.h +++ b/utility/Position.h @@ -1,89 +1,89 @@ // Arithmetic with coordinates. BeOS rulez! // // Copyright © 2001-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. -#ifndef POINT_H -#define POINT_H +#ifndef POSITION_H +#define POSITION_H #include <cmath> #include <OpenGL/gl.h> -class Point +class Position // should be Point, but OS X already defines one { public: GLfloat x; GLfloat y; - Point(void) + Position(void) { // empty } - Point(GLfloat x_, GLfloat y_) + Position(GLfloat x_, GLfloat y_) : x(x_), y(y_) { // empty } }; // Just the operators we'll use; no need to provide the full set. -inline Point -operator +(const Point &p1, const Point &p2) +inline Position +operator +(const Position &p1, const Position &p2) { - return Point(p1.x + p2.x, p1.y + p2.y); + return Position(p1.x + p2.x, p1.y + p2.y); } -inline Point -operator -(const Point &p1, const Point &p2) +inline Position +operator -(const Position &p1, const Position &p2) { - return Point(p1.x - p2.x, p1.y - p2.y); + return Position(p1.x - p2.x, p1.y - p2.y); } -inline Point -operator *(const Point &p, const GLfloat s) +inline Position +operator *(const Position &p, const GLfloat s) { - return Point(p.x * s, p.y * s); + return Position(p.x * s, p.y * s); } -inline Point -operator *(const GLfloat s, const Point &p) +inline Position +operator *(const GLfloat s, const Position &p) { - return Point(p.x * s, p.y * s); + return Position(p.x * s, p.y * s); } inline GLfloat -operator *(const Point &p1, const Point &p2) +operator *(const Position &p1, const Position &p2) { return p1.x * p2.x + p1.y * p2.y; } -inline Point -operator *(const GLfloat t[4], const Point &p) +inline Position +operator *(const GLfloat t[4], const Position &p) { - return Point(t[0] * p.x + t[1] * p.y, + return Position(t[0] * p.x + t[1] * p.y, t[2] * p.x + t[3] * p.y); } inline GLfloat -norm(const Point &p) +norm(const Position &p) { return sqrt(p * p); } -#endif // POINT_H +#endif // POSITION_H
jjk/XamhainII
7f21b4c63d388928677fc0f12e9cb71b0b6e897b
Make preferences thread safe.
diff --git a/XamhainII.xcodeproj/project.pbxproj b/XamhainII.xcodeproj/project.pbxproj index 7854e05..7d31461 100644 --- a/XamhainII.xcodeproj/project.pbxproj +++ b/XamhainII.xcodeproj/project.pbxproj @@ -1,650 +1,638 @@ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 45; objects = { /* Begin PBXAggregateTarget section */ 000D03D61089C45F003F010E /* XamhainII.dmg */ = { isa = PBXAggregateTarget; buildConfigurationList = 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */; buildPhases = ( 000D03D51089C45F003F010E /* ShellScript */, ); dependencies = ( 000D03DA1089C465003F010E /* PBXTargetDependency */, ); name = XamhainII.dmg; productName = XamhainII.dmg; }; /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0032D325108A30770033FA87 /* OpenGL.framework */; }; 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00791842108B081B00156D67 /* XamhainPreferences.mm */; }; - 00791845108B081B00156D67 /* XamhainPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 00791843108B081B00156D67 /* XamhainPreferences.h */; }; - 007C512A108A29BE00ED3242 /* Point.h in Headers */ = {isa = PBXBuildFile; fileRef = 007C5126108A29BE00ED3242 /* Point.h */; }; 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007C5127108A29BE00ED3242 /* RandomColor.cpp */; }; - 007C512C108A29BE00ED3242 /* RandomColor.h in Headers */ = {isa = PBXBuildFile; fileRef = 007C5128108A29BE00ED3242 /* RandomColor.h */; }; - 007C512D108A29BE00ED3242 /* RandomNumbers.h in Headers */ = {isa = PBXBuildFile; fileRef = 007C5129108A29BE00ED3242 /* RandomNumbers.h */; }; 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */; }; 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */; }; 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */; }; 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */; }; 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */; }; 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */; }; 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */; }; 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */; }; 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */; }; 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */; }; 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */; }; 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */; }; 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */; }; 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */; }; 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */; }; 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */; }; 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */; }; 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */; }; 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */; }; 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */; }; 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */; }; 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */; }; 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */; }; 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */; }; 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */; }; 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */; }; 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */; }; 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */; }; 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */; }; 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */; }; 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */; }; 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */; }; 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */; }; 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */; }; 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */; }; 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */; }; 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */; }; 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */; }; 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */; }; 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */; }; 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */; }; 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */; }; 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */; }; 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */; }; - 00DA7837107A73320094FCAB /* XamhainView.h in Headers */ = {isa = PBXBuildFile; fileRef = 00DA7835107A73320094FCAB /* XamhainView.h */; }; 00DA7838107A73320094FCAB /* XamhainView.m in Sources */ = {isa = PBXBuildFile; fileRef = 00DA7836107A73320094FCAB /* XamhainView.m */; }; - 8D255AC70486D3F9007BF209 /* XamhainII_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */; }; 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 000D03D91089C465003F010E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 089C1669FE841209C02AAC07 /* Project object */; proxyType = 1; remoteGlobalIDString = 8D255AC50486D3F9007BF209; remoteInfo = XamhainII; }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ 0032D325108A30770033FA87 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; }; 00791842108B081B00156D67 /* XamhainPreferences.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainPreferences.mm; path = "screen saving/XamhainPreferences.mm"; sourceTree = "<group>"; }; 00791843108B081B00156D67 /* XamhainPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainPreferences.h; path = "screen saving/XamhainPreferences.h"; sourceTree = "<group>"; }; 007C5126108A29BE00ED3242 /* Point.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Point.h; path = utility/Point.h; sourceTree = "<group>"; }; 007C5127108A29BE00ED3242 /* RandomColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RandomColor.cpp; path = utility/RandomColor.cpp; sourceTree = "<group>"; }; 007C5128108A29BE00ED3242 /* RandomColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomColor.h; path = utility/RandomColor.h; sourceTree = "<group>"; }; 007C5129108A29BE00ED3242 /* RandomNumbers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomNumbers.h; path = utility/RandomNumbers.h; sourceTree = "<group>"; }; 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA7835107A73320094FCAB /* XamhainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainView.h; path = "screen saving/XamhainView.h"; sourceTree = "<group>"; }; 00DA7836107A73320094FCAB /* XamhainView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XamhainView.m; path = "screen saving/XamhainView.m"; sourceTree = "<group>"; }; 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ScreenSaver.framework; path = /System/Library/Frameworks/ScreenSaver.framework; sourceTree = "<absolute>"; }; 089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; 089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; }; 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; }; 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XamhainII_Prefix.pch; sourceTree = "<group>"; }; 8D255AD20486D3F9007BF209 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; 8D255AD30486D3F9007BF209 /* XamhainII.saver */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XamhainII.saver; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 8D255ACD0486D3F9007BF209 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */, 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */, 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 007C5125108A299800ED3242 /* Utility */ = { isa = PBXGroup; children = ( 007C5126108A29BE00ED3242 /* Point.h */, 007C5127108A29BE00ED3242 /* RandomColor.cpp */, 007C5128108A29BE00ED3242 /* RandomColor.h */, 007C5129108A29BE00ED3242 /* RandomNumbers.h */, ); name = Utility; sourceTree = "<group>"; }; 00DA77D5107A728C0094FCAB /* Strokes */ = { isa = PBXGroup; children = ( 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */, 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */, 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */, 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */, 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */, 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */, 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */, 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */, 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */, 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */, 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */, 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */, 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */, 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */, 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */, 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */, 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */, 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */, 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */, 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */, 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */, 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */, 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */, 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */, 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */, 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */, 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */, 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */, 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */, 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */, 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */, 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */, 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */, 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */, 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */, 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */, 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */, 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */, 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */, 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */, 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */, 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */, 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */, 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */, ); name = Strokes; path = strokes; sourceTree = "<group>"; }; 00DA7833107A72F00094FCAB /* Screen Saving */ = { isa = PBXGroup; children = ( 00791842108B081B00156D67 /* XamhainPreferences.mm */, 00791843108B081B00156D67 /* XamhainPreferences.h */, 00DA7835107A73320094FCAB /* XamhainView.h */, 00DA7836107A73320094FCAB /* XamhainView.m */, ); name = "Screen Saving"; sourceTree = "<group>"; }; 089C166AFE841209C02AAC07 /* XamhainII */ = { isa = PBXGroup; children = ( 00DA7833107A72F00094FCAB /* Screen Saving */, 007C5125108A299800ED3242 /* Utility */, 32DBCFA70370C4F300C91783 /* Other Sources */, 089C167CFE841241C02AAC07 /* Resources */, 089C1671FE841209C02AAC07 /* Frameworks and Libraries */, 19C28FB8FE9D52D311CA2CBB /* Products */, ); name = XamhainII; sourceTree = "<group>"; }; 089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = { isa = PBXGroup; children = ( 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */, 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */, ); name = "Frameworks and Libraries"; sourceTree = "<group>"; }; 089C167CFE841241C02AAC07 /* Resources */ = { isa = PBXGroup; children = ( 00DA77D5107A728C0094FCAB /* Strokes */, 8D255AD20486D3F9007BF209 /* Info.plist */, 089C167DFE841241C02AAC07 /* InfoPlist.strings */, ); name = Resources; sourceTree = "<group>"; }; 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = { isa = PBXGroup; children = ( 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, 0032D325108A30770033FA87 /* OpenGL.framework */, 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */, ); name = "Linked Frameworks"; sourceTree = "<group>"; }; 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = { isa = PBXGroup; children = ( 089C1672FE841209C02AAC07 /* Foundation.framework */, 089C167FFE841241C02AAC07 /* AppKit.framework */, ); name = "Other Frameworks"; sourceTree = "<group>"; }; 19C28FB8FE9D52D311CA2CBB /* Products */ = { isa = PBXGroup; children = ( 8D255AD30486D3F9007BF209 /* XamhainII.saver */, ); name = Products; sourceTree = "<group>"; }; 32DBCFA70370C4F300C91783 /* Other Sources */ = { isa = PBXGroup; children = ( 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */, ); name = "Other Sources"; sourceTree = "<group>"; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ 8D255AC60486D3F9007BF209 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 8D255AC70486D3F9007BF209 /* XamhainII_Prefix.pch in Headers */, - 00DA7837107A73320094FCAB /* XamhainView.h in Headers */, - 007C512A108A29BE00ED3242 /* Point.h in Headers */, - 007C512C108A29BE00ED3242 /* RandomColor.h in Headers */, - 007C512D108A29BE00ED3242 /* RandomNumbers.h in Headers */, - 00791845108B081B00156D67 /* XamhainPreferences.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ 8D255AC50486D3F9007BF209 /* XamhainII */ = { isa = PBXNativeTarget; buildConfigurationList = EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */; buildPhases = ( 8D255AC60486D3F9007BF209 /* Headers */, 8D255AC90486D3F9007BF209 /* Resources */, 8D255ACB0486D3F9007BF209 /* Sources */, 8D255ACD0486D3F9007BF209 /* Frameworks */, 8D255AD00486D3F9007BF209 /* Rez */, ); buildRules = ( ); dependencies = ( ); name = XamhainII; productInstallPath = "$(HOME)/Library/Screen Savers"; productName = XamhainII; productReference = 8D255AD30486D3F9007BF209 /* XamhainII.saver */; productType = "com.apple.product-type.bundle"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 089C1669FE841209C02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */; compatibilityVersion = "Xcode 3.1"; hasScannedForEncodings = 1; mainGroup = 089C166AFE841209C02AAC07 /* XamhainII */; projectDirPath = ""; projectRoot = ""; targets = ( 8D255AC50486D3F9007BF209 /* XamhainII */, 000D03D61089C45F003F010E /* XamhainII.dmg */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ 8D255AC90486D3F9007BF209 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */, 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */, 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */, 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */, 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */, 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */, 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */, 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */, 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */, 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */, 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */, 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */, 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */, 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */, 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */, 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */, 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */, 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */, 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */, 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */, 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */, 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */, 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */, 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */, 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */, 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */, 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */, 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */, 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */, 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */, 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */, 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */, 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */, 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */, 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */, 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */, 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */, 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */, 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */, 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */, 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */, 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */, 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */, 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */, 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXRezBuildPhase section */ 8D255AD00486D3F9007BF209 /* Rez */ = { isa = PBXRezBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXRezBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ 000D03D51089C45F003F010E /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.saver", ); outputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.dmg", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "# Thanks to Rob Mayoff for explaining how to do this.\n# See http://qwan.org/2007/05/22/using-xcode-to-build-a-disk-image-and-upload-a-web-site/\n\nset -ex\n\n[ \"$ACTION\" = build ] || exit 0\n[ \"$BUILD_VARIANTS\" = \"normal\" ] || exit 0\n\ndir=\"$TEMP_FILES_DIR/disk\"\ndmg=\"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.dmg\"\n\nrm -rf \"$dir\"\nmkdir \"$dir\"\ncp -R \"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.saver\" \"$dir\"\nrm -f \"$dmg\"\nhdiutil create -srcfolder \"$dir\" -volname \"$PROJECT_NAME\" \"$dmg\"\nhdiutil internet-enable -yes \"$dmg\"\nrm -rf \"$dir\"\n"; }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 8D255ACB0486D3F9007BF209 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 00DA7838107A73320094FCAB /* XamhainView.m in Sources */, 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */, 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 000D03DA1089C465003F010E /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 8D255AC50486D3F9007BF209 /* XamhainII */; targetProxy = 000D03D91089C465003F010E /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ 089C167DFE841241C02AAC07 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 089C167EFE841241C02AAC07 /* English */, ); name = InfoPlist.strings; sourceTree = "<group>"; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 000D03D71089C45F003F010E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; PRODUCT_NAME = XamhainII.dmg; }; name = Debug; }; 000D03D81089C45F003F010E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = XamhainII.dmg; ZERO_LINK = NO; }; name = Release; }; EF7AD72E08BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_STRICT_ALIASING = NO; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = NO; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; ZERO_LINK = YES; }; name = Debug; }; EF7AD72F08BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; }; name = Release; }; EF7AD73208BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = NO; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Debug; }; EF7AD73308BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */ = { isa = XCConfigurationList; buildConfigurations = ( 000D03D71089C45F003F010E /* Debug */, 000D03D81089C45F003F010E /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD72E08BB986600CE4634 /* Debug */, EF7AD72F08BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD73208BB986600CE4634 /* Debug */, EF7AD73308BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 089C1669FE841209C02AAC07 /* Project object */; } diff --git a/screen saving/XamhainPreferences.h b/screen saving/XamhainPreferences.h index 697b348..f3b8688 100644 --- a/screen saving/XamhainPreferences.h +++ b/screen saving/XamhainPreferences.h @@ -1,103 +1,97 @@ // XamhainII screen saver preferences. // // Copyright © 2000-2009, Jens Kilian. // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #ifndef XAMHAINPREFERENCES_H #define XAMHAINPREFERENCES_H #include <objc/objc.h> #include <OpenGL/gl.h> class XamhainPreferences { public: - // This is a singleton class. - static const XamhainPreferences & - instance(void); + XamhainPreferences(void); // Screen saving preferences. int numberOfKnots(void) const; bool technicolor(void) const; GLfloat minSize(void) const; GLfloat maxSize(void) const; GLfloat minSpeed(void) const; GLfloat maxSpeed(void) const; GLfloat minSpin(void) const; GLfloat maxSpin(void) const; GLfloat skewProbability(void) const; GLfloat spinProbability(void) const; // Knot engine preferences. int knotSubdivisions(void) const; GLfloat horizontalKnotProbability(void) const; GLfloat verticalKnotProbability(void) const; GLfloat closedKnotProbability(void) const; GLfloat circularKnotProbability(void) const; GLfloat sectionProbability1(void) const; GLfloat sectionProbability2(void) const; GLfloat cornerProbability1(void) const; GLfloat cornerProbability2(void) const; GLfloat broadKnotProbability(void) const; GLfloat hollowKnotProbability(void) const; GLfloat symmetricKnotProbability(void) const; GLfloat horizontalMirrorProbability(void) const; GLfloat verticalMirrorProbability(void) const; // ### TODO: colors private: - XamhainPreferences(void); - XamhainPreferences(const XamhainPreferences &); - XamhainPreferences &operator =(const XamhainPreferences &); - id mDefaults; // actual screen saver defaults }; #endif // XAMHAINPREFERENCES_H diff --git a/screen saving/XamhainPreferences.mm b/screen saving/XamhainPreferences.mm index 66590cc..f5763e9 100644 --- a/screen saving/XamhainPreferences.mm +++ b/screen saving/XamhainPreferences.mm @@ -1,220 +1,234 @@ // XamhainII screen saver preferences. // // Copyright © 2000-2009, Jens Kilian. // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "XamhainPreferences.h" #import "ScreenSaver/ScreenSaverDefaults.h" -namespace +@interface XamhainScreenSaverDefaults { - // Singleton instance. - XamhainPreferences *gpInstance; + // empty } -// Inquire the singleton preferences object. -const XamhainPreferences & -XamhainPreferences::instance(void) ++ (NSUserDefaults *)sharedDefaults; + +@end + +namespace { - if (!gpInstance) { - gpInstance = new XamhainPreferences; + NSUserDefaults *gpInstance = nil; +} + +@implementation XamhainScreenSaverDefaults + ++ (NSUserDefaults *)sharedDefaults +{ + @synchronized(self) { + if (gpInstance == nil) { + gpInstance = [ScreenSaverDefaults defaultsForModuleWithName: @"de.earrame.XamhainII"]; + + // Register initial defaults. + NSDictionary *factoryDefaults = + [NSDictionary dictionaryWithObjectsAndKeys: + @"NumberOfKnots", @"8", + @"Technicolor", @"YES", + @"MinSize", @"0.2", + @"MaxSize", @"0.5", + @"MinSpeed", @"3.0", + @"MaxSpeed", @"6.0", + @"MinSpin", @"1.0", + @"MaxSpin", @"5.0", + @"SkewProbability", @"0.8", + @"SpinProbability", @"0.8", + @"KnotSubdivisions", @"2", + @"HorizontalKnotProbability", @"0.1", + @"VerticalKnotProbability", @"0.2", + @"ClosedKnotProbability", @"0.5", + @"CircularKnotProbability", @"0.5", + @"SectionProbability1", @"0.06", + @"SectionProbability2", @"0.94", + @"CornerProbability1", @"0.2", + @"CornerProbability2", @"0.8", + @"BroadKnotProbability", @"0.5", + @"HollowKnotProbability", @"0.4", + @"SymmetricKnotProbability", @"0.8", + @"HorizontalMirrorProbability", @"0.9", + @"VerticalMirrorProbability", @"0.9", + NULL]; + + [gpInstance registerDefaults: factoryDefaults]; + } } - return *gpInstance; + return gpInstance; } -// Construct the singleton instance. +@end + +// Construct a preferences object - which is actually just a wrapper. XamhainPreferences::XamhainPreferences(void) -: mDefaults([ScreenSaverDefaults defaultsForModuleWithName: @"de.earrame.XamhainII"]) -{ - // Register initial defaults. - NSDictionary *factoryDefaults = - [NSDictionary dictionaryWithObjectsAndKeys: - @"NumberOfKnots", @"8", - @"Technicolor", @"YES", - @"MinSize", @"0.2", - @"MaxSize", @"0.5", - @"MinSpeed", @"3.0", - @"MaxSpeed", @"6.0", - @"MinSpin", @"1.0", - @"MaxSpin", @"5.0", - @"SkewProbability", @"0.8", - @"SpinProbability", @"0.8", - @"KnotSubdivisions", @"2", - @"HorizontalKnotProbability", @"0.1", - @"VerticalKnotProbability", @"0.2", - @"ClosedKnotProbability", @"0.5", - @"CircularKnotProbability", @"0.5", - @"SectionProbability1", @"0.06", - @"SectionProbability2", @"0.94", - @"CornerProbability1", @"0.2", - @"CornerProbability2", @"0.8", - @"BroadKnotProbability", @"0.5", - @"HollowKnotProbability", @"0.4", - @"SymmetricKnotProbability", @"0.8", - @"HorizontalMirrorProbability", @"0.9", - @"VerticalMirrorProbability", @"0.9", - NULL]; - - [mDefaults registerDefaults: factoryDefaults]; +: mDefaults([XamhainScreenSaverDefaults sharedDefaults]) +{ + // empty } // Implementation of inquiry functions. int XamhainPreferences::numberOfKnots(void) const { return [mDefaults integerForKey: @"NumberOfKnots"]; } bool XamhainPreferences::technicolor(void) const { return [mDefaults boolForKey: @"Technicolor"]; } GLfloat XamhainPreferences::minSize(void) const { return [mDefaults floatForKey: @"MinSize"]; } GLfloat XamhainPreferences::maxSize(void) const { return [mDefaults floatForKey: @"MaxSize"]; } GLfloat XamhainPreferences::minSpeed(void) const { return [mDefaults floatForKey: @"MinSpeed"]; } GLfloat XamhainPreferences::maxSpeed(void) const { return [mDefaults floatForKey: @"MaxSpeed"]; } GLfloat XamhainPreferences::minSpin(void) const { return [mDefaults floatForKey: @"MinSpin"]; } GLfloat XamhainPreferences::maxSpin(void) const { return [mDefaults floatForKey: @"MaxSpin"]; } GLfloat XamhainPreferences::skewProbability(void) const { return [mDefaults floatForKey: @"SkewProbability"]; } GLfloat XamhainPreferences::spinProbability(void) const { return [mDefaults floatForKey: @"SpinProbability"]; } int XamhainPreferences::knotSubdivisions(void) const { return [mDefaults integerForKey: @"KnotSubdivisions"]; } GLfloat XamhainPreferences::horizontalKnotProbability(void) const { return [mDefaults floatForKey: @"HorizontalKnotProbability"]; } GLfloat XamhainPreferences::verticalKnotProbability(void) const { return [mDefaults floatForKey: @"VerticalKnotProbability"]; } GLfloat XamhainPreferences::closedKnotProbability(void) const { return [mDefaults floatForKey: @"ClosedKnotProbability"]; } GLfloat XamhainPreferences::circularKnotProbability(void) const { return [mDefaults floatForKey: @"CircularKnotProbability"]; } GLfloat XamhainPreferences::sectionProbability1(void) const { return [mDefaults floatForKey: @"SectionProbability1"]; } GLfloat XamhainPreferences::sectionProbability2(void) const { return [mDefaults floatForKey: @"SectionProbability2"]; } GLfloat XamhainPreferences::cornerProbability1(void) const { return [mDefaults floatForKey: @"CornerProbability1"]; } GLfloat XamhainPreferences::cornerProbability2(void) const { return [mDefaults floatForKey: @"CornerProbability2"]; } GLfloat XamhainPreferences::broadKnotProbability(void) const { return [mDefaults floatForKey: @"BroadKnotProbability"]; } GLfloat XamhainPreferences::hollowKnotProbability(void) const { return [mDefaults floatForKey: @"HollowKnotProbability"]; } GLfloat XamhainPreferences::symmetricKnotProbability(void) const { return [mDefaults floatForKey: @"SymmetricKnotProbability"]; } GLfloat XamhainPreferences::horizontalMirrorProbability(void) const { return [mDefaults floatForKey: @"HorizontalKnotProbability"]; } GLfloat XamhainPreferences::verticalMirrorProbability(void) const { return [mDefaults floatForKey: @"VerticalKnotProbability"]; }
jjk/XamhainII
2cd3157aafd90532e9e4245efb5a54d0a3941ab1
Finish implementing preferences.
diff --git a/screen saving/XamhainPreferences.mm b/screen saving/XamhainPreferences.mm index 97c0907..66590cc 100644 --- a/screen saving/XamhainPreferences.mm +++ b/screen saving/XamhainPreferences.mm @@ -1,191 +1,220 @@ // XamhainII screen saver preferences. // // Copyright © 2000-2009, Jens Kilian. // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "XamhainPreferences.h" #import "ScreenSaver/ScreenSaverDefaults.h" namespace { // Singleton instance. XamhainPreferences *gpInstance; } // Inquire the singleton preferences object. const XamhainPreferences & XamhainPreferences::instance(void) { if (!gpInstance) { gpInstance = new XamhainPreferences; } return *gpInstance; } // Construct the singleton instance. XamhainPreferences::XamhainPreferences(void) : mDefaults([ScreenSaverDefaults defaultsForModuleWithName: @"de.earrame.XamhainII"]) { - // TODO - register initial defaults. + // Register initial defaults. + NSDictionary *factoryDefaults = + [NSDictionary dictionaryWithObjectsAndKeys: + @"NumberOfKnots", @"8", + @"Technicolor", @"YES", + @"MinSize", @"0.2", + @"MaxSize", @"0.5", + @"MinSpeed", @"3.0", + @"MaxSpeed", @"6.0", + @"MinSpin", @"1.0", + @"MaxSpin", @"5.0", + @"SkewProbability", @"0.8", + @"SpinProbability", @"0.8", + @"KnotSubdivisions", @"2", + @"HorizontalKnotProbability", @"0.1", + @"VerticalKnotProbability", @"0.2", + @"ClosedKnotProbability", @"0.5", + @"CircularKnotProbability", @"0.5", + @"SectionProbability1", @"0.06", + @"SectionProbability2", @"0.94", + @"CornerProbability1", @"0.2", + @"CornerProbability2", @"0.8", + @"BroadKnotProbability", @"0.5", + @"HollowKnotProbability", @"0.4", + @"SymmetricKnotProbability", @"0.8", + @"HorizontalMirrorProbability", @"0.9", + @"VerticalMirrorProbability", @"0.9", + NULL]; + + [mDefaults registerDefaults: factoryDefaults]; } // Implementation of inquiry functions. int XamhainPreferences::numberOfKnots(void) const { - return 0; + return [mDefaults integerForKey: @"NumberOfKnots"]; } bool XamhainPreferences::technicolor(void) const { - return false; + return [mDefaults boolForKey: @"Technicolor"]; } GLfloat XamhainPreferences::minSize(void) const { - return 0; + return [mDefaults floatForKey: @"MinSize"]; } GLfloat XamhainPreferences::maxSize(void) const { - return 0; + return [mDefaults floatForKey: @"MaxSize"]; } GLfloat XamhainPreferences::minSpeed(void) const { - return 0; + return [mDefaults floatForKey: @"MinSpeed"]; } GLfloat XamhainPreferences::maxSpeed(void) const { - return 0; + return [mDefaults floatForKey: @"MaxSpeed"]; } GLfloat XamhainPreferences::minSpin(void) const { - return 0; + return [mDefaults floatForKey: @"MinSpin"]; } GLfloat XamhainPreferences::maxSpin(void) const { - return 0; + return [mDefaults floatForKey: @"MaxSpin"]; } GLfloat XamhainPreferences::skewProbability(void) const { - return 0; + return [mDefaults floatForKey: @"SkewProbability"]; } GLfloat XamhainPreferences::spinProbability(void) const { - return 0; + return [mDefaults floatForKey: @"SpinProbability"]; } int XamhainPreferences::knotSubdivisions(void) const { - return 0; + return [mDefaults integerForKey: @"KnotSubdivisions"]; } GLfloat XamhainPreferences::horizontalKnotProbability(void) const { - return 0; + return [mDefaults floatForKey: @"HorizontalKnotProbability"]; } GLfloat XamhainPreferences::verticalKnotProbability(void) const { - return 0; + return [mDefaults floatForKey: @"VerticalKnotProbability"]; } GLfloat XamhainPreferences::closedKnotProbability(void) const { - return 0; + return [mDefaults floatForKey: @"ClosedKnotProbability"]; } GLfloat XamhainPreferences::circularKnotProbability(void) const { - return 0; + return [mDefaults floatForKey: @"CircularKnotProbability"]; } GLfloat XamhainPreferences::sectionProbability1(void) const { - return 0; + return [mDefaults floatForKey: @"SectionProbability1"]; } GLfloat XamhainPreferences::sectionProbability2(void) const { - return 0; + return [mDefaults floatForKey: @"SectionProbability2"]; } GLfloat XamhainPreferences::cornerProbability1(void) const { - return 0; + return [mDefaults floatForKey: @"CornerProbability1"]; } GLfloat XamhainPreferences::cornerProbability2(void) const { - return 0; + return [mDefaults floatForKey: @"CornerProbability2"]; } GLfloat XamhainPreferences::broadKnotProbability(void) const { - return 0; + return [mDefaults floatForKey: @"BroadKnotProbability"]; } GLfloat XamhainPreferences::hollowKnotProbability(void) const { - return 0; + return [mDefaults floatForKey: @"HollowKnotProbability"]; } GLfloat XamhainPreferences::symmetricKnotProbability(void) const { - return 0; + return [mDefaults floatForKey: @"SymmetricKnotProbability"]; } GLfloat XamhainPreferences::horizontalMirrorProbability(void) const { - return 0; + return [mDefaults floatForKey: @"HorizontalKnotProbability"]; } GLfloat XamhainPreferences::verticalMirrorProbability(void) const { - return 0; + return [mDefaults floatForKey: @"VerticalKnotProbability"]; }
jjk/XamhainII
84187985f20d656555b9dff5cabbe262ff4a5981
Add skeleton preferences.
diff --git a/XamhainII.xcodeproj/project.pbxproj b/XamhainII.xcodeproj/project.pbxproj index fe04a6c..7854e05 100644 --- a/XamhainII.xcodeproj/project.pbxproj +++ b/XamhainII.xcodeproj/project.pbxproj @@ -1,642 +1,650 @@ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 45; objects = { /* Begin PBXAggregateTarget section */ 000D03D61089C45F003F010E /* XamhainII.dmg */ = { isa = PBXAggregateTarget; buildConfigurationList = 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */; buildPhases = ( 000D03D51089C45F003F010E /* ShellScript */, ); dependencies = ( 000D03DA1089C465003F010E /* PBXTargetDependency */, ); name = XamhainII.dmg; productName = XamhainII.dmg; }; /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0032D325108A30770033FA87 /* OpenGL.framework */; }; + 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00791842108B081B00156D67 /* XamhainPreferences.mm */; }; + 00791845108B081B00156D67 /* XamhainPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 00791843108B081B00156D67 /* XamhainPreferences.h */; }; 007C512A108A29BE00ED3242 /* Point.h in Headers */ = {isa = PBXBuildFile; fileRef = 007C5126108A29BE00ED3242 /* Point.h */; }; 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007C5127108A29BE00ED3242 /* RandomColor.cpp */; }; 007C512C108A29BE00ED3242 /* RandomColor.h in Headers */ = {isa = PBXBuildFile; fileRef = 007C5128108A29BE00ED3242 /* RandomColor.h */; }; 007C512D108A29BE00ED3242 /* RandomNumbers.h in Headers */ = {isa = PBXBuildFile; fileRef = 007C5129108A29BE00ED3242 /* RandomNumbers.h */; }; 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */; }; 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */; }; 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */; }; 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */; }; 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */; }; 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */; }; 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */; }; 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */; }; 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */; }; 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */; }; 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */; }; 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */; }; 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */; }; 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */; }; 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */; }; 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */; }; 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */; }; 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */; }; 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */; }; 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */; }; 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */; }; 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */; }; 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */; }; 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */; }; 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */; }; 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */; }; 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */; }; 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */; }; 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */; }; 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */; }; 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */; }; 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */; }; 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */; }; 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */; }; 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */; }; 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */; }; 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */; }; 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */; }; 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */; }; 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */; }; 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */; }; 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */; }; 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */; }; 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */; }; 00DA7837107A73320094FCAB /* XamhainView.h in Headers */ = {isa = PBXBuildFile; fileRef = 00DA7835107A73320094FCAB /* XamhainView.h */; }; 00DA7838107A73320094FCAB /* XamhainView.m in Sources */ = {isa = PBXBuildFile; fileRef = 00DA7836107A73320094FCAB /* XamhainView.m */; }; 8D255AC70486D3F9007BF209 /* XamhainII_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */; }; 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 000D03D91089C465003F010E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 089C1669FE841209C02AAC07 /* Project object */; proxyType = 1; remoteGlobalIDString = 8D255AC50486D3F9007BF209; remoteInfo = XamhainII; }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ 0032D325108A30770033FA87 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; }; + 00791842108B081B00156D67 /* XamhainPreferences.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XamhainPreferences.mm; path = "screen saving/XamhainPreferences.mm"; sourceTree = "<group>"; }; + 00791843108B081B00156D67 /* XamhainPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainPreferences.h; path = "screen saving/XamhainPreferences.h"; sourceTree = "<group>"; }; 007C5126108A29BE00ED3242 /* Point.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Point.h; path = utility/Point.h; sourceTree = "<group>"; }; 007C5127108A29BE00ED3242 /* RandomColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RandomColor.cpp; path = utility/RandomColor.cpp; sourceTree = "<group>"; }; 007C5128108A29BE00ED3242 /* RandomColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomColor.h; path = utility/RandomColor.h; sourceTree = "<group>"; }; 007C5129108A29BE00ED3242 /* RandomNumbers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomNumbers.h; path = utility/RandomNumbers.h; sourceTree = "<group>"; }; 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA7835107A73320094FCAB /* XamhainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainView.h; path = "screen saving/XamhainView.h"; sourceTree = "<group>"; }; 00DA7836107A73320094FCAB /* XamhainView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XamhainView.m; path = "screen saving/XamhainView.m"; sourceTree = "<group>"; }; 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ScreenSaver.framework; path = /System/Library/Frameworks/ScreenSaver.framework; sourceTree = "<absolute>"; }; 089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; 089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; }; 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; }; 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XamhainII_Prefix.pch; sourceTree = "<group>"; }; 8D255AD20486D3F9007BF209 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; 8D255AD30486D3F9007BF209 /* XamhainII.saver */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XamhainII.saver; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 8D255ACD0486D3F9007BF209 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */, 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */, 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 007C5125108A299800ED3242 /* Utility */ = { isa = PBXGroup; children = ( 007C5126108A29BE00ED3242 /* Point.h */, 007C5127108A29BE00ED3242 /* RandomColor.cpp */, 007C5128108A29BE00ED3242 /* RandomColor.h */, 007C5129108A29BE00ED3242 /* RandomNumbers.h */, ); name = Utility; sourceTree = "<group>"; }; 00DA77D5107A728C0094FCAB /* Strokes */ = { isa = PBXGroup; children = ( 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */, 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */, 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */, 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */, 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */, 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */, 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */, 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */, 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */, 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */, 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */, 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */, 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */, 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */, 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */, 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */, 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */, 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */, 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */, 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */, 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */, 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */, 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */, 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */, 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */, 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */, 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */, 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */, 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */, 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */, 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */, 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */, 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */, 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */, 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */, 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */, 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */, 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */, 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */, 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */, 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */, 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */, 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */, 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */, ); name = Strokes; path = strokes; sourceTree = "<group>"; }; 00DA7833107A72F00094FCAB /* Screen Saving */ = { isa = PBXGroup; children = ( + 00791842108B081B00156D67 /* XamhainPreferences.mm */, + 00791843108B081B00156D67 /* XamhainPreferences.h */, 00DA7835107A73320094FCAB /* XamhainView.h */, 00DA7836107A73320094FCAB /* XamhainView.m */, ); name = "Screen Saving"; sourceTree = "<group>"; }; 089C166AFE841209C02AAC07 /* XamhainII */ = { isa = PBXGroup; children = ( 00DA7833107A72F00094FCAB /* Screen Saving */, 007C5125108A299800ED3242 /* Utility */, 32DBCFA70370C4F300C91783 /* Other Sources */, 089C167CFE841241C02AAC07 /* Resources */, 089C1671FE841209C02AAC07 /* Frameworks and Libraries */, 19C28FB8FE9D52D311CA2CBB /* Products */, ); name = XamhainII; sourceTree = "<group>"; }; 089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = { isa = PBXGroup; children = ( 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */, 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */, ); name = "Frameworks and Libraries"; sourceTree = "<group>"; }; 089C167CFE841241C02AAC07 /* Resources */ = { isa = PBXGroup; children = ( 00DA77D5107A728C0094FCAB /* Strokes */, 8D255AD20486D3F9007BF209 /* Info.plist */, 089C167DFE841241C02AAC07 /* InfoPlist.strings */, ); name = Resources; sourceTree = "<group>"; }; 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = { isa = PBXGroup; children = ( 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, 0032D325108A30770033FA87 /* OpenGL.framework */, 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */, ); name = "Linked Frameworks"; sourceTree = "<group>"; }; 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = { isa = PBXGroup; children = ( 089C1672FE841209C02AAC07 /* Foundation.framework */, 089C167FFE841241C02AAC07 /* AppKit.framework */, ); name = "Other Frameworks"; sourceTree = "<group>"; }; 19C28FB8FE9D52D311CA2CBB /* Products */ = { isa = PBXGroup; children = ( 8D255AD30486D3F9007BF209 /* XamhainII.saver */, ); name = Products; sourceTree = "<group>"; }; 32DBCFA70370C4F300C91783 /* Other Sources */ = { isa = PBXGroup; children = ( 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */, ); name = "Other Sources"; sourceTree = "<group>"; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ 8D255AC60486D3F9007BF209 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 8D255AC70486D3F9007BF209 /* XamhainII_Prefix.pch in Headers */, 00DA7837107A73320094FCAB /* XamhainView.h in Headers */, 007C512A108A29BE00ED3242 /* Point.h in Headers */, 007C512C108A29BE00ED3242 /* RandomColor.h in Headers */, 007C512D108A29BE00ED3242 /* RandomNumbers.h in Headers */, + 00791845108B081B00156D67 /* XamhainPreferences.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ 8D255AC50486D3F9007BF209 /* XamhainII */ = { isa = PBXNativeTarget; buildConfigurationList = EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */; buildPhases = ( 8D255AC60486D3F9007BF209 /* Headers */, 8D255AC90486D3F9007BF209 /* Resources */, 8D255ACB0486D3F9007BF209 /* Sources */, 8D255ACD0486D3F9007BF209 /* Frameworks */, 8D255AD00486D3F9007BF209 /* Rez */, ); buildRules = ( ); dependencies = ( ); name = XamhainII; productInstallPath = "$(HOME)/Library/Screen Savers"; productName = XamhainII; productReference = 8D255AD30486D3F9007BF209 /* XamhainII.saver */; productType = "com.apple.product-type.bundle"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 089C1669FE841209C02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */; compatibilityVersion = "Xcode 3.1"; hasScannedForEncodings = 1; mainGroup = 089C166AFE841209C02AAC07 /* XamhainII */; projectDirPath = ""; projectRoot = ""; targets = ( 8D255AC50486D3F9007BF209 /* XamhainII */, 000D03D61089C45F003F010E /* XamhainII.dmg */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ 8D255AC90486D3F9007BF209 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */, 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */, 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */, 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */, 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */, 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */, 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */, 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */, 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */, 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */, 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */, 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */, 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */, 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */, 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */, 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */, 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */, 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */, 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */, 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */, 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */, 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */, 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */, 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */, 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */, 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */, 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */, 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */, 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */, 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */, 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */, 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */, 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */, 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */, 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */, 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */, 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */, 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */, 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */, 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */, 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */, 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */, 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */, 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */, 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXRezBuildPhase section */ 8D255AD00486D3F9007BF209 /* Rez */ = { isa = PBXRezBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXRezBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ 000D03D51089C45F003F010E /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.saver", ); outputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.dmg", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "# Thanks to Rob Mayoff for explaining how to do this.\n# See http://qwan.org/2007/05/22/using-xcode-to-build-a-disk-image-and-upload-a-web-site/\n\nset -ex\n\n[ \"$ACTION\" = build ] || exit 0\n[ \"$BUILD_VARIANTS\" = \"normal\" ] || exit 0\n\ndir=\"$TEMP_FILES_DIR/disk\"\ndmg=\"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.dmg\"\n\nrm -rf \"$dir\"\nmkdir \"$dir\"\ncp -R \"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.saver\" \"$dir\"\nrm -f \"$dmg\"\nhdiutil create -srcfolder \"$dir\" -volname \"$PROJECT_NAME\" \"$dmg\"\nhdiutil internet-enable -yes \"$dmg\"\nrm -rf \"$dir\"\n"; }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 8D255ACB0486D3F9007BF209 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 00DA7838107A73320094FCAB /* XamhainView.m in Sources */, 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */, + 00791844108B081B00156D67 /* XamhainPreferences.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 000D03DA1089C465003F010E /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 8D255AC50486D3F9007BF209 /* XamhainII */; targetProxy = 000D03D91089C465003F010E /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ 089C167DFE841241C02AAC07 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 089C167EFE841241C02AAC07 /* English */, ); name = InfoPlist.strings; sourceTree = "<group>"; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 000D03D71089C45F003F010E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; PRODUCT_NAME = XamhainII.dmg; }; name = Debug; }; 000D03D81089C45F003F010E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = XamhainII.dmg; ZERO_LINK = NO; }; name = Release; }; EF7AD72E08BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_STRICT_ALIASING = NO; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = NO; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; ZERO_LINK = YES; }; name = Debug; }; EF7AD72F08BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; }; name = Release; }; EF7AD73208BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = NO; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Debug; }; EF7AD73308BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */ = { isa = XCConfigurationList; buildConfigurations = ( 000D03D71089C45F003F010E /* Debug */, 000D03D81089C45F003F010E /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD72E08BB986600CE4634 /* Debug */, EF7AD72F08BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD73208BB986600CE4634 /* Debug */, EF7AD73308BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 089C1669FE841209C02AAC07 /* Project object */; } diff --git a/screen saving/XamhainPreferences.h b/screen saving/XamhainPreferences.h new file mode 100644 index 0000000..697b348 --- /dev/null +++ b/screen saving/XamhainPreferences.h @@ -0,0 +1,103 @@ +// XamhainII screen saver preferences. +// +// Copyright © 2000-2009, Jens Kilian. +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#ifndef XAMHAINPREFERENCES_H +#define XAMHAINPREFERENCES_H + +#include <objc/objc.h> +#include <OpenGL/gl.h> + +class XamhainPreferences +{ +public: + // This is a singleton class. + static const XamhainPreferences & + instance(void); + + // Screen saving preferences. + int + numberOfKnots(void) const; + bool + technicolor(void) const; + + GLfloat + minSize(void) const; + GLfloat + maxSize(void) const; + + GLfloat + minSpeed(void) const; + GLfloat + maxSpeed(void) const; + + GLfloat + minSpin(void) const; + GLfloat + maxSpin(void) const; + + GLfloat + skewProbability(void) const; + GLfloat + spinProbability(void) const; + + // Knot engine preferences. + int + knotSubdivisions(void) const; + + GLfloat + horizontalKnotProbability(void) const; + GLfloat + verticalKnotProbability(void) const; + GLfloat + closedKnotProbability(void) const; + GLfloat + circularKnotProbability(void) const; + + GLfloat + sectionProbability1(void) const; + GLfloat + sectionProbability2(void) const; + GLfloat + cornerProbability1(void) const; + GLfloat + cornerProbability2(void) const; + + GLfloat + broadKnotProbability(void) const; + GLfloat + hollowKnotProbability(void) const; + + GLfloat + symmetricKnotProbability(void) const; + GLfloat + horizontalMirrorProbability(void) const; + GLfloat + verticalMirrorProbability(void) const; + + // ### TODO: colors + +private: + XamhainPreferences(void); + XamhainPreferences(const XamhainPreferences &); + XamhainPreferences &operator =(const XamhainPreferences &); + + id mDefaults; // actual screen saver defaults +}; + +#endif // XAMHAINPREFERENCES_H diff --git a/screen saving/XamhainPreferences.mm b/screen saving/XamhainPreferences.mm new file mode 100644 index 0000000..97c0907 --- /dev/null +++ b/screen saving/XamhainPreferences.mm @@ -0,0 +1,191 @@ +// XamhainII screen saver preferences. +// +// Copyright © 2000-2009, Jens Kilian. +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#include "XamhainPreferences.h" + +#import "ScreenSaver/ScreenSaverDefaults.h" + +namespace +{ + // Singleton instance. + XamhainPreferences *gpInstance; +} + +// Inquire the singleton preferences object. +const XamhainPreferences & +XamhainPreferences::instance(void) +{ + if (!gpInstance) { + gpInstance = new XamhainPreferences; + } + + return *gpInstance; +} + +// Construct the singleton instance. +XamhainPreferences::XamhainPreferences(void) +: mDefaults([ScreenSaverDefaults defaultsForModuleWithName: @"de.earrame.XamhainII"]) +{ + // TODO - register initial defaults. +} + +// Implementation of inquiry functions. +int +XamhainPreferences::numberOfKnots(void) const +{ + return 0; +} + +bool +XamhainPreferences::technicolor(void) const +{ + return false; +} + +GLfloat +XamhainPreferences::minSize(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::maxSize(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::minSpeed(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::maxSpeed(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::minSpin(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::maxSpin(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::skewProbability(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::spinProbability(void) const +{ + return 0; +} + +int +XamhainPreferences::knotSubdivisions(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::horizontalKnotProbability(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::verticalKnotProbability(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::closedKnotProbability(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::circularKnotProbability(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::sectionProbability1(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::sectionProbability2(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::cornerProbability1(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::cornerProbability2(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::broadKnotProbability(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::hollowKnotProbability(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::symmetricKnotProbability(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::horizontalMirrorProbability(void) const +{ + return 0; +} + +GLfloat +XamhainPreferences::verticalMirrorProbability(void) const +{ + return 0; +}
jjk/XamhainII
6688df3e029e1c5ade86c5f63e71933f0e74d3a1
Use copyright sign in comments.
diff --git a/utility/Point.h b/utility/Point.h index a9972b0..d62f1c4 100644 --- a/utility/Point.h +++ b/utility/Point.h @@ -1,89 +1,89 @@ // Arithmetic with coordinates. BeOS rulez! // -// Copyright (c) 2001-2009 Jens Kilian +// Copyright © 2001-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #ifndef POINT_H #define POINT_H #include <cmath> #include <OpenGL/gl.h> class Point { public: GLfloat x; GLfloat y; Point(void) { // empty } Point(GLfloat x_, GLfloat y_) : x(x_), y(y_) { // empty } }; // Just the operators we'll use; no need to provide the full set. inline Point operator +(const Point &p1, const Point &p2) { return Point(p1.x + p2.x, p1.y + p2.y); } inline Point operator -(const Point &p1, const Point &p2) { return Point(p1.x - p2.x, p1.y - p2.y); } inline Point operator *(const Point &p, const GLfloat s) { return Point(p.x * s, p.y * s); } inline Point operator *(const GLfloat s, const Point &p) { return Point(p.x * s, p.y * s); } inline GLfloat operator *(const Point &p1, const Point &p2) { return p1.x * p2.x + p1.y * p2.y; } inline Point operator *(const GLfloat t[4], const Point &p) { return Point(t[0] * p.x + t[1] * p.y, t[2] * p.x + t[3] * p.y); } inline GLfloat norm(const Point &p) { return sqrt(p * p); } #endif // POINT_H diff --git a/utility/RandomColor.cpp b/utility/RandomColor.cpp index afba0e1..ca14ceb 100644 --- a/utility/RandomColor.cpp +++ b/utility/RandomColor.cpp @@ -1,81 +1,81 @@ // Select a color of random hue, within a given range of lightness, // saturation and transparency. // -// Copyright (c) 1997-2009 Jens Kilian +// Copyright © 1997-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #include "RandomColor.h" #include <OpenGL/gl.h> #include "RandomNumbers.h" // We could of course use the native OS X color management services instead. // Muahaha. Just kidding. namespace { inline GLfloat rgb(GLfloat q1, GLfloat q2, int hue) { hue = (hue + 360) % 360; if (hue < 60) { return q1 + (q2-q1) * hue / 60.0; } else if (hue < 180) { return q2; } else if (hue < 240) { return q1 + (q2-q1) * (240 - hue) / 60.0; } else { return q1; } } } RandomColor::RandomColor( GLfloat minL, GLfloat maxL, GLfloat minS, GLfloat maxS, GLfloat minT, GLfloat maxT, int hue) { if (hue < 0) { hue = randomInteger(360); } else { hue %= 360; } GLfloat lightness = minL + randomFloat() * (maxL-minL); GLfloat saturation = minS + randomFloat() * (maxS-minS); // HLS to RGB conversion. Sheer magic, don't ask me :-) GLfloat p2 = (lightness <= 0.5) ? lightness * (saturation + 1.0) : lightness + saturation - lightness*saturation; GLfloat p1 = 2.0*lightness - p2; if (saturation == 0.0) { mColor[0] = mColor[1] = mColor[2] = lightness; } else { mColor[0] = rgb(p1, p2, hue + 120); mColor[1] = rgb(p1, p2, hue); mColor[2] = rgb(p1, p2, hue - 120); } mColor[3] = minT + randomFloat() * (maxT-minT); } diff --git a/utility/RandomColor.h b/utility/RandomColor.h index b4d0c20..9921e1d 100644 --- a/utility/RandomColor.h +++ b/utility/RandomColor.h @@ -1,63 +1,63 @@ // Select a color of random hue, within a given range of lightness, // saturation and transparency. // -// Copyright (c) 1997-2009 Jens Kilian +// Copyright © 1997-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #ifndef RANDOMCOLOR_H #define RANDOMCOLOR_H #include <OpenGL/gl.h> class RandomColor { public: RandomColor(void) { // empty } RandomColor(GLfloat minL, GLfloat maxL, GLfloat minS, GLfloat maxS, GLfloat minT, GLfloat maxT, int hue = -1); RandomColor(const RandomColor &orig) { for (int i = 0; i < 4; ++i) { mColor[i] = orig.mColor[i]; } } RandomColor & operator =(const RandomColor &orig) { for (int i = 0; i < 4; ++i) { mColor[i] = orig.mColor[i]; } return *this; } operator const GLfloat *(void) const { return mColor; } private: GLfloat mColor[4]; }; #endif // RANDOMCOLOR_H diff --git a/utility/RandomNumbers.h b/utility/RandomNumbers.h index 976fe94..a3520e8 100644 --- a/utility/RandomNumbers.h +++ b/utility/RandomNumbers.h @@ -1,51 +1,51 @@ // Utility functions for calculating random numbers. // -// Copyright (c) 2000-2009 Jens Kilian +// Copyright © 2000-2009 Jens Kilian // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #ifndef RANDOMNUMBERS_H #define RANDOMNUMBERS_H #include <cstdlib> // We could use the random routines from the ScreenSaver framework, // but (1) they return values from closed intervals, and Xamhain was // written with half-open intervals in mind; and (2) the relevant // header files are written in Objective-C. // Generate a random float from [min, max). inline float randomFloat(const float min = 0.0f, const float max = 1.0f) { return min + (max - min) * ((float)random() / ((float)RAND_MAX + 1.0)); } // Generate a random double from [min, max). inline double randomDouble(const double min = 0.0, const double max = 1.0) { return min + (max - min) * ((double)random() / ((double)RAND_MAX + 1.0)); } // Generate a random integer. inline int randomInteger(const int max) { return (int)(randomDouble() * max); } #endif // RANDOMNUMBERS_H
jjk/XamhainII
76ee2b94c51ea831f3c1289909d075a5abeaf935
Port utility routines.
diff --git a/XamhainII.xcodeproj/project.pbxproj b/XamhainII.xcodeproj/project.pbxproj index 220b5cc..fe04a6c 100644 --- a/XamhainII.xcodeproj/project.pbxproj +++ b/XamhainII.xcodeproj/project.pbxproj @@ -1,614 +1,642 @@ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 45; objects = { /* Begin PBXAggregateTarget section */ 000D03D61089C45F003F010E /* XamhainII.dmg */ = { isa = PBXAggregateTarget; buildConfigurationList = 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */; buildPhases = ( 000D03D51089C45F003F010E /* ShellScript */, ); dependencies = ( 000D03DA1089C465003F010E /* PBXTargetDependency */, ); name = XamhainII.dmg; productName = XamhainII.dmg; }; /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0032D325108A30770033FA87 /* OpenGL.framework */; }; + 007C512A108A29BE00ED3242 /* Point.h in Headers */ = {isa = PBXBuildFile; fileRef = 007C5126108A29BE00ED3242 /* Point.h */; }; + 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007C5127108A29BE00ED3242 /* RandomColor.cpp */; }; + 007C512C108A29BE00ED3242 /* RandomColor.h in Headers */ = {isa = PBXBuildFile; fileRef = 007C5128108A29BE00ED3242 /* RandomColor.h */; }; + 007C512D108A29BE00ED3242 /* RandomNumbers.h in Headers */ = {isa = PBXBuildFile; fileRef = 007C5129108A29BE00ED3242 /* RandomNumbers.h */; }; 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */; }; 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */; }; 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */; }; 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */; }; 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */; }; 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */; }; 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */; }; 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */; }; 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */; }; 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */; }; 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */; }; 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */; }; 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */; }; 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */; }; 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */; }; 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */; }; 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */; }; 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */; }; 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */; }; 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */; }; 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */; }; 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */; }; 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */; }; 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */; }; 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */; }; 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */; }; 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */; }; 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */; }; 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */; }; 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */; }; 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */; }; 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */; }; 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */; }; 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */; }; 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */; }; 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */; }; 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */; }; 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */; }; 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */; }; 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */; }; 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */; }; 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */; }; 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */; }; 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */; }; 00DA7837107A73320094FCAB /* XamhainView.h in Headers */ = {isa = PBXBuildFile; fileRef = 00DA7835107A73320094FCAB /* XamhainView.h */; }; 00DA7838107A73320094FCAB /* XamhainView.m in Sources */ = {isa = PBXBuildFile; fileRef = 00DA7836107A73320094FCAB /* XamhainView.m */; }; 8D255AC70486D3F9007BF209 /* XamhainII_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */; }; 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 000D03D91089C465003F010E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 089C1669FE841209C02AAC07 /* Project object */; proxyType = 1; - remoteGlobalIDString = 8D255AC50486D3F9007BF209 /* XamhainII */; + remoteGlobalIDString = 8D255AC50486D3F9007BF209; remoteInfo = XamhainII; }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 0032D325108A30770033FA87 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; }; + 007C5126108A29BE00ED3242 /* Point.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Point.h; path = utility/Point.h; sourceTree = "<group>"; }; + 007C5127108A29BE00ED3242 /* RandomColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RandomColor.cpp; path = utility/RandomColor.cpp; sourceTree = "<group>"; }; + 007C5128108A29BE00ED3242 /* RandomColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomColor.h; path = utility/RandomColor.h; sourceTree = "<group>"; }; + 007C5129108A29BE00ED3242 /* RandomNumbers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RandomNumbers.h; path = utility/RandomNumbers.h; sourceTree = "<group>"; }; 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_corner.pdf; sourceTree = "<group>"; }; 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DDD.pdf; sourceTree = "<group>"; }; 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHD.pdf; sourceTree = "<group>"; }; 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHH.pdf; sourceTree = "<group>"; }; 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHV.pdf; sourceTree = "<group>"; }; 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDD.pdf; sourceTree = "<group>"; }; 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDH.pdf; sourceTree = "<group>"; }; 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDV.pdf; sourceTree = "<group>"; }; 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHH.pdf; sourceTree = "<group>"; }; 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHV.pdf; sourceTree = "<group>"; }; 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HVV.pdf; sourceTree = "<group>"; }; 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_corner.pdf; sourceTree = "<group>"; }; 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DDD.pdf; sourceTree = "<group>"; }; 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHD.pdf; sourceTree = "<group>"; }; 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHH.pdf; sourceTree = "<group>"; }; 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHV.pdf; sourceTree = "<group>"; }; 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDD.pdf; sourceTree = "<group>"; }; 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDH.pdf; sourceTree = "<group>"; }; 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDV.pdf; sourceTree = "<group>"; }; 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHH.pdf; sourceTree = "<group>"; }; 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHV.pdf; sourceTree = "<group>"; }; 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HVV.pdf; sourceTree = "<group>"; }; 00DA7835107A73320094FCAB /* XamhainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainView.h; path = "screen saving/XamhainView.h"; sourceTree = "<group>"; }; 00DA7836107A73320094FCAB /* XamhainView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XamhainView.m; path = "screen saving/XamhainView.m"; sourceTree = "<group>"; }; 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ScreenSaver.framework; path = /System/Library/Frameworks/ScreenSaver.framework; sourceTree = "<absolute>"; }; 089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; 089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; }; 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; }; 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XamhainII_Prefix.pch; sourceTree = "<group>"; }; 8D255AD20486D3F9007BF209 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; 8D255AD30486D3F9007BF209 /* XamhainII.saver */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XamhainII.saver; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 8D255ACD0486D3F9007BF209 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */, 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */, + 0032D326108A30770033FA87 /* OpenGL.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 007C5125108A299800ED3242 /* Utility */ = { + isa = PBXGroup; + children = ( + 007C5126108A29BE00ED3242 /* Point.h */, + 007C5127108A29BE00ED3242 /* RandomColor.cpp */, + 007C5128108A29BE00ED3242 /* RandomColor.h */, + 007C5129108A29BE00ED3242 /* RandomNumbers.h */, + ); + name = Utility; + sourceTree = "<group>"; + }; 00DA77D5107A728C0094FCAB /* Strokes */ = { isa = PBXGroup; children = ( 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */, 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */, 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */, 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */, 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */, 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */, 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */, 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */, 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */, 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */, 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */, 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */, 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */, 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */, 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */, 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */, 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */, 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */, 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */, 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */, 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */, 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */, 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */, 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */, 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */, 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */, 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */, 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */, 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */, 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */, 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */, 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */, 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */, 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */, 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */, 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */, 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */, 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */, 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */, 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */, 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */, 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */, 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */, 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */, ); name = Strokes; path = strokes; sourceTree = "<group>"; }; 00DA7833107A72F00094FCAB /* Screen Saving */ = { isa = PBXGroup; children = ( 00DA7835107A73320094FCAB /* XamhainView.h */, 00DA7836107A73320094FCAB /* XamhainView.m */, ); name = "Screen Saving"; sourceTree = "<group>"; }; 089C166AFE841209C02AAC07 /* XamhainII */ = { isa = PBXGroup; children = ( 00DA7833107A72F00094FCAB /* Screen Saving */, + 007C5125108A299800ED3242 /* Utility */, 32DBCFA70370C4F300C91783 /* Other Sources */, 089C167CFE841241C02AAC07 /* Resources */, 089C1671FE841209C02AAC07 /* Frameworks and Libraries */, 19C28FB8FE9D52D311CA2CBB /* Products */, ); name = XamhainII; sourceTree = "<group>"; }; 089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = { isa = PBXGroup; children = ( 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */, 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */, ); name = "Frameworks and Libraries"; sourceTree = "<group>"; }; 089C167CFE841241C02AAC07 /* Resources */ = { isa = PBXGroup; children = ( 00DA77D5107A728C0094FCAB /* Strokes */, 8D255AD20486D3F9007BF209 /* Info.plist */, 089C167DFE841241C02AAC07 /* InfoPlist.strings */, ); name = Resources; sourceTree = "<group>"; }; 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = { isa = PBXGroup; children = ( 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, + 0032D325108A30770033FA87 /* OpenGL.framework */, 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */, ); name = "Linked Frameworks"; sourceTree = "<group>"; }; 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = { isa = PBXGroup; children = ( 089C1672FE841209C02AAC07 /* Foundation.framework */, 089C167FFE841241C02AAC07 /* AppKit.framework */, ); name = "Other Frameworks"; sourceTree = "<group>"; }; 19C28FB8FE9D52D311CA2CBB /* Products */ = { isa = PBXGroup; children = ( 8D255AD30486D3F9007BF209 /* XamhainII.saver */, ); name = Products; sourceTree = "<group>"; }; 32DBCFA70370C4F300C91783 /* Other Sources */ = { isa = PBXGroup; children = ( 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */, ); name = "Other Sources"; sourceTree = "<group>"; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ 8D255AC60486D3F9007BF209 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 8D255AC70486D3F9007BF209 /* XamhainII_Prefix.pch in Headers */, 00DA7837107A73320094FCAB /* XamhainView.h in Headers */, + 007C512A108A29BE00ED3242 /* Point.h in Headers */, + 007C512C108A29BE00ED3242 /* RandomColor.h in Headers */, + 007C512D108A29BE00ED3242 /* RandomNumbers.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ 8D255AC50486D3F9007BF209 /* XamhainII */ = { isa = PBXNativeTarget; buildConfigurationList = EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */; buildPhases = ( 8D255AC60486D3F9007BF209 /* Headers */, 8D255AC90486D3F9007BF209 /* Resources */, 8D255ACB0486D3F9007BF209 /* Sources */, 8D255ACD0486D3F9007BF209 /* Frameworks */, 8D255AD00486D3F9007BF209 /* Rez */, ); buildRules = ( ); dependencies = ( ); name = XamhainII; productInstallPath = "$(HOME)/Library/Screen Savers"; productName = XamhainII; productReference = 8D255AD30486D3F9007BF209 /* XamhainII.saver */; productType = "com.apple.product-type.bundle"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 089C1669FE841209C02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */; compatibilityVersion = "Xcode 3.1"; hasScannedForEncodings = 1; mainGroup = 089C166AFE841209C02AAC07 /* XamhainII */; projectDirPath = ""; projectRoot = ""; targets = ( 8D255AC50486D3F9007BF209 /* XamhainII */, 000D03D61089C45F003F010E /* XamhainII.dmg */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ 8D255AC90486D3F9007BF209 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */, 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */, 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */, 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */, 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */, 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */, 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */, 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */, 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */, 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */, 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */, 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */, 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */, 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */, 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */, 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */, 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */, 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */, 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */, 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */, 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */, 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */, 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */, 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */, 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */, 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */, 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */, 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */, 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */, 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */, 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */, 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */, 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */, 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */, 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */, 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */, 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */, 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */, 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */, 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */, 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */, 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */, 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */, 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */, 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXRezBuildPhase section */ 8D255AD00486D3F9007BF209 /* Rez */ = { isa = PBXRezBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXRezBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ 000D03D51089C45F003F010E /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.saver", ); outputPaths = ( "$(BUILT_PRODUCTS_DIR)/XamhainII.dmg", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "# Thanks to Rob Mayoff for explaining how to do this.\n# See http://qwan.org/2007/05/22/using-xcode-to-build-a-disk-image-and-upload-a-web-site/\n\nset -ex\n\n[ \"$ACTION\" = build ] || exit 0\n[ \"$BUILD_VARIANTS\" = \"normal\" ] || exit 0\n\ndir=\"$TEMP_FILES_DIR/disk\"\ndmg=\"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.dmg\"\n\nrm -rf \"$dir\"\nmkdir \"$dir\"\ncp -R \"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.saver\" \"$dir\"\nrm -f \"$dmg\"\nhdiutil create -srcfolder \"$dir\" -volname \"$PROJECT_NAME\" \"$dmg\"\nhdiutil internet-enable -yes \"$dmg\"\nrm -rf \"$dir\"\n"; }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 8D255ACB0486D3F9007BF209 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 00DA7838107A73320094FCAB /* XamhainView.m in Sources */, + 007C512B108A29BE00ED3242 /* RandomColor.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 000D03DA1089C465003F010E /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 8D255AC50486D3F9007BF209 /* XamhainII */; targetProxy = 000D03D91089C465003F010E /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ 089C167DFE841241C02AAC07 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 089C167EFE841241C02AAC07 /* English */, ); name = InfoPlist.strings; sourceTree = "<group>"; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 000D03D71089C45F003F010E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; PRODUCT_NAME = XamhainII.dmg; }; name = Debug; }; 000D03D81089C45F003F010E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = XamhainII.dmg; ZERO_LINK = NO; }; name = Release; }; EF7AD72E08BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_STRICT_ALIASING = NO; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = NO; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; ZERO_LINK = YES; }; name = Debug; }; EF7AD72F08BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_OBJC_GC = required; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XamhainII_Prefix.pch; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = YES; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VALUE = YES; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; PRODUCT_NAME = XamhainII; WRAPPER_EXTENSION = saver; }; name = Release; }; EF7AD73208BB986600CE4634 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = NO; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Debug; }; EF7AD73308BB986600CE4634 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; SDKROOT = macosx10.6; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */ = { isa = XCConfigurationList; buildConfigurations = ( 000D03D71089C45F003F010E /* Debug */, 000D03D81089C45F003F010E /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD72E08BB986600CE4634 /* Debug */, EF7AD72F08BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */ = { isa = XCConfigurationList; buildConfigurations = ( EF7AD73208BB986600CE4634 /* Debug */, EF7AD73308BB986600CE4634 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 089C1669FE841209C02AAC07 /* Project object */; } diff --git a/XamhainII_Prefix.pch b/XamhainII_Prefix.pch index 0137bad..e00384f 100644 --- a/XamhainII_Prefix.pch +++ b/XamhainII_Prefix.pch @@ -1,24 +1,26 @@ // Prefix header for all source files of the 'XamhainII' target // in the 'XamhainII' project. // // Copyright © 2009, Jens Kilian. // // This file is part of XamhainII. // // XamhainII is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // XamhainII 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with XamhainII. If not, see <http://www.gnu.org/licenses/>. #ifdef __OBJC__ #import <Foundation/Foundation.h> #import <AppKit/AppKit.h> #endif + +#include <OpenGL/gl.h> diff --git a/utility/Point.h b/utility/Point.h new file mode 100644 index 0000000..a9972b0 --- /dev/null +++ b/utility/Point.h @@ -0,0 +1,89 @@ +// Arithmetic with coordinates. BeOS rulez! +// +// Copyright (c) 2001-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#ifndef POINT_H +#define POINT_H + +#include <cmath> + +#include <OpenGL/gl.h> + +class Point +{ +public: + GLfloat x; + GLfloat y; + + Point(void) + { + // empty + } + + Point(GLfloat x_, GLfloat y_) + : x(x_), y(y_) + { + // empty + } +}; + +// Just the operators we'll use; no need to provide the full set. +inline Point +operator +(const Point &p1, const Point &p2) +{ + return Point(p1.x + p2.x, p1.y + p2.y); +} + +inline Point +operator -(const Point &p1, const Point &p2) +{ + return Point(p1.x - p2.x, p1.y - p2.y); +} + +inline Point +operator *(const Point &p, const GLfloat s) +{ + return Point(p.x * s, p.y * s); +} + +inline Point +operator *(const GLfloat s, const Point &p) +{ + return Point(p.x * s, p.y * s); +} + +inline GLfloat +operator *(const Point &p1, const Point &p2) +{ + return p1.x * p2.x + p1.y * p2.y; +} + +inline Point +operator *(const GLfloat t[4], const Point &p) +{ + return Point(t[0] * p.x + t[1] * p.y, + t[2] * p.x + t[3] * p.y); +} + +inline GLfloat +norm(const Point &p) +{ + return sqrt(p * p); +} + +#endif // POINT_H diff --git a/utility/RandomColor.cpp b/utility/RandomColor.cpp new file mode 100644 index 0000000..afba0e1 --- /dev/null +++ b/utility/RandomColor.cpp @@ -0,0 +1,81 @@ +// Select a color of random hue, within a given range of lightness, +// saturation and transparency. +// +// Copyright (c) 1997-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#include "RandomColor.h" + +#include <OpenGL/gl.h> + +#include "RandomNumbers.h" + +// We could of course use the native OS X color management services instead. +// Muahaha. Just kidding. + +namespace +{ + inline GLfloat + rgb(GLfloat q1, GLfloat q2, int hue) + { + hue = (hue + 360) % 360; + if (hue < 60) { + return q1 + (q2-q1) * hue / 60.0; + + } else if (hue < 180) { + return q2; + + } else if (hue < 240) { + return q1 + (q2-q1) * (240 - hue) / 60.0; + + } else { + return q1; + } + } +} + +RandomColor::RandomColor( + GLfloat minL, GLfloat maxL, + GLfloat minS, GLfloat maxS, + GLfloat minT, GLfloat maxT, + int hue) +{ + if (hue < 0) { + hue = randomInteger(360); + } else { + hue %= 360; + } + + GLfloat lightness = minL + randomFloat() * (maxL-minL); + GLfloat saturation = minS + randomFloat() * (maxS-minS); + + // HLS to RGB conversion. Sheer magic, don't ask me :-) + GLfloat p2 = (lightness <= 0.5) + ? lightness * (saturation + 1.0) + : lightness + saturation - lightness*saturation; + GLfloat p1 = 2.0*lightness - p2; + + if (saturation == 0.0) { + mColor[0] = mColor[1] = mColor[2] = lightness; + } else { + mColor[0] = rgb(p1, p2, hue + 120); + mColor[1] = rgb(p1, p2, hue); + mColor[2] = rgb(p1, p2, hue - 120); + } + + mColor[3] = minT + randomFloat() * (maxT-minT); +} diff --git a/utility/RandomColor.h b/utility/RandomColor.h new file mode 100644 index 0000000..b4d0c20 --- /dev/null +++ b/utility/RandomColor.h @@ -0,0 +1,63 @@ +// Select a color of random hue, within a given range of lightness, +// saturation and transparency. +// +// Copyright (c) 1997-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#ifndef RANDOMCOLOR_H +#define RANDOMCOLOR_H + +#include <OpenGL/gl.h> + +class RandomColor { +public: + RandomColor(void) + { + // empty + } + + RandomColor(GLfloat minL, GLfloat maxL, + GLfloat minS, GLfloat maxS, + GLfloat minT, GLfloat maxT, + int hue = -1); + + RandomColor(const RandomColor &orig) + { + for (int i = 0; i < 4; ++i) { + mColor[i] = orig.mColor[i]; + } + } + + RandomColor & + operator =(const RandomColor &orig) + { + for (int i = 0; i < 4; ++i) { + mColor[i] = orig.mColor[i]; + } + return *this; + } + + operator const GLfloat *(void) const + { + return mColor; + } + +private: + GLfloat mColor[4]; +}; + +#endif // RANDOMCOLOR_H diff --git a/utility/RandomNumbers.h b/utility/RandomNumbers.h new file mode 100644 index 0000000..976fe94 --- /dev/null +++ b/utility/RandomNumbers.h @@ -0,0 +1,51 @@ +// Utility functions for calculating random numbers. +// +// Copyright (c) 2000-2009 Jens Kilian +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#ifndef RANDOMNUMBERS_H +#define RANDOMNUMBERS_H + +#include <cstdlib> + +// We could use the random routines from the ScreenSaver framework, +// but (1) they return values from closed intervals, and Xamhain was +// written with half-open intervals in mind; and (2) the relevant +// header files are written in Objective-C. + +// Generate a random float from [min, max). +inline float +randomFloat(const float min = 0.0f, const float max = 1.0f) +{ + return min + (max - min) * ((float)random() / ((float)RAND_MAX + 1.0)); +} + +// Generate a random double from [min, max). +inline double +randomDouble(const double min = 0.0, const double max = 1.0) +{ + return min + (max - min) * ((double)random() / ((double)RAND_MAX + 1.0)); +} + +// Generate a random integer. +inline int +randomInteger(const int max) +{ + return (int)(randomDouble() * max); +} + +#endif // RANDOMNUMBERS_H
jjk/XamhainII
23c629b8adf503eaf6461d3def5ae43d2c931166
Basic screen saver and resources.
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9204398 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Files to ignore +# +build diff --git a/English.lproj/InfoPlist.strings b/English.lproj/InfoPlist.strings new file mode 100644 index 0000000..d247954 Binary files /dev/null and b/English.lproj/InfoPlist.strings differ diff --git a/Info.plist b/Info.plist new file mode 100644 index 0000000..2888dc2 --- /dev/null +++ b/Info.plist @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleExecutable</key> + <string>${EXECUTABLE_NAME}</string> + <key>CFBundleIconFile</key> + <string></string> + <key>CFBundleIdentifier</key> + <string>de.earrame.${PRODUCT_NAME:identifier}</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>${PRODUCT_NAME}</string> + <key>CFBundlePackageType</key> + <string>BNDL</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1.0</string> + <key>NSPrincipalClass</key> + <string>XamhainView</string> +</dict> +</plist> diff --git a/XamhainII.xcodeproj/default.pbxuser b/XamhainII.xcodeproj/default.pbxuser new file mode 100644 index 0000000..72122b6 --- /dev/null +++ b/XamhainII.xcodeproj/default.pbxuser @@ -0,0 +1,286 @@ +// !$*UTF8*$! +{ + 00758B321089BA5B009D6C40 /* PBXBookmark */ = { + isa = PBXBookmark; + fRef = 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */; + }; + 00758B331089BA5B009D6C40 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 089C167EFE841241C02AAC07 /* English */; + name = "InfoPlist.strings: 17"; + rLen = 0; + rLoc = 717; + rType = 0; + vrLen = 717; + vrLoc = 0; + }; + 00758B341089BA5B009D6C40 /* PlistBookmark */ = { + isa = PlistBookmark; + fRef = 8D255AD20486D3F9007BF209 /* Info.plist */; + fallbackIsa = PBXBookmark; + isK = 0; + kPath = ( + ); + name = /Users/jjk/Projects/XamhainII/Info.plist; + rLen = 0; + rLoc = 9223372036854775808; + }; + 00758B351089BA5B009D6C40 /* PBXBookmark */ = { + isa = PBXBookmark; + fRef = 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */; + }; + 00758B361089BA5B009D6C40 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 00DA7836107A73320094FCAB /* XamhainView.m */; + name = "XamhainView.m: 3"; + rLen = 0; + rLoc = 36; + rType = 0; + vrLen = 1002; + vrLoc = 0; + }; + 00758B371089BA5B009D6C40 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 00DA7835107A73320094FCAB /* XamhainView.h */; + name = "XamhainView.h: 3"; + rLen = 0; + rLoc = 36; + rType = 0; + vrLen = 866; + vrLoc = 0; + }; + 007A96301089B7BD00036720 /* PBXBookmark */ = { + isa = PBXBookmark; + fRef = 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */; + }; + 007A96311089B7BD00036720 /* PBXBookmark */ = { + isa = PBXBookmark; + fRef = 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */; + }; + 007A96351089B7BD00036720 /* PBXBookmark */ = { + isa = PBXBookmark; + fRef = 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */; + }; + 007A96361089B7BD00036720 /* PBXBookmark */ = { + isa = PBXBookmark; + fRef = 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */; + }; + 007A96371089B7BD00036720 /* PBXBookmark */ = { + isa = PBXBookmark; + fRef = 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */; + }; + 007A96381089B7BD00036720 /* PBXBookmark */ = { + isa = PBXBookmark; + fRef = 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */; + }; + 00AE8D621078F42800BF666F /* Source Control */ = { + isa = PBXSourceControlManager; + fallbackIsa = XCSourceControlManager; + isSCMEnabled = 0; + scmConfiguration = { + repositoryNamesForRoots = { + "" = ""; + }; + }; + }; + 00AE8D631078F42800BF666F /* Code sense */ = { + isa = PBXCodeSenseManager; + indexTemplatePath = ""; + }; + 00BBD5D21089BAAE003EFE03 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */; + name = "XamhainII_Prefix.pch: 11"; + rLen = 0; + rLoc = 421; + rType = 0; + vrLen = 914; + vrLoc = 0; + }; + 00D71816107E721600314C48 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 00D71817107E721600314C48 /* Point.h */; + name = "Point.h: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 957; + vrLoc = 0; + }; + 00D71817107E721600314C48 /* Point.h */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = Point.h; + path = "/Users/jjk/Projects/xscreensaver-5.10/hacks/XamhainII/Point.h"; + sourceTree = "<absolute>"; + }; + 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 263}, {1142, 610}}"; + }; + }; + 00DA7835107A73320094FCAB /* XamhainView.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {856, 377}}"; + sepNavSelRange = "{36, 0}"; + sepNavVisRange = "{0, 866}"; + }; + }; + 00DA7836107A73320094FCAB /* XamhainView.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {856, 858}}"; + sepNavSelRange = "{36, 0}"; + sepNavVisRange = "{0, 1002}"; + sepNavWindowFrame = "{{15, 263}, {1142, 610}}"; + }; + }; + 00DA788E107A76F50094FCAB /* PBXBookmark */ = { + isa = PBXBookmark; + fRef = 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */; + }; + 00DA788F107A76F50094FCAB /* PBXBookmark */ = { + isa = PBXBookmark; + fRef = 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */; + }; + 00DA7890107A76F50094FCAB /* PBXBookmark */ = { + isa = PBXBookmark; + fRef = 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */; + }; + 00EE9EEC1089BBA7003D3992 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */; + name = "XamhainII_Prefix.pch: 11"; + rLen = 0; + rLoc = 421; + rType = 0; + vrLen = 914; + vrLoc = 0; + }; + 089C1669FE841209C02AAC07 /* Project object */ = { + activeBuildConfigurationName = Debug; + activeTarget = 8D255AC50486D3F9007BF209 /* XamhainII */; + addToTargets = ( + 8D255AC50486D3F9007BF209 /* XamhainII */, + ); + codeSenseManager = 00AE8D631078F42800BF666F /* Code sense */; + perUserDictionary = { + PBXConfiguration.PBXFileTableDataSource3.PBXBookmarksDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXBookmarksDataSource_NameID; + PBXFileTableDataSourceColumnWidthsKey = ( + 200, + 200, + 488, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXBookmarksDataSource_LocationID, + PBXBookmarksDataSource_NameID, + PBXBookmarksDataSource_CommentsID, + ); + }; + PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, + 678, + 20, + 48, + 43, + 43, + 20, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXFileDataSource_FiletypeID, + PBXFileDataSource_Filename_ColumnID, + PBXFileDataSource_Built_ColumnID, + PBXFileDataSource_ObjectSize_ColumnID, + PBXFileDataSource_Errors_ColumnID, + PBXFileDataSource_Warnings_ColumnID, + PBXFileDataSource_Target_ColumnID, + ); + }; + PBXConfiguration.PBXFileTableDataSource3.PBXFindDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXFindDataSource_LocationID; + PBXFileTableDataSourceColumnWidthsKey = ( + 200, + 692, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXFindDataSource_MessageID, + PBXFindDataSource_LocationID, + ); + }; + PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, + 638, + 60, + 20, + 48, + 43, + 43, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXFileDataSource_FiletypeID, + PBXFileDataSource_Filename_ColumnID, + PBXTargetDataSource_PrimaryAttribute, + PBXFileDataSource_Built_ColumnID, + PBXFileDataSource_ObjectSize_ColumnID, + PBXFileDataSource_Errors_ColumnID, + PBXFileDataSource_Warnings_ColumnID, + ); + }; + PBXPerProjectTemplateStateSaveDate = 277461771; + PBXWorkspaceStateSaveDate = 277461771; + }; + perUserProjectItems = { + 00758B321089BA5B009D6C40 /* PBXBookmark */ = 00758B321089BA5B009D6C40 /* PBXBookmark */; + 00758B331089BA5B009D6C40 /* PBXTextBookmark */ = 00758B331089BA5B009D6C40 /* PBXTextBookmark */; + 00758B341089BA5B009D6C40 /* PlistBookmark */ = 00758B341089BA5B009D6C40 /* PlistBookmark */; + 00758B351089BA5B009D6C40 /* PBXBookmark */ = 00758B351089BA5B009D6C40 /* PBXBookmark */; + 00758B361089BA5B009D6C40 /* PBXTextBookmark */ = 00758B361089BA5B009D6C40 /* PBXTextBookmark */; + 00758B371089BA5B009D6C40 /* PBXTextBookmark */ = 00758B371089BA5B009D6C40 /* PBXTextBookmark */; + 007A96301089B7BD00036720 /* PBXBookmark */ = 007A96301089B7BD00036720 /* PBXBookmark */; + 007A96311089B7BD00036720 /* PBXBookmark */ = 007A96311089B7BD00036720 /* PBXBookmark */; + 007A96351089B7BD00036720 /* PBXBookmark */ = 007A96351089B7BD00036720 /* PBXBookmark */; + 007A96361089B7BD00036720 /* PBXBookmark */ = 007A96361089B7BD00036720 /* PBXBookmark */; + 007A96371089B7BD00036720 /* PBXBookmark */ = 007A96371089B7BD00036720 /* PBXBookmark */; + 007A96381089B7BD00036720 /* PBXBookmark */ = 007A96381089B7BD00036720 /* PBXBookmark */; + 00BBD5D21089BAAE003EFE03 /* PBXTextBookmark */ = 00BBD5D21089BAAE003EFE03 /* PBXTextBookmark */; + 00D71816107E721600314C48 /* PBXTextBookmark */ = 00D71816107E721600314C48 /* PBXTextBookmark */; + 00DA788E107A76F50094FCAB /* PBXBookmark */ = 00DA788E107A76F50094FCAB /* PBXBookmark */; + 00DA788F107A76F50094FCAB /* PBXBookmark */ = 00DA788F107A76F50094FCAB /* PBXBookmark */; + 00DA7890107A76F50094FCAB /* PBXBookmark */ = 00DA7890107A76F50094FCAB /* PBXBookmark */; + 00EE9EEC1089BBA7003D3992 /* PBXTextBookmark */ = 00EE9EEC1089BBA7003D3992 /* PBXTextBookmark */; + }; + sourceControlManager = 00AE8D621078F42800BF666F /* Source Control */; + userBuildSettings = { + }; + }; + 089C167EFE841241C02AAC07 /* English */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {856, 377}}"; + sepNavSelRange = "{717, 0}"; + sepNavVisRange = "{0, 717}"; + }; + }; + 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {856, 361}}"; + sepNavSelRange = "{421, 0}"; + sepNavVisRange = "{0, 914}"; + }; + }; + 8D255AC50486D3F9007BF209 /* XamhainII */ = { + activeExec = 0; + }; + 8D255AD20486D3F9007BF209 /* Info.plist */ = { + uiCtxt = { + sepNavWindowFrame = "{{28, 265}, {750, 558}}"; + }; + }; +} diff --git a/XamhainII.xcodeproj/project.pbxproj b/XamhainII.xcodeproj/project.pbxproj new file mode 100644 index 0000000..220b5cc --- /dev/null +++ b/XamhainII.xcodeproj/project.pbxproj @@ -0,0 +1,614 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 45; + objects = { + +/* Begin PBXAggregateTarget section */ + 000D03D61089C45F003F010E /* XamhainII.dmg */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */; + buildPhases = ( + 000D03D51089C45F003F010E /* ShellScript */, + ); + dependencies = ( + 000D03DA1089C465003F010E /* PBXTargetDependency */, + ); + name = XamhainII.dmg; + productName = XamhainII.dmg; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */; }; + 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */; }; + 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */; }; + 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */; }; + 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */; }; + 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */; }; + 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */; }; + 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */; }; + 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */; }; + 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */; }; + 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */; }; + 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */; }; + 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */; }; + 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */; }; + 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */; }; + 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */; }; + 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */; }; + 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */; }; + 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */; }; + 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */; }; + 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */; }; + 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */; }; + 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */; }; + 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */; }; + 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */; }; + 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */; }; + 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */; }; + 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */; }; + 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */; }; + 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */; }; + 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */; }; + 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */; }; + 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */; }; + 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */; }; + 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */; }; + 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */; }; + 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */; }; + 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */; }; + 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */; }; + 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */; }; + 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */; }; + 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */; }; + 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */; }; + 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */; }; + 00DA7837107A73320094FCAB /* XamhainView.h in Headers */ = {isa = PBXBuildFile; fileRef = 00DA7835107A73320094FCAB /* XamhainView.h */; }; + 00DA7838107A73320094FCAB /* XamhainView.m in Sources */ = {isa = PBXBuildFile; fileRef = 00DA7836107A73320094FCAB /* XamhainView.m */; }; + 8D255AC70486D3F9007BF209 /* XamhainII_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */; }; + 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; + 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; + 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 000D03D91089C465003F010E /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 089C1669FE841209C02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 8D255AC50486D3F9007BF209 /* XamhainII */; + remoteInfo = XamhainII; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_corner.pdf; sourceTree = "<group>"; }; + 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DDD.pdf; sourceTree = "<group>"; }; + 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHD.pdf; sourceTree = "<group>"; }; + 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHH.pdf; sourceTree = "<group>"; }; + 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_DHV.pdf; sourceTree = "<group>"; }; + 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDD.pdf; sourceTree = "<group>"; }; + 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDH.pdf; sourceTree = "<group>"; }; + 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HDV.pdf; sourceTree = "<group>"; }; + 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHH.pdf; sourceTree = "<group>"; }; + 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HHV.pdf; sourceTree = "<group>"; }; + 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_fill_HVV.pdf; sourceTree = "<group>"; }; + 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_corner.pdf; sourceTree = "<group>"; }; + 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DDD.pdf; sourceTree = "<group>"; }; + 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHD.pdf; sourceTree = "<group>"; }; + 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHH.pdf; sourceTree = "<group>"; }; + 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_DHV.pdf; sourceTree = "<group>"; }; + 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDD.pdf; sourceTree = "<group>"; }; + 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDH.pdf; sourceTree = "<group>"; }; + 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HDV.pdf; sourceTree = "<group>"; }; + 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHH.pdf; sourceTree = "<group>"; }; + 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HHV.pdf; sourceTree = "<group>"; }; + 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = broad_outline_HVV.pdf; sourceTree = "<group>"; }; + 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_corner.pdf; sourceTree = "<group>"; }; + 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DDD.pdf; sourceTree = "<group>"; }; + 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHD.pdf; sourceTree = "<group>"; }; + 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHH.pdf; sourceTree = "<group>"; }; + 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_DHV.pdf; sourceTree = "<group>"; }; + 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDD.pdf; sourceTree = "<group>"; }; + 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDH.pdf; sourceTree = "<group>"; }; + 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HDV.pdf; sourceTree = "<group>"; }; + 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHH.pdf; sourceTree = "<group>"; }; + 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HHV.pdf; sourceTree = "<group>"; }; + 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_fill_HVV.pdf; sourceTree = "<group>"; }; + 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_corner.pdf; sourceTree = "<group>"; }; + 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DDD.pdf; sourceTree = "<group>"; }; + 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHD.pdf; sourceTree = "<group>"; }; + 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHH.pdf; sourceTree = "<group>"; }; + 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_DHV.pdf; sourceTree = "<group>"; }; + 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDD.pdf; sourceTree = "<group>"; }; + 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDH.pdf; sourceTree = "<group>"; }; + 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HDV.pdf; sourceTree = "<group>"; }; + 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHH.pdf; sourceTree = "<group>"; }; + 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HHV.pdf; sourceTree = "<group>"; }; + 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = slender_outline_HVV.pdf; sourceTree = "<group>"; }; + 00DA7835107A73320094FCAB /* XamhainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XamhainView.h; path = "screen saving/XamhainView.h"; sourceTree = "<group>"; }; + 00DA7836107A73320094FCAB /* XamhainView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XamhainView.m; path = "screen saving/XamhainView.m"; sourceTree = "<group>"; }; + 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ScreenSaver.framework; path = /System/Library/Frameworks/ScreenSaver.framework; sourceTree = "<absolute>"; }; + 089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; + 089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; + 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; }; + 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; }; + 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XamhainII_Prefix.pch; sourceTree = "<group>"; }; + 8D255AD20486D3F9007BF209 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; + 8D255AD30486D3F9007BF209 /* XamhainII.saver */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XamhainII.saver; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8D255ACD0486D3F9007BF209 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D255ACE0486D3F9007BF209 /* Cocoa.framework in Frameworks */, + 8D255ACF0486D3F9007BF209 /* ScreenSaver.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 00DA77D5107A728C0094FCAB /* Strokes */ = { + isa = PBXGroup; + children = ( + 00DA77D6107A728C0094FCAB /* broad_fill_corner.pdf */, + 00DA77D7107A728C0094FCAB /* broad_fill_DDD.pdf */, + 00DA77D8107A728C0094FCAB /* broad_fill_DHD.pdf */, + 00DA77D9107A728C0094FCAB /* broad_fill_DHH.pdf */, + 00DA77DA107A728C0094FCAB /* broad_fill_DHV.pdf */, + 00DA77DB107A728C0094FCAB /* broad_fill_HDD.pdf */, + 00DA77DC107A728C0094FCAB /* broad_fill_HDH.pdf */, + 00DA77DD107A728C0094FCAB /* broad_fill_HDV.pdf */, + 00DA77DE107A728C0094FCAB /* broad_fill_HHH.pdf */, + 00DA77DF107A728C0094FCAB /* broad_fill_HHV.pdf */, + 00DA77E0107A728C0094FCAB /* broad_fill_HVV.pdf */, + 00DA77E1107A728C0094FCAB /* broad_outline_corner.pdf */, + 00DA77E2107A728C0094FCAB /* broad_outline_DDD.pdf */, + 00DA77E3107A728C0094FCAB /* broad_outline_DHD.pdf */, + 00DA77E4107A728C0094FCAB /* broad_outline_DHH.pdf */, + 00DA77E5107A728C0094FCAB /* broad_outline_DHV.pdf */, + 00DA77E6107A728C0094FCAB /* broad_outline_HDD.pdf */, + 00DA77E7107A728C0094FCAB /* broad_outline_HDH.pdf */, + 00DA77E8107A728C0094FCAB /* broad_outline_HDV.pdf */, + 00DA77E9107A728C0094FCAB /* broad_outline_HHH.pdf */, + 00DA77EA107A728C0094FCAB /* broad_outline_HHV.pdf */, + 00DA77EB107A728C0094FCAB /* broad_outline_HVV.pdf */, + 00DA77EC107A728C0094FCAB /* slender_fill_corner.pdf */, + 00DA77ED107A728C0094FCAB /* slender_fill_DDD.pdf */, + 00DA77EE107A728C0094FCAB /* slender_fill_DHD.pdf */, + 00DA77EF107A728C0094FCAB /* slender_fill_DHH.pdf */, + 00DA77F0107A728C0094FCAB /* slender_fill_DHV.pdf */, + 00DA77F1107A728C0094FCAB /* slender_fill_HDD.pdf */, + 00DA77F2107A728C0094FCAB /* slender_fill_HDH.pdf */, + 00DA77F3107A728C0094FCAB /* slender_fill_HDV.pdf */, + 00DA77F4107A728C0094FCAB /* slender_fill_HHH.pdf */, + 00DA77F5107A728C0094FCAB /* slender_fill_HHV.pdf */, + 00DA77F6107A728C0094FCAB /* slender_fill_HVV.pdf */, + 00DA77F7107A728C0094FCAB /* slender_outline_corner.pdf */, + 00DA77F8107A728C0094FCAB /* slender_outline_DDD.pdf */, + 00DA77F9107A728C0094FCAB /* slender_outline_DHD.pdf */, + 00DA77FA107A728C0094FCAB /* slender_outline_DHH.pdf */, + 00DA77FB107A728C0094FCAB /* slender_outline_DHV.pdf */, + 00DA77FC107A728C0094FCAB /* slender_outline_HDD.pdf */, + 00DA77FD107A728C0094FCAB /* slender_outline_HDH.pdf */, + 00DA77FE107A728C0094FCAB /* slender_outline_HDV.pdf */, + 00DA77FF107A728C0094FCAB /* slender_outline_HHH.pdf */, + 00DA7800107A728C0094FCAB /* slender_outline_HHV.pdf */, + 00DA7801107A728C0094FCAB /* slender_outline_HVV.pdf */, + ); + name = Strokes; + path = strokes; + sourceTree = "<group>"; + }; + 00DA7833107A72F00094FCAB /* Screen Saving */ = { + isa = PBXGroup; + children = ( + 00DA7835107A73320094FCAB /* XamhainView.h */, + 00DA7836107A73320094FCAB /* XamhainView.m */, + ); + name = "Screen Saving"; + sourceTree = "<group>"; + }; + 089C166AFE841209C02AAC07 /* XamhainII */ = { + isa = PBXGroup; + children = ( + 00DA7833107A72F00094FCAB /* Screen Saving */, + 32DBCFA70370C4F300C91783 /* Other Sources */, + 089C167CFE841241C02AAC07 /* Resources */, + 089C1671FE841209C02AAC07 /* Frameworks and Libraries */, + 19C28FB8FE9D52D311CA2CBB /* Products */, + ); + name = XamhainII; + sourceTree = "<group>"; + }; + 089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = { + isa = PBXGroup; + children = ( + 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */, + 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */, + ); + name = "Frameworks and Libraries"; + sourceTree = "<group>"; + }; + 089C167CFE841241C02AAC07 /* Resources */ = { + isa = PBXGroup; + children = ( + 00DA77D5107A728C0094FCAB /* Strokes */, + 8D255AD20486D3F9007BF209 /* Info.plist */, + 089C167DFE841241C02AAC07 /* InfoPlist.strings */, + ); + name = Resources; + sourceTree = "<group>"; + }; + 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = { + isa = PBXGroup; + children = ( + 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, + 06F27B2DFFEEEFEF11CA0E56 /* ScreenSaver.framework */, + ); + name = "Linked Frameworks"; + sourceTree = "<group>"; + }; + 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = { + isa = PBXGroup; + children = ( + 089C1672FE841209C02AAC07 /* Foundation.framework */, + 089C167FFE841241C02AAC07 /* AppKit.framework */, + ); + name = "Other Frameworks"; + sourceTree = "<group>"; + }; + 19C28FB8FE9D52D311CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 8D255AD30486D3F9007BF209 /* XamhainII.saver */, + ); + name = Products; + sourceTree = "<group>"; + }; + 32DBCFA70370C4F300C91783 /* Other Sources */ = { + isa = PBXGroup; + children = ( + 32DBCFA80370C50100C91783 /* XamhainII_Prefix.pch */, + ); + name = "Other Sources"; + sourceTree = "<group>"; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 8D255AC60486D3F9007BF209 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D255AC70486D3F9007BF209 /* XamhainII_Prefix.pch in Headers */, + 00DA7837107A73320094FCAB /* XamhainView.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 8D255AC50486D3F9007BF209 /* XamhainII */ = { + isa = PBXNativeTarget; + buildConfigurationList = EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */; + buildPhases = ( + 8D255AC60486D3F9007BF209 /* Headers */, + 8D255AC90486D3F9007BF209 /* Resources */, + 8D255ACB0486D3F9007BF209 /* Sources */, + 8D255ACD0486D3F9007BF209 /* Frameworks */, + 8D255AD00486D3F9007BF209 /* Rez */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = XamhainII; + productInstallPath = "$(HOME)/Library/Screen Savers"; + productName = XamhainII; + productReference = 8D255AD30486D3F9007BF209 /* XamhainII.saver */; + productType = "com.apple.product-type.bundle"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 089C1669FE841209C02AAC07 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */; + compatibilityVersion = "Xcode 3.1"; + hasScannedForEncodings = 1; + mainGroup = 089C166AFE841209C02AAC07 /* XamhainII */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8D255AC50486D3F9007BF209 /* XamhainII */, + 000D03D61089C45F003F010E /* XamhainII.dmg */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8D255AC90486D3F9007BF209 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D255ACA0486D3F9007BF209 /* InfoPlist.strings in Resources */, + 00DA7802107A728C0094FCAB /* broad_fill_corner.pdf in Resources */, + 00DA7803107A728C0094FCAB /* broad_fill_DDD.pdf in Resources */, + 00DA7804107A728C0094FCAB /* broad_fill_DHD.pdf in Resources */, + 00DA7805107A728C0094FCAB /* broad_fill_DHH.pdf in Resources */, + 00DA7806107A728C0094FCAB /* broad_fill_DHV.pdf in Resources */, + 00DA7807107A728C0094FCAB /* broad_fill_HDD.pdf in Resources */, + 00DA7808107A728C0094FCAB /* broad_fill_HDH.pdf in Resources */, + 00DA7809107A728C0094FCAB /* broad_fill_HDV.pdf in Resources */, + 00DA780A107A728C0094FCAB /* broad_fill_HHH.pdf in Resources */, + 00DA780B107A728C0094FCAB /* broad_fill_HHV.pdf in Resources */, + 00DA780C107A728C0094FCAB /* broad_fill_HVV.pdf in Resources */, + 00DA780D107A728C0094FCAB /* broad_outline_corner.pdf in Resources */, + 00DA780E107A728C0094FCAB /* broad_outline_DDD.pdf in Resources */, + 00DA780F107A728C0094FCAB /* broad_outline_DHD.pdf in Resources */, + 00DA7810107A728C0094FCAB /* broad_outline_DHH.pdf in Resources */, + 00DA7811107A728C0094FCAB /* broad_outline_DHV.pdf in Resources */, + 00DA7812107A728C0094FCAB /* broad_outline_HDD.pdf in Resources */, + 00DA7813107A728C0094FCAB /* broad_outline_HDH.pdf in Resources */, + 00DA7814107A728C0094FCAB /* broad_outline_HDV.pdf in Resources */, + 00DA7815107A728C0094FCAB /* broad_outline_HHH.pdf in Resources */, + 00DA7816107A728C0094FCAB /* broad_outline_HHV.pdf in Resources */, + 00DA7817107A728C0094FCAB /* broad_outline_HVV.pdf in Resources */, + 00DA7818107A728C0094FCAB /* slender_fill_corner.pdf in Resources */, + 00DA7819107A728C0094FCAB /* slender_fill_DDD.pdf in Resources */, + 00DA781A107A728C0094FCAB /* slender_fill_DHD.pdf in Resources */, + 00DA781B107A728C0094FCAB /* slender_fill_DHH.pdf in Resources */, + 00DA781C107A728C0094FCAB /* slender_fill_DHV.pdf in Resources */, + 00DA781D107A728C0094FCAB /* slender_fill_HDD.pdf in Resources */, + 00DA781E107A728C0094FCAB /* slender_fill_HDH.pdf in Resources */, + 00DA781F107A728C0094FCAB /* slender_fill_HDV.pdf in Resources */, + 00DA7820107A728C0094FCAB /* slender_fill_HHH.pdf in Resources */, + 00DA7821107A728C0094FCAB /* slender_fill_HHV.pdf in Resources */, + 00DA7822107A728C0094FCAB /* slender_fill_HVV.pdf in Resources */, + 00DA7823107A728C0094FCAB /* slender_outline_corner.pdf in Resources */, + 00DA7824107A728C0094FCAB /* slender_outline_DDD.pdf in Resources */, + 00DA7825107A728C0094FCAB /* slender_outline_DHD.pdf in Resources */, + 00DA7826107A728C0094FCAB /* slender_outline_DHH.pdf in Resources */, + 00DA7827107A728C0094FCAB /* slender_outline_DHV.pdf in Resources */, + 00DA7828107A728C0094FCAB /* slender_outline_HDD.pdf in Resources */, + 00DA7829107A728C0094FCAB /* slender_outline_HDH.pdf in Resources */, + 00DA782A107A728C0094FCAB /* slender_outline_HDV.pdf in Resources */, + 00DA782B107A728C0094FCAB /* slender_outline_HHH.pdf in Resources */, + 00DA782C107A728C0094FCAB /* slender_outline_HHV.pdf in Resources */, + 00DA782D107A728C0094FCAB /* slender_outline_HVV.pdf in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXRezBuildPhase section */ + 8D255AD00486D3F9007BF209 /* Rez */ = { + isa = PBXRezBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXRezBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 000D03D51089C45F003F010E /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "$(BUILT_PRODUCTS_DIR)/XamhainII.saver", + ); + outputPaths = ( + "$(BUILT_PRODUCTS_DIR)/XamhainII.dmg", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "# Thanks to Rob Mayoff for explaining how to do this.\n# See http://qwan.org/2007/05/22/using-xcode-to-build-a-disk-image-and-upload-a-web-site/\n\nset -ex\n\n[ \"$ACTION\" = build ] || exit 0\n[ \"$BUILD_VARIANTS\" = \"normal\" ] || exit 0\n\ndir=\"$TEMP_FILES_DIR/disk\"\ndmg=\"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.dmg\"\n\nrm -rf \"$dir\"\nmkdir \"$dir\"\ncp -R \"$BUILT_PRODUCTS_DIR/$PROJECT_NAME.saver\" \"$dir\"\nrm -f \"$dmg\"\nhdiutil create -srcfolder \"$dir\" -volname \"$PROJECT_NAME\" \"$dmg\"\nhdiutil internet-enable -yes \"$dmg\"\nrm -rf \"$dir\"\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8D255ACB0486D3F9007BF209 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 00DA7838107A73320094FCAB /* XamhainView.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 000D03DA1089C465003F010E /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 8D255AC50486D3F9007BF209 /* XamhainII */; + targetProxy = 000D03D91089C465003F010E /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 089C167DFE841241C02AAC07 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 089C167EFE841241C02AAC07 /* English */, + ); + name = InfoPlist.strings; + sourceTree = "<group>"; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 000D03D71089C45F003F010E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + PRODUCT_NAME = XamhainII.dmg; + }; + name = Debug; + }; + 000D03D81089C45F003F010E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + PRODUCT_NAME = XamhainII.dmg; + ZERO_LINK = NO; + }; + name = Release; + }; + EF7AD72E08BB986600CE4634 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_ENABLE_OBJC_GC = required; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = XamhainII_Prefix.pch; + GCC_STRICT_ALIASING = NO; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = NO; + GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; + GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO; + GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; + GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; + GCC_WARN_MISSING_PARENTHESES = YES; + GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; + GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; + GCC_WARN_PEDANTIC = YES; + GCC_WARN_PROTOTYPE_CONVERSION = NO; + GCC_WARN_SHADOW = YES; + GCC_WARN_SIGN_COMPARE = YES; + GCC_WARN_STRICT_SELECTOR_MATCH = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = NO; + GCC_WARN_UNKNOWN_PRAGMAS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_LABEL = YES; + GCC_WARN_UNUSED_PARAMETER = YES; + GCC_WARN_UNUSED_VALUE = YES; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Library/Screen Savers"; + PRODUCT_NAME = XamhainII; + WRAPPER_EXTENSION = saver; + ZERO_LINK = YES; + }; + name = Debug; + }; + EF7AD72F08BB986600CE4634 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_ENABLE_OBJC_GC = required; + GCC_MODEL_TUNING = G5; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = XamhainII_Prefix.pch; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = NO; + GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; + GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; + GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; + GCC_WARN_MISSING_PARENTHESES = YES; + GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; + GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; + GCC_WARN_PEDANTIC = YES; + GCC_WARN_PROTOTYPE_CONVERSION = NO; + GCC_WARN_SHADOW = YES; + GCC_WARN_SIGN_COMPARE = YES; + GCC_WARN_STRICT_SELECTOR_MATCH = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNKNOWN_PRAGMAS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_LABEL = YES; + GCC_WARN_UNUSED_PARAMETER = YES; + GCC_WARN_UNUSED_VALUE = YES; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Library/Screen Savers"; + PRODUCT_NAME = XamhainII; + WRAPPER_EXTENSION = saver; + }; + name = Release; + }; + EF7AD73208BB986600CE4634 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_GC = supported; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + ONLY_ACTIVE_ARCH = NO; + PREBINDING = NO; + SDKROOT = macosx10.6; + }; + name = Debug; + }; + EF7AD73308BB986600CE4634 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_GC = supported; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PREBINDING = NO; + SDKROOT = macosx10.6; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 000D03DC1089C467003F010E /* Build configuration list for PBXAggregateTarget "XamhainII.dmg" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 000D03D71089C45F003F010E /* Debug */, + 000D03D81089C45F003F010E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + EF7AD72D08BB986600CE4634 /* Build configuration list for PBXNativeTarget "XamhainII" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + EF7AD72E08BB986600CE4634 /* Debug */, + EF7AD72F08BB986600CE4634 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + EF7AD73108BB986600CE4634 /* Build configuration list for PBXProject "XamhainII" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + EF7AD73208BB986600CE4634 /* Debug */, + EF7AD73308BB986600CE4634 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 089C1669FE841209C02AAC07 /* Project object */; +} diff --git a/XamhainII_Prefix.pch b/XamhainII_Prefix.pch new file mode 100644 index 0000000..0137bad --- /dev/null +++ b/XamhainII_Prefix.pch @@ -0,0 +1,24 @@ +// Prefix header for all source files of the 'XamhainII' target +// in the 'XamhainII' project. +// +// Copyright © 2009, Jens Kilian. +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#ifdef __OBJC__ + #import <Foundation/Foundation.h> + #import <AppKit/AppKit.h> +#endif diff --git a/screen saving/XamhainView.h b/screen saving/XamhainView.h new file mode 100644 index 0000000..497e3da --- /dev/null +++ b/screen saving/XamhainView.h @@ -0,0 +1,28 @@ +// XamhainII screen saver view. +// +// Copyright © 2009, Jens Kilian. +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#import <ScreenSaver/ScreenSaver.h> + + +@interface XamhainView : ScreenSaverView +{ + int phase; +} + +@end diff --git a/screen saving/XamhainView.m b/screen saving/XamhainView.m new file mode 100644 index 0000000..28a4712 --- /dev/null +++ b/screen saving/XamhainView.m @@ -0,0 +1,77 @@ +// XamhainII screen saver view. +// +// Copyright © 2009, Jens Kilian. +// +// This file is part of XamhainII. +// +// XamhainII is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// XamhainII 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with XamhainII. If not, see <http://www.gnu.org/licenses/>. + +#import "XamhainView.h" + + +@implementation XamhainView + +- (id)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview +{ + self = [super initWithFrame:frame isPreview:isPreview]; + if (self) { + [self setAnimationTimeInterval:1/30.0]; + } + + phase = 0; + + return self; +} + +- (void)startAnimation +{ + [super startAnimation]; +} + +- (void)stopAnimation +{ + [super stopAnimation]; +} + +- (void)drawRect:(NSRect)rect +{ + [super drawRect:rect]; +} + +- (void)animateOneFrame +{ + ++phase; + + [[NSColor colorWithCalibratedHue:(phase % 500) / 500.0 + saturation:1.0 + brightness:1.0 + alpha:1.0] setFill]; + + NSRect bounds = [self bounds]; + CGFloat d = NSWidth(bounds) / 25.0; + bounds = NSInsetRect(bounds, d, d); + NSFrameRectWithWidth(bounds, d); +} + +- (BOOL)hasConfigureSheet +{ + return NO; +} + +- (NSWindow*)configureSheet +{ + return nil; +} + +@end diff --git a/strokes/broad_fill_DDD.pdf b/strokes/broad_fill_DDD.pdf new file mode 100644 index 0000000..d039190 Binary files /dev/null and b/strokes/broad_fill_DDD.pdf differ diff --git a/strokes/broad_fill_DHD.pdf b/strokes/broad_fill_DHD.pdf new file mode 100644 index 0000000..34d3bd4 Binary files /dev/null and b/strokes/broad_fill_DHD.pdf differ diff --git a/strokes/broad_fill_DHH.pdf b/strokes/broad_fill_DHH.pdf new file mode 100644 index 0000000..455d0ed Binary files /dev/null and b/strokes/broad_fill_DHH.pdf differ diff --git a/strokes/broad_fill_DHV.pdf b/strokes/broad_fill_DHV.pdf new file mode 100644 index 0000000..876a9ca --- /dev/null +++ b/strokes/broad_fill_DHV.pdf @@ -0,0 +1,68 @@ +%PDF-1.4 +%µí®û +3 0 obj +<< /Length 4 0 R + /Filter /FlateDecode +>> +stream +xœNA +1 ¼çói›¦Ý‚‡Õƒñ «Â.T~ßlIf ÐF BßÁñyâ‚Õ­mN{ìî‚×—?÷Ž7]o<ÈãG4„ž¶ãμР-"rłÀ5˜+MŠÄ5Eç 2'ÉP¶1c†q)É9XEálªªºÐѼ¹wÎ8cêOOôç%K +endstream +endobj +4 0 obj + 146 +endobj +2 0 obj +<< + /ExtGState << + /a0 << /CA 1 /ca 1 >> + >> +>> +endobj +5 0 obj +<< /Type /Page + /Parent 1 0 R + /MediaBox [ 0 0 10 10 ] + /Contents 3 0 R + /Group << + /Type /Group + /S /Transparency + /CS /DeviceRGB + >> + /Resources 2 0 R +>> +endobj +1 0 obj +<< /Type /Pages + /Kids [ 5 0 R ] + /Count 1 +>> +endobj +6 0 obj +<< /Creator (cairo 1.8.8 (http://cairographics.org)) + /Producer (cairo 1.8.8 (http://cairographics.org)) +>> +endobj +7 0 obj +<< /Type /Catalog + /Pages 1 0 R +>> +endobj +xref +0 8 +0000000000 65535 f +0000000529 00000 n +0000000259 00000 n +0000000015 00000 n +0000000237 00000 n +0000000331 00000 n +0000000594 00000 n +0000000719 00000 n +trailer +<< /Size 8 + /Root 7 0 R + /Info 6 0 R +>> +startxref +771 +%%EOF diff --git a/strokes/broad_fill_HDD.pdf b/strokes/broad_fill_HDD.pdf new file mode 100644 index 0000000..190adb1 Binary files /dev/null and b/strokes/broad_fill_HDD.pdf differ diff --git a/strokes/broad_fill_HDH.pdf b/strokes/broad_fill_HDH.pdf new file mode 100644 index 0000000..3cd653c Binary files /dev/null and b/strokes/broad_fill_HDH.pdf differ diff --git a/strokes/broad_fill_HDV.pdf b/strokes/broad_fill_HDV.pdf new file mode 100644 index 0000000..f1c0bd8 --- /dev/null +++ b/strokes/broad_fill_HDV.pdf @@ -0,0 +1,69 @@ +%PDF-1.4 +%µí®û +3 0 obj +<< /Length 4 0 R + /Filter /FlateDecode +>> +stream +xœ]OA +1 ¼çóÆ4kÝõ‚à¡z𠤊 V¨ü¾i’L&L&4Êh$ˆžÁð¼`‡I=¶+ÌN‚ë‹æx›¶6Üèp„°àLfß !º7t2¥T9!$TôF wü³²“÷¶Ë“úքò[ªðCbîΑ‡q‰…×>þš +vÈþD¦‡ƒ([ +endstream +endobj +4 0 obj + 138 +endobj +2 0 obj +<< + /ExtGState << + /a0 << /CA 1 /ca 1 >> + >> +>> +endobj +5 0 obj +<< /Type /Page + /Parent 1 0 R + /MediaBox [ 0 0 10 10 ] + /Contents 3 0 R + /Group << + /Type /Group + /S /Transparency + /CS /DeviceRGB + >> + /Resources 2 0 R +>> +endobj +1 0 obj +<< /Type /Pages + /Kids [ 5 0 R ] + /Count 1 +>> +endobj +6 0 obj +<< /Creator (cairo 1.8.8 (http://cairographics.org)) + /Producer (cairo 1.8.8 (http://cairographics.org)) +>> +endobj +7 0 obj +<< /Type /Catalog + /Pages 1 0 R +>> +endobj +xref +0 8 +0000000000 65535 f +0000000521 00000 n +0000000251 00000 n +0000000015 00000 n +0000000229 00000 n +0000000323 00000 n +0000000586 00000 n +0000000711 00000 n +trailer +<< /Size 8 + /Root 7 0 R + /Info 6 0 R +>> +startxref +763 +%%EOF diff --git a/strokes/broad_fill_HHH.pdf b/strokes/broad_fill_HHH.pdf new file mode 100644 index 0000000..3d00469 Binary files /dev/null and b/strokes/broad_fill_HHH.pdf differ diff --git a/strokes/broad_fill_HHV.pdf b/strokes/broad_fill_HHV.pdf new file mode 100644 index 0000000..d0ed5bc Binary files /dev/null and b/strokes/broad_fill_HHV.pdf differ diff --git a/strokes/broad_fill_HVV.pdf b/strokes/broad_fill_HVV.pdf new file mode 100644 index 0000000..de3600b --- /dev/null +++ b/strokes/broad_fill_HVV.pdf @@ -0,0 +1,68 @@ +%PDF-1.4 +%µí®û +3 0 obj +<< /Length 4 0 R + /Filter /FlateDecode +>> +stream +xœ-ŽM +Â0…÷sŠwŒùm{Ap‘ºp!.$Š TH]xý¾„2ÿo>†©’QÅÂu7Œõ…+¾”šÍGïŸDü©¹ÝaÕâ)ÄϨp5­P)‹Œš`ˆLpˆ#œ?aÐè"<ש炠‰Të½Æv®Í²_(¸ ÷7³l’"f +endstream +endobj +4 0 obj + 131 +endobj +2 0 obj +<< + /ExtGState << + /a0 << /CA 1 /ca 1 >> + >> +>> +endobj +5 0 obj +<< /Type /Page + /Parent 1 0 R + /MediaBox [ 0 0 10 10 ] + /Contents 3 0 R + /Group << + /Type /Group + /S /Transparency + /CS /DeviceRGB + >> + /Resources 2 0 R +>> +endobj +1 0 obj +<< /Type /Pages + /Kids [ 5 0 R ] + /Count 1 +>> +endobj +6 0 obj +<< /Creator (cairo 1.8.8 (http://cairographics.org)) + /Producer (cairo 1.8.8 (http://cairographics.org)) +>> +endobj +7 0 obj +<< /Type /Catalog + /Pages 1 0 R +>> +endobj +xref +0 8 +0000000000 65535 f +0000000514 00000 n +0000000244 00000 n +0000000015 00000 n +0000000222 00000 n +0000000316 00000 n +0000000579 00000 n +0000000704 00000 n +trailer +<< /Size 8 + /Root 7 0 R + /Info 6 0 R +>> +startxref +756 +%%EOF diff --git a/strokes/broad_fill_corner.pdf b/strokes/broad_fill_corner.pdf new file mode 100644 index 0000000..2771fcb Binary files /dev/null and b/strokes/broad_fill_corner.pdf differ diff --git a/strokes/broad_outline_DDD.pdf b/strokes/broad_outline_DDD.pdf new file mode 100644 index 0000000..b3263ab Binary files /dev/null and b/strokes/broad_outline_DDD.pdf differ diff --git a/strokes/broad_outline_DHD.pdf b/strokes/broad_outline_DHD.pdf new file mode 100644 index 0000000..9cdc0a7 --- /dev/null +++ b/strokes/broad_outline_DHD.pdf @@ -0,0 +1,69 @@ +%PDF-1.4 +%µí®û +3 0 obj +<< /Length 4 0 R + /Filter /FlateDecode +>> +stream +xœ-ŽA +ƒ@ E÷9Å¿À¤™í +….F.ÄE±¥PjaìÂë§’üòødJÈ$ˆ¥ƒky¢Ç×Ñ^í§»àõ£«³«ëMÃaÁƒ<~CF,Ù°'ÓLAX…r-†‘M߬2T,ç¿ëaÓqþƒ©<”hP;s +endstream +endobj +4 0 obj + 123 +endobj +2 0 obj +<< + /ExtGState << + /a0 << /CA 1 /ca 1 >> + >> +>> +endobj +5 0 obj +<< /Type /Page + /Parent 1 0 R + /MediaBox [ 0 0 10 10 ] + /Contents 3 0 R + /Group << + /Type /Group + /S /Transparency + /CS /DeviceRGB + >> + /Resources 2 0 R +>> +endobj +1 0 obj +<< /Type /Pages + /Kids [ 5 0 R ] + /Count 1 +>> +endobj +6 0 obj +<< /Creator (cairo 1.8.8 (http://cairographics.org)) + /Producer (cairo 1.8.8 (http://cairographics.org)) +>> +endobj +7 0 obj +<< /Type /Catalog + /Pages 1 0 R +>> +endobj +xref +0 8 +0000000000 65535 f +0000000506 00000 n +0000000236 00000 n +0000000015 00000 n +0000000214 00000 n +0000000308 00000 n +0000000571 00000 n +0000000696 00000 n +trailer +<< /Size 8 + /Root 7 0 R + /Info 6 0 R +>> +startxref +748 +%%EOF diff --git a/strokes/broad_outline_DHH.pdf b/strokes/broad_outline_DHH.pdf new file mode 100644 index 0000000..e359ee1 Binary files /dev/null and b/strokes/broad_outline_DHH.pdf differ diff --git a/strokes/broad_outline_DHV.pdf b/strokes/broad_outline_DHV.pdf new file mode 100644 index 0000000..5028ccb --- /dev/null +++ b/strokes/broad_outline_DHV.pdf @@ -0,0 +1,68 @@ +%PDF-1.4 +%µí®û +3 0 obj +<< /Length 4 0 R + /Filter /FlateDecode +>> +stream +xœNË +A »÷+ò[;¯Î삇уñ £Â.Œü}»C›”„Ú©¢“À Ÿ'.XÍÚæ´Çî.x})ágÞÁð¦ë ‚Yüˆ7²ÓvÌi MÂ^=<'‰Xà¸85CD༱÷‰ƒ$DÖ9¡A9ç`ì´ sRv%šˆ³Zóèl8£Ž§+ý{%L +endstream +endobj +4 0 obj + 146 +endobj +2 0 obj +<< + /ExtGState << + /a0 << /CA 1 /ca 1 >> + >> +>> +endobj +5 0 obj +<< /Type /Page + /Parent 1 0 R + /MediaBox [ 0 0 10 10 ] + /Contents 3 0 R + /Group << + /Type /Group + /S /Transparency + /CS /DeviceRGB + >> + /Resources 2 0 R +>> +endobj +1 0 obj +<< /Type /Pages + /Kids [ 5 0 R ] + /Count 1 +>> +endobj +6 0 obj +<< /Creator (cairo 1.8.8 (http://cairographics.org)) + /Producer (cairo 1.8.8 (http://cairographics.org)) +>> +endobj +7 0 obj +<< /Type /Catalog + /Pages 1 0 R +>> +endobj +xref +0 8 +0000000000 65535 f +0000000529 00000 n +0000000259 00000 n +0000000015 00000 n +0000000237 00000 n +0000000331 00000 n +0000000594 00000 n +0000000719 00000 n +trailer +<< /Size 8 + /Root 7 0 R + /Info 6 0 R +>> +startxref +771 +%%EOF diff --git a/strokes/broad_outline_HDD.pdf b/strokes/broad_outline_HDD.pdf new file mode 100644 index 0000000..698c085 Binary files /dev/null and b/strokes/broad_outline_HDD.pdf differ diff --git a/strokes/broad_outline_HDH.pdf b/strokes/broad_outline_HDH.pdf new file mode 100644 index 0000000..8bcff11 Binary files /dev/null and b/strokes/broad_outline_HDH.pdf differ diff --git a/strokes/broad_outline_HDV.pdf b/strokes/broad_outline_HDV.pdf new file mode 100644 index 0000000..8e76421 --- /dev/null +++ b/strokes/broad_outline_HDV.pdf @@ -0,0 +1,68 @@ +%PDF-1.4 +%µí®û +3 0 obj +<< /Length 4 0 R + /Filter /FlateDecode +>> +stream +xœ]OA +1 ¼ç󁯴KÝõ‚à¡z𠤊 v¡zðû&<H2™0™Ò© “ zÅóŠf•,vk,΂ۋ2Þªmw:ž ,¸Ú·èˆî FªÔF#g„Œk’âNœ†É{Ýå)ùNõ·Ôà‡DÝÆ‘‡q…¥WM{¢Ðˆ'(\ +endstream +endobj +4 0 obj + 138 +endobj +2 0 obj +<< + /ExtGState << + /a0 << /CA 1 /ca 1 >> + >> +>> +endobj +5 0 obj +<< /Type /Page + /Parent 1 0 R + /MediaBox [ 0 0 10 10 ] + /Contents 3 0 R + /Group << + /Type /Group + /S /Transparency + /CS /DeviceRGB + >> + /Resources 2 0 R +>> +endobj +1 0 obj +<< /Type /Pages + /Kids [ 5 0 R ] + /Count 1 +>> +endobj +6 0 obj +<< /Creator (cairo 1.8.8 (http://cairographics.org)) + /Producer (cairo 1.8.8 (http://cairographics.org)) +>> +endobj +7 0 obj +<< /Type /Catalog + /Pages 1 0 R +>> +endobj +xref +0 8 +0000000000 65535 f +0000000521 00000 n +0000000251 00000 n +0000000015 00000 n +0000000229 00000 n +0000000323 00000 n +0000000586 00000 n +0000000711 00000 n +trailer +<< /Size 8 + /Root 7 0 R + /Info 6 0 R +>> +startxref +763 +%%EOF diff --git a/strokes/broad_outline_HHH.pdf b/strokes/broad_outline_HHH.pdf new file mode 100644 index 0000000..51a5bb6 Binary files /dev/null and b/strokes/broad_outline_HHH.pdf differ diff --git a/strokes/broad_outline_HHV.pdf b/strokes/broad_outline_HHV.pdf new file mode 100644 index 0000000..68a2355 Binary files /dev/null and b/strokes/broad_outline_HHV.pdf differ diff --git a/strokes/broad_outline_HVV.pdf b/strokes/broad_outline_HVV.pdf new file mode 100644 index 0000000..5a6809c --- /dev/null +++ b/strokes/broad_outline_HVV.pdf @@ -0,0 +1,68 @@ +%PDF-1.4 +%µí®û +3 0 obj +<< /Length 4 0 R + /Filter /FlateDecode +>> +stream +xœ-ŽM +Â0…÷sŠwŒùm{Ap‘ºp!.$Š TH]xý¾„2ÿo>†©’QÅÂu7Œõ…+¾”šÍGïŸ$ü©¹ÝaÕâ)ÄϨp5­P)‹Œš`ˆLpˆ#œ?aÐè"<ש炠‰Të½Æv®Í²_(¸ ÷7³l"g +endstream +endobj +4 0 obj + 131 +endobj +2 0 obj +<< + /ExtGState << + /a0 << /CA 1 /ca 1 >> + >> +>> +endobj +5 0 obj +<< /Type /Page + /Parent 1 0 R + /MediaBox [ 0 0 10 10 ] + /Contents 3 0 R + /Group << + /Type /Group + /S /Transparency + /CS /DeviceRGB + >> + /Resources 2 0 R +>> +endobj +1 0 obj +<< /Type /Pages + /Kids [ 5 0 R ] + /Count 1 +>> +endobj +6 0 obj +<< /Creator (cairo 1.8.8 (http://cairographics.org)) + /Producer (cairo 1.8.8 (http://cairographics.org)) +>> +endobj +7 0 obj +<< /Type /Catalog + /Pages 1 0 R +>> +endobj +xref +0 8 +0000000000 65535 f +0000000514 00000 n +0000000244 00000 n +0000000015 00000 n +0000000222 00000 n +0000000316 00000 n +0000000579 00000 n +0000000704 00000 n +trailer +<< /Size 8 + /Root 7 0 R + /Info 6 0 R +>> +startxref +756 +%%EOF diff --git a/strokes/broad_outline_corner.pdf b/strokes/broad_outline_corner.pdf new file mode 100644 index 0000000..406380c Binary files /dev/null and b/strokes/broad_outline_corner.pdf differ diff --git a/strokes/slender_fill_DDD.pdf b/strokes/slender_fill_DDD.pdf new file mode 100644 index 0000000..0b3920f Binary files /dev/null and b/strokes/slender_fill_DDD.pdf differ diff --git a/strokes/slender_fill_DHD.pdf b/strokes/slender_fill_DHD.pdf new file mode 100644 index 0000000..7f59cd8 Binary files /dev/null and b/strokes/slender_fill_DHD.pdf differ diff --git a/strokes/slender_fill_DHH.pdf b/strokes/slender_fill_DHH.pdf new file mode 100644 index 0000000..dce2e82 Binary files /dev/null and b/strokes/slender_fill_DHH.pdf differ diff --git a/strokes/slender_fill_DHV.pdf b/strokes/slender_fill_DHV.pdf new file mode 100644 index 0000000..db8804a --- /dev/null +++ b/strokes/slender_fill_DHV.pdf @@ -0,0 +1,68 @@ +%PDF-1.4 +%µí®û +3 0 obj +<< /Length 4 0 R + /Filter /FlateDecode +>> +stream +xœNA +1 ¼çóiڦ݂‡Õƒñ «Â.T~ßlIf ÐF BßÁñyâ‚Õ­mN{ìî‚×—?÷Ž7]o<ÈãG4„ž¶ãμР¬¦PΒ° p æ*ńÈ5ª³jAæ(‰m̘a\JtVQ8›*‡š\¤Ñ¼¹wÎ8cêOOô¿%I +endstream +endobj +4 0 obj + 146 +endobj +2 0 obj +<< + /ExtGState << + /a0 << /CA 1 /ca 1 >> + >> +>> +endobj +5 0 obj +<< /Type /Page + /Parent 1 0 R + /MediaBox [ 0 0 10 10 ] + /Contents 3 0 R + /Group << + /Type /Group + /S /Transparency + /CS /DeviceRGB + >> + /Resources 2 0 R +>> +endobj +1 0 obj +<< /Type /Pages + /Kids [ 5 0 R ] + /Count 1 +>> +endobj +6 0 obj +<< /Creator (cairo 1.8.8 (http://cairographics.org)) + /Producer (cairo 1.8.8 (http://cairographics.org)) +>> +endobj +7 0 obj +<< /Type /Catalog + /Pages 1 0 R +>> +endobj +xref +0 8 +0000000000 65535 f +0000000529 00000 n +0000000259 00000 n +0000000015 00000 n +0000000237 00000 n +0000000331 00000 n +0000000594 00000 n +0000000719 00000 n +trailer +<< /Size 8 + /Root 7 0 R + /Info 6 0 R +>> +startxref +771 +%%EOF diff --git a/strokes/slender_fill_HDD.pdf b/strokes/slender_fill_HDD.pdf new file mode 100644 index 0000000..59321a7 Binary files /dev/null and b/strokes/slender_fill_HDD.pdf differ diff --git a/strokes/slender_fill_HDH.pdf b/strokes/slender_fill_HDH.pdf new file mode 100644 index 0000000..807fcd7 Binary files /dev/null and b/strokes/slender_fill_HDH.pdf differ diff --git a/strokes/slender_fill_HDV.pdf b/strokes/slender_fill_HDV.pdf new file mode 100644 index 0000000..64a97cc Binary files /dev/null and b/strokes/slender_fill_HDV.pdf differ diff --git a/strokes/slender_fill_HHH.pdf b/strokes/slender_fill_HHH.pdf new file mode 100644 index 0000000..558ed98 Binary files /dev/null and b/strokes/slender_fill_HHH.pdf differ diff --git a/strokes/slender_fill_HHV.pdf b/strokes/slender_fill_HHV.pdf new file mode 100644 index 0000000..1fa43e2 Binary files /dev/null and b/strokes/slender_fill_HHV.pdf differ diff --git a/strokes/slender_fill_HVV.pdf b/strokes/slender_fill_HVV.pdf new file mode 100644 index 0000000..cddd0e5 --- /dev/null +++ b/strokes/slender_fill_HVV.pdf @@ -0,0 +1,68 @@ +%PDF-1.4 +%µí®û +3 0 obj +<< /Length 4 0 R + /Filter /FlateDecode +>> +stream +xœ-ŽM +Â0…÷sŠwŒùm{Ap‘ºp!.$Š TH]xý¾„2ÿo>†©’QÅÂu7Œõ…+¾”šÍGïŸxü©¹ÝaÕâ)ÄϨp5­P)‹Œš`ˆLpˆ#œ?aÐè"<ש炠‰Të½Æv®Í²_(¸ ÷7³l†"d +endstream +endobj +4 0 obj + 131 +endobj +2 0 obj +<< + /ExtGState << + /a0 << /CA 1 /ca 1 >> + >> +>> +endobj +5 0 obj +<< /Type /Page + /Parent 1 0 R + /MediaBox [ 0 0 10 10 ] + /Contents 3 0 R + /Group << + /Type /Group + /S /Transparency + /CS /DeviceRGB + >> + /Resources 2 0 R +>> +endobj +1 0 obj +<< /Type /Pages + /Kids [ 5 0 R ] + /Count 1 +>> +endobj +6 0 obj +<< /Creator (cairo 1.8.8 (http://cairographics.org)) + /Producer (cairo 1.8.8 (http://cairographics.org)) +>> +endobj +7 0 obj +<< /Type /Catalog + /Pages 1 0 R +>> +endobj +xref +0 8 +0000000000 65535 f +0000000514 00000 n +0000000244 00000 n +0000000015 00000 n +0000000222 00000 n +0000000316 00000 n +0000000579 00000 n +0000000704 00000 n +trailer +<< /Size 8 + /Root 7 0 R + /Info 6 0 R +>> +startxref +756 +%%EOF diff --git a/strokes/slender_fill_corner.pdf b/strokes/slender_fill_corner.pdf new file mode 100644 index 0000000..dd8313c Binary files /dev/null and b/strokes/slender_fill_corner.pdf differ diff --git a/strokes/slender_outline_DDD.pdf b/strokes/slender_outline_DDD.pdf new file mode 100644 index 0000000..f053e01 Binary files /dev/null and b/strokes/slender_outline_DDD.pdf differ diff --git a/strokes/slender_outline_DHD.pdf b/strokes/slender_outline_DHD.pdf new file mode 100644 index 0000000..46d5043 Binary files /dev/null and b/strokes/slender_outline_DHD.pdf differ diff --git a/strokes/slender_outline_DHH.pdf b/strokes/slender_outline_DHH.pdf new file mode 100644 index 0000000..05e69cf Binary files /dev/null and b/strokes/slender_outline_DHH.pdf differ diff --git a/strokes/slender_outline_DHV.pdf b/strokes/slender_outline_DHV.pdf new file mode 100644 index 0000000..54756b5 --- /dev/null +++ b/strokes/slender_outline_DHV.pdf @@ -0,0 +1,69 @@ +%PDF-1.4 +%µí®û +3 0 obj +<< /Length 4 0 R + /Filter /FlateDecode +>> +stream +xœNË +1 ¼ç+æ6¦¯´û‚à¡z𠤊 ìBõàï›-I&̐Ò©¢“Àžl>O\°š´ÕiÝ]ðú’焟©›7]o<È Gt¸q=m˔¶Ð$ìÕÃ\±Àqqj,†ˆÀ%xCï3Iˆ¬sBƒrÎÁÐiAæ¤ +*ìJ4gµä‘ÙpFoWú\%¬ +endstream +endobj +4 0 obj + 147 +endobj +2 0 obj +<< + /ExtGState << + /a0 << /CA 1 /ca 1 >> + >> +>> +endobj +5 0 obj +<< /Type /Page + /Parent 1 0 R + /MediaBox [ 0 0 10 10 ] + /Contents 3 0 R + /Group << + /Type /Group + /S /Transparency + /CS /DeviceRGB + >> + /Resources 2 0 R +>> +endobj +1 0 obj +<< /Type /Pages + /Kids [ 5 0 R ] + /Count 1 +>> +endobj +6 0 obj +<< /Creator (cairo 1.8.8 (http://cairographics.org)) + /Producer (cairo 1.8.8 (http://cairographics.org)) +>> +endobj +7 0 obj +<< /Type /Catalog + /Pages 1 0 R +>> +endobj +xref +0 8 +0000000000 65535 f +0000000530 00000 n +0000000260 00000 n +0000000015 00000 n +0000000238 00000 n +0000000332 00000 n +0000000595 00000 n +0000000720 00000 n +trailer +<< /Size 8 + /Root 7 0 R + /Info 6 0 R +>> +startxref +772 +%%EOF diff --git a/strokes/slender_outline_HDD.pdf b/strokes/slender_outline_HDD.pdf new file mode 100644 index 0000000..f61b281 Binary files /dev/null and b/strokes/slender_outline_HDD.pdf differ diff --git a/strokes/slender_outline_HDH.pdf b/strokes/slender_outline_HDH.pdf new file mode 100644 index 0000000..adb417f Binary files /dev/null and b/strokes/slender_outline_HDH.pdf differ diff --git a/strokes/slender_outline_HDV.pdf b/strokes/slender_outline_HDV.pdf new file mode 100644 index 0000000..f390ab0 --- /dev/null +++ b/strokes/slender_outline_HDV.pdf @@ -0,0 +1,69 @@ +%PDF-1.4 +%µí®û +3 0 obj +<< /Length 4 0 R + /Filter /FlateDecode +>> +stream +xœ]OK +B1 ÜçsÆ´úž'Յ q!U±ª ¯oÁ…ä3a2H§‚N‚è´žW0+e±[cqÜ^”8ã­ìFëNÇ„RÃÑÕÁ@™ÚhTyÈh°Á¼ücâ4L>«—§ä8eԟ©Á‰ª #ã +Kï¶þŠ*ö(þF¡ׯ(¼ +endstream +endobj +4 0 obj + 139 +endobj +2 0 obj +<< + /ExtGState << + /a0 << /CA 1 /ca 1 >> + >> +>> +endobj +5 0 obj +<< /Type /Page + /Parent 1 0 R + /MediaBox [ 0 0 10 10 ] + /Contents 3 0 R + /Group << + /Type /Group + /S /Transparency + /CS /DeviceRGB + >> + /Resources 2 0 R +>> +endobj +1 0 obj +<< /Type /Pages + /Kids [ 5 0 R ] + /Count 1 +>> +endobj +6 0 obj +<< /Creator (cairo 1.8.8 (http://cairographics.org)) + /Producer (cairo 1.8.8 (http://cairographics.org)) +>> +endobj +7 0 obj +<< /Type /Catalog + /Pages 1 0 R +>> +endobj +xref +0 8 +0000000000 65535 f +0000000522 00000 n +0000000252 00000 n +0000000015 00000 n +0000000230 00000 n +0000000324 00000 n +0000000587 00000 n +0000000712 00000 n +trailer +<< /Size 8 + /Root 7 0 R + /Info 6 0 R +>> +startxref +764 +%%EOF diff --git a/strokes/slender_outline_HHH.pdf b/strokes/slender_outline_HHH.pdf new file mode 100644 index 0000000..9d346f9 Binary files /dev/null and b/strokes/slender_outline_HHH.pdf differ diff --git a/strokes/slender_outline_HHV.pdf b/strokes/slender_outline_HHV.pdf new file mode 100644 index 0000000..638a85b Binary files /dev/null and b/strokes/slender_outline_HHV.pdf differ diff --git a/strokes/slender_outline_HVV.pdf b/strokes/slender_outline_HVV.pdf new file mode 100644 index 0000000..5493cb9 --- /dev/null +++ b/strokes/slender_outline_HVV.pdf @@ -0,0 +1,69 @@ +%PDF-1.4 +%µí®û +3 0 obj +<< /Length 4 0 R + /Filter /FlateDecode +>> +stream +xœ-ŽM +Â0…÷sŠwŒùm{Ap‘ºp!.$Š TH]xý¾„2ÿo†©’QÅÂu7Œõ…+¾”šÍGïŸxMøS=1>r»ÃªÅS¸pF…ë´i…JYd$nˆLpˆ#œ?aÐè"ÚµÔsAÐDªõ^c +;×fÙ/\û£Y6[`"Ç +endstream +endobj +4 0 obj + 132 +endobj +2 0 obj +<< + /ExtGState << + /a0 << /CA 1 /ca 1 >> + >> +>> +endobj +5 0 obj +<< /Type /Page + /Parent 1 0 R + /MediaBox [ 0 0 10 10 ] + /Contents 3 0 R + /Group << + /Type /Group + /S /Transparency + /CS /DeviceRGB + >> + /Resources 2 0 R +>> +endobj +1 0 obj +<< /Type /Pages + /Kids [ 5 0 R ] + /Count 1 +>> +endobj +6 0 obj +<< /Creator (cairo 1.8.8 (http://cairographics.org)) + /Producer (cairo 1.8.8 (http://cairographics.org)) +>> +endobj +7 0 obj +<< /Type /Catalog + /Pages 1 0 R +>> +endobj +xref +0 8 +0000000000 65535 f +0000000515 00000 n +0000000245 00000 n +0000000015 00000 n +0000000223 00000 n +0000000317 00000 n +0000000580 00000 n +0000000705 00000 n +trailer +<< /Size 8 + /Root 7 0 R + /Info 6 0 R +>> +startxref +757 +%%EOF diff --git a/strokes/slender_outline_corner.pdf b/strokes/slender_outline_corner.pdf new file mode 100644 index 0000000..e71af11 Binary files /dev/null and b/strokes/slender_outline_corner.pdf differ
bestpractical/module-refresh
d496e27c6122d07fcf7ca6ee21281501a8f76c47
Prep 0.18
diff --git a/Changes b/Changes index bfb84a6..53980b1 100644 --- a/Changes +++ b/Changes @@ -1,88 +1,92 @@ +0.18 Tue May 10 03:33:29 CST 2022 + + * Fix uninitialized warnings when modules were not successfully loaded + 0.17 Wed Oct 26 08:34:17 EST 2011 * Warnings avoidance for reloading a module not in %INC * Updated inc/ and META.yml 0.16 Fri Apr 15 15:03:21 EST 2011 * SIGNATURE file bug 0.15 Fri Apr 15 15:00:15 EST 2011 * No functional changes. Added missing test dependencies. Thanks to JQUELIN & Paul at City Fan 0.14 Tue Apr 12 18:07:44 EST 2011 * Actually remove subroutines from the symbol table, Thanks to DOY. 0.13 Thu May 3 23:03:00 EDT 2007 * Requires 5.8.1. (Uses tricks that don't work on 5.6). Thanks to DCANTRELL 0.12 Mon Apr 30 15:34:42 EDT 2007 * Requires 5.6. (Causes 5.5 to bus error). Thanks to RJBS. 0.11 Tue Apr 24 13:25:24 EDT 2007 * Fix for [rt.cpan.org #26536] Test suite uses /tmp with predictable filenames Reported by ANDK 0.10_01 Tue May 9 01:21:55 EDT 2006 * Module::Refresh->refresh_module_if_modified($module) as suggested by Daisuke Maki 0.09 Thu Dec 22 19:03:14 EST 2005 * Artur Bergman pointed out a bug in the overview docs. 0.08 * From Ivan Kohler. (rt.cpan.org #14879) Without this patch, I was getting a fatal error: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. This patch changes this to a warning and adds the name of the subroutine that triggered it. I now get the non-fatal warning: HTML::Mason::handler: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. 0.07 Sun Aug 21 13:25:20 EDT 2005 * Put in a work-around for a perl bug before 5.8.7. 0.06 Fri May 20 22:11:11 EDT 2005 * Trade overrefreshing for underrefreshing in some cases; test and document (We were over-aggressively reloading modules -- David Glasser 0.05 Tue Nov 16 23:15:10 EST 2004 * Explicitly, don't clobber the 'VERSION' symbol on setup. 0.04 Thu Nov 11 12:53:21 CST 2004 * Fix tests to run correctly on Win32. 0.03 Wed Nov 10 21:30:59 CST 2004 * "Anonymize" all our methods so we can refresh ourselves. * POD cleanup; nomenclature unification. * ->refresh now implicitly calls ->new for the first time. minor doc updates * Various cleanups to make it 5.005-friendly. * Use (inode, size, mtime) as the cache value instead of mtime alone. 0.02 Wed Nov 10 18:28:12 CST 2004 - Now we clean out subroutines loaded by the package we're unloading. 0.01 Mon Nov 8 19:48:00 CST 2004 - Initial release diff --git a/META.yml b/META.yml index 552417a..ee266b3 100644 --- a/META.yml +++ b/META.yml @@ -1,28 +1,28 @@ --- abstract: 'Refresh %INC files when updated on disk' author: - 'Jesse Vincent <[email protected]>' build_requires: ExtUtils::MakeMaker: 6.36 File::Temp: '0.19' Path::Class: 0 Test::More: 0 configure_requires: ExtUtils::MakeMaker: 6.36 distribution_type: module dynamic_config: 1 generated_by: 'Module::Install version 1.19' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Module-Refresh no_index: directory: - inc - t requires: perl: 5.8.1 resources: license: http://dev.perl.org/licenses/ -version: '0.17' +version: '0.18' diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index b69d95f..85d4919 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,238 +1,238 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); -$VERSION = "0.17"; +$VERSION = "0.18"; BEGIN { # Turn on the debugger's symbol source tracing $^P |= 0x10; # Work around bug in pre-5.8.7 perl where turning on $^P # causes caller() to be confused about eval {}'s in the stack. # (See http://rt.perl.org/rt3/Ticket/Display.html?id=35059 for more info.) eval 'sub DB::sub' if $] < 5.008007; } =head1 NAME Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS # During each request, call this once to refresh changed modules: Module::Refresh->refresh; # Each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Acme/Current.pm'); =head1 DESCRIPTION This module is a generalization of the functionality provided by L<Apache::StatINC> and L<Apache::Reload>. It's designed to make it easy to do simple iterative development when working in a persistent environment. It does not require mod_perl. =cut =head2 new Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->update_cache($_) for keys %INC; return ($self); } =head2 refresh Refresh all modules that have mtimes on disk newer than the newest ones we've got. Calls C<new> to initialize the cache if it had not yet been called. Specifically, it will renew any module that was loaded before the previous call to C<refresh> (or C<new>) and has changed on disk since then. If a module was both loaded for the first time B<and> changed on disk between the previous call and this one, it will B<not> be reloaded by this call (or any future one); you will need to update the modification time again (by using the Unix C<touch> command or making a change to it) in order for it to be reloaded. =cut sub refresh { my $self = shift; return $self->new if !%CACHE; foreach my $mod ( sort keys %INC ) { $self->refresh_module_if_modified($mod); } return ($self); } =head2 refresh_module_if_modified $module If $module has been modified on disk, refresh it. Otherwise, do nothing =cut sub refresh_module_if_modified { my $self = shift; return $self->new if !%CACHE; my $mod = shift; if (!$INC{$mod}) { return; } elsif ( !$CACHE{$mod} ) { $self->update_cache($mod); } elsif ( $self->mtime( $INC{$mod} ) ne $CACHE{$mod} ) { $self->refresh_module($mod); } } =head2 refresh_module $module Refresh a module. It doesn't matter if it's already up to date. Just do it. Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->update_cache($mod); return ($self); } =head2 unload_module $module Remove a module from C<%INC>, and remove all subroutines defined in it. =cut sub unload_module { my $self = shift; my $mod = shift; my $file = $INC{$mod}; delete $INC{$mod}; delete $CACHE{$mod}; $self->unload_subs($file); return ($self); } =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat( $_[1] ) )[ 1, 7, 9 ]; } =head2 update_cache $file Updates the cached "last modified" time for $file. =cut sub update_cache { my $self = shift; my $module_pm = shift; # In case the module was not loaded successfully. return unless defined $INC{$module_pm}; $CACHE{$module_pm} = $self->mtime( $INC{$module_pm} ); } =head2 unload_subs $file Wipe out subs defined in $file. =cut sub unload_subs { my $self = shift; my $file = shift; foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { warn "Deleting $sym from $file" if ( $sym =~ /freeze/ ); eval { undef &$sym }; warn "$sym: $@" if $@; delete $DB::sub{$sym}; { no strict 'refs'; if ($sym =~ /^(.*::)(.*?)$/) { delete *{$1}->{$2}; } } } return $self; } # "Anonymize" all our subroutines into unnamed closures; so we can safely # refresh this very package. BEGIN { no strict 'refs'; foreach my $sym ( sort keys %{ __PACKAGE__ . '::' } ) { next if $sym eq 'VERSION'; # Skip the version sub, inherited from UNIVERSAL my $code = __PACKAGE__->can($sym) or next; delete ${ __PACKAGE__ . '::' }{$sym}; *$sym = sub { goto &$code }; } } 1; =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table properly, so we mess up on things like global variables that were previously set. =head1 SEE ALSO L<Apache::StatINC>, L<Module::Reload> =head1 COPYRIGHT Copyright 2004,2011 by Jesse Vincent E<lt>[email protected]<gt>, Audrey Tang E<lt>[email protected]<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<http://www.perl.com/perl/misc/Artistic.html> =cut
bestpractical/module-refresh
e107528829fb3630744d65691cded45cc9f3a5e8
Fix uninitialized warnings when modules were not successfully loaded
diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index 9893ed9..b69d95f 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,235 +1,238 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); $VERSION = "0.17"; BEGIN { # Turn on the debugger's symbol source tracing $^P |= 0x10; # Work around bug in pre-5.8.7 perl where turning on $^P # causes caller() to be confused about eval {}'s in the stack. # (See http://rt.perl.org/rt3/Ticket/Display.html?id=35059 for more info.) eval 'sub DB::sub' if $] < 5.008007; } =head1 NAME Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS # During each request, call this once to refresh changed modules: Module::Refresh->refresh; # Each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Acme/Current.pm'); =head1 DESCRIPTION This module is a generalization of the functionality provided by L<Apache::StatINC> and L<Apache::Reload>. It's designed to make it easy to do simple iterative development when working in a persistent environment. It does not require mod_perl. =cut =head2 new Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->update_cache($_) for keys %INC; return ($self); } =head2 refresh Refresh all modules that have mtimes on disk newer than the newest ones we've got. Calls C<new> to initialize the cache if it had not yet been called. Specifically, it will renew any module that was loaded before the previous call to C<refresh> (or C<new>) and has changed on disk since then. If a module was both loaded for the first time B<and> changed on disk between the previous call and this one, it will B<not> be reloaded by this call (or any future one); you will need to update the modification time again (by using the Unix C<touch> command or making a change to it) in order for it to be reloaded. =cut sub refresh { my $self = shift; return $self->new if !%CACHE; foreach my $mod ( sort keys %INC ) { $self->refresh_module_if_modified($mod); } return ($self); } =head2 refresh_module_if_modified $module If $module has been modified on disk, refresh it. Otherwise, do nothing =cut sub refresh_module_if_modified { my $self = shift; return $self->new if !%CACHE; my $mod = shift; if (!$INC{$mod}) { return; } elsif ( !$CACHE{$mod} ) { $self->update_cache($mod); } elsif ( $self->mtime( $INC{$mod} ) ne $CACHE{$mod} ) { $self->refresh_module($mod); } } =head2 refresh_module $module Refresh a module. It doesn't matter if it's already up to date. Just do it. Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->update_cache($mod); return ($self); } =head2 unload_module $module Remove a module from C<%INC>, and remove all subroutines defined in it. =cut sub unload_module { my $self = shift; my $mod = shift; my $file = $INC{$mod}; delete $INC{$mod}; delete $CACHE{$mod}; $self->unload_subs($file); return ($self); } =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat( $_[1] ) )[ 1, 7, 9 ]; } =head2 update_cache $file Updates the cached "last modified" time for $file. =cut sub update_cache { my $self = shift; my $module_pm = shift; + # In case the module was not loaded successfully. + return unless defined $INC{$module_pm}; + $CACHE{$module_pm} = $self->mtime( $INC{$module_pm} ); } =head2 unload_subs $file Wipe out subs defined in $file. =cut sub unload_subs { my $self = shift; my $file = shift; foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { warn "Deleting $sym from $file" if ( $sym =~ /freeze/ ); eval { undef &$sym }; warn "$sym: $@" if $@; delete $DB::sub{$sym}; { no strict 'refs'; if ($sym =~ /^(.*::)(.*?)$/) { delete *{$1}->{$2}; } } } return $self; } # "Anonymize" all our subroutines into unnamed closures; so we can safely # refresh this very package. BEGIN { no strict 'refs'; foreach my $sym ( sort keys %{ __PACKAGE__ . '::' } ) { next if $sym eq 'VERSION'; # Skip the version sub, inherited from UNIVERSAL my $code = __PACKAGE__->can($sym) or next; delete ${ __PACKAGE__ . '::' }{$sym}; *$sym = sub { goto &$code }; } } 1; =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table properly, so we mess up on things like global variables that were previously set. =head1 SEE ALSO L<Apache::StatINC>, L<Module::Reload> =head1 COPYRIGHT Copyright 2004,2011 by Jesse Vincent E<lt>[email protected]<gt>, Audrey Tang E<lt>[email protected]<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<http://www.perl.com/perl/misc/Artistic.html> =cut
bestpractical/module-refresh
b7122211fbb19ef589c45ea28f6a29979e55169e
Version 0.17 releng
diff --git a/Changes b/Changes index 38d4a21..bfb84a6 100644 --- a/Changes +++ b/Changes @@ -1,83 +1,88 @@ +0.17 Wed Oct 26 08:34:17 EST 2011 + + * Warnings avoidance for reloading a module not in %INC + * Updated inc/ and META.yml + 0.16 Fri Apr 15 15:03:21 EST 2011 - + * SIGNATURE file bug 0.15 Fri Apr 15 15:00:15 EST 2011 * No functional changes. Added missing test dependencies. Thanks to JQUELIN & Paul at City Fan 0.14 Tue Apr 12 18:07:44 EST 2011 * Actually remove subroutines from the symbol table, Thanks to DOY. 0.13 Thu May 3 23:03:00 EDT 2007 * Requires 5.8.1. (Uses tricks that don't work on 5.6). Thanks to DCANTRELL 0.12 Mon Apr 30 15:34:42 EDT 2007 * Requires 5.6. (Causes 5.5 to bus error). Thanks to RJBS. 0.11 Tue Apr 24 13:25:24 EDT 2007 * Fix for [rt.cpan.org #26536] Test suite uses /tmp with predictable filenames Reported by ANDK 0.10_01 Tue May 9 01:21:55 EDT 2006 * Module::Refresh->refresh_module_if_modified($module) as suggested by Daisuke Maki 0.09 Thu Dec 22 19:03:14 EST 2005 * Artur Bergman pointed out a bug in the overview docs. 0.08 * From Ivan Kohler. (rt.cpan.org #14879) Without this patch, I was getting a fatal error: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. This patch changes this to a warning and adds the name of the subroutine that triggered it. I now get the non-fatal warning: HTML::Mason::handler: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. 0.07 Sun Aug 21 13:25:20 EDT 2005 * Put in a work-around for a perl bug before 5.8.7. 0.06 Fri May 20 22:11:11 EDT 2005 * Trade overrefreshing for underrefreshing in some cases; test and document (We were over-aggressively reloading modules -- David Glasser 0.05 Tue Nov 16 23:15:10 EST 2004 * Explicitly, don't clobber the 'VERSION' symbol on setup. 0.04 Thu Nov 11 12:53:21 CST 2004 * Fix tests to run correctly on Win32. 0.03 Wed Nov 10 21:30:59 CST 2004 * "Anonymize" all our methods so we can refresh ourselves. * POD cleanup; nomenclature unification. * ->refresh now implicitly calls ->new for the first time. minor doc updates * Various cleanups to make it 5.005-friendly. * Use (inode, size, mtime) as the cache value instead of mtime alone. 0.02 Wed Nov 10 18:28:12 CST 2004 - Now we clean out subroutines loaded by the package we're unloading. 0.01 Mon Nov 8 19:48:00 CST 2004 - Initial release diff --git a/META.yml b/META.yml index e109212..307e6a9 100644 --- a/META.yml +++ b/META.yml @@ -1,11 +1,27 @@ -name: Module-Refresh -version: 0.01 -author: Jesse Vincent <[email protected]> -license: perl -distribution_type: module +--- +abstract: 'Refresh %INC files when updated on disk' +author: + - 'Jesse Vincent <[email protected]>' build_requires: + ExtUtils::MakeMaker: 6.42 + File::Temp: 0.19 + Path::Class: 0 Test::More: 0 +configure_requires: + ExtUtils::MakeMaker: 6.42 +distribution_type: module +generated_by: 'Module::Install version 1.01' +license: perl +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: 1.4 +name: Module-Refresh no_index: directory: - inc -generated_by: Module::Install version 0.36 + - t +requires: + perl: 5.8.1 +resources: + license: http://dev.perl.org/licenses/ +version: 0.17 diff --git a/Makefile.PL b/Makefile.PL index 9c343f7..310a636 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,12 +1,13 @@ use inc::Module::Install; requires( perl => '5.8.1'); name('Module-Refresh'); author('Jesse Vincent <[email protected]>'); license('perl'); version_from('lib/Module/Refresh.pm'); abstract_from('lib/Module/Refresh.pm'); build_requires ('Test::More' => 0, 'Path::Class' => 0, 'File::Temp' => "0.19", ); +sign; &WriteAll; diff --git a/SIGNATURE b/SIGNATURE index de78ad0..dae78a9 100644 --- a/SIGNATURE +++ b/SIGNATURE @@ -1,40 +1,40 @@ This file contains message digests of all files listed in MANIFEST, -signed via the Module::Signature module, version 0.66. +signed via the Module::Signature module, version 0.68. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -SHA1 3b6b523dfd11a462961d22ce70b78ae6df5fae7d Changes +SHA1 a4f3feed692a81d74a635d2bf286b97316ac3fcc Changes SHA1 68778c52d10c41f67e469665dd332886a6c628e6 MANIFEST -SHA1 b7486e3cbe8cb200c626c9c5c8e0a16b13affb0c META.yml -SHA1 2a1de49cf5174c72b89629051e8de4ac05b05bd4 Makefile.PL -SHA1 0de53a33616127f8680e6e4118741e80f354cd3e inc/Module/Install.pm -SHA1 11d43fa1484b63eb90b0a3a1b62dcb7e71060084 inc/Module/Install/Base.pm -SHA1 d3122b9f825c49da1184636699531ac0a7844da0 inc/Module/Install/Can.pm -SHA1 9f146b26e914b78d7f07559d1810bca6d96c2bc7 inc/Module/Install/Fetch.pm -SHA1 836dc65ebcb2913f5a7da77ddba4b6d46bd98f99 inc/Module/Install/Makefile.pm -SHA1 2d0fae3f1ecf71666075b39911cb4694b1310edd inc/Module/Install/Metadata.pm -SHA1 71c0f2e04d98c302c22d92b03ab8852f768b6431 inc/Module/Install/Win32.pm -SHA1 ea6fe523768b5c7d8a50528fbc18885bb0901d88 inc/Module/Install/WriteAll.pm -SHA1 a1e63fe6eb40f7c1429887654ef0c273e1e15420 lib/Module/Refresh.pm +SHA1 21ad6726ffa49bb496f518929755463ac851cd22 META.yml +SHA1 7dc0bf7724559c484f67e74284e7648b839846c5 Makefile.PL +SHA1 7b4ae50ebac72d20761171c4c2b50c206344ea40 inc/Module/Install.pm +SHA1 d9fe55a427fe2fd75b5029afeeaa61b592e07f79 inc/Module/Install/Base.pm +SHA1 62d3922826d9f89f20c185e7031ac8f028504745 inc/Module/Install/Can.pm +SHA1 dc809f64fb70a26b069a36f8d3d353d520dbb7e1 inc/Module/Install/Fetch.pm +SHA1 73ab91490a628452cc140db72ef9d13a1326d211 inc/Module/Install/Makefile.pm +SHA1 8ce3f2b414e4617e6233dd4ba10830f8c5d672ec inc/Module/Install/Metadata.pm +SHA1 3b0acd2eeac93a0afe48120f5648f0db362e5bbf inc/Module/Install/Win32.pm +SHA1 f08924f051e623f8e09fa6a121993c4a9cf7d9eb inc/Module/Install/WriteAll.pm +SHA1 f909a4d4184fd9010c9b297aa5a7657b79af5ade lib/Module/Refresh.pm SHA1 59ee3fb5cc33fa83f37010c6f1bbffc96169c3d4 t/0-smoke.t SHA1 9103ce09992aa9abff57823a090e109b1e9511a5 t/1api.t SHA1 d6fce094ee7fb7e800f646ac216dcc4a8a45f7db t/2lateuse.t SHA1 ca479c7b8ae0997a66d18c00216ac44c1346cbc4 t/clear_symtable.t -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) -iEYEARECAAYFAk2n0bQACgkQEi9d9xCOQEaiHQCfb9SPMjZShk3f/Q1Yb9kBbCyk -6qYAn0uFvaSX2gC6Os7WW+WkjWH2OBZW -=H1/Q +iEYEARECAAYFAk6n/x0ACgkQMflWJZZAbqDsGQCdHksIHXp4ZuLI4Hw3M96G4Twr +QBQAoJ+hLMllRyCs1OIPGcrOVocamEEd +=hM+z -----END PGP SIGNATURE----- diff --git a/inc/Module/Install.pm b/inc/Module/Install.pm index ed08a92..74caf9c 100644 --- a/inc/Module/Install.pm +++ b/inc/Module/Install.pm @@ -1,169 +1,470 @@ -#line 1 "inc/Module/Install.pm - /Library/Perl/5.8.1/Module/Install.pm" +#line 1 package Module::Install; -$VERSION = '0.36'; -die << "." unless $INC{join('/', inc => split(/::/, __PACKAGE__)).'.pm'}; +# For any maintainers: +# The load order for Module::Install is a bit magic. +# It goes something like this... +# +# IF ( host has Module::Install installed, creating author mode ) { +# 1. Makefile.PL calls "use inc::Module::Install" +# 2. $INC{inc/Module/Install.pm} set to installed version of inc::Module::Install +# 3. The installed version of inc::Module::Install loads +# 4. inc::Module::Install calls "require Module::Install" +# 5. The ./inc/ version of Module::Install loads +# } ELSE { +# 1. Makefile.PL calls "use inc::Module::Install" +# 2. $INC{inc/Module/Install.pm} set to ./inc/ version of Module::Install +# 3. The ./inc/ version of Module::Install loads +# } + +use 5.005; +use strict 'vars'; +use Cwd (); +use File::Find (); +use File::Path (); + +use vars qw{$VERSION $MAIN}; +BEGIN { + # All Module::Install core packages now require synchronised versions. + # This will be used to ensure we don't accidentally load old or + # different versions of modules. + # This is not enforced yet, but will be some time in the next few + # releases once we can make sure it won't clash with custom + # Module::Install extensions. + $VERSION = '1.01'; + + # Storage for the pseudo-singleton + $MAIN = undef; + + *inc::Module::Install::VERSION = *VERSION; + @inc::Module::Install::ISA = __PACKAGE__; + +} + +sub import { + my $class = shift; + my $self = $class->new(@_); + my $who = $self->_caller; + + #------------------------------------------------------------- + # all of the following checks should be included in import(), + # to allow "eval 'require Module::Install; 1' to test + # installation of Module::Install. (RT #51267) + #------------------------------------------------------------- + + # Whether or not inc::Module::Install is actually loaded, the + # $INC{inc/Module/Install.pm} is what will still get set as long as + # the caller loaded module this in the documented manner. + # If not set, the caller may NOT have loaded the bundled version, and thus + # they may not have a MI version that works with the Makefile.PL. This would + # result in false errors or unexpected behaviour. And we don't want that. + my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm'; + unless ( $INC{$file} ) { die <<"END_DIE" } + Please invoke ${\__PACKAGE__} with: - use inc::${\__PACKAGE__}; + use inc::${\__PACKAGE__}; not: - use ${\__PACKAGE__}; + use ${\__PACKAGE__}; -. +END_DIE -use strict 'vars'; -use Cwd (); -use File::Find (); -use File::Path (); + # This reportedly fixes a rare Win32 UTC file time issue, but + # as this is a non-cross-platform XS module not in the core, + # we shouldn't really depend on it. See RT #24194 for detail. + # (Also, this module only supports Perl 5.6 and above). + eval "use Win32::UTCFileTime" if $^O eq 'MSWin32' && $] >= 5.006; -@inc::Module::Install::ISA = 'Module::Install'; -*inc::Module::Install::VERSION = *VERSION; + # If the script that is loading Module::Install is from the future, + # then make will detect this and cause it to re-run over and over + # again. This is bad. Rather than taking action to touch it (which + # is unreliable on some platforms and requires write permissions) + # for now we should catch this and refuse to run. + if ( -f $0 ) { + my $s = (stat($0))[9]; -#line 129 + # If the modification time is only slightly in the future, + # sleep briefly to remove the problem. + my $a = $s - time; + if ( $a > 0 and $a < 5 ) { sleep 5 } -sub import { - my $class = shift; - my $self = $class->new(@_); + # Too far in the future, throw an error. + my $t = time; + if ( $s > $t ) { die <<"END_DIE" } - if (not -f $self->{file}) { - require "$self->{path}/$self->{dispatch}.pm"; - File::Path::mkpath("$self->{prefix}/$self->{author}"); - $self->{admin} = - "$self->{name}::$self->{dispatch}"->new(_top => $self); - $self->{admin}->init; - @_ = ($class, _self => $self); - goto &{"$self->{name}::import"}; - } +Your installer $0 has a modification time in the future ($s > $t). - *{caller(0) . "::AUTOLOAD"} = $self->autoload; +This is known to create infinite loops in make. - # Unregister loader and worker packages so subdirs can use them again - delete $INC{"$self->{file}"}; - delete $INC{"$self->{path}.pm"}; -} +Please correct this, then run $0 again. -#line 156 +END_DIE + } -sub autoload { - my $self = shift; - my $caller = caller; - my $cwd = Cwd::cwd(); - my $sym = "$caller\::AUTOLOAD"; + # Build.PL was formerly supported, but no longer is due to excessive + # difficulty in implementing every single feature twice. + if ( $0 =~ /Build.PL$/i ) { die <<"END_DIE" } - $sym->{$cwd} = sub { - my $pwd = Cwd::cwd(); - if (my $code = $sym->{$pwd}) { - goto &$code unless $cwd eq $pwd; # delegate back to parent dirs - } - $$sym =~ /([^:]+)$/ or die "Cannot autoload $caller"; - unshift @_, ($self, $1); - goto &{$self->can('call')} unless uc($1) eq $1; - }; -} +Module::Install no longer supports Build.PL. -#line 181 +It was impossible to maintain duel backends, and has been deprecated. -sub new { - my ($class, %args) = @_; +Please remove all Build.PL files and only use the Makefile.PL installer. - return $args{_self} if $args{_self}; +END_DIE - $args{dispatch} ||= 'Admin'; - $args{prefix} ||= 'inc'; - $args{author} ||= '.author'; - $args{bundle} ||= 'inc/BUNDLES'; + #------------------------------------------------------------- - $class =~ s/^\Q$args{prefix}\E:://; - $args{name} ||= $class; - $args{version} ||= $class->VERSION; + # To save some more typing in Module::Install installers, every... + # use inc::Module::Install + # ...also acts as an implicit use strict. + $^H |= strict::bits(qw(refs subs vars)); - unless ($args{path}) { - $args{path} = $args{name}; - $args{path} =~ s!::!/!g; - } - $args{file} ||= "$args{prefix}/$args{path}.pm"; + #------------------------------------------------------------- - bless(\%args, $class); + unless ( -f $self->{file} ) { + foreach my $key (keys %INC) { + delete $INC{$key} if $key =~ /Module\/Install/; + } + + local $^W; + require "$self->{path}/$self->{dispatch}.pm"; + File::Path::mkpath("$self->{prefix}/$self->{author}"); + $self->{admin} = "$self->{name}::$self->{dispatch}"->new( _top => $self ); + $self->{admin}->init; + @_ = ($class, _self => $self); + goto &{"$self->{name}::import"}; + } + + local $^W; + *{"${who}::AUTOLOAD"} = $self->autoload; + $self->preload; + + # Unregister loader and worker packages so subdirs can use them again + delete $INC{'inc/Module/Install.pm'}; + delete $INC{'Module/Install.pm'}; + + # Save to the singleton + $MAIN = $self; + + return 1; } -#line 210 +sub autoload { + my $self = shift; + my $who = $self->_caller; + my $cwd = Cwd::cwd(); + my $sym = "${who}::AUTOLOAD"; + $sym->{$cwd} = sub { + my $pwd = Cwd::cwd(); + if ( my $code = $sym->{$pwd} ) { + # Delegate back to parent dirs + goto &$code unless $cwd eq $pwd; + } + unless ($$sym =~ s/([^:]+)$//) { + # XXX: it looks like we can't retrieve the missing function + # via $$sym (usually $main::AUTOLOAD) in this case. + # I'm still wondering if we should slurp Makefile.PL to + # get some context or not ... + my ($package, $file, $line) = caller; + die <<"EOT"; +Unknown function is found at $file line $line. +Execution of $file aborted due to runtime errors. + +If you're a contributor to a project, you may need to install +some Module::Install extensions from CPAN (or other repository). +If you're a user of a module, please contact the author. +EOT + } + my $method = $1; + if ( uc($method) eq $method ) { + # Do nothing + return; + } elsif ( $method =~ /^_/ and $self->can($method) ) { + # Dispatch to the root M:I class + return $self->$method(@_); + } + + # Dispatch to the appropriate plugin + unshift @_, ( $self, $1 ); + goto &{$self->can('call')}; + }; +} -sub call { - my $self = shift; - my $method = shift; - my $obj = $self->load($method) or return; +sub preload { + my $self = shift; + unless ( $self->{extensions} ) { + $self->load_extensions( + "$self->{prefix}/$self->{path}", $self + ); + } + + my @exts = @{$self->{extensions}}; + unless ( @exts ) { + @exts = $self->{admin}->load_all_extensions; + } + + my %seen; + foreach my $obj ( @exts ) { + while (my ($method, $glob) = each %{ref($obj) . '::'}) { + next unless $obj->can($method); + next if $method =~ /^_/; + next if $method eq uc($method); + $seen{$method}++; + } + } + + my $who = $self->_caller; + foreach my $name ( sort keys %seen ) { + local $^W; + *{"${who}::$name"} = sub { + ${"${who}::AUTOLOAD"} = "${who}::$name"; + goto &{"${who}::AUTOLOAD"}; + }; + } +} - unshift @_, $obj; - goto &{$obj->can($method)}; +sub new { + my ($class, %args) = @_; + + delete $INC{'FindBin.pm'}; + { + # to suppress the redefine warning + local $SIG{__WARN__} = sub {}; + require FindBin; + } + + # ignore the prefix on extension modules built from top level. + my $base_path = Cwd::abs_path($FindBin::Bin); + unless ( Cwd::abs_path(Cwd::cwd()) eq $base_path ) { + delete $args{prefix}; + } + return $args{_self} if $args{_self}; + + $args{dispatch} ||= 'Admin'; + $args{prefix} ||= 'inc'; + $args{author} ||= ($^O eq 'VMS' ? '_author' : '.author'); + $args{bundle} ||= 'inc/BUNDLES'; + $args{base} ||= $base_path; + $class =~ s/^\Q$args{prefix}\E:://; + $args{name} ||= $class; + $args{version} ||= $class->VERSION; + unless ( $args{path} ) { + $args{path} = $args{name}; + $args{path} =~ s!::!/!g; + } + $args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm"; + $args{wrote} = 0; + + bless( \%args, $class ); } -#line 225 +sub call { + my ($self, $method) = @_; + my $obj = $self->load($method) or return; + splice(@_, 0, 2, $obj); + goto &{$obj->can($method)}; +} sub load { - my ($self, $method) = @_; + my ($self, $method) = @_; - $self->load_extensions( - "$self->{prefix}/$self->{path}", $self - ) unless $self->{extensions}; + $self->load_extensions( + "$self->{prefix}/$self->{path}", $self + ) unless $self->{extensions}; - foreach my $obj (@{$self->{extensions}}) { - return $obj if $obj->can($method); - } + foreach my $obj (@{$self->{extensions}}) { + return $obj if $obj->can($method); + } - my $admin = $self->{admin} or die << "END"; + my $admin = $self->{admin} or die <<"END_DIE"; The '$method' method does not exist in the '$self->{prefix}' path! Please remove the '$self->{prefix}' directory and run $0 again to load it. -END +END_DIE - my $obj = $admin->load($method, 1); - push @{$self->{extensions}}, $obj; + my $obj = $admin->load($method, 1); + push @{$self->{extensions}}, $obj; - $obj; + $obj; } -#line 255 - sub load_extensions { - my ($self, $path, $top_obj) = @_; + my ($self, $path, $top) = @_; + + my $should_reload = 0; + unless ( grep { ! ref $_ and lc $_ eq lc $self->{prefix} } @INC ) { + unshift @INC, $self->{prefix}; + $should_reload = 1; + } + + foreach my $rv ( $self->find_extensions($path) ) { + my ($file, $pkg) = @{$rv}; + next if $self->{pathnames}{$pkg}; + + local $@; + my $new = eval { local $^W; require $file; $pkg->can('new') }; + unless ( $new ) { + warn $@ if $@; + next; + } + $self->{pathnames}{$pkg} = + $should_reload ? delete $INC{$file} : $INC{$file}; + push @{$self->{extensions}}, &{$new}($pkg, _top => $top ); + } + + $self->{extensions} ||= []; +} + +sub find_extensions { + my ($self, $path) = @_; + + my @found; + File::Find::find( sub { + my $file = $File::Find::name; + return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is; + my $subpath = $1; + return if lc($subpath) eq lc($self->{dispatch}); + + $file = "$self->{path}/$subpath.pm"; + my $pkg = "$self->{name}::$subpath"; + $pkg =~ s!/!::!g; + + # If we have a mixed-case package name, assume case has been preserved + # correctly. Otherwise, root through the file to locate the case-preserved + # version of the package name. + if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) { + my $content = Module::Install::_read($subpath . '.pm'); + my $in_pod = 0; + foreach ( split //, $content ) { + $in_pod = 1 if /^=\w/; + $in_pod = 0 if /^=cut/; + next if ($in_pod || /^=cut/); # skip pod text + next if /^\s*#/; # and comments + if ( m/^\s*package\s+($pkg)\s*;/i ) { + $pkg = $1; + last; + } + } + } + + push @found, [ $file, $pkg ]; + }, $path ) if -d $path; + + @found; +} + - unshift @INC, $self->{prefix} - unless grep { $_ eq $self->{prefix} } @INC; - local @INC = ($path, @INC); - foreach my $rv ($self->find_extensions($path)) { - my ($file, $pkg) = @{$rv}; - next if $self->{pathnames}{$pkg}; - eval { require $file; 1 } or (warn($@), next); - $self->{pathnames}{$pkg} = delete $INC{$file}; - push @{$self->{extensions}}, $pkg->new( _top => $top_obj ); - } + +##################################################################### +# Common Utility Functions + +sub _caller { + my $depth = 0; + my $call = caller($depth); + while ( $call eq __PACKAGE__ ) { + $depth++; + $call = caller($depth); + } + return $call; } -#line 279 +# Done in evals to avoid confusing Perl::MinimumVersion +eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@; +sub _read { + local *FH; + open( FH, '<', $_[0] ) or die "open($_[0]): $!"; + my $string = do { local $/; <FH> }; + close FH or die "close($_[0]): $!"; + return $string; +} +END_NEW +sub _read { + local *FH; + open( FH, "< $_[0]" ) or die "open($_[0]): $!"; + my $string = do { local $/; <FH> }; + close FH or die "close($_[0]): $!"; + return $string; +} +END_OLD + +sub _readperl { + my $string = Module::Install::_read($_[0]); + $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; + $string =~ s/(\n)\n*__(?:DATA|END)__\b.*\z/$1/s; + $string =~ s/\n\n=\w+.+?\n\n=cut\b.+?\n+/\n\n/sg; + return $string; +} -sub find_extensions { - my ($self, $path) = @_; - my @found; +sub _readpod { + my $string = Module::Install::_read($_[0]); + $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; + return $string if $_[0] =~ /\.pod\z/; + $string =~ s/(^|\n=cut\b.+?\n+)[^=\s].+?\n(\n=\w+|\z)/$1$2/sg; + $string =~ s/\n*=pod\b[^\n]*\n+/\n\n/sg; + $string =~ s/\n*=cut\b[^\n]*\n+/\n\n/sg; + $string =~ s/^\n+//s; + return $string; +} - File::Find::find(sub { - my $file = $File::Find::name; - return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is; - return if $1 eq $self->{dispatch}; +# Done in evals to avoid confusing Perl::MinimumVersion +eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@; +sub _write { + local *FH; + open( FH, '>', $_[0] ) or die "open($_[0]): $!"; + foreach ( 1 .. $#_ ) { + print FH $_[$_] or die "print($_[0]): $!"; + } + close FH or die "close($_[0]): $!"; +} +END_NEW +sub _write { + local *FH; + open( FH, "> $_[0]" ) or die "open($_[0]): $!"; + foreach ( 1 .. $#_ ) { + print FH $_[$_] or die "print($_[0]): $!"; + } + close FH or die "close($_[0]): $!"; +} +END_OLD + +# _version is for processing module versions (eg, 1.03_05) not +# Perl versions (eg, 5.8.1). +sub _version ($) { + my $s = shift || 0; + my $d =()= $s =~ /(\.)/g; + if ( $d >= 2 ) { + # Normalise multipart versions + $s =~ s/(\.)(\d{1,3})/sprintf("$1%03d",$2)/eg; + } + $s =~ s/^(\d+)\.?//; + my $l = $1 || 0; + my @v = map { + $_ . '0' x (3 - length $_) + } $s =~ /(\d{1,3})\D?/g; + $l = $l . '.' . join '', @v if @v; + return $l + 0; +} - $file = "$self->{path}/$1.pm"; - my $pkg = "$self->{name}::$1"; $pkg =~ s!/!::!g; - push @found, [$file, $pkg]; - }, $path) if -d $path; +sub _cmp ($$) { + _version($_[0]) <=> _version($_[1]); +} - @found; +# Cloned from Params::Util::_CLASS +sub _CLASS ($) { + ( + defined $_[0] + and + ! ref $_[0] + and + $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s + ) ? $_[0] : undef; } 1; -__END__ - -#line 617 +# Copyright 2008 - 2011 Adam Kennedy. diff --git a/inc/Module/Install/Base.pm b/inc/Module/Install/Base.pm index 826be07..d3662c9 100644 --- a/inc/Module/Install/Base.pm +++ b/inc/Module/Install/Base.pm @@ -1,54 +1,83 @@ -#line 1 "inc/Module/Install/Base.pm - /Library/Perl/5.8.1/Module/Install/Base.pm" +#line 1 package Module::Install::Base; -#line 28 +use strict 'vars'; +use vars qw{$VERSION}; +BEGIN { + $VERSION = '1.01'; +} -sub new { - my ($class, %args) = @_; +# Suspend handler for "redefined" warnings +BEGIN { + my $w = $SIG{__WARN__}; + $SIG{__WARN__} = sub { $w }; +} - foreach my $method (qw(call load)) { - *{"$class\::$method"} = sub { - +shift->_top->$method(@_); - } unless defined &{"$class\::$method"}; - } +#line 42 - bless(\%args, $class); +sub new { + my $class = shift; + unless ( defined &{"${class}::call"} ) { + *{"${class}::call"} = sub { shift->_top->call(@_) }; + } + unless ( defined &{"${class}::load"} ) { + *{"${class}::load"} = sub { shift->_top->load(@_) }; + } + bless { @_ }, $class; } -#line 46 +#line 61 sub AUTOLOAD { - my $self = shift; - goto &{$self->_top->autoload}; + local $@; + my $func = eval { shift->_top->autoload } or return; + goto &$func; } -#line 57 +#line 75 -sub _top { $_[0]->{_top} } +sub _top { + $_[0]->{_top}; +} -#line 68 +#line 90 sub admin { - my $self = shift; - $self->_top->{admin} or Module::Install::Base::FakeAdmin->new; + $_[0]->_top->{admin} + or + Module::Install::Base::FakeAdmin->new; } +#line 106 + sub is_admin { - my $self = shift; - $self->admin->VERSION; + ! $_[0]->admin->isa('Module::Install::Base::FakeAdmin'); } sub DESTROY {} package Module::Install::Base::FakeAdmin; -my $Fake; -sub new { $Fake ||= bless(\@_, $_[0]) } +use vars qw{$VERSION}; +BEGIN { + $VERSION = $Module::Install::Base::VERSION; +} + +my $fake; + +sub new { + $fake ||= bless(\@_, $_[0]); +} + sub AUTOLOAD {} + sub DESTROY {} -1; +# Restore warning handler +BEGIN { + $SIG{__WARN__} = $SIG{__WARN__}->(); +} -__END__ +1; -#line 112 +#line 159 diff --git a/inc/Module/Install/Can.pm b/inc/Module/Install/Can.pm index 64202a8..276409a 100644 --- a/inc/Module/Install/Can.pm +++ b/inc/Module/Install/Can.pm @@ -1,38 +1,81 @@ -#line 1 "inc/Module/Install/Can.pm - /Library/Perl/5.8.1/Module/Install/Can.pm" +#line 1 package Module::Install::Can; -use Module::Install::Base; @ISA = qw(Module::Install::Base); -$VERSION = '0.01'; use strict; -use Config (); -use File::Spec (); -use ExtUtils::MakeMaker (); +use Config (); +use File::Spec (); +use ExtUtils::MakeMaker (); +use Module::Install::Base (); + +use vars qw{$VERSION @ISA $ISCORE}; +BEGIN { + $VERSION = '1.01'; + @ISA = 'Module::Install::Base'; + $ISCORE = 1; +} + +# check if we can load some module +### Upgrade this to not have to load the module if possible +sub can_use { + my ($self, $mod, $ver) = @_; + $mod =~ s{::|\\}{/}g; + $mod .= '.pm' unless $mod =~ /\.pm$/i; + + my $pkg = $mod; + $pkg =~ s{/}{::}g; + $pkg =~ s{\.pm$}{}i; + + local $@; + eval { require $mod; $pkg->VERSION($ver || 0); 1 }; +} # check if we can run some command sub can_run { - my ($self, $cmd) = @_; + my ($self, $cmd) = @_; - my $_cmd = $cmd; - return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd)); + my $_cmd = $cmd; + return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd)); - for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { - my $abs = File::Spec->catfile($dir, $_[1]); - return $abs if (-x $abs or $abs = MM->maybe_command($abs)); - } + for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { + next if $dir eq ''; + my $abs = File::Spec->catfile($dir, $_[1]); + return $abs if (-x $abs or $abs = MM->maybe_command($abs)); + } - return; + return; } +# can we locate a (the) C compiler sub can_cc { - my $self = shift; - my @chunks = split(/ /, $Config::Config{cc}) or return; + my $self = shift; + my @chunks = split(/ /, $Config::Config{cc}) or return; + + # $Config{cc} may contain args; try to find out the program part + while (@chunks) { + return $self->can_run("@chunks") || (pop(@chunks), next); + } - # $Config{cc} may contain args; try to find out the program part - while (@chunks) { - return $self->can_run("@chunks") || (pop(@chunks), next); - } + return; +} - return; +# Fix Cygwin bug on maybe_command(); +if ( $^O eq 'cygwin' ) { + require ExtUtils::MM_Cygwin; + require ExtUtils::MM_Win32; + if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) { + *ExtUtils::MM_Cygwin::maybe_command = sub { + my ($self, $file) = @_; + if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) { + ExtUtils::MM_Win32->maybe_command($file); + } else { + ExtUtils::MM_Unix->maybe_command($file); + } + } + } } 1; + +__END__ + +#line 156 diff --git a/inc/Module/Install/Fetch.pm b/inc/Module/Install/Fetch.pm index 9b76e7e..093cb7a 100644 --- a/inc/Module/Install/Fetch.pm +++ b/inc/Module/Install/Fetch.pm @@ -1,86 +1,93 @@ -#line 1 "inc/Module/Install/Fetch.pm - /Library/Perl/5.8.1/Module/Install/Fetch.pm" +#line 1 package Module::Install::Fetch; -use Module::Install::Base; @ISA = qw(Module::Install::Base); -$VERSION = '0.01'; +use strict; +use Module::Install::Base (); + +use vars qw{$VERSION @ISA $ISCORE}; +BEGIN { + $VERSION = '1.01'; + @ISA = 'Module::Install::Base'; + $ISCORE = 1; +} sub get_file { my ($self, %args) = @_; - my ($scheme, $host, $path, $file) = + my ($scheme, $host, $path, $file) = $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; - if ($scheme eq 'http' and !eval { require LWP::Simple; 1 }) { + if ( $scheme eq 'http' and ! eval { require LWP::Simple; 1 } ) { $args{url} = $args{ftp_url} or (warn("LWP support unavailable!\n"), return); - ($scheme, $host, $path, $file) = + ($scheme, $host, $path, $file) = $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; } $|++; print "Fetching '$file' from $host... "; unless (eval { require Socket; Socket::inet_aton($host) }) { warn "'$host' resolve failed!\n"; return; } return unless $scheme eq 'ftp' or $scheme eq 'http'; require Cwd; my $dir = Cwd::getcwd(); chdir $args{local_dir} or return if exists $args{local_dir}; if (eval { require LWP::Simple; 1 }) { LWP::Simple::mirror($args{url}, $file); } elsif (eval { require Net::FTP; 1 }) { eval { # use Net::FTP to get past firewall my $ftp = Net::FTP->new($host, Passive => 1, Timeout => 600); $ftp->login("anonymous", '[email protected]'); $ftp->cwd($path); $ftp->binary; $ftp->get($file) or (warn("$!\n"), return); $ftp->quit; } } elsif (my $ftp = $self->can_run('ftp')) { eval { # no Net::FTP, fallback to ftp.exe require FileHandle; my $fh = FileHandle->new; local $SIG{CHLD} = 'IGNORE'; unless ($fh->open("|$ftp -n")) { warn "Couldn't open ftp: $!\n"; chdir $dir; return; } - my @dialog = split(/\n/, << "."); + my @dialog = split(/\n/, <<"END_FTP"); open $host user anonymous anonymous\@example.com cd $path binary get $file $file quit -. +END_FTP foreach (@dialog) { $fh->print("$_\n") } $fh->close; } } else { warn "No working 'ftp' program available!\n"; chdir $dir; return; } unless (-f $file) { warn "Fetching failed: $@\n"; chdir $dir; return; } return if exists $args{size} and -s $file != $args{size}; system($args{run}) if exists $args{run}; unlink($file) if $args{remove}; print(((!exists $args{check_for} or -e $args{check_for}) ? "done!" : "failed! ($!)"), "\n"); chdir $dir; return !$?; } 1; diff --git a/inc/Module/Install/Makefile.pm b/inc/Module/Install/Makefile.pm index e2f7e39..4c71003 100644 --- a/inc/Module/Install/Makefile.pm +++ b/inc/Module/Install/Makefile.pm @@ -1,143 +1,415 @@ -#line 1 "inc/Module/Install/Makefile.pm - /Library/Perl/5.8.1/Module/Install/Makefile.pm" +#line 1 package Module::Install::Makefile; -use Module::Install::Base; @ISA = qw(Module::Install::Base); - -$VERSION = '0.01'; use strict 'vars'; -use vars '$VERSION'; - -use ExtUtils::MakeMaker (); +use ExtUtils::MakeMaker (); +use Module::Install::Base (); +use Fcntl qw/:flock :seek/; + +use vars qw{$VERSION @ISA $ISCORE}; +BEGIN { + $VERSION = '1.01'; + @ISA = 'Module::Install::Base'; + $ISCORE = 1; +} sub Makefile { $_[0] } -sub prompt { - shift; - goto &ExtUtils::MakeMaker::prompt; -} +my %seen = (); -sub makemaker_args { - my $self = shift; - my $args = ($self->{makemaker_args} ||= {}); - %$args = ( %$args, @_ ) if @_; - $args; -} +sub prompt { + shift; -sub clean_files { - my $self = shift; - my $clean = $self->makemaker_args->{clean} ||= {}; - %$clean = ( - %$clean, - FILES => join(" ", grep length, $clean->{FILES}, @_), - ); -} + # Infinite loop protection + my @c = caller(); + if ( ++$seen{"$c[1]|$c[2]|$_[0]"} > 3 ) { + die "Caught an potential prompt infinite loop ($c[1]|$c[2]|$_[0])"; + } -sub libs { - my $self = shift; - my $libs = ref $_[0] ? shift : [shift]; - $self->makemaker_args( LIBS => $libs ); + # In automated testing or non-interactive session, always use defaults + if ( ($ENV{AUTOMATED_TESTING} or -! -t STDIN) and ! $ENV{PERL_MM_USE_DEFAULT} ) { + local $ENV{PERL_MM_USE_DEFAULT} = 1; + goto &ExtUtils::MakeMaker::prompt; + } else { + goto &ExtUtils::MakeMaker::prompt; + } } -sub inc { - my $self = shift; - $self->makemaker_args( INC => shift ); +# Store a cleaned up version of the MakeMaker version, +# since we need to behave differently in a variety of +# ways based on the MM version. +my $makemaker = eval $ExtUtils::MakeMaker::VERSION; + +# If we are passed a param, do a "newer than" comparison. +# Otherwise, just return the MakeMaker version. +sub makemaker { + ( @_ < 2 or $makemaker >= eval($_[1]) ) ? $makemaker : 0 } -sub write { - my $self = shift; - die "&Makefile->write() takes no arguments\n" if @_; +# Ripped from ExtUtils::MakeMaker 6.56, and slightly modified +# as we only need to know here whether the attribute is an array +# or a hash or something else (which may or may not be appendable). +my %makemaker_argtype = ( + C => 'ARRAY', + CONFIG => 'ARRAY', +# CONFIGURE => 'CODE', # ignore + DIR => 'ARRAY', + DL_FUNCS => 'HASH', + DL_VARS => 'ARRAY', + EXCLUDE_EXT => 'ARRAY', + EXE_FILES => 'ARRAY', + FUNCLIST => 'ARRAY', + H => 'ARRAY', + IMPORTS => 'HASH', + INCLUDE_EXT => 'ARRAY', + LIBS => 'ARRAY', # ignore '' + MAN1PODS => 'HASH', + MAN3PODS => 'HASH', + META_ADD => 'HASH', + META_MERGE => 'HASH', + PL_FILES => 'HASH', + PM => 'HASH', + PMLIBDIRS => 'ARRAY', + PMLIBPARENTDIRS => 'ARRAY', + PREREQ_PM => 'HASH', + CONFIGURE_REQUIRES => 'HASH', + SKIP => 'ARRAY', + TYPEMAPS => 'ARRAY', + XS => 'HASH', +# VERSION => ['version',''], # ignore +# _KEEP_AFTER_FLUSH => '', + + clean => 'HASH', + depend => 'HASH', + dist => 'HASH', + dynamic_lib=> 'HASH', + linkext => 'HASH', + macro => 'HASH', + postamble => 'HASH', + realclean => 'HASH', + test => 'HASH', + tool_autosplit => 'HASH', + + # special cases where you can use makemaker_append + CCFLAGS => 'APPENDABLE', + DEFINE => 'APPENDABLE', + INC => 'APPENDABLE', + LDDLFLAGS => 'APPENDABLE', + LDFROM => 'APPENDABLE', +); - my $args = $self->makemaker_args; +sub makemaker_args { + my ($self, %new_args) = @_; + my $args = ( $self->{makemaker_args} ||= {} ); + foreach my $key (keys %new_args) { + if ($makemaker_argtype{$key}) { + if ($makemaker_argtype{$key} eq 'ARRAY') { + $args->{$key} = [] unless defined $args->{$key}; + unless (ref $args->{$key} eq 'ARRAY') { + $args->{$key} = [$args->{$key}] + } + push @{$args->{$key}}, + ref $new_args{$key} eq 'ARRAY' + ? @{$new_args{$key}} + : $new_args{$key}; + } + elsif ($makemaker_argtype{$key} eq 'HASH') { + $args->{$key} = {} unless defined $args->{$key}; + foreach my $skey (keys %{ $new_args{$key} }) { + $args->{$key}{$skey} = $new_args{$key}{$skey}; + } + } + elsif ($makemaker_argtype{$key} eq 'APPENDABLE') { + $self->makemaker_append($key => $new_args{$key}); + } + } + else { + if (defined $args->{$key}) { + warn qq{MakeMaker attribute "$key" is overriden; use "makemaker_append" to append values\n}; + } + $args->{$key} = $new_args{$key}; + } + } + return $args; +} - $args->{DISTNAME} = $self->name; - $args->{NAME} = $self->module_name || $self->name || $self->determine_NAME($args); - $args->{VERSION} = $self->version || $self->determine_VERSION($args); - $args->{NAME} =~ s/-/::/g; +# For mm args that take multiple space-seperated args, +# append an argument to the current list. +sub makemaker_append { + my $self = shift; + my $name = shift; + my $args = $self->makemaker_args; + $args->{$name} = defined $args->{$name} + ? join( ' ', $args->{$name}, @_ ) + : join( ' ', @_ ); +} - if ($] >= 5.005) { - $args->{ABSTRACT} = $self->abstract; - $args->{AUTHOR} = $self->author; - } - if ( eval($ExtUtils::MakeMaker::VERSION) >= 6.10 ) { - $args->{NO_META} = 1; - } - if ( eval($ExtUtils::MakeMaker::VERSION) > 6.17 ) { - $args->{SIGN} = 1 if $self->sign; - } - delete $args->{SIGN} unless $self->is_admin; +sub build_subdirs { + my $self = shift; + my $subdirs = $self->makemaker_args->{DIR} ||= []; + for my $subdir (@_) { + push @$subdirs, $subdir; + } +} - # merge both kinds of requires into prereq_pm - my $prereq = ($args->{PREREQ_PM} ||= {}); - %$prereq = ( %$prereq, map { @$_ } map { @$_ } grep $_, - ($self->build_requires, $self->requires) ); +sub clean_files { + my $self = shift; + my $clean = $self->makemaker_args->{clean} ||= {}; + %$clean = ( + %$clean, + FILES => join ' ', grep { length $_ } ($clean->{FILES} || (), @_), + ); +} - # merge both kinds of requires into prereq_pm - my $dir = ($args->{DIR} ||= []); - if ($self->bundles) { - push @$dir, map "$_->[1]", @{$self->bundles}; - delete $prereq->{$_->[0]} for @{$self->bundles}; - } +sub realclean_files { + my $self = shift; + my $realclean = $self->makemaker_args->{realclean} ||= {}; + %$realclean = ( + %$realclean, + FILES => join ' ', grep { length $_ } ($realclean->{FILES} || (), @_), + ); +} - if (my $perl_version = $self->perl_version) { - eval "use $perl_version; 1" - or die "ERROR: perl: Version $] is installed, ". - "but we need version >= $perl_version"; - } +sub libs { + my $self = shift; + my $libs = ref $_[0] ? shift : [ shift ]; + $self->makemaker_args( LIBS => $libs ); +} - my %args = map {($_ => $args->{$_})} grep {defined($args->{$_})} keys %$args; +sub inc { + my $self = shift; + $self->makemaker_args( INC => shift ); +} - if ($self->admin->preop) { - $args{dist} = $self->admin->preop; - } +sub _wanted_t { +} - ExtUtils::MakeMaker::WriteMakefile(%args); +sub tests_recursive { + my $self = shift; + my $dir = shift || 't'; + unless ( -d $dir ) { + die "tests_recursive dir '$dir' does not exist"; + } + my %tests = map { $_ => 1 } split / /, ($self->tests || ''); + require File::Find; + File::Find::find( + sub { /\.t$/ and -f $_ and $tests{"$File::Find::dir/*.t"} = 1 }, + $dir + ); + $self->tests( join ' ', sort keys %tests ); +} - $self->fix_up_makefile(); +sub write { + my $self = shift; + die "&Makefile->write() takes no arguments\n" if @_; + + # Check the current Perl version + my $perl_version = $self->perl_version; + if ( $perl_version ) { + eval "use $perl_version; 1" + or die "ERROR: perl: Version $] is installed, " + . "but we need version >= $perl_version"; + } + + # Make sure we have a new enough MakeMaker + require ExtUtils::MakeMaker; + + if ( $perl_version and $self->_cmp($perl_version, '5.006') >= 0 ) { + # MakeMaker can complain about module versions that include + # an underscore, even though its own version may contain one! + # Hence the funny regexp to get rid of it. See RT #35800 + # for details. + my $v = $ExtUtils::MakeMaker::VERSION =~ /^(\d+\.\d+)/; + $self->build_requires( 'ExtUtils::MakeMaker' => $v ); + $self->configure_requires( 'ExtUtils::MakeMaker' => $v ); + } else { + # Allow legacy-compatibility with 5.005 by depending on the + # most recent EU:MM that supported 5.005. + $self->build_requires( 'ExtUtils::MakeMaker' => 6.42 ); + $self->configure_requires( 'ExtUtils::MakeMaker' => 6.42 ); + } + + # Generate the MakeMaker params + my $args = $self->makemaker_args; + $args->{DISTNAME} = $self->name; + $args->{NAME} = $self->module_name || $self->name; + $args->{NAME} =~ s/-/::/g; + $args->{VERSION} = $self->version or die <<'EOT'; +ERROR: Can't determine distribution version. Please specify it +explicitly via 'version' in Makefile.PL, or set a valid $VERSION +in a module, and provide its file path via 'version_from' (or +'all_from' if you prefer) in Makefile.PL. +EOT + + $DB::single = 1; + if ( $self->tests ) { + my @tests = split ' ', $self->tests; + my %seen; + $args->{test} = { + TESTS => (join ' ', grep {!$seen{$_}++} @tests), + }; + } elsif ( $Module::Install::ExtraTests::use_extratests ) { + # Module::Install::ExtraTests doesn't set $self->tests and does its own tests via harness. + # So, just ignore our xt tests here. + } elsif ( -d 'xt' and ($Module::Install::AUTHOR or $ENV{RELEASE_TESTING}) ) { + $args->{test} = { + TESTS => join( ' ', map { "$_/*.t" } grep { -d $_ } qw{ t xt } ), + }; + } + if ( $] >= 5.005 ) { + $args->{ABSTRACT} = $self->abstract; + $args->{AUTHOR} = join ', ', @{$self->author || []}; + } + if ( $self->makemaker(6.10) ) { + $args->{NO_META} = 1; + #$args->{NO_MYMETA} = 1; + } + if ( $self->makemaker(6.17) and $self->sign ) { + $args->{SIGN} = 1; + } + unless ( $self->is_admin ) { + delete $args->{SIGN}; + } + if ( $self->makemaker(6.31) and $self->license ) { + $args->{LICENSE} = $self->license; + } + + my $prereq = ($args->{PREREQ_PM} ||= {}); + %$prereq = ( %$prereq, + map { @$_ } # flatten [module => version] + map { @$_ } + grep $_, + ($self->requires) + ); + + # Remove any reference to perl, PREREQ_PM doesn't support it + delete $args->{PREREQ_PM}->{perl}; + + # Merge both kinds of requires into BUILD_REQUIRES + my $build_prereq = ($args->{BUILD_REQUIRES} ||= {}); + %$build_prereq = ( %$build_prereq, + map { @$_ } # flatten [module => version] + map { @$_ } + grep $_, + ($self->configure_requires, $self->build_requires) + ); + + # Remove any reference to perl, BUILD_REQUIRES doesn't support it + delete $args->{BUILD_REQUIRES}->{perl}; + + # Delete bundled dists from prereq_pm, add it to Makefile DIR + my $subdirs = ($args->{DIR} || []); + if ($self->bundles) { + my %processed; + foreach my $bundle (@{ $self->bundles }) { + my ($mod_name, $dist_dir) = @$bundle; + delete $prereq->{$mod_name}; + $dist_dir = File::Basename::basename($dist_dir); # dir for building this module + if (not exists $processed{$dist_dir}) { + if (-d $dist_dir) { + # List as sub-directory to be processed by make + push @$subdirs, $dist_dir; + } + # Else do nothing: the module is already present on the system + $processed{$dist_dir} = undef; + } + } + } + + unless ( $self->makemaker('6.55_03') ) { + %$prereq = (%$prereq,%$build_prereq); + delete $args->{BUILD_REQUIRES}; + } + + if ( my $perl_version = $self->perl_version ) { + eval "use $perl_version; 1" + or die "ERROR: perl: Version $] is installed, " + . "but we need version >= $perl_version"; + + if ( $self->makemaker(6.48) ) { + $args->{MIN_PERL_VERSION} = $perl_version; + } + } + + if ($self->installdirs) { + warn qq{old INSTALLDIRS (probably set by makemaker_args) is overriden by installdirs\n} if $args->{INSTALLDIRS}; + $args->{INSTALLDIRS} = $self->installdirs; + } + + my %args = map { + ( $_ => $args->{$_} ) } grep {defined($args->{$_} ) + } keys %$args; + + my $user_preop = delete $args{dist}->{PREOP}; + if ( my $preop = $self->admin->preop($user_preop) ) { + foreach my $key ( keys %$preop ) { + $args{dist}->{$key} = $preop->{$key}; + } + } + + my $mm = ExtUtils::MakeMaker::WriteMakefile(%args); + $self->fix_up_makefile($mm->{FIRST_MAKEFILE} || 'Makefile'); } sub fix_up_makefile { - my $self = shift; - my $top_class = ref($self->_top) || ''; - my $top_version = $self->_top->VERSION || ''; - - my $preamble = $self->preamble - ? "# Preamble by $top_class $top_version\n" . $self->preamble - : ''; - my $postamble = "# Postamble by $top_class $top_version\n" . - ($self->postamble || ''); - - open MAKEFILE, '< Makefile' or die $!; - my $makefile = do { local $/; <MAKEFILE> }; - close MAKEFILE; - - $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /; - $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g; - $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g; - - $makefile =~ s/^(FULLPERL = .*)/$1 -Iinc/m; - $makefile =~ s/^(PERL = .*)/$1 -Iinc/m; - - open MAKEFILE, '> Makefile' or die $!; - print MAKEFILE "$preamble$makefile$postamble"; - close MAKEFILE; + my $self = shift; + my $makefile_name = shift; + my $top_class = ref($self->_top) || ''; + my $top_version = $self->_top->VERSION || ''; + + my $preamble = $self->preamble + ? "# Preamble by $top_class $top_version\n" + . $self->preamble + : ''; + my $postamble = "# Postamble by $top_class $top_version\n" + . ($self->postamble || ''); + + local *MAKEFILE; + open MAKEFILE, "+< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!"; + eval { flock MAKEFILE, LOCK_EX }; + my $makefile = do { local $/; <MAKEFILE> }; + + $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /; + $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g; + $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g; + $makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m; + $makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m; + + # Module::Install will never be used to build the Core Perl + # Sometimes PERL_LIB and PERL_ARCHLIB get written anyway, which breaks + # PREFIX/PERL5LIB, and thus, install_share. Blank them if they exist + $makefile =~ s/^PERL_LIB = .+/PERL_LIB =/m; + #$makefile =~ s/^PERL_ARCHLIB = .+/PERL_ARCHLIB =/m; + + # Perl 5.005 mentions PERL_LIB explicitly, so we have to remove that as well. + $makefile =~ s/(\"?)-I\$\(PERL_LIB\)\1//g; + + # XXX - This is currently unused; not sure if it breaks other MM-users + # $makefile =~ s/^pm_to_blib\s+:\s+/pm_to_blib :: /mg; + + seek MAKEFILE, 0, SEEK_SET; + truncate MAKEFILE, 0; + print MAKEFILE "$preamble$makefile$postamble" or die $!; + close MAKEFILE or die $!; + + 1; } sub preamble { - my ($self, $text) = @_; - $self->{preamble} = $text . $self->{preamble} if defined $text; - $self->{preamble}; + my ($self, $text) = @_; + $self->{preamble} = $text . $self->{preamble} if defined $text; + $self->{preamble}; } sub postamble { - my ($self, $text) = @_; - - $self->{postamble} ||= $self->admin->postamble; - $self->{postamble} .= $text if defined $text; - $self->{postamble} + my ($self, $text) = @_; + $self->{postamble} ||= $self->admin->postamble; + $self->{postamble} .= $text if defined $text; + $self->{postamble} } 1; __END__ -#line 273 +#line 541 diff --git a/inc/Module/Install/Metadata.pm b/inc/Module/Install/Metadata.pm index a839a10..3b01e09 100644 --- a/inc/Module/Install/Metadata.pm +++ b/inc/Module/Install/Metadata.pm @@ -1,187 +1,716 @@ -#line 1 "inc/Module/Install/Metadata.pm - /Library/Perl/5.8.1/Module/Install/Metadata.pm" +#line 1 package Module::Install::Metadata; -use Module::Install::Base; @ISA = qw(Module::Install::Base); - -$VERSION = '0.04'; use strict 'vars'; -use vars qw($VERSION); +use Module::Install::Base (); + +use vars qw{$VERSION @ISA $ISCORE}; +BEGIN { + $VERSION = '1.01'; + @ISA = 'Module::Install::Base'; + $ISCORE = 1; +} -sub Meta { shift } +my @boolean_keys = qw{ + sign +}; -my @scalar_keys = qw( - name module_name version abstract author license - distribution_type sign perl_version -); -my @tuple_keys = qw(build_requires requires recommends bundles); - -foreach my $key (@scalar_keys) { - *$key = sub { - my $self = shift; - return $self->{'values'}{$key} unless @_; - $self->{'values'}{$key} = shift; - return $self; - }; -} - -foreach my $key (@tuple_keys) { - *$key = sub { - my $self = shift; - return $self->{'values'}{$key} unless @_; - my @rv; - while (@_) { - my $module = shift or last; - my $version = shift || 0; - if ($module eq 'perl') { - $version =~ s{^(\d+)\.(\d+)\.(\d+)} - {$1 + $2/1_000 + $3/1_000_000}e; - $self->perl_version($version); - next; - } - my $rv = [$module, $version]; - push @{$self->{'values'}{$key}}, $rv; - push @rv, $rv; - } - return @rv; - }; +my @scalar_keys = qw{ + name + module_name + abstract + version + distribution_type + tests + installdirs +}; + +my @tuple_keys = qw{ + configure_requires + build_requires + requires + recommends + bundles + resources +}; + +my @resource_keys = qw{ + homepage + bugtracker + repository +}; + +my @array_keys = qw{ + keywords + author +}; + +*authors = \&author; + +sub Meta { shift } +sub Meta_BooleanKeys { @boolean_keys } +sub Meta_ScalarKeys { @scalar_keys } +sub Meta_TupleKeys { @tuple_keys } +sub Meta_ResourceKeys { @resource_keys } +sub Meta_ArrayKeys { @array_keys } + +foreach my $key ( @boolean_keys ) { + *$key = sub { + my $self = shift; + if ( defined wantarray and not @_ ) { + return $self->{values}->{$key}; + } + $self->{values}->{$key} = ( @_ ? $_[0] : 1 ); + return $self; + }; } -sub features { - my $self = shift; - while (my ($name, $mods) = splice(@_, 0, 2)) { - my $count = 0; - push @{$self->{'values'}{'features'}}, ($name => [ - map { (++$count % 2 and ref($_) and ($count += $#$_)) ? @$_ : $_ } @$mods - ] ); - } - return @{$self->{'values'}{'features'}}; +foreach my $key ( @scalar_keys ) { + *$key = sub { + my $self = shift; + return $self->{values}->{$key} if defined wantarray and !@_; + $self->{values}->{$key} = shift; + return $self; + }; } -sub no_index { - my $self = shift; - my $type = shift; - push @{$self->{'values'}{'no_index'}{$type}}, @_ if $type; - return $self->{'values'}{'no_index'}; +foreach my $key ( @array_keys ) { + *$key = sub { + my $self = shift; + return $self->{values}->{$key} if defined wantarray and !@_; + $self->{values}->{$key} ||= []; + push @{$self->{values}->{$key}}, @_; + return $self; + }; } -sub _dump { - my $self = shift; - my $package = ref($self->_top); - my $version = $self->_top->VERSION; - my %values = %{$self->{'values'}}; - - delete $values{sign}; - if (my $perl_version = delete $values{perl_version}) { - # Always canonical to three-dot version - $perl_version =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2), int($3))}e - if $perl_version >= 5.006; - $values{requires} = [ - [perl => $perl_version], - @{$values{requires}||[]}, - ]; - } +foreach my $key ( @resource_keys ) { + *$key = sub { + my $self = shift; + unless ( @_ ) { + return () unless $self->{values}->{resources}; + return map { $_->[1] } + grep { $_->[0] eq $key } + @{ $self->{values}->{resources} }; + } + return $self->{values}->{resources}->{$key} unless @_; + my $uri = shift or die( + "Did not provide a value to $key()" + ); + $self->resources( $key => $uri ); + return 1; + }; +} - warn "No license specified, setting license = 'unknown'\n" - unless $values{license}; - - $values{license} ||= 'unknown'; - $values{distribution_type} ||= 'module'; - $values{name} ||= do { - my $name = $values{module_name}; - $name =~ s/::/-/g; - $name; - } if $values{module_name}; - - if ($values{name} =~ /::/) { - my $name = $values{name}; - $name =~ s/::/-/g; - die "Error in name(): '$values{name}' should be '$name'!\n"; - } +foreach my $key ( grep { $_ ne "resources" } @tuple_keys) { + *$key = sub { + my $self = shift; + return $self->{values}->{$key} unless @_; + my @added; + while ( @_ ) { + my $module = shift or last; + my $version = shift || 0; + push @added, [ $module, $version ]; + } + push @{ $self->{values}->{$key} }, @added; + return map {@$_} @added; + }; +} - my $dump = ''; - foreach my $key (@scalar_keys) { - $dump .= "$key: $values{$key}\n" if exists $values{$key}; - } - foreach my $key (@tuple_keys) { - next unless exists $values{$key}; - $dump .= "$key:\n"; - foreach (@{$values{$key}}) { - $dump .= " $_->[0]: $_->[1]\n"; - } - } +# Resource handling +my %lc_resource = map { $_ => 1 } qw{ + homepage + license + bugtracker + repository +}; - if (my $no_index = $values{no_index}) { - push @{$no_index->{'directory'}}, 'inc'; - require YAML; - local $YAML::UseHeader = 0; - $dump .= YAML::Dump({ no_index => $no_index}); - } - else { - $dump .= << "META"; -no_index: - directory: - - inc -META - } - - $dump .= "generated_by: $package version $version\n"; - return $dump; +sub resources { + my $self = shift; + while ( @_ ) { + my $name = shift or last; + my $value = shift or next; + if ( $name eq lc $name and ! $lc_resource{$name} ) { + die("Unsupported reserved lowercase resource '$name'"); + } + $self->{values}->{resources} ||= []; + push @{ $self->{values}->{resources} }, [ $name, $value ]; + } + $self->{values}->{resources}; +} + +# Aliases for build_requires that will have alternative +# meanings in some future version of META.yml. +sub test_requires { shift->build_requires(@_) } +sub install_requires { shift->build_requires(@_) } + +# Aliases for installdirs options +sub install_as_core { $_[0]->installdirs('perl') } +sub install_as_cpan { $_[0]->installdirs('site') } +sub install_as_site { $_[0]->installdirs('site') } +sub install_as_vendor { $_[0]->installdirs('vendor') } + +sub dynamic_config { + my $self = shift; + unless ( @_ ) { + warn "You MUST provide an explicit true/false value to dynamic_config\n"; + return $self; + } + $self->{values}->{dynamic_config} = $_[0] ? 1 : 0; + return 1; +} + +sub perl_version { + my $self = shift; + return $self->{values}->{perl_version} unless @_; + my $version = shift or die( + "Did not provide a value to perl_version()" + ); + + # Normalize the version + $version = $self->_perl_version($version); + + # We don't support the reall old versions + unless ( $version >= 5.005 ) { + die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n"; + } + + $self->{values}->{perl_version} = $version; +} + +sub all_from { + my ( $self, $file ) = @_; + + unless ( defined($file) ) { + my $name = $self->name or die( + "all_from called with no args without setting name() first" + ); + $file = join('/', 'lib', split(/-/, $name)) . '.pm'; + $file =~ s{.*/}{} unless -e $file; + unless ( -e $file ) { + die("all_from cannot find $file from $name"); + } + } + unless ( -f $file ) { + die("The path '$file' does not exist, or is not a file"); + } + + $self->{values}{all_from} = $file; + + # Some methods pull from POD instead of code. + # If there is a matching .pod, use that instead + my $pod = $file; + $pod =~ s/\.pm$/.pod/i; + $pod = $file unless -e $pod; + + # Pull the different values + $self->name_from($file) unless $self->name; + $self->version_from($file) unless $self->version; + $self->perl_version_from($file) unless $self->perl_version; + $self->author_from($pod) unless @{$self->author || []}; + $self->license_from($pod) unless $self->license; + $self->abstract_from($pod) unless $self->abstract; + + return 1; +} + +sub provides { + my $self = shift; + my $provides = ( $self->{values}->{provides} ||= {} ); + %$provides = (%$provides, @_) if @_; + return $provides; +} + +sub auto_provides { + my $self = shift; + return $self unless $self->is_admin; + unless (-e 'MANIFEST') { + warn "Cannot deduce auto_provides without a MANIFEST, skipping\n"; + return $self; + } + # Avoid spurious warnings as we are not checking manifest here. + local $SIG{__WARN__} = sub {1}; + require ExtUtils::Manifest; + local *ExtUtils::Manifest::manicheck = sub { return }; + + require Module::Build; + my $build = Module::Build->new( + dist_name => $self->name, + dist_version => $self->version, + license => $self->license, + ); + $self->provides( %{ $build->find_dist_packages || {} } ); +} + +sub feature { + my $self = shift; + my $name = shift; + my $features = ( $self->{values}->{features} ||= [] ); + my $mods; + + if ( @_ == 1 and ref( $_[0] ) ) { + # The user used ->feature like ->features by passing in the second + # argument as a reference. Accomodate for that. + $mods = $_[0]; + } else { + $mods = \@_; + } + + my $count = 0; + push @$features, ( + $name => [ + map { + ref($_) ? ( ref($_) eq 'HASH' ) ? %$_ : @$_ : $_ + } @$mods + ] + ); + + return @$features; +} + +sub features { + my $self = shift; + while ( my ( $name, $mods ) = splice( @_, 0, 2 ) ) { + $self->feature( $name, @$mods ); + } + return $self->{values}->{features} + ? @{ $self->{values}->{features} } + : (); +} + +sub no_index { + my $self = shift; + my $type = shift; + push @{ $self->{values}->{no_index}->{$type} }, @_ if $type; + return $self->{values}->{no_index}; } sub read { - my $self = shift; - $self->include_deps( 'YAML', 0 ); - require YAML; - my $data = YAML::LoadFile( 'META.yml' ); - # Call methods explicitly in case user has already set some values. - while ( my ($key, $value) = each %$data ) { - next unless $self->can( $key ); - if (ref $value eq 'HASH') { - while (my ($module, $version) = each %$value) { - $self->$key( $module => $version ); - } - } - else { - $self->$key( $value ); - } - } - return $self; + my $self = shift; + $self->include_deps( 'YAML::Tiny', 0 ); + + require YAML::Tiny; + my $data = YAML::Tiny::LoadFile('META.yml'); + + # Call methods explicitly in case user has already set some values. + while ( my ( $key, $value ) = each %$data ) { + next unless $self->can($key); + if ( ref $value eq 'HASH' ) { + while ( my ( $module, $version ) = each %$value ) { + $self->can($key)->($self, $module => $version ); + } + } else { + $self->can($key)->($self, $value); + } + } + return $self; } sub write { + my $self = shift; + return $self unless $self->is_admin; + $self->admin->write_meta; + return $self; +} + +sub version_from { + require ExtUtils::MM_Unix; + my ( $self, $file ) = @_; + $self->version( ExtUtils::MM_Unix->parse_version($file) ); + + # for version integrity check + $self->makemaker_args( VERSION_FROM => $file ); +} + +sub abstract_from { + require ExtUtils::MM_Unix; + my ( $self, $file ) = @_; + $self->abstract( + bless( + { DISTNAME => $self->name }, + 'ExtUtils::MM_Unix' + )->parse_abstract($file) + ); +} + +# Add both distribution and module name +sub name_from { + my ($self, $file) = @_; + if ( + Module::Install::_read($file) =~ m/ + ^ \s* + package \s* + ([\w:]+) + \s* ; + /ixms + ) { + my ($name, $module_name) = ($1, $1); + $name =~ s{::}{-}g; + $self->name($name); + unless ( $self->module_name ) { + $self->module_name($module_name); + } + } else { + die("Cannot determine name from $file\n"); + } +} + +sub _extract_perl_version { + if ( + $_[0] =~ m/ + ^\s* + (?:use|require) \s* + v? + ([\d_\.]+) + \s* ; + /ixms + ) { + my $perl_version = $1; + $perl_version =~ s{_}{}g; + return $perl_version; + } else { + return; + } +} + +sub perl_version_from { + my $self = shift; + my $perl_version=_extract_perl_version(Module::Install::_read($_[0])); + if ($perl_version) { + $self->perl_version($perl_version); + } else { + warn "Cannot determine perl version info from $_[0]\n"; + return; + } +} + +sub author_from { + my $self = shift; + my $content = Module::Install::_read($_[0]); + if ($content =~ m/ + =head \d \s+ (?:authors?)\b \s* + ([^\n]*) + | + =head \d \s+ (?:licen[cs]e|licensing|copyright|legal)\b \s* + .*? copyright .*? \d\d\d[\d.]+ \s* (?:\bby\b)? \s* + ([^\n]*) + /ixms) { + my $author = $1 || $2; + + # XXX: ugly but should work anyway... + if (eval "require Pod::Escapes; 1") { + # Pod::Escapes has a mapping table. + # It's in core of perl >= 5.9.3, and should be installed + # as one of the Pod::Simple's prereqs, which is a prereq + # of Pod::Text 3.x (see also below). + $author =~ s{ E<( (\d+) | ([A-Za-z]+) )> } + { + defined $2 + ? chr($2) + : defined $Pod::Escapes::Name2character_number{$1} + ? chr($Pod::Escapes::Name2character_number{$1}) + : do { + warn "Unknown escape: E<$1>"; + "E<$1>"; + }; + }gex; + } + elsif (eval "require Pod::Text; 1" && $Pod::Text::VERSION < 3) { + # Pod::Text < 3.0 has yet another mapping table, + # though the table name of 2.x and 1.x are different. + # (1.x is in core of Perl < 5.6, 2.x is in core of + # Perl < 5.9.3) + my $mapping = ($Pod::Text::VERSION < 2) + ? \%Pod::Text::HTML_Escapes + : \%Pod::Text::ESCAPES; + $author =~ s{ E<( (\d+) | ([A-Za-z]+) )> } + { + defined $2 + ? chr($2) + : defined $mapping->{$1} + ? $mapping->{$1} + : do { + warn "Unknown escape: E<$1>"; + "E<$1>"; + }; + }gex; + } + else { + $author =~ s{E<lt>}{<}g; + $author =~ s{E<gt>}{>}g; + } + $self->author($author); + } else { + warn "Cannot determine author info from $_[0]\n"; + } +} + +#Stolen from M::B +my %license_urls = ( + perl => 'http://dev.perl.org/licenses/', + apache => 'http://apache.org/licenses/LICENSE-2.0', + apache_1_1 => 'http://apache.org/licenses/LICENSE-1.1', + artistic => 'http://opensource.org/licenses/artistic-license.php', + artistic_2 => 'http://opensource.org/licenses/artistic-license-2.0.php', + lgpl => 'http://opensource.org/licenses/lgpl-license.php', + lgpl2 => 'http://opensource.org/licenses/lgpl-2.1.php', + lgpl3 => 'http://opensource.org/licenses/lgpl-3.0.html', + bsd => 'http://opensource.org/licenses/bsd-license.php', + gpl => 'http://opensource.org/licenses/gpl-license.php', + gpl2 => 'http://opensource.org/licenses/gpl-2.0.php', + gpl3 => 'http://opensource.org/licenses/gpl-3.0.html', + mit => 'http://opensource.org/licenses/mit-license.php', + mozilla => 'http://opensource.org/licenses/mozilla1.1.php', + open_source => undef, + unrestricted => undef, + restrictive => undef, + unknown => undef, +); + +sub license { + my $self = shift; + return $self->{values}->{license} unless @_; + my $license = shift or die( + 'Did not provide a value to license()' + ); + $license = __extract_license($license) || lc $license; + $self->{values}->{license} = $license; + + # Automatically fill in license URLs + if ( $license_urls{$license} ) { + $self->resources( license => $license_urls{$license} ); + } + + return 1; +} + +sub _extract_license { + my $pod = shift; + my $matched; + return __extract_license( + ($matched) = $pod =~ m/ + (=head \d \s+ L(?i:ICEN[CS]E|ICENSING)\b.*?) + (=head \d.*|=cut.*|)\z + /xms + ) || __extract_license( + ($matched) = $pod =~ m/ + (=head \d \s+ (?:C(?i:OPYRIGHTS?)|L(?i:EGAL))\b.*?) + (=head \d.*|=cut.*|)\z + /xms + ); +} + +sub __extract_license { + my $license_text = shift or return; + my @phrases = ( + '(?:under )?the same (?:terms|license) as (?:perl|the perl (?:\d )?programming language)' => 'perl', 1, + '(?:under )?the terms of (?:perl|the perl programming language) itself' => 'perl', 1, + 'Artistic and GPL' => 'perl', 1, + 'GNU general public license' => 'gpl', 1, + 'GNU public license' => 'gpl', 1, + 'GNU lesser general public license' => 'lgpl', 1, + 'GNU lesser public license' => 'lgpl', 1, + 'GNU library general public license' => 'lgpl', 1, + 'GNU library public license' => 'lgpl', 1, + 'GNU Free Documentation license' => 'unrestricted', 1, + 'GNU Affero General Public License' => 'open_source', 1, + '(?:Free)?BSD license' => 'bsd', 1, + 'Artistic license 2\.0' => 'artistic_2', 1, + 'Artistic license' => 'artistic', 1, + 'Apache (?:Software )?license' => 'apache', 1, + 'GPL' => 'gpl', 1, + 'LGPL' => 'lgpl', 1, + 'BSD' => 'bsd', 1, + 'Artistic' => 'artistic', 1, + 'MIT' => 'mit', 1, + 'Mozilla Public License' => 'mozilla', 1, + 'Q Public License' => 'open_source', 1, + 'OpenSSL License' => 'unrestricted', 1, + 'SSLeay License' => 'unrestricted', 1, + 'zlib License' => 'open_source', 1, + 'proprietary' => 'proprietary', 0, + ); + while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) { + $pattern =~ s#\s+#\\s+#gs; + if ( $license_text =~ /\b$pattern\b/i ) { + return $license; + } + } + return ''; +} + +sub license_from { + my $self = shift; + if (my $license=_extract_license(Module::Install::_read($_[0]))) { + $self->license($license); + } else { + warn "Cannot determine license info from $_[0]\n"; + return 'unknown'; + } +} + +sub _extract_bugtracker { + my @links = $_[0] =~ m#L<( + https?\Q://rt.cpan.org/\E[^>]+| + https?\Q://github.com/\E[\w_]+/[\w_]+/issues| + https?\Q://code.google.com/p/\E[\w_\-]+/issues/list + )>#gx; + my %links; + @links{@links}=(); + @links=keys %links; + return @links; +} + +sub bugtracker_from { + my $self = shift; + my $content = Module::Install::_read($_[0]); + my @links = _extract_bugtracker($content); + unless ( @links ) { + warn "Cannot determine bugtracker info from $_[0]\n"; + return 0; + } + if ( @links > 1 ) { + warn "Found more than one bugtracker link in $_[0]\n"; + return 0; + } + + # Set the bugtracker + bugtracker( $links[0] ); + return 1; +} + +sub requires_from { + my $self = shift; + my $content = Module::Install::_readperl($_[0]); + my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg; + while ( @requires ) { + my $module = shift @requires; + my $version = shift @requires; + $self->requires( $module => $version ); + } +} + +sub test_requires_from { + my $self = shift; + my $content = Module::Install::_readperl($_[0]); + my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg; + while ( @requires ) { + my $module = shift @requires; + my $version = shift @requires; + $self->test_requires( $module => $version ); + } +} + +# Convert triple-part versions (eg, 5.6.1 or 5.8.9) to +# numbers (eg, 5.006001 or 5.008009). +# Also, convert double-part versions (eg, 5.8) +sub _perl_version { + my $v = $_[-1]; + $v =~ s/^([1-9])\.([1-9]\d?\d?)$/sprintf("%d.%03d",$1,$2)/e; + $v =~ s/^([1-9])\.([1-9]\d?\d?)\.(0|[1-9]\d?\d?)$/sprintf("%d.%03d%03d",$1,$2,$3 || 0)/e; + $v =~ s/(\.\d\d\d)000$/$1/; + $v =~ s/_.+$//; + if ( ref($v) ) { + # Numify + $v = $v + 0; + } + return $v; +} + +sub add_metadata { my $self = shift; - return $self unless $self->is_admin; - - META_NOT_OURS: { - local *FH; - if (open FH, "META.yml") { - while (<FH>) { - last META_NOT_OURS if /^generated_by: Module::Install\b/; - } - return $self if -s FH; - } + my %hash = @_; + for my $key (keys %hash) { + warn "add_metadata: $key is not prefixed with 'x_'.\n" . + "Use appopriate function to add non-private metadata.\n" unless $key =~ /^x_/; + $self->{values}->{$key} = $hash{$key}; } +} + - warn "Writing META.yml\n"; - open META, "> META.yml" or warn "Cannot write to META.yml: $!"; - print META $self->_dump; - close META; - return $self; +###################################################################### +# MYMETA Support + +sub WriteMyMeta { + die "WriteMyMeta has been deprecated"; } -sub version_from { - my ($self, $version_from) = @_; - require ExtUtils::MM_Unix; - $self->version(ExtUtils::MM_Unix->parse_version($version_from)); +sub write_mymeta_yaml { + my $self = shift; + + # We need YAML::Tiny to write the MYMETA.yml file + unless ( eval { require YAML::Tiny; 1; } ) { + return 1; + } + + # Generate the data + my $meta = $self->_write_mymeta_data or return 1; + + # Save as the MYMETA.yml file + print "Writing MYMETA.yml\n"; + YAML::Tiny::DumpFile('MYMETA.yml', $meta); } -sub abstract_from { - my ($self, $abstract_from) = @_; - require ExtUtils::MM_Unix; - $self->abstract( - bless( { DISTNAME => $self->name }, 'ExtUtils::MM_Unix') - ->parse_abstract($abstract_from) - ); +sub write_mymeta_json { + my $self = shift; + + # We need JSON to write the MYMETA.json file + unless ( eval { require JSON; 1; } ) { + return 1; + } + + # Generate the data + my $meta = $self->_write_mymeta_data or return 1; + + # Save as the MYMETA.yml file + print "Writing MYMETA.json\n"; + Module::Install::_write( + 'MYMETA.json', + JSON->new->pretty(1)->canonical->encode($meta), + ); +} + +sub _write_mymeta_data { + my $self = shift; + + # If there's no existing META.yml there is nothing we can do + return undef unless -f 'META.yml'; + + # We need Parse::CPAN::Meta to load the file + unless ( eval { require Parse::CPAN::Meta; 1; } ) { + return undef; + } + + # Merge the perl version into the dependencies + my $val = $self->Meta->{values}; + my $perl = delete $val->{perl_version}; + if ( $perl ) { + $val->{requires} ||= []; + my $requires = $val->{requires}; + + # Canonize to three-dot version after Perl 5.6 + if ( $perl >= 5.006 ) { + $perl =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2||0), int($3||0))}e + } + unshift @$requires, [ perl => $perl ]; + } + + # Load the advisory META.yml file + my @yaml = Parse::CPAN::Meta::LoadFile('META.yml'); + my $meta = $yaml[0]; + + # Overwrite the non-configure dependency hashs + delete $meta->{requires}; + delete $meta->{build_requires}; + delete $meta->{recommends}; + if ( exists $val->{requires} ) { + $meta->{requires} = { map { @$_ } @{ $val->{requires} } }; + } + if ( exists $val->{build_requires} ) { + $meta->{build_requires} = { map { @$_ } @{ $val->{build_requires} } }; + } + + return $meta; } 1; diff --git a/inc/Module/Install/Win32.pm b/inc/Module/Install/Win32.pm index 119ae8c..3139a63 100644 --- a/inc/Module/Install/Win32.pm +++ b/inc/Module/Install/Win32.pm @@ -1,63 +1,64 @@ -#line 1 "inc/Module/Install/Win32.pm - /Library/Perl/5.8.1/Module/Install/Win32.pm" +#line 1 package Module::Install::Win32; -use Module::Install::Base; @ISA = qw(Module::Install::Base); - -$VERSION = '0.02'; use strict; +use Module::Install::Base (); + +use vars qw{$VERSION @ISA $ISCORE}; +BEGIN { + $VERSION = '1.01'; + @ISA = 'Module::Install::Base'; + $ISCORE = 1; +} # determine if the user needs nmake, and download it if needed sub check_nmake { - my $self = shift; - $self->load('can_run'); - $self->load('get_file'); - - require Config; - return unless ( - $Config::Config{make} and - $Config::Config{make} =~ /^nmake\b/i and - $^O eq 'MSWin32' and - !$self->can_run('nmake') - ); - - print "The required 'nmake' executable not found, fetching it...\n"; - - require File::Basename; - my $rv = $self->get_file( - url => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe', - ftp_url => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe', - local_dir => File::Basename::dirname($^X), - size => 51928, - run => 'Nmake15.exe /o > nul', - check_for => 'Nmake.exe', - remove => 1, - ); - - if (!$rv) { - die << '.'; + my $self = shift; + $self->load('can_run'); + $self->load('get_file'); + + require Config; + return unless ( + $^O eq 'MSWin32' and + $Config::Config{make} and + $Config::Config{make} =~ /^nmake\b/i and + ! $self->can_run('nmake') + ); + + print "The required 'nmake' executable not found, fetching it...\n"; + + require File::Basename; + my $rv = $self->get_file( + url => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe', + ftp_url => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe', + local_dir => File::Basename::dirname($^X), + size => 51928, + run => 'Nmake15.exe /o > nul', + check_for => 'Nmake.exe', + remove => 1, + ); + + die <<'END_MESSAGE' unless $rv; ------------------------------------------------------------------------------- Since you are using Microsoft Windows, you will need the 'nmake' utility before installation. It's available at: http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe or ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe Please download the file manually, save it to a directory in %PATH% (e.g. C:\WINDOWS\COMMAND\), then launch the MS-DOS command line shell, "cd" to that directory, and run "Nmake15.exe" from there; that will create the 'nmake.exe' file needed by this module. You may then resume the installation process described in README. ------------------------------------------------------------------------------- -. - } +END_MESSAGE + } 1; - -__END__ - diff --git a/inc/Module/Install/WriteAll.pm b/inc/Module/Install/WriteAll.pm index b1ec113..1f724a7 100644 --- a/inc/Module/Install/WriteAll.pm +++ b/inc/Module/Install/WriteAll.pm @@ -1,36 +1,63 @@ -#line 1 "inc/Module/Install/WriteAll.pm - /Library/Perl/5.8.1/Module/Install/WriteAll.pm" +#line 1 package Module::Install::WriteAll; -use Module::Install::Base; @ISA = qw(Module::Install::Base); + +use strict; +use Module::Install::Base (); + +use vars qw{$VERSION @ISA $ISCORE}; +BEGIN { + $VERSION = '1.01'; + @ISA = qw{Module::Install::Base}; + $ISCORE = 1; +} sub WriteAll { - my $self = shift; - my %args = ( - meta => 1, - sign => 0, - inline => 0, - check_nmake => 1, - @_ - ); - - $self->sign(1) if $args{sign}; - $self->Meta->write if $args{meta}; - $self->admin->WriteAll(%args) if $self->is_admin; - - if ($0 =~ /Build.PL$/i) { - $self->Build->write; - } - else { + my $self = shift; + my %args = ( + meta => 1, + sign => 0, + inline => 0, + check_nmake => 1, + @_, + ); + + $self->sign(1) if $args{sign}; + $self->admin->WriteAll(%args) if $self->is_admin; + $self->check_nmake if $args{check_nmake}; - $self->makemaker_args( PL_FILES => {} ) - unless $self->makemaker_args->{'PL_FILES'}; - - if ($args{inline}) { - $self->Inline->write; - } - else { - $self->Makefile->write; - } - } + unless ( $self->makemaker_args->{PL_FILES} ) { + # XXX: This still may be a bit over-defensive... + unless ($self->makemaker(6.25)) { + $self->makemaker_args( PL_FILES => {} ) if -f 'Build.PL'; + } + } + + # Until ExtUtils::MakeMaker support MYMETA.yml, make sure + # we clean it up properly ourself. + $self->realclean_files('MYMETA.yml'); + + if ( $args{inline} ) { + $self->Inline->write; + } else { + $self->Makefile->write; + } + + # The Makefile write process adds a couple of dependencies, + # so write the META.yml files after the Makefile. + if ( $args{meta} ) { + $self->Meta->write; + } + + # Experimental support for MYMETA + if ( $ENV{X_MYMETA} ) { + if ( $ENV{X_MYMETA} eq 'JSON' ) { + $self->Meta->write_mymeta_json; + } else { + $self->Meta->write_mymeta_yaml; + } + } + + return 1; } 1; diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index b1e16c0..9893ed9 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,235 +1,235 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); -$VERSION = "0.16"; +$VERSION = "0.17"; BEGIN { # Turn on the debugger's symbol source tracing $^P |= 0x10; # Work around bug in pre-5.8.7 perl where turning on $^P # causes caller() to be confused about eval {}'s in the stack. # (See http://rt.perl.org/rt3/Ticket/Display.html?id=35059 for more info.) eval 'sub DB::sub' if $] < 5.008007; } =head1 NAME Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS # During each request, call this once to refresh changed modules: Module::Refresh->refresh; # Each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Acme/Current.pm'); =head1 DESCRIPTION This module is a generalization of the functionality provided by L<Apache::StatINC> and L<Apache::Reload>. It's designed to make it easy to do simple iterative development when working in a persistent environment. It does not require mod_perl. =cut =head2 new Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->update_cache($_) for keys %INC; return ($self); } =head2 refresh Refresh all modules that have mtimes on disk newer than the newest ones we've got. Calls C<new> to initialize the cache if it had not yet been called. Specifically, it will renew any module that was loaded before the previous call to C<refresh> (or C<new>) and has changed on disk since then. If a module was both loaded for the first time B<and> changed on disk between the previous call and this one, it will B<not> be reloaded by this call (or any future one); you will need to update the modification time again (by using the Unix C<touch> command or making a change to it) in order for it to be reloaded. =cut sub refresh { my $self = shift; return $self->new if !%CACHE; foreach my $mod ( sort keys %INC ) { $self->refresh_module_if_modified($mod); } return ($self); } =head2 refresh_module_if_modified $module If $module has been modified on disk, refresh it. Otherwise, do nothing =cut sub refresh_module_if_modified { my $self = shift; return $self->new if !%CACHE; my $mod = shift; if (!$INC{$mod}) { return; } elsif ( !$CACHE{$mod} ) { $self->update_cache($mod); } elsif ( $self->mtime( $INC{$mod} ) ne $CACHE{$mod} ) { $self->refresh_module($mod); } } =head2 refresh_module $module Refresh a module. It doesn't matter if it's already up to date. Just do it. Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->update_cache($mod); return ($self); } =head2 unload_module $module Remove a module from C<%INC>, and remove all subroutines defined in it. =cut sub unload_module { my $self = shift; my $mod = shift; my $file = $INC{$mod}; delete $INC{$mod}; delete $CACHE{$mod}; $self->unload_subs($file); return ($self); } =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat( $_[1] ) )[ 1, 7, 9 ]; } =head2 update_cache $file Updates the cached "last modified" time for $file. =cut sub update_cache { my $self = shift; my $module_pm = shift; $CACHE{$module_pm} = $self->mtime( $INC{$module_pm} ); } =head2 unload_subs $file Wipe out subs defined in $file. =cut sub unload_subs { my $self = shift; my $file = shift; foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { warn "Deleting $sym from $file" if ( $sym =~ /freeze/ ); eval { undef &$sym }; warn "$sym: $@" if $@; delete $DB::sub{$sym}; { no strict 'refs'; if ($sym =~ /^(.*::)(.*?)$/) { delete *{$1}->{$2}; } } } return $self; } # "Anonymize" all our subroutines into unnamed closures; so we can safely # refresh this very package. BEGIN { no strict 'refs'; foreach my $sym ( sort keys %{ __PACKAGE__ . '::' } ) { next if $sym eq 'VERSION'; # Skip the version sub, inherited from UNIVERSAL my $code = __PACKAGE__->can($sym) or next; delete ${ __PACKAGE__ . '::' }{$sym}; *$sym = sub { goto &$code }; } } 1; =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table properly, so we mess up on things like global variables that were previously set. =head1 SEE ALSO L<Apache::StatINC>, L<Module::Reload> =head1 COPYRIGHT Copyright 2004,2011 by Jesse Vincent E<lt>[email protected]<gt>, Audrey Tang E<lt>[email protected]<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<http://www.perl.com/perl/misc/Artistic.html> =cut
bestpractical/module-refresh
40de516a85c2873638f006944ebe98f848e1320d
Warnings avoidance for reloading a module not in %INC
diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index d729f84..b1e16c0 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,233 +1,235 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); $VERSION = "0.16"; BEGIN { # Turn on the debugger's symbol source tracing $^P |= 0x10; # Work around bug in pre-5.8.7 perl where turning on $^P # causes caller() to be confused about eval {}'s in the stack. # (See http://rt.perl.org/rt3/Ticket/Display.html?id=35059 for more info.) eval 'sub DB::sub' if $] < 5.008007; } =head1 NAME Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS # During each request, call this once to refresh changed modules: Module::Refresh->refresh; # Each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Acme/Current.pm'); =head1 DESCRIPTION This module is a generalization of the functionality provided by L<Apache::StatINC> and L<Apache::Reload>. It's designed to make it easy to do simple iterative development when working in a persistent environment. It does not require mod_perl. =cut =head2 new Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->update_cache($_) for keys %INC; return ($self); } =head2 refresh Refresh all modules that have mtimes on disk newer than the newest ones we've got. Calls C<new> to initialize the cache if it had not yet been called. Specifically, it will renew any module that was loaded before the previous call to C<refresh> (or C<new>) and has changed on disk since then. If a module was both loaded for the first time B<and> changed on disk between the previous call and this one, it will B<not> be reloaded by this call (or any future one); you will need to update the modification time again (by using the Unix C<touch> command or making a change to it) in order for it to be reloaded. =cut sub refresh { my $self = shift; return $self->new if !%CACHE; foreach my $mod ( sort keys %INC ) { $self->refresh_module_if_modified($mod); } return ($self); } =head2 refresh_module_if_modified $module If $module has been modified on disk, refresh it. Otherwise, do nothing =cut sub refresh_module_if_modified { my $self = shift; return $self->new if !%CACHE; my $mod = shift; - if ( !$CACHE{$mod} ) { + if (!$INC{$mod}) { + return; + } elsif ( !$CACHE{$mod} ) { $self->update_cache($mod); } elsif ( $self->mtime( $INC{$mod} ) ne $CACHE{$mod} ) { $self->refresh_module($mod); } } =head2 refresh_module $module Refresh a module. It doesn't matter if it's already up to date. Just do it. Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->update_cache($mod); return ($self); } =head2 unload_module $module Remove a module from C<%INC>, and remove all subroutines defined in it. =cut sub unload_module { my $self = shift; my $mod = shift; my $file = $INC{$mod}; delete $INC{$mod}; delete $CACHE{$mod}; $self->unload_subs($file); return ($self); } =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat( $_[1] ) )[ 1, 7, 9 ]; } =head2 update_cache $file Updates the cached "last modified" time for $file. =cut sub update_cache { my $self = shift; my $module_pm = shift; $CACHE{$module_pm} = $self->mtime( $INC{$module_pm} ); } =head2 unload_subs $file Wipe out subs defined in $file. =cut sub unload_subs { my $self = shift; my $file = shift; foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { warn "Deleting $sym from $file" if ( $sym =~ /freeze/ ); eval { undef &$sym }; warn "$sym: $@" if $@; delete $DB::sub{$sym}; { no strict 'refs'; if ($sym =~ /^(.*::)(.*?)$/) { delete *{$1}->{$2}; } } } return $self; } # "Anonymize" all our subroutines into unnamed closures; so we can safely # refresh this very package. BEGIN { no strict 'refs'; foreach my $sym ( sort keys %{ __PACKAGE__ . '::' } ) { next if $sym eq 'VERSION'; # Skip the version sub, inherited from UNIVERSAL my $code = __PACKAGE__->can($sym) or next; delete ${ __PACKAGE__ . '::' }{$sym}; *$sym = sub { goto &$code }; } } 1; =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table properly, so we mess up on things like global variables that were previously set. =head1 SEE ALSO L<Apache::StatINC>, L<Module::Reload> =head1 COPYRIGHT Copyright 2004,2011 by Jesse Vincent E<lt>[email protected]<gt>, Audrey Tang E<lt>[email protected]<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<http://www.perl.com/perl/misc/Artistic.html> =cut
bestpractical/module-refresh
c38a14ca25b8dba9cbc9abe005f9c987b67fb121
releng
diff --git a/Changes b/Changes index 2a5a3e3..38d4a21 100644 --- a/Changes +++ b/Changes @@ -1,79 +1,83 @@ +0.16 Fri Apr 15 15:03:21 EST 2011 + + * SIGNATURE file bug + 0.15 Fri Apr 15 15:00:15 EST 2011 * No functional changes. Added missing test dependencies. Thanks to JQUELIN & Paul at City Fan 0.14 Tue Apr 12 18:07:44 EST 2011 * Actually remove subroutines from the symbol table, Thanks to DOY. 0.13 Thu May 3 23:03:00 EDT 2007 * Requires 5.8.1. (Uses tricks that don't work on 5.6). Thanks to DCANTRELL 0.12 Mon Apr 30 15:34:42 EDT 2007 * Requires 5.6. (Causes 5.5 to bus error). Thanks to RJBS. 0.11 Tue Apr 24 13:25:24 EDT 2007 * Fix for [rt.cpan.org #26536] Test suite uses /tmp with predictable filenames Reported by ANDK 0.10_01 Tue May 9 01:21:55 EDT 2006 * Module::Refresh->refresh_module_if_modified($module) as suggested by Daisuke Maki 0.09 Thu Dec 22 19:03:14 EST 2005 * Artur Bergman pointed out a bug in the overview docs. 0.08 * From Ivan Kohler. (rt.cpan.org #14879) Without this patch, I was getting a fatal error: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. This patch changes this to a warning and adds the name of the subroutine that triggered it. I now get the non-fatal warning: HTML::Mason::handler: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. 0.07 Sun Aug 21 13:25:20 EDT 2005 * Put in a work-around for a perl bug before 5.8.7. 0.06 Fri May 20 22:11:11 EDT 2005 * Trade overrefreshing for underrefreshing in some cases; test and document (We were over-aggressively reloading modules -- David Glasser 0.05 Tue Nov 16 23:15:10 EST 2004 * Explicitly, don't clobber the 'VERSION' symbol on setup. 0.04 Thu Nov 11 12:53:21 CST 2004 * Fix tests to run correctly on Win32. 0.03 Wed Nov 10 21:30:59 CST 2004 * "Anonymize" all our methods so we can refresh ourselves. * POD cleanup; nomenclature unification. * ->refresh now implicitly calls ->new for the first time. minor doc updates * Various cleanups to make it 5.005-friendly. * Use (inode, size, mtime) as the cache value instead of mtime alone. 0.02 Wed Nov 10 18:28:12 CST 2004 - Now we clean out subroutines loaded by the package we're unloading. 0.01 Mon Nov 8 19:48:00 CST 2004 - Initial release diff --git a/SIGNATURE b/SIGNATURE index f3ceb23..de78ad0 100644 --- a/SIGNATURE +++ b/SIGNATURE @@ -1,40 +1,40 @@ This file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.66. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -SHA1 b2baa913348d9787b6d205a3e78659e9c3500c74 Changes +SHA1 3b6b523dfd11a462961d22ce70b78ae6df5fae7d Changes SHA1 68778c52d10c41f67e469665dd332886a6c628e6 MANIFEST SHA1 b7486e3cbe8cb200c626c9c5c8e0a16b13affb0c META.yml SHA1 2a1de49cf5174c72b89629051e8de4ac05b05bd4 Makefile.PL SHA1 0de53a33616127f8680e6e4118741e80f354cd3e inc/Module/Install.pm SHA1 11d43fa1484b63eb90b0a3a1b62dcb7e71060084 inc/Module/Install/Base.pm SHA1 d3122b9f825c49da1184636699531ac0a7844da0 inc/Module/Install/Can.pm SHA1 9f146b26e914b78d7f07559d1810bca6d96c2bc7 inc/Module/Install/Fetch.pm SHA1 836dc65ebcb2913f5a7da77ddba4b6d46bd98f99 inc/Module/Install/Makefile.pm SHA1 2d0fae3f1ecf71666075b39911cb4694b1310edd inc/Module/Install/Metadata.pm SHA1 71c0f2e04d98c302c22d92b03ab8852f768b6431 inc/Module/Install/Win32.pm SHA1 ea6fe523768b5c7d8a50528fbc18885bb0901d88 inc/Module/Install/WriteAll.pm -SHA1 be57bedec6e611ee720e1014776fdbb05e25812c lib/Module/Refresh.pm +SHA1 a1e63fe6eb40f7c1429887654ef0c273e1e15420 lib/Module/Refresh.pm SHA1 59ee3fb5cc33fa83f37010c6f1bbffc96169c3d4 t/0-smoke.t SHA1 9103ce09992aa9abff57823a090e109b1e9511a5 t/1api.t SHA1 d6fce094ee7fb7e800f646ac216dcc4a8a45f7db t/2lateuse.t SHA1 ca479c7b8ae0997a66d18c00216ac44c1346cbc4 t/clear_symtable.t -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) -iEYEARECAAYFAk2n0TYACgkQEi9d9xCOQEa3zACgjJK0UG9aiRBd9dapKLx+/7U6 -BNUAnRSgyqP9eAEYm0wxOy4CBiEzcQwc -=iNV5 +iEYEARECAAYFAk2n0bQACgkQEi9d9xCOQEaiHQCfb9SPMjZShk3f/Q1Yb9kBbCyk +6qYAn0uFvaSX2gC6Os7WW+WkjWH2OBZW +=H1/Q -----END PGP SIGNATURE----- diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index 6e72eda..d729f84 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,233 +1,233 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); -$VERSION = "0.15"; +$VERSION = "0.16"; BEGIN { # Turn on the debugger's symbol source tracing $^P |= 0x10; # Work around bug in pre-5.8.7 perl where turning on $^P # causes caller() to be confused about eval {}'s in the stack. # (See http://rt.perl.org/rt3/Ticket/Display.html?id=35059 for more info.) eval 'sub DB::sub' if $] < 5.008007; } =head1 NAME Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS # During each request, call this once to refresh changed modules: Module::Refresh->refresh; # Each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Acme/Current.pm'); =head1 DESCRIPTION This module is a generalization of the functionality provided by L<Apache::StatINC> and L<Apache::Reload>. It's designed to make it easy to do simple iterative development when working in a persistent environment. It does not require mod_perl. =cut =head2 new Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->update_cache($_) for keys %INC; return ($self); } =head2 refresh Refresh all modules that have mtimes on disk newer than the newest ones we've got. Calls C<new> to initialize the cache if it had not yet been called. Specifically, it will renew any module that was loaded before the previous call to C<refresh> (or C<new>) and has changed on disk since then. If a module was both loaded for the first time B<and> changed on disk between the previous call and this one, it will B<not> be reloaded by this call (or any future one); you will need to update the modification time again (by using the Unix C<touch> command or making a change to it) in order for it to be reloaded. =cut sub refresh { my $self = shift; return $self->new if !%CACHE; foreach my $mod ( sort keys %INC ) { $self->refresh_module_if_modified($mod); } return ($self); } =head2 refresh_module_if_modified $module If $module has been modified on disk, refresh it. Otherwise, do nothing =cut sub refresh_module_if_modified { my $self = shift; return $self->new if !%CACHE; my $mod = shift; if ( !$CACHE{$mod} ) { $self->update_cache($mod); } elsif ( $self->mtime( $INC{$mod} ) ne $CACHE{$mod} ) { $self->refresh_module($mod); } } =head2 refresh_module $module Refresh a module. It doesn't matter if it's already up to date. Just do it. Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->update_cache($mod); return ($self); } =head2 unload_module $module Remove a module from C<%INC>, and remove all subroutines defined in it. =cut sub unload_module { my $self = shift; my $mod = shift; my $file = $INC{$mod}; delete $INC{$mod}; delete $CACHE{$mod}; $self->unload_subs($file); return ($self); } =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat( $_[1] ) )[ 1, 7, 9 ]; } =head2 update_cache $file Updates the cached "last modified" time for $file. =cut sub update_cache { my $self = shift; my $module_pm = shift; $CACHE{$module_pm} = $self->mtime( $INC{$module_pm} ); } =head2 unload_subs $file Wipe out subs defined in $file. =cut sub unload_subs { my $self = shift; my $file = shift; foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { warn "Deleting $sym from $file" if ( $sym =~ /freeze/ ); eval { undef &$sym }; warn "$sym: $@" if $@; delete $DB::sub{$sym}; { no strict 'refs'; if ($sym =~ /^(.*::)(.*?)$/) { delete *{$1}->{$2}; } } } return $self; } # "Anonymize" all our subroutines into unnamed closures; so we can safely # refresh this very package. BEGIN { no strict 'refs'; foreach my $sym ( sort keys %{ __PACKAGE__ . '::' } ) { next if $sym eq 'VERSION'; # Skip the version sub, inherited from UNIVERSAL my $code = __PACKAGE__->can($sym) or next; delete ${ __PACKAGE__ . '::' }{$sym}; *$sym = sub { goto &$code }; } } 1; =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table properly, so we mess up on things like global variables that were previously set. =head1 SEE ALSO L<Apache::StatINC>, L<Module::Reload> =head1 COPYRIGHT Copyright 2004,2011 by Jesse Vincent E<lt>[email protected]<gt>, Audrey Tang E<lt>[email protected]<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<http://www.perl.com/perl/misc/Artistic.html> =cut
bestpractical/module-refresh
1911f78b8d586c7c296b163720af09f694f1ba02
signature for 0.15
diff --git a/SIGNATURE b/SIGNATURE index 4f25c43..f3ceb23 100644 --- a/SIGNATURE +++ b/SIGNATURE @@ -1,40 +1,40 @@ This file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.66. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -SHA1 c319570e3ba54dd6637c447c67a8b739623ee31a Changes +SHA1 b2baa913348d9787b6d205a3e78659e9c3500c74 Changes SHA1 68778c52d10c41f67e469665dd332886a6c628e6 MANIFEST SHA1 b7486e3cbe8cb200c626c9c5c8e0a16b13affb0c META.yml -SHA1 67db1c195cf3a6397112cbb3639553e7d3bd8bab Makefile.PL +SHA1 2a1de49cf5174c72b89629051e8de4ac05b05bd4 Makefile.PL SHA1 0de53a33616127f8680e6e4118741e80f354cd3e inc/Module/Install.pm SHA1 11d43fa1484b63eb90b0a3a1b62dcb7e71060084 inc/Module/Install/Base.pm SHA1 d3122b9f825c49da1184636699531ac0a7844da0 inc/Module/Install/Can.pm SHA1 9f146b26e914b78d7f07559d1810bca6d96c2bc7 inc/Module/Install/Fetch.pm SHA1 836dc65ebcb2913f5a7da77ddba4b6d46bd98f99 inc/Module/Install/Makefile.pm SHA1 2d0fae3f1ecf71666075b39911cb4694b1310edd inc/Module/Install/Metadata.pm SHA1 71c0f2e04d98c302c22d92b03ab8852f768b6431 inc/Module/Install/Win32.pm SHA1 ea6fe523768b5c7d8a50528fbc18885bb0901d88 inc/Module/Install/WriteAll.pm -SHA1 eb9346b7280652fcd17cb01fdb0f653a455ddf0f lib/Module/Refresh.pm +SHA1 be57bedec6e611ee720e1014776fdbb05e25812c lib/Module/Refresh.pm SHA1 59ee3fb5cc33fa83f37010c6f1bbffc96169c3d4 t/0-smoke.t SHA1 9103ce09992aa9abff57823a090e109b1e9511a5 t/1api.t SHA1 d6fce094ee7fb7e800f646ac216dcc4a8a45f7db t/2lateuse.t SHA1 ca479c7b8ae0997a66d18c00216ac44c1346cbc4 t/clear_symtable.t -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) -iEYEARECAAYFAk2kCJQACgkQEi9d9xCOQEbuRwCguO+nwibDF2xnnsWUthVu5iFH -czoAoMe6gAYBCPvfMA3MX3tkI1+FCdO/ -=YPJG +iEYEARECAAYFAk2n0TYACgkQEi9d9xCOQEa3zACgjJK0UG9aiRBd9dapKLx+/7U6 +BNUAnRSgyqP9eAEYm0wxOy4CBiEzcQwc +=iNV5 -----END PGP SIGNATURE-----
bestpractical/module-refresh
84678de6c7a0c0e2fc96e52752bf075eb024ac32
Checking in changes prior to tagging of version 0.15.
diff --git a/Changes b/Changes index 46a26f4..2a5a3e3 100644 --- a/Changes +++ b/Changes @@ -1,78 +1,79 @@ +0.15 Fri Apr 15 15:00:15 EST 2011 * No functional changes. Added missing test dependencies. Thanks to JQUELIN & Paul at City Fan 0.14 Tue Apr 12 18:07:44 EST 2011 * Actually remove subroutines from the symbol table, Thanks to DOY. 0.13 Thu May 3 23:03:00 EDT 2007 * Requires 5.8.1. (Uses tricks that don't work on 5.6). Thanks to DCANTRELL 0.12 Mon Apr 30 15:34:42 EDT 2007 * Requires 5.6. (Causes 5.5 to bus error). Thanks to RJBS. 0.11 Tue Apr 24 13:25:24 EDT 2007 * Fix for [rt.cpan.org #26536] Test suite uses /tmp with predictable filenames Reported by ANDK 0.10_01 Tue May 9 01:21:55 EDT 2006 * Module::Refresh->refresh_module_if_modified($module) as suggested by Daisuke Maki 0.09 Thu Dec 22 19:03:14 EST 2005 * Artur Bergman pointed out a bug in the overview docs. 0.08 * From Ivan Kohler. (rt.cpan.org #14879) Without this patch, I was getting a fatal error: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. This patch changes this to a warning and adds the name of the subroutine that triggered it. I now get the non-fatal warning: HTML::Mason::handler: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. 0.07 Sun Aug 21 13:25:20 EDT 2005 * Put in a work-around for a perl bug before 5.8.7. 0.06 Fri May 20 22:11:11 EDT 2005 * Trade overrefreshing for underrefreshing in some cases; test and document (We were over-aggressively reloading modules -- David Glasser 0.05 Tue Nov 16 23:15:10 EST 2004 * Explicitly, don't clobber the 'VERSION' symbol on setup. 0.04 Thu Nov 11 12:53:21 CST 2004 * Fix tests to run correctly on Win32. 0.03 Wed Nov 10 21:30:59 CST 2004 * "Anonymize" all our methods so we can refresh ourselves. * POD cleanup; nomenclature unification. * ->refresh now implicitly calls ->new for the first time. minor doc updates * Various cleanups to make it 5.005-friendly. * Use (inode, size, mtime) as the cache value instead of mtime alone. 0.02 Wed Nov 10 18:28:12 CST 2004 - Now we clean out subroutines loaded by the package we're unloading. 0.01 Mon Nov 8 19:48:00 CST 2004 - Initial release diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index 9681b60..6e72eda 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,233 +1,233 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); -$VERSION = "0.14"; +$VERSION = "0.15"; BEGIN { # Turn on the debugger's symbol source tracing $^P |= 0x10; # Work around bug in pre-5.8.7 perl where turning on $^P # causes caller() to be confused about eval {}'s in the stack. # (See http://rt.perl.org/rt3/Ticket/Display.html?id=35059 for more info.) eval 'sub DB::sub' if $] < 5.008007; } =head1 NAME Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS # During each request, call this once to refresh changed modules: Module::Refresh->refresh; # Each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Acme/Current.pm'); =head1 DESCRIPTION This module is a generalization of the functionality provided by L<Apache::StatINC> and L<Apache::Reload>. It's designed to make it easy to do simple iterative development when working in a persistent environment. It does not require mod_perl. =cut =head2 new Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->update_cache($_) for keys %INC; return ($self); } =head2 refresh Refresh all modules that have mtimes on disk newer than the newest ones we've got. Calls C<new> to initialize the cache if it had not yet been called. Specifically, it will renew any module that was loaded before the previous call to C<refresh> (or C<new>) and has changed on disk since then. If a module was both loaded for the first time B<and> changed on disk between the previous call and this one, it will B<not> be reloaded by this call (or any future one); you will need to update the modification time again (by using the Unix C<touch> command or making a change to it) in order for it to be reloaded. =cut sub refresh { my $self = shift; return $self->new if !%CACHE; foreach my $mod ( sort keys %INC ) { $self->refresh_module_if_modified($mod); } return ($self); } =head2 refresh_module_if_modified $module If $module has been modified on disk, refresh it. Otherwise, do nothing =cut sub refresh_module_if_modified { my $self = shift; return $self->new if !%CACHE; my $mod = shift; if ( !$CACHE{$mod} ) { $self->update_cache($mod); } elsif ( $self->mtime( $INC{$mod} ) ne $CACHE{$mod} ) { $self->refresh_module($mod); } } =head2 refresh_module $module Refresh a module. It doesn't matter if it's already up to date. Just do it. Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->update_cache($mod); return ($self); } =head2 unload_module $module Remove a module from C<%INC>, and remove all subroutines defined in it. =cut sub unload_module { my $self = shift; my $mod = shift; my $file = $INC{$mod}; delete $INC{$mod}; delete $CACHE{$mod}; $self->unload_subs($file); return ($self); } =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat( $_[1] ) )[ 1, 7, 9 ]; } =head2 update_cache $file Updates the cached "last modified" time for $file. =cut sub update_cache { my $self = shift; my $module_pm = shift; $CACHE{$module_pm} = $self->mtime( $INC{$module_pm} ); } =head2 unload_subs $file Wipe out subs defined in $file. =cut sub unload_subs { my $self = shift; my $file = shift; foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { warn "Deleting $sym from $file" if ( $sym =~ /freeze/ ); eval { undef &$sym }; warn "$sym: $@" if $@; delete $DB::sub{$sym}; { no strict 'refs'; if ($sym =~ /^(.*::)(.*?)$/) { delete *{$1}->{$2}; } } } return $self; } # "Anonymize" all our subroutines into unnamed closures; so we can safely # refresh this very package. BEGIN { no strict 'refs'; foreach my $sym ( sort keys %{ __PACKAGE__ . '::' } ) { next if $sym eq 'VERSION'; # Skip the version sub, inherited from UNIVERSAL my $code = __PACKAGE__->can($sym) or next; delete ${ __PACKAGE__ . '::' }{$sym}; *$sym = sub { goto &$code }; } } 1; =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table properly, so we mess up on things like global variables that were previously set. =head1 SEE ALSO L<Apache::StatINC>, L<Module::Reload> =head1 COPYRIGHT Copyright 2004,2011 by Jesse Vincent E<lt>[email protected]<gt>, Audrey Tang E<lt>[email protected]<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<http://www.perl.com/perl/misc/Artistic.html> =cut
bestpractical/module-refresh
05a45631a8d93f1eda5d4b8c4fcb0dac63de8d17
added manifest.skip to itself
diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP new file mode 100644 index 0000000..8f62c27 --- /dev/null +++ b/MANIFEST.SKIP @@ -0,0 +1,12 @@ +TODO +MANIFEST.SKIP +^Makefile$ +blib +pm_to_blib +.swp$ +~$ +.tmp$ +.bak$ +.git/ +.gitignore$ +.shipit$
bestpractical/module-refresh
07094622058742140b25a071245877e7a9c82654
Date: Wed, 13 Apr 2011 05:59:10 -0400 From: "[email protected] via RT" <[email protected]> To: undisclosed-recipients: ; Subject: [rt.cpan.org #67427] missing buildrequires: path::class X-Spam-Status: No, score=-1.91 tagged_above=-99.9 required=10 tests=[BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01] autolearn=ham
diff --git a/Changes b/Changes index 25233a1..46a26f4 100644 --- a/Changes +++ b/Changes @@ -1,75 +1,78 @@ + + * No functional changes. Added missing test dependencies. Thanks to JQUELIN & Paul at City Fan + 0.14 Tue Apr 12 18:07:44 EST 2011 * Actually remove subroutines from the symbol table, Thanks to DOY. 0.13 Thu May 3 23:03:00 EDT 2007 * Requires 5.8.1. (Uses tricks that don't work on 5.6). Thanks to DCANTRELL 0.12 Mon Apr 30 15:34:42 EDT 2007 * Requires 5.6. (Causes 5.5 to bus error). Thanks to RJBS. 0.11 Tue Apr 24 13:25:24 EDT 2007 * Fix for [rt.cpan.org #26536] Test suite uses /tmp with predictable filenames Reported by ANDK 0.10_01 Tue May 9 01:21:55 EDT 2006 * Module::Refresh->refresh_module_if_modified($module) as suggested by Daisuke Maki 0.09 Thu Dec 22 19:03:14 EST 2005 * Artur Bergman pointed out a bug in the overview docs. 0.08 * From Ivan Kohler. (rt.cpan.org #14879) Without this patch, I was getting a fatal error: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. This patch changes this to a warning and adds the name of the subroutine that triggered it. I now get the non-fatal warning: HTML::Mason::handler: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. 0.07 Sun Aug 21 13:25:20 EDT 2005 * Put in a work-around for a perl bug before 5.8.7. 0.06 Fri May 20 22:11:11 EDT 2005 * Trade overrefreshing for underrefreshing in some cases; test and document (We were over-aggressively reloading modules -- David Glasser 0.05 Tue Nov 16 23:15:10 EST 2004 * Explicitly, don't clobber the 'VERSION' symbol on setup. 0.04 Thu Nov 11 12:53:21 CST 2004 * Fix tests to run correctly on Win32. 0.03 Wed Nov 10 21:30:59 CST 2004 * "Anonymize" all our methods so we can refresh ourselves. * POD cleanup; nomenclature unification. * ->refresh now implicitly calls ->new for the first time. minor doc updates * Various cleanups to make it 5.005-friendly. * Use (inode, size, mtime) as the cache value instead of mtime alone. 0.02 Wed Nov 10 18:28:12 CST 2004 - Now we clean out subroutines loaded by the package we're unloading. 0.01 Mon Nov 8 19:48:00 CST 2004 - Initial release
bestpractical/module-refresh
073cb1dba054b5d8f3c70f2b5d495253ed81b9d4
Add missing build deps
diff --git a/.shipit b/.shipit new file mode 100644 index 0000000..44c02c1 --- /dev/null +++ b/.shipit @@ -0,0 +1,10 @@ +# auto-generated shipit config file. +steps = FindVersion, ChangeVersion, CheckChangeLog, DistTest, Commit, Tag, MakeDist, UploadCPAN, Twitter + +git.tagpattern = %v +twitter.config = ~/.twitterrc + +# svn.tagpattern = MyProj-%v +# svn.tagpattern = http://code.example.com/svn/tags/MyProj-%v + +# CheckChangeLog.files = ChangeLog, MyProj.CHANGES diff --git a/Makefile.PL b/Makefile.PL index 196e560..9c343f7 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,11 +1,12 @@ use inc::Module::Install; requires( perl => '5.8.1'); name('Module-Refresh'); author('Jesse Vincent <[email protected]>'); license('perl'); version_from('lib/Module/Refresh.pm'); abstract_from('lib/Module/Refresh.pm'); build_requires ('Test::More' => 0, - 'File::Temp' => 0, + 'Path::Class' => 0, + 'File::Temp' => "0.19", ); &WriteAll;
bestpractical/module-refresh
12165463bdb498351ee80315d5b91999b009563b
Fixes for [rt.cpan.org #67262] subroutines not being unloaded
diff --git a/Changes b/Changes index b3c8964..5e362f4 100644 --- a/Changes +++ b/Changes @@ -1,72 +1,74 @@ + * Actually remove subroutines from the symbol table, Thanks to DOY. + 0.13 Thu May 3 23:03:00 EDT 2007 * Requires 5.8.1. (Uses tricks that don't work on 5.6). Thanks to DCANTRELL 0.12 Mon Apr 30 15:34:42 EDT 2007 * Requires 5.6. (Causes 5.5 to bus error). Thanks to RJBS. 0.11 Tue Apr 24 13:25:24 EDT 2007 * Fix for [rt.cpan.org #26536] Test suite uses /tmp with predictable filenames Reported by ANDK 0.10_01 Tue May 9 01:21:55 EDT 2006 * Module::Refresh->refresh_module_if_modified($module) as suggested by Daisuke Maki 0.09 Thu Dec 22 19:03:14 EST 2005 * Artur Bergman pointed out a bug in the overview docs. 0.08 * From Ivan Kohler. (rt.cpan.org #14879) Without this patch, I was getting a fatal error: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. This patch changes this to a warning and adds the name of the subroutine that triggered it. I now get the non-fatal warning: HTML::Mason::handler: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. 0.07 Sun Aug 21 13:25:20 EDT 2005 * Put in a work-around for a perl bug before 5.8.7. 0.06 Fri May 20 22:11:11 EDT 2005 * Trade overrefreshing for underrefreshing in some cases; test and document (We were over-aggressively reloading modules -- David Glasser 0.05 Tue Nov 16 23:15:10 EST 2004 * Explicitly, don't clobber the 'VERSION' symbol on setup. 0.04 Thu Nov 11 12:53:21 CST 2004 * Fix tests to run correctly on Win32. 0.03 Wed Nov 10 21:30:59 CST 2004 * "Anonymize" all our methods so we can refresh ourselves. * POD cleanup; nomenclature unification. * ->refresh now implicitly calls ->new for the first time. minor doc updates * Various cleanups to make it 5.005-friendly. * Use (inode, size, mtime) as the cache value instead of mtime alone. 0.02 Wed Nov 10 18:28:12 CST 2004 - Now we clean out subroutines loaded by the package we're unloading. 0.01 Mon Nov 8 19:48:00 CST 2004 - Initial release diff --git a/MANIFEST b/MANIFEST index 42c5d55..875e1a8 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,17 +1,18 @@ -SIGNATURE Changes inc/Module/Install.pm inc/Module/Install/Base.pm inc/Module/Install/Can.pm inc/Module/Install/Fetch.pm inc/Module/Install/Makefile.pm inc/Module/Install/Metadata.pm inc/Module/Install/Win32.pm inc/Module/Install/WriteAll.pm lib/Module/Refresh.pm Makefile.PL MANIFEST This list of files META.yml +SIGNATURE t/0-smoke.t t/1api.t t/2lateuse.t +t/clear_symtable.t diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index ce6259c..b8bf3c3 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,226 +1,233 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); $VERSION = "0.13"; BEGIN { # Turn on the debugger's symbol source tracing $^P |= 0x10; # Work around bug in pre-5.8.7 perl where turning on $^P # causes caller() to be confused about eval {}'s in the stack. # (See http://rt.perl.org/rt3/Ticket/Display.html?id=35059 for more info.) eval 'sub DB::sub' if $] < 5.008007; } =head1 NAME Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS # During each request, call this once to refresh changed modules: Module::Refresh->refresh; # Each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Acme/Current.pm'); =head1 DESCRIPTION This module is a generalization of the functionality provided by L<Apache::StatINC> and L<Apache::Reload>. It's designed to make it easy to do simple iterative development when working in a persistent environment. It does not require mod_perl. =cut =head2 new Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->update_cache($_) for keys %INC; return ($self); } =head2 refresh Refresh all modules that have mtimes on disk newer than the newest ones we've got. Calls C<new> to initialize the cache if it had not yet been called. Specifically, it will renew any module that was loaded before the previous call to C<refresh> (or C<new>) and has changed on disk since then. If a module was both loaded for the first time B<and> changed on disk between the previous call and this one, it will B<not> be reloaded by this call (or any future one); you will need to update the modification time again (by using the Unix C<touch> command or making a change to it) in order for it to be reloaded. =cut sub refresh { my $self = shift; return $self->new if !%CACHE; foreach my $mod ( sort keys %INC ) { $self->refresh_module_if_modified($mod); } return ($self); } =head2 refresh_module_if_modified $module If $module has been modified on disk, refresh it. Otherwise, do nothing =cut sub refresh_module_if_modified { my $self = shift; return $self->new if !%CACHE; my $mod = shift; if ( !$CACHE{$mod} ) { $self->update_cache($mod); } elsif ( $self->mtime( $INC{$mod} ) ne $CACHE{$mod} ) { $self->refresh_module($mod); } } =head2 refresh_module $module Refresh a module. It doesn't matter if it's already up to date. Just do it. Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->update_cache($mod); return ($self); } =head2 unload_module $module Remove a module from C<%INC>, and remove all subroutines defined in it. =cut sub unload_module { my $self = shift; my $mod = shift; my $file = $INC{$mod}; delete $INC{$mod}; delete $CACHE{$mod}; $self->unload_subs($file); return ($self); } =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat( $_[1] ) )[ 1, 7, 9 ]; } =head2 update_cache $file Updates the cached "last modified" time for $file. =cut sub update_cache { my $self = shift; my $module_pm = shift; $CACHE{$module_pm} = $self->mtime( $INC{$module_pm} ); } =head2 unload_subs $file Wipe out subs defined in $file. =cut sub unload_subs { my $self = shift; my $file = shift; foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { + warn "Deleting $sym from $file" if ( $sym =~ /freeze/ ); eval { undef &$sym }; warn "$sym: $@" if $@; delete $DB::sub{$sym}; + { no strict 'refs'; + if ($sym =~ /^(.*::)(.*?)$/) { + delete *{$1}->{$2}; + } + } } return $self; } # "Anonymize" all our subroutines into unnamed closures; so we can safely # refresh this very package. BEGIN { no strict 'refs'; foreach my $sym ( sort keys %{ __PACKAGE__ . '::' } ) { next if $sym eq 'VERSION'; # Skip the version sub, inherited from UNIVERSAL my $code = __PACKAGE__->can($sym) or next; delete ${ __PACKAGE__ . '::' }{$sym}; *$sym = sub { goto &$code }; } } 1; =head1 BUGS -When we walk the symbol table to whack reloaded subroutines, we don't have a good way -to invalidate the symbol table. +When we walk the symbol table to whack reloaded subroutines, we don't +have a good way to invalidate the symbol table properly, so we mess up +on things like global variables that were previously set. =head1 SEE ALSO L<Apache::StatINC>, L<Module::Reload> =head1 COPYRIGHT -Copyright 2004 by Jesse Vincent E<lt>[email protected]<gt>, -Autrijus Tang E<lt>[email protected]<gt> +Copyright 2004,2011 by Jesse Vincent E<lt>[email protected]<gt>, +Audrey Tang E<lt>[email protected]<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<http://www.perl.com/perl/misc/Artistic.html> =cut
bestpractical/module-refresh
58fb2de2757af7cd6102dde160e47b9baf142bd4
* 0.13. Does not work on 5.6
diff --git a/Changes b/Changes index 387b124..b3c8964 100644 --- a/Changes +++ b/Changes @@ -1,68 +1,72 @@ +0.13 Thu May 3 23:03:00 EDT 2007 + + * Requires 5.8.1. (Uses tricks that don't work on 5.6). Thanks to DCANTRELL + 0.12 Mon Apr 30 15:34:42 EDT 2007 * Requires 5.6. (Causes 5.5 to bus error). Thanks to RJBS. 0.11 Tue Apr 24 13:25:24 EDT 2007 * Fix for [rt.cpan.org #26536] Test suite uses /tmp with predictable filenames Reported by ANDK 0.10_01 Tue May 9 01:21:55 EDT 2006 * Module::Refresh->refresh_module_if_modified($module) as suggested by Daisuke Maki 0.09 Thu Dec 22 19:03:14 EST 2005 * Artur Bergman pointed out a bug in the overview docs. 0.08 * From Ivan Kohler. (rt.cpan.org #14879) Without this patch, I was getting a fatal error: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. This patch changes this to a warning and adds the name of the subroutine that triggered it. I now get the non-fatal warning: HTML::Mason::handler: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. 0.07 Sun Aug 21 13:25:20 EDT 2005 * Put in a work-around for a perl bug before 5.8.7. 0.06 Fri May 20 22:11:11 EDT 2005 * Trade overrefreshing for underrefreshing in some cases; test and document (We were over-aggressively reloading modules -- David Glasser 0.05 Tue Nov 16 23:15:10 EST 2004 * Explicitly, don't clobber the 'VERSION' symbol on setup. 0.04 Thu Nov 11 12:53:21 CST 2004 * Fix tests to run correctly on Win32. 0.03 Wed Nov 10 21:30:59 CST 2004 * "Anonymize" all our methods so we can refresh ourselves. * POD cleanup; nomenclature unification. * ->refresh now implicitly calls ->new for the first time. minor doc updates * Various cleanups to make it 5.005-friendly. * Use (inode, size, mtime) as the cache value instead of mtime alone. 0.02 Wed Nov 10 18:28:12 CST 2004 - Now we clean out subroutines loaded by the package we're unloading. 0.01 Mon Nov 8 19:48:00 CST 2004 - Initial release diff --git a/Makefile.PL b/Makefile.PL index 85802b2..196e560 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,11 +1,11 @@ use inc::Module::Install; -requires( perl => '5.6.1'); +requires( perl => '5.8.1'); name('Module-Refresh'); author('Jesse Vincent <[email protected]>'); license('perl'); version_from('lib/Module/Refresh.pm'); abstract_from('lib/Module/Refresh.pm'); build_requires ('Test::More' => 0, 'File::Temp' => 0, ); &WriteAll; diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index 0771338..ce6259c 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,226 +1,226 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); -$VERSION = "0.12"; +$VERSION = "0.13"; BEGIN { # Turn on the debugger's symbol source tracing $^P |= 0x10; # Work around bug in pre-5.8.7 perl where turning on $^P # causes caller() to be confused about eval {}'s in the stack. # (See http://rt.perl.org/rt3/Ticket/Display.html?id=35059 for more info.) eval 'sub DB::sub' if $] < 5.008007; } =head1 NAME Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS # During each request, call this once to refresh changed modules: Module::Refresh->refresh; # Each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Acme/Current.pm'); =head1 DESCRIPTION This module is a generalization of the functionality provided by L<Apache::StatINC> and L<Apache::Reload>. It's designed to make it easy to do simple iterative development when working in a persistent environment. It does not require mod_perl. =cut =head2 new Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->update_cache($_) for keys %INC; return ($self); } =head2 refresh Refresh all modules that have mtimes on disk newer than the newest ones we've got. Calls C<new> to initialize the cache if it had not yet been called. Specifically, it will renew any module that was loaded before the previous call to C<refresh> (or C<new>) and has changed on disk since then. If a module was both loaded for the first time B<and> changed on disk between the previous call and this one, it will B<not> be reloaded by this call (or any future one); you will need to update the modification time again (by using the Unix C<touch> command or making a change to it) in order for it to be reloaded. =cut sub refresh { my $self = shift; return $self->new if !%CACHE; foreach my $mod ( sort keys %INC ) { $self->refresh_module_if_modified($mod); } return ($self); } =head2 refresh_module_if_modified $module If $module has been modified on disk, refresh it. Otherwise, do nothing =cut sub refresh_module_if_modified { my $self = shift; return $self->new if !%CACHE; my $mod = shift; if ( !$CACHE{$mod} ) { $self->update_cache($mod); } elsif ( $self->mtime( $INC{$mod} ) ne $CACHE{$mod} ) { $self->refresh_module($mod); } } =head2 refresh_module $module Refresh a module. It doesn't matter if it's already up to date. Just do it. Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->update_cache($mod); return ($self); } =head2 unload_module $module Remove a module from C<%INC>, and remove all subroutines defined in it. =cut sub unload_module { my $self = shift; my $mod = shift; my $file = $INC{$mod}; delete $INC{$mod}; delete $CACHE{$mod}; $self->unload_subs($file); return ($self); } =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat( $_[1] ) )[ 1, 7, 9 ]; } =head2 update_cache $file Updates the cached "last modified" time for $file. =cut sub update_cache { my $self = shift; my $module_pm = shift; $CACHE{$module_pm} = $self->mtime( $INC{$module_pm} ); } =head2 unload_subs $file Wipe out subs defined in $file. =cut sub unload_subs { my $self = shift; my $file = shift; foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { warn "Deleting $sym from $file" if ( $sym =~ /freeze/ ); eval { undef &$sym }; warn "$sym: $@" if $@; delete $DB::sub{$sym}; } return $self; } # "Anonymize" all our subroutines into unnamed closures; so we can safely # refresh this very package. BEGIN { no strict 'refs'; foreach my $sym ( sort keys %{ __PACKAGE__ . '::' } ) { next if $sym eq 'VERSION'; # Skip the version sub, inherited from UNIVERSAL my $code = __PACKAGE__->can($sym) or next; delete ${ __PACKAGE__ . '::' }{$sym}; *$sym = sub { goto &$code }; } } 1; =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table. =head1 SEE ALSO L<Apache::StatINC>, L<Module::Reload> =head1 COPYRIGHT Copyright 2004 by Jesse Vincent E<lt>[email protected]<gt>, Autrijus Tang E<lt>[email protected]<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<http://www.perl.com/perl/misc/Artistic.html> =cut
bestpractical/module-refresh
e551a9de3e6025ceee3c17fcbc385f75e26691b8
* 0.11 - fixes a problem where the test suite didn't celan up after itself
diff --git a/Changes b/Changes index 9fe5f3d..623031f 100644 --- a/Changes +++ b/Changes @@ -1,58 +1,64 @@ + +0.11 Tue Apr 24 13:25:24 EDT 2007 + + * Fix for [rt.cpan.org #26536] Test suite uses /tmp with predictable filenames + Reported by ANDK + 0.10_01 Tue May 9 01:21:55 EDT 2006 * Module::Refresh->refresh_module_if_modified($module) as suggested by Daisuke Maki 0.09 Thu Dec 22 19:03:14 EST 2005 * Artur Bergman pointed out a bug in the overview docs. 0.08 * From Ivan Kohler. (rt.cpan.org #14879) Without this patch, I was getting a fatal error: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. This patch changes this to a warning and adds the name of the subroutine that triggered it. I now get the non-fatal warning: HTML::Mason::handler: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. 0.07 Sun Aug 21 13:25:20 EDT 2005 * Put in a work-around for a perl bug before 5.8.7. 0.06 Fri May 20 22:11:11 EDT 2005 * Trade overrefreshing for underrefreshing in some cases; test and document (We were over-aggressively reloading modules -- David Glasser 0.05 Tue Nov 16 23:15:10 EST 2004 * Explicitly, don't clobber the 'VERSION' symbol on setup. 0.04 Thu Nov 11 12:53:21 CST 2004 * Fix tests to run correctly on Win32. 0.03 Wed Nov 10 21:30:59 CST 2004 * "Anonymize" all our methods so we can refresh ourselves. * POD cleanup; nomenclature unification. * ->refresh now implicitly calls ->new for the first time. minor doc updates * Various cleanups to make it 5.005-friendly. * Use (inode, size, mtime) as the cache value instead of mtime alone. 0.02 Wed Nov 10 18:28:12 CST 2004 - Now we clean out subroutines loaded by the package we're unloading. 0.01 Mon Nov 8 19:48:00 CST 2004 - Initial release diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index 4d27699..2c3243c 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,226 +1,226 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); -$VERSION = "0.10_01"; +$VERSION = "0.11"; BEGIN { # Turn on the debugger's symbol source tracing $^P |= 0x10; # Work around bug in pre-5.8.7 perl where turning on $^P # causes caller() to be confused about eval {}'s in the stack. # (See http://rt.perl.org/rt3/Ticket/Display.html?id=35059 for more info.) eval 'sub DB::sub' if $] < 5.008007; } =head1 NAME Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS # During each request, call this once to refresh changed modules: Module::Refresh->refresh; # Each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Acme/Current.pm'); =head1 DESCRIPTION This module is a generalization of the functionality provided by L<Apache::StatINC> and L<Apache::Reload>. It's designed to make it easy to do simple iterative development when working in a persistent environment. It does not require mod_perl. =cut =head2 new Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->update_cache($_) for keys %INC; return ($self); } =head2 refresh Refresh all modules that have mtimes on disk newer than the newest ones we've got. Calls C<new> to initialize the cache if it had not yet been called. Specifically, it will renew any module that was loaded before the previous call to C<refresh> (or C<new>) and has changed on disk since then. If a module was both loaded for the first time B<and> changed on disk between the previous call and this one, it will B<not> be reloaded by this call (or any future one); you will need to update the modification time again (by using the Unix C<touch> command or making a change to it) in order for it to be reloaded. =cut sub refresh { my $self = shift; return $self->new if !%CACHE; foreach my $mod ( sort keys %INC ) { $self->refresh_module_if_modified($mod); } return ($self); } =head2 refresh_module_if_modified $module If $module has been modified on disk, refresh it. Otherwise, do nothing =cut sub refresh_module_if_modified { my $self = shift; return $self->new if !%CACHE; my $mod = shift; if ( !$CACHE{$mod} ) { $self->update_cache($mod); } elsif ( $self->mtime( $INC{$mod} ) ne $CACHE{$mod} ) { $self->refresh_module($mod); } } =head2 refresh_module $module Refresh a module. It doesn't matter if it's already up to date. Just do it. Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->update_cache($mod); return ($self); } =head2 unload_module $module Remove a module from C<%INC>, and remove all subroutines defined in it. =cut sub unload_module { my $self = shift; my $mod = shift; my $file = $INC{$mod}; delete $INC{$mod}; delete $CACHE{$mod}; $self->unload_subs($file); return ($self); } =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat( $_[1] ) )[ 1, 7, 9 ]; } =head2 update_cache $file Updates the cached "last modified" time for $file. =cut sub update_cache { my $self = shift; my $module_pm = shift; $CACHE{$module_pm} = $self->mtime( $INC{$module_pm} ); } =head2 unload_subs $file Wipe out subs defined in $file. =cut sub unload_subs { my $self = shift; my $file = shift; foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { warn "Deleting $sym from $file" if ( $sym =~ /freeze/ ); eval { undef &$sym }; warn "$sym: $@" if $@; delete $DB::sub{$sym}; } return $self; } # "Anonymize" all our subroutines into unnamed closures; so we can safely # refresh this very package. BEGIN { no strict 'refs'; foreach my $sym ( sort keys %{ __PACKAGE__ . '::' } ) { next if $sym eq 'VERSION'; # Skip the version sub, inherited from UNIVERSAL my $code = __PACKAGE__->can($sym) or next; delete ${ __PACKAGE__ . '::' }{$sym}; *$sym = sub { goto &$code }; } } 1; =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table. =head1 SEE ALSO L<Apache::StatINC>, L<Module::Reload> =head1 COPYRIGHT Copyright 2004 by Jesse Vincent E<lt>[email protected]<gt>, Autrijus Tang E<lt>[email protected]<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<http://www.perl.com/perl/misc/Artistic.html> =cut diff --git a/t/1api.t b/t/1api.t index feae6ce..adb74d3 100755 --- a/t/1api.t +++ b/t/1api.t @@ -1,70 +1,70 @@ #!/usr/bin/perl -w use strict; use Test::More qw/no_plan/; -use File::Spec; +use File::Temp 'tempdir'; +my $tmp = tempdir( CLEANUP => 1 ); -my $tmp = File::Spec->tmpdir; my $file = $tmp."/".'FooBar.pm'; push @INC, $tmp; write_out(<<"."); package Foo::Bar; sub foo { 'bar' } 1; . use_ok('Module::Refresh'); use_ok('FooBar', "Required our dummy module"); my $r = Module::Refresh->new(); # is our non-file-based method available? can_ok('Foo::Bar', 'not_in_foobarpm'); is(Foo::Bar->foo, 'bar', "We got the right result"); write_out(<<"."); package Foo::Bar; sub foo { 'baz' } 1; . is(Foo::Bar->foo, 'bar', "We got the right result, still"); $r->refresh; is(Foo::Bar->foo, 'baz', "We got the right new result,"); # After a refresh, did we blow away our non-file-based comp? can_ok('Foo::Bar', 'not_in_foobarpm'); $r->unload_subs($file); ok(!defined(&Foo::Bar::foo), "We cleaned out the 'foo' method'"); #ok(!UNIVERSAL::can('Foo::Bar', 'foo'), "We cleaned out the 'foo' method'"); #require "FooBar.pm"; #is(Foo::Bar->foo, 'baz', "We got the right new result,"); sub write_out { local *FH; open FH, "> $file" or die "Cannot open $file: $!"; print FH $_[0]; close FH; } END { unlink $file; } package Foo::Bar; sub not_in_foobarpm { return "woo"; } 1; diff --git a/t/2lateuse.t b/t/2lateuse.t index 2f0689b..9f1c386 100755 --- a/t/2lateuse.t +++ b/t/2lateuse.t @@ -1,45 +1,45 @@ #!/usr/bin/perl -w use strict; package FOOBAR; use Test::More qw/no_plan/; # can't really have a plan, since we're hoping the test will not be called -use File::Spec; +use File::Temp 'tempdir'; +my $tmp = tempdir( CLEANUP => 1 ); -my $tmp = File::Spec->tmpdir; my $file = $tmp."/".'BeepBeep.pm'; push @INC, $tmp; write_out(<<'.'); package BeepBeep; our $Beep; Test::More::is($Beep++, 0, "This line works exactly once!"); 1; . use_ok('Module::Refresh'); Module::Refresh->refresh; # This does the first INC scan use_ok('BeepBeep', "Required our dummy module"); Module::Refresh->refresh; # BeepBeep should *not* be refreshed here, because it has not # changed, even if M::R has not seen it before! sub write_out { local *FH; open FH, "> $file" or die "Cannot open $file: $!"; print FH $_[0]; close FH; } END { unlink $file; } 1;
bestpractical/module-refresh
b165a2592e84d299ca7ce70647abb349ac5d1019
* Tests should clean up after themselves
diff --git a/t/1api.t b/t/1api.t index d7696bf..feae6ce 100755 --- a/t/1api.t +++ b/t/1api.t @@ -1,66 +1,70 @@ #!/usr/bin/perl -w use strict; use Test::More qw/no_plan/; use File::Spec; my $tmp = File::Spec->tmpdir; my $file = $tmp."/".'FooBar.pm'; push @INC, $tmp; write_out(<<"."); package Foo::Bar; sub foo { 'bar' } 1; . use_ok('Module::Refresh'); use_ok('FooBar', "Required our dummy module"); my $r = Module::Refresh->new(); # is our non-file-based method available? can_ok('Foo::Bar', 'not_in_foobarpm'); is(Foo::Bar->foo, 'bar', "We got the right result"); write_out(<<"."); package Foo::Bar; sub foo { 'baz' } 1; . is(Foo::Bar->foo, 'bar', "We got the right result, still"); $r->refresh; is(Foo::Bar->foo, 'baz', "We got the right new result,"); # After a refresh, did we blow away our non-file-based comp? can_ok('Foo::Bar', 'not_in_foobarpm'); $r->unload_subs($file); ok(!defined(&Foo::Bar::foo), "We cleaned out the 'foo' method'"); #ok(!UNIVERSAL::can('Foo::Bar', 'foo'), "We cleaned out the 'foo' method'"); #require "FooBar.pm"; #is(Foo::Bar->foo, 'baz', "We got the right new result,"); sub write_out { local *FH; open FH, "> $file" or die "Cannot open $file: $!"; print FH $_[0]; close FH; } +END { + unlink $file; +} + package Foo::Bar; sub not_in_foobarpm { return "woo"; } 1; diff --git a/t/2lateuse.t b/t/2lateuse.t index 87d77cc..2f0689b 100755 --- a/t/2lateuse.t +++ b/t/2lateuse.t @@ -1,41 +1,45 @@ #!/usr/bin/perl -w use strict; package FOOBAR; use Test::More qw/no_plan/; # can't really have a plan, since we're hoping the test will not be called use File::Spec; my $tmp = File::Spec->tmpdir; my $file = $tmp."/".'BeepBeep.pm'; push @INC, $tmp; write_out(<<'.'); package BeepBeep; our $Beep; Test::More::is($Beep++, 0, "This line works exactly once!"); 1; . use_ok('Module::Refresh'); Module::Refresh->refresh; # This does the first INC scan use_ok('BeepBeep', "Required our dummy module"); Module::Refresh->refresh; # BeepBeep should *not* be refreshed here, because it has not # changed, even if M::R has not seen it before! sub write_out { local *FH; open FH, "> $file" or die "Cannot open $file: $!"; print FH $_[0]; close FH; } +END { + unlink $file; +} + 1;
bestpractical/module-refresh
121c0b344f78d8ca9f54cdf41b8b5606d1a41d40
0.10_01 Tue May 9 01:21:55 EDT 2006
diff --git a/Changes b/Changes index 2d1e7ac..9fe5f3d 100644 --- a/Changes +++ b/Changes @@ -1,53 +1,58 @@ +0.10_01 Tue May 9 01:21:55 EDT 2006 + +* Module::Refresh->refresh_module_if_modified($module) + as suggested by Daisuke Maki + 0.09 Thu Dec 22 19:03:14 EST 2005 * Artur Bergman pointed out a bug in the overview docs. 0.08 * From Ivan Kohler. (rt.cpan.org #14879) Without this patch, I was getting a fatal error: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. This patch changes this to a warning and adds the name of the subroutine that triggered it. I now get the non-fatal warning: HTML::Mason::handler: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. 0.07 Sun Aug 21 13:25:20 EDT 2005 * Put in a work-around for a perl bug before 5.8.7. 0.06 Fri May 20 22:11:11 EDT 2005 * Trade overrefreshing for underrefreshing in some cases; test and document (We were over-aggressively reloading modules -- David Glasser 0.05 Tue Nov 16 23:15:10 EST 2004 * Explicitly, don't clobber the 'VERSION' symbol on setup. 0.04 Thu Nov 11 12:53:21 CST 2004 * Fix tests to run correctly on Win32. 0.03 Wed Nov 10 21:30:59 CST 2004 * "Anonymize" all our methods so we can refresh ourselves. * POD cleanup; nomenclature unification. * ->refresh now implicitly calls ->new for the first time. minor doc updates * Various cleanups to make it 5.005-friendly. * Use (inode, size, mtime) as the cache value instead of mtime alone. 0.02 Wed Nov 10 18:28:12 CST 2004 - Now we clean out subroutines loaded by the package we're unloading. 0.01 Mon Nov 8 19:48:00 CST 2004 - Initial release diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index 0aa090c..4d27699 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,206 +1,226 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); -$VERSION = "0.09"; +$VERSION = "0.10_01"; + +BEGIN { -BEGIN { # Turn on the debugger's symbol source tracing $^P |= 0x10; # Work around bug in pre-5.8.7 perl where turning on $^P # causes caller() to be confused about eval {}'s in the stack. # (See http://rt.perl.org/rt3/Ticket/Display.html?id=35059 for more info.) eval 'sub DB::sub' if $] < 5.008007; } =head1 NAME Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS # During each request, call this once to refresh changed modules: Module::Refresh->refresh; # Each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Acme/Current.pm'); =head1 DESCRIPTION This module is a generalization of the functionality provided by L<Apache::StatINC> and L<Apache::Reload>. It's designed to make it easy to do simple iterative development when working in a persistent environment. It does not require mod_perl. =cut =head2 new Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->update_cache($_) for keys %INC; return ($self); -}; +} =head2 refresh Refresh all modules that have mtimes on disk newer than the newest ones we've got. Calls C<new> to initialize the cache if it had not yet been called. Specifically, it will renew any module that was loaded before the previous call to C<refresh> (or C<new>) and has changed on disk since then. If a module was both loaded for the first time B<and> changed on disk between the previous call and this one, it will B<not> be reloaded by this call (or any future one); you will need to update the modification time again (by using the Unix C<touch> command or making a change to it) in order for it to be reloaded. =cut sub refresh { my $self = shift; return $self->new if !%CACHE; - foreach my $mod (sort keys %INC) { - if ( !$CACHE{$mod} ) { - $self->update_cache($mod); - } elsif ( $self->mtime($INC{$mod}) ne $CACHE{$mod} ) { - $self->refresh_module($mod); - } + foreach my $mod ( sort keys %INC ) { + $self->refresh_module_if_modified($mod); } return ($self); -}; +} + +=head2 refresh_module_if_modified $module + +If $module has been modified on disk, refresh it. Otherwise, do nothing + + +=cut + +sub refresh_module_if_modified { + my $self = shift; + return $self->new if !%CACHE; + my $mod = shift; + + if ( !$CACHE{$mod} ) { + $self->update_cache($mod); + } elsif ( $self->mtime( $INC{$mod} ) ne $CACHE{$mod} ) { + $self->refresh_module($mod); + } + +} =head2 refresh_module $module Refresh a module. It doesn't matter if it's already up to date. Just do it. Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->update_cache($mod); return ($self); -}; +} =head2 unload_module $module Remove a module from C<%INC>, and remove all subroutines defined in it. =cut sub unload_module { my $self = shift; my $mod = shift; my $file = $INC{$mod}; delete $INC{$mod}; delete $CACHE{$mod}; $self->unload_subs($file); return ($self); -}; +} =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { - return join ' ', ( stat($_[1]) )[1, 7, 9]; -}; + return join ' ', ( stat( $_[1] ) )[ 1, 7, 9 ]; +} =head2 update_cache $file Updates the cached "last modified" time for $file. =cut sub update_cache { - my $self = shift; + my $self = shift; my $module_pm = shift; - $CACHE{$module_pm} = $self->mtime($INC{$module_pm}); -}; + $CACHE{$module_pm} = $self->mtime( $INC{$module_pm} ); +} =head2 unload_subs $file Wipe out subs defined in $file. =cut sub unload_subs { my $self = shift; my $file = shift; - foreach my $sym ( - grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub - ) { - warn "Deleting $sym from $file" if ($sym =~ /freeze/); + foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } + keys %DB::sub ) + { + warn "Deleting $sym from $file" if ( $sym =~ /freeze/ ); eval { undef &$sym }; warn "$sym: $@" if $@; delete $DB::sub{$sym}; } return $self; -}; +} # "Anonymize" all our subroutines into unnamed closures; so we can safely # refresh this very package. BEGIN { no strict 'refs'; - foreach my $sym (sort keys %{__PACKAGE__.'::'}) { - next if $sym eq 'VERSION'; # Skip the version sub, inherited from UNIVERSAL + foreach my $sym ( sort keys %{ __PACKAGE__ . '::' } ) { + next + if $sym eq + 'VERSION'; # Skip the version sub, inherited from UNIVERSAL my $code = __PACKAGE__->can($sym) or next; - delete ${__PACKAGE__.'::'}{$sym}; + delete ${ __PACKAGE__ . '::' }{$sym}; *$sym = sub { goto &$code }; } } 1; =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table. =head1 SEE ALSO L<Apache::StatINC>, L<Module::Reload> =head1 COPYRIGHT Copyright 2004 by Jesse Vincent E<lt>[email protected]<gt>, Autrijus Tang E<lt>[email protected]<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<http://www.perl.com/perl/misc/Artistic.html> =cut +
bestpractical/module-refresh
a666c0fc06be194a3ed8456bafe00cb8a6da7ba4
* 0.09 -doc fixes
diff --git a/Changes b/Changes index 30c7fa3..2d1e7ac 100644 --- a/Changes +++ b/Changes @@ -1,49 +1,53 @@ +0.09 Thu Dec 22 19:03:14 EST 2005 + +* Artur Bergman pointed out a bug in the overview docs. + 0.08 * From Ivan Kohler. (rt.cpan.org #14879) Without this patch, I was getting a fatal error: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. This patch changes this to a warning and adds the name of the subroutine that triggered it. I now get the non-fatal warning: HTML::Mason::handler: Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. 0.07 Sun Aug 21 13:25:20 EDT 2005 * Put in a work-around for a perl bug before 5.8.7. 0.06 Fri May 20 22:11:11 EDT 2005 * Trade overrefreshing for underrefreshing in some cases; test and document (We were over-aggressively reloading modules -- David Glasser 0.05 Tue Nov 16 23:15:10 EST 2004 * Explicitly, don't clobber the 'VERSION' symbol on setup. 0.04 Thu Nov 11 12:53:21 CST 2004 * Fix tests to run correctly on Win32. 0.03 Wed Nov 10 21:30:59 CST 2004 * "Anonymize" all our methods so we can refresh ourselves. * POD cleanup; nomenclature unification. * ->refresh now implicitly calls ->new for the first time. minor doc updates * Various cleanups to make it 5.005-friendly. * Use (inode, size, mtime) as the cache value instead of mtime alone. 0.02 Wed Nov 10 18:28:12 CST 2004 - Now we clean out subroutines loaded by the package we're unloading. 0.01 Mon Nov 8 19:48:00 CST 2004 - Initial release diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index 7289bc2..0aa090c 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,206 +1,206 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); -$VERSION = "0.08"; +$VERSION = "0.09"; BEGIN { # Turn on the debugger's symbol source tracing $^P |= 0x10; # Work around bug in pre-5.8.7 perl where turning on $^P # causes caller() to be confused about eval {}'s in the stack. # (See http://rt.perl.org/rt3/Ticket/Display.html?id=35059 for more info.) eval 'sub DB::sub' if $] < 5.008007; } =head1 NAME Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS # During each request, call this once to refresh changed modules: Module::Refresh->refresh; # Each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: - $refresher->refresh_module('Acme::Current'); + $refresher->refresh_module('Acme/Current.pm'); =head1 DESCRIPTION This module is a generalization of the functionality provided by L<Apache::StatINC> and L<Apache::Reload>. It's designed to make it easy to do simple iterative development when working in a persistent environment. It does not require mod_perl. =cut =head2 new Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->update_cache($_) for keys %INC; return ($self); }; =head2 refresh Refresh all modules that have mtimes on disk newer than the newest ones we've got. Calls C<new> to initialize the cache if it had not yet been called. Specifically, it will renew any module that was loaded before the previous call to C<refresh> (or C<new>) and has changed on disk since then. If a module was both loaded for the first time B<and> changed on disk between the previous call and this one, it will B<not> be reloaded by this call (or any future one); you will need to update the modification time again (by using the Unix C<touch> command or making a change to it) in order for it to be reloaded. =cut sub refresh { my $self = shift; return $self->new if !%CACHE; foreach my $mod (sort keys %INC) { if ( !$CACHE{$mod} ) { $self->update_cache($mod); } elsif ( $self->mtime($INC{$mod}) ne $CACHE{$mod} ) { $self->refresh_module($mod); } } return ($self); }; =head2 refresh_module $module Refresh a module. It doesn't matter if it's already up to date. Just do it. Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->update_cache($mod); return ($self); }; =head2 unload_module $module Remove a module from C<%INC>, and remove all subroutines defined in it. =cut sub unload_module { my $self = shift; my $mod = shift; my $file = $INC{$mod}; delete $INC{$mod}; delete $CACHE{$mod}; $self->unload_subs($file); return ($self); }; =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat($_[1]) )[1, 7, 9]; }; =head2 update_cache $file Updates the cached "last modified" time for $file. =cut sub update_cache { my $self = shift; my $module_pm = shift; $CACHE{$module_pm} = $self->mtime($INC{$module_pm}); }; =head2 unload_subs $file Wipe out subs defined in $file. =cut sub unload_subs { my $self = shift; my $file = shift; foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { warn "Deleting $sym from $file" if ($sym =~ /freeze/); eval { undef &$sym }; warn "$sym: $@" if $@; delete $DB::sub{$sym}; } return $self; }; # "Anonymize" all our subroutines into unnamed closures; so we can safely # refresh this very package. BEGIN { no strict 'refs'; foreach my $sym (sort keys %{__PACKAGE__.'::'}) { next if $sym eq 'VERSION'; # Skip the version sub, inherited from UNIVERSAL my $code = __PACKAGE__->can($sym) or next; delete ${__PACKAGE__.'::'}{$sym}; *$sym = sub { goto &$code }; } } 1; =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table. =head1 SEE ALSO L<Apache::StatINC>, L<Module::Reload> =head1 COPYRIGHT Copyright 2004 by Jesse Vincent E<lt>[email protected]<gt>, Autrijus Tang E<lt>[email protected]<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<http://www.perl.com/perl/misc/Artistic.html> =cut
bestpractical/module-refresh
bb5504b482eb2b9840faded67b9f8fe468733d6d
tweak the DESCRIPTION block to be a little more informative
diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index ae5ce1b..7289bc2 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,203 +1,206 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); $VERSION = "0.08"; BEGIN { # Turn on the debugger's symbol source tracing $^P |= 0x10; # Work around bug in pre-5.8.7 perl where turning on $^P # causes caller() to be confused about eval {}'s in the stack. # (See http://rt.perl.org/rt3/Ticket/Display.html?id=35059 for more info.) eval 'sub DB::sub' if $] < 5.008007; } =head1 NAME Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS # During each request, call this once to refresh changed modules: Module::Refresh->refresh; # Each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Acme::Current'); =head1 DESCRIPTION This module is a generalization of the functionality provided by -B<Apache::StatINC>. It's designed to make it easy to do simple iterative -development when working in a persistent environment. +L<Apache::StatINC> and L<Apache::Reload>. It's designed to make it +easy to do simple iterative development when working in a persistent +environment. + +It does not require mod_perl. =cut =head2 new Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->update_cache($_) for keys %INC; return ($self); }; =head2 refresh Refresh all modules that have mtimes on disk newer than the newest ones we've got. Calls C<new> to initialize the cache if it had not yet been called. Specifically, it will renew any module that was loaded before the previous call to C<refresh> (or C<new>) and has changed on disk since then. If a module was both loaded for the first time B<and> changed on disk between the previous call and this one, it will B<not> be reloaded by this call (or any future one); you will need to update the modification time again (by using the Unix C<touch> command or making a change to it) in order for it to be reloaded. =cut sub refresh { my $self = shift; return $self->new if !%CACHE; foreach my $mod (sort keys %INC) { if ( !$CACHE{$mod} ) { $self->update_cache($mod); } elsif ( $self->mtime($INC{$mod}) ne $CACHE{$mod} ) { $self->refresh_module($mod); } } return ($self); }; =head2 refresh_module $module Refresh a module. It doesn't matter if it's already up to date. Just do it. Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->update_cache($mod); return ($self); }; =head2 unload_module $module Remove a module from C<%INC>, and remove all subroutines defined in it. =cut sub unload_module { my $self = shift; my $mod = shift; my $file = $INC{$mod}; delete $INC{$mod}; delete $CACHE{$mod}; $self->unload_subs($file); return ($self); }; =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat($_[1]) )[1, 7, 9]; }; =head2 update_cache $file Updates the cached "last modified" time for $file. =cut sub update_cache { my $self = shift; my $module_pm = shift; $CACHE{$module_pm} = $self->mtime($INC{$module_pm}); }; =head2 unload_subs $file Wipe out subs defined in $file. =cut sub unload_subs { my $self = shift; my $file = shift; foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { warn "Deleting $sym from $file" if ($sym =~ /freeze/); eval { undef &$sym }; warn "$sym: $@" if $@; delete $DB::sub{$sym}; } return $self; }; # "Anonymize" all our subroutines into unnamed closures; so we can safely # refresh this very package. BEGIN { no strict 'refs'; foreach my $sym (sort keys %{__PACKAGE__.'::'}) { next if $sym eq 'VERSION'; # Skip the version sub, inherited from UNIVERSAL my $code = __PACKAGE__->can($sym) or next; delete ${__PACKAGE__.'::'}{$sym}; *$sym = sub { goto &$code }; } } 1; =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table. =head1 SEE ALSO L<Apache::StatINC>, L<Module::Reload> =head1 COPYRIGHT Copyright 2004 by Jesse Vincent E<lt>[email protected]<gt>, Autrijus Tang E<lt>[email protected]<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<http://www.perl.com/perl/misc/Artistic.html> =cut
bestpractical/module-refresh
a990eb7ef9670217ba8069344e85b19580edf554
* blow-away-current-sub bug caught by ivan kohler
diff --git a/Changes b/Changes index ca59269..30c7fa3 100644 --- a/Changes +++ b/Changes @@ -1,37 +1,49 @@ +0.08 + * From Ivan Kohler. (rt.cpan.org #14879) + Without this patch, I was getting a fatal error: + Can't undef active subroutine at /usr/share/perl5/Module/Refresh.pm line 154. + + This patch changes this to a warning and adds the name of the subroutine that + triggered it. I now get the non-fatal warning: + + HTML::Mason::handler: Can't undef active subroutine at + /usr/share/perl5/Module/Refresh.pm line 154. + + 0.07 Sun Aug 21 13:25:20 EDT 2005 * Put in a work-around for a perl bug before 5.8.7. 0.06 Fri May 20 22:11:11 EDT 2005 * Trade overrefreshing for underrefreshing in some cases; test and document (We were over-aggressively reloading modules -- David Glasser 0.05 Tue Nov 16 23:15:10 EST 2004 * Explicitly, don't clobber the 'VERSION' symbol on setup. 0.04 Thu Nov 11 12:53:21 CST 2004 * Fix tests to run correctly on Win32. 0.03 Wed Nov 10 21:30:59 CST 2004 * "Anonymize" all our methods so we can refresh ourselves. * POD cleanup; nomenclature unification. * ->refresh now implicitly calls ->new for the first time. minor doc updates * Various cleanups to make it 5.005-friendly. * Use (inode, size, mtime) as the cache value instead of mtime alone. 0.02 Wed Nov 10 18:28:12 CST 2004 - Now we clean out subroutines loaded by the package we're unloading. 0.01 Mon Nov 8 19:48:00 CST 2004 - Initial release diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index c524955..ae5ce1b 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,202 +1,203 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); -$VERSION = "0.07"; +$VERSION = "0.08"; BEGIN { # Turn on the debugger's symbol source tracing $^P |= 0x10; # Work around bug in pre-5.8.7 perl where turning on $^P # causes caller() to be confused about eval {}'s in the stack. # (See http://rt.perl.org/rt3/Ticket/Display.html?id=35059 for more info.) eval 'sub DB::sub' if $] < 5.008007; } =head1 NAME Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS # During each request, call this once to refresh changed modules: Module::Refresh->refresh; # Each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Acme::Current'); =head1 DESCRIPTION This module is a generalization of the functionality provided by B<Apache::StatINC>. It's designed to make it easy to do simple iterative development when working in a persistent environment. =cut =head2 new Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->update_cache($_) for keys %INC; return ($self); }; =head2 refresh Refresh all modules that have mtimes on disk newer than the newest ones we've got. Calls C<new> to initialize the cache if it had not yet been called. Specifically, it will renew any module that was loaded before the previous call to C<refresh> (or C<new>) and has changed on disk since then. If a module was both loaded for the first time B<and> changed on disk between the previous call and this one, it will B<not> be reloaded by this call (or any future one); you will need to update the modification time again (by using the Unix C<touch> command or making a change to it) in order for it to be reloaded. =cut sub refresh { my $self = shift; return $self->new if !%CACHE; foreach my $mod (sort keys %INC) { if ( !$CACHE{$mod} ) { $self->update_cache($mod); } elsif ( $self->mtime($INC{$mod}) ne $CACHE{$mod} ) { $self->refresh_module($mod); } } return ($self); }; =head2 refresh_module $module Refresh a module. It doesn't matter if it's already up to date. Just do it. Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->update_cache($mod); return ($self); }; =head2 unload_module $module Remove a module from C<%INC>, and remove all subroutines defined in it. =cut sub unload_module { my $self = shift; my $mod = shift; my $file = $INC{$mod}; delete $INC{$mod}; delete $CACHE{$mod}; $self->unload_subs($file); return ($self); }; =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat($_[1]) )[1, 7, 9]; }; =head2 update_cache $file Updates the cached "last modified" time for $file. =cut sub update_cache { my $self = shift; my $module_pm = shift; $CACHE{$module_pm} = $self->mtime($INC{$module_pm}); }; =head2 unload_subs $file Wipe out subs defined in $file. =cut sub unload_subs { my $self = shift; my $file = shift; foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { warn "Deleting $sym from $file" if ($sym =~ /freeze/); - undef &$sym; + eval { undef &$sym }; + warn "$sym: $@" if $@; delete $DB::sub{$sym}; } return $self; }; # "Anonymize" all our subroutines into unnamed closures; so we can safely # refresh this very package. BEGIN { no strict 'refs'; foreach my $sym (sort keys %{__PACKAGE__.'::'}) { next if $sym eq 'VERSION'; # Skip the version sub, inherited from UNIVERSAL my $code = __PACKAGE__->can($sym) or next; delete ${__PACKAGE__.'::'}{$sym}; *$sym = sub { goto &$code }; } } 1; =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table. =head1 SEE ALSO L<Apache::StatINC>, L<Module::Reload> =head1 COPYRIGHT Copyright 2004 by Jesse Vincent E<lt>[email protected]<gt>, Autrijus Tang E<lt>[email protected]<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<http://www.perl.com/perl/misc/Artistic.html> =cut
bestpractical/module-refresh
72e79c713608d90ee536d1690eb618df23af14da
Workaround perl <5.8.7 $^P/eval/caller bug. This will be 0.07 once it definitely works.
diff --git a/Changes b/Changes index f79f726..ca59269 100644 --- a/Changes +++ b/Changes @@ -1,33 +1,37 @@ +0.07 Sun Aug 21 13:25:20 EDT 2005 + + * Put in a work-around for a perl bug before 5.8.7. + 0.06 Fri May 20 22:11:11 EDT 2005 * Trade overrefreshing for underrefreshing in some cases; test and document (We were over-aggressively reloading modules -- David Glasser 0.05 Tue Nov 16 23:15:10 EST 2004 * Explicitly, don't clobber the 'VERSION' symbol on setup. 0.04 Thu Nov 11 12:53:21 CST 2004 * Fix tests to run correctly on Win32. 0.03 Wed Nov 10 21:30:59 CST 2004 * "Anonymize" all our methods so we can refresh ourselves. * POD cleanup; nomenclature unification. * ->refresh now implicitly calls ->new for the first time. minor doc updates * Various cleanups to make it 5.005-friendly. * Use (inode, size, mtime) as the cache value instead of mtime alone. 0.02 Wed Nov 10 18:28:12 CST 2004 - Now we clean out subroutines loaded by the package we're unloading. 0.01 Mon Nov 8 19:48:00 CST 2004 - Initial release diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index adf8bbf..c524955 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,195 +1,202 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); -$VERSION = "0.06"; +$VERSION = "0.07"; -# Turn on the debugger's symbol source tracing -BEGIN { $^P |= 0x10 }; +BEGIN { + # Turn on the debugger's symbol source tracing + $^P |= 0x10; + + # Work around bug in pre-5.8.7 perl where turning on $^P + # causes caller() to be confused about eval {}'s in the stack. + # (See http://rt.perl.org/rt3/Ticket/Display.html?id=35059 for more info.) + eval 'sub DB::sub' if $] < 5.008007; +} =head1 NAME Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS # During each request, call this once to refresh changed modules: Module::Refresh->refresh; # Each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Acme::Current'); =head1 DESCRIPTION This module is a generalization of the functionality provided by B<Apache::StatINC>. It's designed to make it easy to do simple iterative development when working in a persistent environment. =cut =head2 new Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->update_cache($_) for keys %INC; return ($self); }; =head2 refresh Refresh all modules that have mtimes on disk newer than the newest ones we've got. Calls C<new> to initialize the cache if it had not yet been called. Specifically, it will renew any module that was loaded before the previous call to C<refresh> (or C<new>) and has changed on disk since then. If a module was both loaded for the first time B<and> changed on disk between the previous call and this one, it will B<not> be reloaded by this call (or any future one); you will need to update the modification time again (by using the Unix C<touch> command or making a change to it) in order for it to be reloaded. =cut sub refresh { my $self = shift; return $self->new if !%CACHE; foreach my $mod (sort keys %INC) { if ( !$CACHE{$mod} ) { $self->update_cache($mod); } elsif ( $self->mtime($INC{$mod}) ne $CACHE{$mod} ) { $self->refresh_module($mod); } } return ($self); }; =head2 refresh_module $module Refresh a module. It doesn't matter if it's already up to date. Just do it. Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->update_cache($mod); return ($self); }; =head2 unload_module $module Remove a module from C<%INC>, and remove all subroutines defined in it. =cut sub unload_module { my $self = shift; my $mod = shift; my $file = $INC{$mod}; delete $INC{$mod}; delete $CACHE{$mod}; $self->unload_subs($file); return ($self); }; =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat($_[1]) )[1, 7, 9]; }; =head2 update_cache $file Updates the cached "last modified" time for $file. =cut sub update_cache { my $self = shift; my $module_pm = shift; $CACHE{$module_pm} = $self->mtime($INC{$module_pm}); }; =head2 unload_subs $file Wipe out subs defined in $file. =cut sub unload_subs { my $self = shift; my $file = shift; foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { warn "Deleting $sym from $file" if ($sym =~ /freeze/); undef &$sym; delete $DB::sub{$sym}; } return $self; }; # "Anonymize" all our subroutines into unnamed closures; so we can safely # refresh this very package. BEGIN { no strict 'refs'; foreach my $sym (sort keys %{__PACKAGE__.'::'}) { next if $sym eq 'VERSION'; # Skip the version sub, inherited from UNIVERSAL my $code = __PACKAGE__->can($sym) or next; delete ${__PACKAGE__.'::'}{$sym}; *$sym = sub { goto &$code }; } } 1; =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table. =head1 SEE ALSO L<Apache::StatINC>, L<Module::Reload> =head1 COPYRIGHT Copyright 2004 by Jesse Vincent E<lt>[email protected]<gt>, Autrijus Tang E<lt>[email protected]<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<http://www.perl.com/perl/misc/Artistic.html> =cut
bestpractical/module-refresh
817d2691bc12be098d42bff3663e504cef223a8a
* This be 0.06
diff --git a/Changes b/Changes index e9370eb..f79f726 100644 --- a/Changes +++ b/Changes @@ -1,26 +1,33 @@ +0.06 Fri May 20 22:11:11 EDT 2005 + + * Trade overrefreshing for underrefreshing in some cases; test and document + (We were over-aggressively reloading modules + -- David Glasser + + 0.05 Tue Nov 16 23:15:10 EST 2004 * Explicitly, don't clobber the 'VERSION' symbol on setup. 0.04 Thu Nov 11 12:53:21 CST 2004 * Fix tests to run correctly on Win32. 0.03 Wed Nov 10 21:30:59 CST 2004 * "Anonymize" all our methods so we can refresh ourselves. * POD cleanup; nomenclature unification. * ->refresh now implicitly calls ->new for the first time. minor doc updates * Various cleanups to make it 5.005-friendly. * Use (inode, size, mtime) as the cache value instead of mtime alone. 0.02 Wed Nov 10 18:28:12 CST 2004 - Now we clean out subroutines loaded by the package we're unloading. 0.01 Mon Nov 8 19:48:00 CST 2004 - Initial release diff --git a/MANIFEST b/MANIFEST index 6d3ff26..42c5d55 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,14 +1,17 @@ +SIGNATURE +Changes inc/Module/Install.pm inc/Module/Install/Base.pm inc/Module/Install/Can.pm inc/Module/Install/Fetch.pm inc/Module/Install/Makefile.pm inc/Module/Install/Metadata.pm inc/Module/Install/Win32.pm inc/Module/Install/WriteAll.pm lib/Module/Refresh.pm Makefile.PL MANIFEST This list of files META.yml t/0-smoke.t t/1api.t +t/2lateuse.t diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index ec3e9b9..adf8bbf 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,194 +1,195 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); -$VERSION = "0.05"; +$VERSION = "0.06"; # Turn on the debugger's symbol source tracing BEGIN { $^P |= 0x10 }; =head1 NAME Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS # During each request, call this once to refresh changed modules: Module::Refresh->refresh; # Each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Acme::Current'); =head1 DESCRIPTION This module is a generalization of the functionality provided by B<Apache::StatINC>. It's designed to make it easy to do simple iterative development when working in a persistent environment. =cut =head2 new Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->update_cache($_) for keys %INC; return ($self); }; =head2 refresh Refresh all modules that have mtimes on disk newer than the newest ones we've got. Calls C<new> to initialize the cache if it had not yet been called. Specifically, it will renew any module that was loaded before the previous call to C<refresh> (or C<new>) and has changed on disk since then. If a module was both loaded for the first time B<and> changed on disk between the previous call and this one, it will B<not> be reloaded by this call (or any future one); you will need to update the modification time again (by using the Unix C<touch> command or making a change to it) in order for it to be reloaded. =cut sub refresh { my $self = shift; return $self->new if !%CACHE; foreach my $mod (sort keys %INC) { if ( !$CACHE{$mod} ) { $self->update_cache($mod); } elsif ( $self->mtime($INC{$mod}) ne $CACHE{$mod} ) { $self->refresh_module($mod); } } return ($self); }; =head2 refresh_module $module Refresh a module. It doesn't matter if it's already up to date. Just do it. Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->update_cache($mod); return ($self); }; =head2 unload_module $module Remove a module from C<%INC>, and remove all subroutines defined in it. =cut sub unload_module { my $self = shift; my $mod = shift; my $file = $INC{$mod}; delete $INC{$mod}; delete $CACHE{$mod}; $self->unload_subs($file); return ($self); }; =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat($_[1]) )[1, 7, 9]; }; =head2 update_cache $file Updates the cached "last modified" time for $file. =cut sub update_cache { my $self = shift; my $module_pm = shift; $CACHE{$module_pm} = $self->mtime($INC{$module_pm}); }; =head2 unload_subs $file Wipe out subs defined in $file. =cut sub unload_subs { my $self = shift; my $file = shift; foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { + warn "Deleting $sym from $file" if ($sym =~ /freeze/); undef &$sym; delete $DB::sub{$sym}; } return $self; }; # "Anonymize" all our subroutines into unnamed closures; so we can safely # refresh this very package. BEGIN { no strict 'refs'; foreach my $sym (sort keys %{__PACKAGE__.'::'}) { next if $sym eq 'VERSION'; # Skip the version sub, inherited from UNIVERSAL my $code = __PACKAGE__->can($sym) or next; delete ${__PACKAGE__.'::'}{$sym}; *$sym = sub { goto &$code }; } } 1; =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table. =head1 SEE ALSO L<Apache::StatINC>, L<Module::Reload> =head1 COPYRIGHT Copyright 2004 by Jesse Vincent E<lt>[email protected]<gt>, Autrijus Tang E<lt>[email protected]<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<http://www.perl.com/perl/misc/Artistic.html> =cut
bestpractical/module-refresh
7eddcf1c58b1f8645f3505d11ca2ca0421ca995d
Trade overrefreshing for underrefreshing in some cases; test and document
diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index 5095be0..ec3e9b9 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,172 +1,194 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); $VERSION = "0.05"; # Turn on the debugger's symbol source tracing BEGIN { $^P |= 0x10 }; =head1 NAME Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS # During each request, call this once to refresh changed modules: Module::Refresh->refresh; # Each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Acme::Current'); =head1 DESCRIPTION This module is a generalization of the functionality provided by B<Apache::StatINC>. It's designed to make it easy to do simple iterative development when working in a persistent environment. =cut =head2 new Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; - $CACHE{$_} = $self->mtime($INC{$_}) for ( keys %INC ); + $self->update_cache($_) for keys %INC; return ($self); }; =head2 refresh Refresh all modules that have mtimes on disk newer than the newest ones we've got. Calls C<new> to initialize the cache if it had not yet been called. +Specifically, it will renew any module that was loaded before the previous call +to C<refresh> (or C<new>) and has changed on disk since then. If a module was +both loaded for the first time B<and> changed on disk between the previous call +and this one, it will B<not> be reloaded by this call (or any future one); you +will need to update the modification time again (by using the Unix C<touch> command or +making a change to it) in order for it to be reloaded. + =cut sub refresh { my $self = shift; return $self->new if !%CACHE; foreach my $mod (sort keys %INC) { - if ( !$CACHE{$mod} or ( $self->mtime($INC{$mod}) ne $CACHE{$mod} ) ) { + if ( !$CACHE{$mod} ) { + $self->update_cache($mod); + } elsif ( $self->mtime($INC{$mod}) ne $CACHE{$mod} ) { $self->refresh_module($mod); } } return ($self); }; =head2 refresh_module $module Refresh a module. It doesn't matter if it's already up to date. Just do it. Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; - $CACHE{$mod} = $self->mtime( $INC{$mod} ); + $self->update_cache($mod); return ($self); }; =head2 unload_module $module Remove a module from C<%INC>, and remove all subroutines defined in it. =cut sub unload_module { my $self = shift; my $mod = shift; my $file = $INC{$mod}; delete $INC{$mod}; delete $CACHE{$mod}; $self->unload_subs($file); return ($self); }; =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat($_[1]) )[1, 7, 9]; }; +=head2 update_cache $file + +Updates the cached "last modified" time for $file. + +=cut + +sub update_cache { + my $self = shift; + my $module_pm = shift; + + $CACHE{$module_pm} = $self->mtime($INC{$module_pm}); +}; + =head2 unload_subs $file Wipe out subs defined in $file. =cut sub unload_subs { my $self = shift; my $file = shift; foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { undef &$sym; delete $DB::sub{$sym}; } return $self; }; # "Anonymize" all our subroutines into unnamed closures; so we can safely # refresh this very package. BEGIN { no strict 'refs'; foreach my $sym (sort keys %{__PACKAGE__.'::'}) { next if $sym eq 'VERSION'; # Skip the version sub, inherited from UNIVERSAL my $code = __PACKAGE__->can($sym) or next; delete ${__PACKAGE__.'::'}{$sym}; *$sym = sub { goto &$code }; } } 1; =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table. =head1 SEE ALSO L<Apache::StatINC>, L<Module::Reload> =head1 COPYRIGHT Copyright 2004 by Jesse Vincent E<lt>[email protected]<gt>, Autrijus Tang E<lt>[email protected]<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<http://www.perl.com/perl/misc/Artistic.html> =cut diff --git a/t/1api.t b/t/1api.t index 080797f..d7696bf 100755 --- a/t/1api.t +++ b/t/1api.t @@ -1,67 +1,66 @@ #!/usr/bin/perl -w use strict; use Test::More qw/no_plan/; use File::Spec; my $tmp = File::Spec->tmpdir; my $file = $tmp."/".'FooBar.pm'; push @INC, $tmp; write_out(<<"."); package Foo::Bar; sub foo { 'bar' } 1; . use_ok('Module::Refresh'); -my $r = Module::Refresh->new(); - use_ok('FooBar', "Required our dummy module"); +my $r = Module::Refresh->new(); + # is our non-file-based method available? can_ok('Foo::Bar', 'not_in_foobarpm'); - is(Foo::Bar->foo, 'bar', "We got the right result"); write_out(<<"."); package Foo::Bar; sub foo { 'baz' } 1; . is(Foo::Bar->foo, 'bar', "We got the right result, still"); $r->refresh; is(Foo::Bar->foo, 'baz', "We got the right new result,"); # After a refresh, did we blow away our non-file-based comp? can_ok('Foo::Bar', 'not_in_foobarpm'); $r->unload_subs($file); ok(!defined(&Foo::Bar::foo), "We cleaned out the 'foo' method'"); #ok(!UNIVERSAL::can('Foo::Bar', 'foo'), "We cleaned out the 'foo' method'"); #require "FooBar.pm"; #is(Foo::Bar->foo, 'baz', "We got the right new result,"); sub write_out { local *FH; open FH, "> $file" or die "Cannot open $file: $!"; print FH $_[0]; close FH; } package Foo::Bar; sub not_in_foobarpm { return "woo"; } 1; diff --git a/t/2lateuse.t b/t/2lateuse.t new file mode 100755 index 0000000..87d77cc --- /dev/null +++ b/t/2lateuse.t @@ -0,0 +1,41 @@ +#!/usr/bin/perl -w + +use strict; + +package FOOBAR; + +use Test::More qw/no_plan/; +# can't really have a plan, since we're hoping the test will not be called +use File::Spec; + +my $tmp = File::Spec->tmpdir; +my $file = $tmp."/".'BeepBeep.pm'; +push @INC, $tmp; + +write_out(<<'.'); +package BeepBeep; +our $Beep; +Test::More::is($Beep++, 0, "This line works exactly once!"); +1; +. + +use_ok('Module::Refresh'); + +Module::Refresh->refresh; # This does the first INC scan + +use_ok('BeepBeep', "Required our dummy module"); + +Module::Refresh->refresh; + +# BeepBeep should *not* be refreshed here, because it has not +# changed, even if M::R has not seen it before! + + +sub write_out { + local *FH; + open FH, "> $file" or die "Cannot open $file: $!"; + print FH $_[0]; + close FH; +} + +1;
bestpractical/module-refresh
8cfd18367a52aaa5847a9971c262f71863e56bbc
do not clobber our own version. become 0,05
diff --git a/Changes b/Changes index ae53045..e9370eb 100644 --- a/Changes +++ b/Changes @@ -1,22 +1,26 @@ +0.05 Tue Nov 16 23:15:10 EST 2004 + + * Explicitly, don't clobber the 'VERSION' symbol on setup. + 0.04 Thu Nov 11 12:53:21 CST 2004 * Fix tests to run correctly on Win32. 0.03 Wed Nov 10 21:30:59 CST 2004 * "Anonymize" all our methods so we can refresh ourselves. * POD cleanup; nomenclature unification. * ->refresh now implicitly calls ->new for the first time. minor doc updates * Various cleanups to make it 5.005-friendly. * Use (inode, size, mtime) as the cache value instead of mtime alone. 0.02 Wed Nov 10 18:28:12 CST 2004 - Now we clean out subroutines loaded by the package we're unloading. 0.01 Mon Nov 8 19:48:00 CST 2004 - Initial release diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index 11b6ea4..5095be0 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,170 +1,172 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); -$VERSION = "0.04"; +$VERSION = "0.05"; # Turn on the debugger's symbol source tracing BEGIN { $^P |= 0x10 }; =head1 NAME Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS # During each request, call this once to refresh changed modules: Module::Refresh->refresh; # Each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Acme::Current'); =head1 DESCRIPTION This module is a generalization of the functionality provided by B<Apache::StatINC>. It's designed to make it easy to do simple iterative development when working in a persistent environment. =cut =head2 new Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $CACHE{$_} = $self->mtime($INC{$_}) for ( keys %INC ); return ($self); }; =head2 refresh Refresh all modules that have mtimes on disk newer than the newest ones we've got. Calls C<new> to initialize the cache if it had not yet been called. =cut sub refresh { my $self = shift; return $self->new if !%CACHE; foreach my $mod (sort keys %INC) { if ( !$CACHE{$mod} or ( $self->mtime($INC{$mod}) ne $CACHE{$mod} ) ) { $self->refresh_module($mod); } } return ($self); }; =head2 refresh_module $module Refresh a module. It doesn't matter if it's already up to date. Just do it. Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $CACHE{$mod} = $self->mtime( $INC{$mod} ); return ($self); }; =head2 unload_module $module Remove a module from C<%INC>, and remove all subroutines defined in it. =cut sub unload_module { my $self = shift; my $mod = shift; my $file = $INC{$mod}; delete $INC{$mod}; delete $CACHE{$mod}; $self->unload_subs($file); return ($self); }; =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat($_[1]) )[1, 7, 9]; }; =head2 unload_subs $file Wipe out subs defined in $file. =cut sub unload_subs { my $self = shift; my $file = shift; foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { undef &$sym; delete $DB::sub{$sym}; } return $self; }; # "Anonymize" all our subroutines into unnamed closures; so we can safely # refresh this very package. BEGIN { no strict 'refs'; foreach my $sym (sort keys %{__PACKAGE__.'::'}) { + next if $sym eq 'VERSION'; # Skip the version sub, inherited from UNIVERSAL my $code = __PACKAGE__->can($sym) or next; delete ${__PACKAGE__.'::'}{$sym}; *$sym = sub { goto &$code }; } + } 1; =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table. =head1 SEE ALSO L<Apache::StatINC>, L<Module::Reload> =head1 COPYRIGHT Copyright 2004 by Jesse Vincent E<lt>[email protected]<gt>, Autrijus Tang E<lt>[email protected]<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<http://www.perl.com/perl/misc/Artistic.html> =cut
bestpractical/module-refresh
05fd349cad26accf54c0c817ca1a466a1b302a1f
* Fix tests to run correctly on win32
diff --git a/Changes b/Changes index 72ea95f..ae53045 100644 --- a/Changes +++ b/Changes @@ -1,19 +1,22 @@ +0.04 Thu Nov 11 12:53:21 CST 2004 + + * Fix tests to run correctly on Win32. 0.03 Wed Nov 10 21:30:59 CST 2004 * "Anonymize" all our methods so we can refresh ourselves. * POD cleanup; nomenclature unification. * ->refresh now implicitly calls ->new for the first time. minor doc updates * Various cleanups to make it 5.005-friendly. * Use (inode, size, mtime) as the cache value instead of mtime alone. 0.02 Wed Nov 10 18:28:12 CST 2004 - Now we clean out subroutines loaded by the package we're unloading. 0.01 Mon Nov 8 19:48:00 CST 2004 - Initial release diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index 352fe97..11b6ea4 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,170 +1,170 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); -$VERSION = "0.03"; +$VERSION = "0.04"; # Turn on the debugger's symbol source tracing BEGIN { $^P |= 0x10 }; =head1 NAME Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS # During each request, call this once to refresh changed modules: Module::Refresh->refresh; # Each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Acme::Current'); =head1 DESCRIPTION This module is a generalization of the functionality provided by B<Apache::StatINC>. It's designed to make it easy to do simple iterative development when working in a persistent environment. =cut =head2 new Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $CACHE{$_} = $self->mtime($INC{$_}) for ( keys %INC ); return ($self); }; =head2 refresh Refresh all modules that have mtimes on disk newer than the newest ones we've got. Calls C<new> to initialize the cache if it had not yet been called. =cut sub refresh { my $self = shift; return $self->new if !%CACHE; foreach my $mod (sort keys %INC) { if ( !$CACHE{$mod} or ( $self->mtime($INC{$mod}) ne $CACHE{$mod} ) ) { $self->refresh_module($mod); } } return ($self); }; =head2 refresh_module $module Refresh a module. It doesn't matter if it's already up to date. Just do it. Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $CACHE{$mod} = $self->mtime( $INC{$mod} ); return ($self); }; =head2 unload_module $module Remove a module from C<%INC>, and remove all subroutines defined in it. =cut sub unload_module { my $self = shift; my $mod = shift; my $file = $INC{$mod}; delete $INC{$mod}; delete $CACHE{$mod}; $self->unload_subs($file); return ($self); }; =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat($_[1]) )[1, 7, 9]; }; =head2 unload_subs $file Wipe out subs defined in $file. =cut sub unload_subs { my $self = shift; my $file = shift; foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { undef &$sym; delete $DB::sub{$sym}; } return $self; }; # "Anonymize" all our subroutines into unnamed closures; so we can safely # refresh this very package. BEGIN { no strict 'refs'; foreach my $sym (sort keys %{__PACKAGE__.'::'}) { my $code = __PACKAGE__->can($sym) or next; delete ${__PACKAGE__.'::'}{$sym}; *$sym = sub { goto &$code }; } } 1; =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table. =head1 SEE ALSO L<Apache::StatINC>, L<Module::Reload> =head1 COPYRIGHT Copyright 2004 by Jesse Vincent E<lt>[email protected]<gt>, Autrijus Tang E<lt>[email protected]<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<http://www.perl.com/perl/misc/Artistic.html> =cut diff --git a/t/1api.t b/t/1api.t index dede22a..080797f 100755 --- a/t/1api.t +++ b/t/1api.t @@ -1,67 +1,67 @@ #!/usr/bin/perl -w use strict; use Test::More qw/no_plan/; use File::Spec; my $tmp = File::Spec->tmpdir; -my $file = File::Spec->catfile($tmp, 'FooBar.pm'); +my $file = $tmp."/".'FooBar.pm'; push @INC, $tmp; write_out(<<"."); package Foo::Bar; sub foo { 'bar' } 1; . use_ok('Module::Refresh'); my $r = Module::Refresh->new(); use_ok('FooBar', "Required our dummy module"); # is our non-file-based method available? can_ok('Foo::Bar', 'not_in_foobarpm'); is(Foo::Bar->foo, 'bar', "We got the right result"); write_out(<<"."); package Foo::Bar; sub foo { 'baz' } 1; . is(Foo::Bar->foo, 'bar', "We got the right result, still"); $r->refresh; is(Foo::Bar->foo, 'baz', "We got the right new result,"); # After a refresh, did we blow away our non-file-based comp? can_ok('Foo::Bar', 'not_in_foobarpm'); $r->unload_subs($file); ok(!defined(&Foo::Bar::foo), "We cleaned out the 'foo' method'"); #ok(!UNIVERSAL::can('Foo::Bar', 'foo'), "We cleaned out the 'foo' method'"); #require "FooBar.pm"; #is(Foo::Bar->foo, 'baz', "We got the right new result,"); sub write_out { local *FH; open FH, "> $file" or die "Cannot open $file: $!"; print FH $_[0]; close FH; } package Foo::Bar; sub not_in_foobarpm { return "woo"; } 1;
bestpractical/module-refresh
e3b798bb741ee7094f8777de071fe11961eb54e7
Bumping to 0.03
diff --git a/Changes b/Changes index 111a419..72ea95f 100644 --- a/Changes +++ b/Changes @@ -1,7 +1,19 @@ + +0.03 Wed Nov 10 21:30:59 CST 2004 + + * "Anonymize" all our methods so we can refresh ourselves. + * POD cleanup; nomenclature unification. + * ->refresh now implicitly calls ->new for the first time. + + minor doc updates + + * Various cleanups to make it 5.005-friendly. + * Use (inode, size, mtime) as the cache value instead of mtime alone. + 0.02 Wed Nov 10 18:28:12 CST 2004 - Now we clean out subroutines loaded by the package we're unloading. 0.01 Mon Nov 8 19:48:00 CST 2004 - Initial release diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index d2b0aa6..352fe97 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,170 +1,170 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); -$VERSION = "0.02"; +$VERSION = "0.03"; # Turn on the debugger's symbol source tracing BEGIN { $^P |= 0x10 }; =head1 NAME Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS # During each request, call this once to refresh changed modules: Module::Refresh->refresh; # Each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Acme::Current'); =head1 DESCRIPTION This module is a generalization of the functionality provided by B<Apache::StatINC>. It's designed to make it easy to do simple iterative development when working in a persistent environment. =cut =head2 new Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $CACHE{$_} = $self->mtime($INC{$_}) for ( keys %INC ); return ($self); }; =head2 refresh Refresh all modules that have mtimes on disk newer than the newest ones we've got. Calls C<new> to initialize the cache if it had not yet been called. =cut sub refresh { my $self = shift; return $self->new if !%CACHE; foreach my $mod (sort keys %INC) { if ( !$CACHE{$mod} or ( $self->mtime($INC{$mod}) ne $CACHE{$mod} ) ) { $self->refresh_module($mod); } } return ($self); }; =head2 refresh_module $module Refresh a module. It doesn't matter if it's already up to date. Just do it. Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $CACHE{$mod} = $self->mtime( $INC{$mod} ); return ($self); }; =head2 unload_module $module Remove a module from C<%INC>, and remove all subroutines defined in it. =cut sub unload_module { my $self = shift; my $mod = shift; my $file = $INC{$mod}; delete $INC{$mod}; delete $CACHE{$mod}; $self->unload_subs($file); return ($self); }; =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat($_[1]) )[1, 7, 9]; }; =head2 unload_subs $file Wipe out subs defined in $file. =cut sub unload_subs { my $self = shift; my $file = shift; foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { undef &$sym; delete $DB::sub{$sym}; } return $self; }; # "Anonymize" all our subroutines into unnamed closures; so we can safely # refresh this very package. BEGIN { no strict 'refs'; foreach my $sym (sort keys %{__PACKAGE__.'::'}) { my $code = __PACKAGE__->can($sym) or next; delete ${__PACKAGE__.'::'}{$sym}; *$sym = sub { goto &$code }; } } 1; =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table. =head1 SEE ALSO L<Apache::StatINC>, L<Module::Reload> =head1 COPYRIGHT Copyright 2004 by Jesse Vincent E<lt>[email protected]<gt>, Autrijus Tang E<lt>[email protected]<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<http://www.perl.com/perl/misc/Artistic.html> =cut
bestpractical/module-refresh
8b79c2f3b547a2575f270e31f6ce6c638fb2439f
* "Anonymize" all our methods so we can refresh ourselves. * POD cleanup; nomenclature unification. * ->refresh now implicitly calls ->new for the first time.
diff --git a/Makefile.PL b/Makefile.PL index a88a1d1..2dc6659 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,8 +1,9 @@ use inc::Module::Install; name('Module-Refresh'); author('Jesse Vincent <[email protected]>'); license('perl'); version_from('lib/Module/Refresh.pm'); +abstract_from('lib/Module/Refresh.pm'); build_requires ('Test::More' => 0); &WriteAll; diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index fe5b362..d2b0aa6 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,163 +1,170 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); $VERSION = "0.02"; # Turn on the debugger's symbol source tracing -BEGIN {$^P |= 0x10}; +BEGIN { $^P |= 0x10 }; + +=head1 NAME + +Module::Refresh - Refresh %INC files when updated on disk =head1 SYNOPSIS - my $refresher = Module::Refresh->new(); + # During each request, call this once to refresh changed modules: - $refresher->refresh_updated(); + Module::Refresh->refresh; - # each night at midnight, you automatically download the latest - # Acme::Current from CPAN. Use this snippet to make your running + # Each night at midnight, you automatically download the latest + # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Acme::Current'); =head1 DESCRIPTION -This module is a generalization of the functionality provided by Apache::StatINC. It's designed to make it easy to do simple iterative development when working in a persistent environment. To that end +This module is a generalization of the functionality provided by +B<Apache::StatINC>. It's designed to make it easy to do simple iterative +development when working in a persistent environment. =cut =head2 new -Initialize the module refresher; +Initialize the module refresher. =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; - $self->initialize; - return $self; -} - -=head2 initialize - -When we start up, set the mtime of each module to I<now>, so we don't go about -refreshing and refreshing everything. - -=cut - -sub initialize { - my $self = shift; $CACHE{$_} = $self->mtime($INC{$_}) for ( keys %INC ); return ($self); -} +}; -=head2 refresh_updated +=head2 refresh -refresh all modules that have mtimes on disk newer than the newest ones we've got. +Refresh all modules that have mtimes on disk newer than the newest ones we've got. +Calls C<new> to initialize the cache if it had not yet been called. =cut -sub refresh_updated { +sub refresh { my $self = shift; + + return $self->new if !%CACHE; + foreach my $mod (sort keys %INC) { if ( !$CACHE{$mod} or ( $self->mtime($INC{$mod}) ne $CACHE{$mod} ) ) { $self->refresh_module($mod); } } return ($self); -} +}; + +=head2 refresh_module $module -=head2 refresh_module $mod +Refresh a module. It doesn't matter if it's already up to date. Just do it. -refresh module $mod. It doesn't matter if it's already up to date. Just do it. +Note that it only accepts module names like C<Foo/Bar.pm>, not C<Foo::Bar>. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; - $self->cache_mtime( $mod => $self->mtime( $INC{$mod} ) ); + $CACHE{$mod} = $self->mtime( $INC{$mod} ); return ($self); -} +}; + +=head2 unload_module $module + +Remove a module from C<%INC>, and remove all subroutines defined in it. + +=cut sub unload_module { my $self = shift; - my $file = shift; - my $path = $INC{$file}; - delete $INC{$file}; - delete $CACHE{$file}; - $self->cleanup_subs($path); - return ($self); -} - -sub cache_mtime { - my $self = shift; - my $mod = shift; - my $mtime = shift; + my $mod = shift; + my $file = $INC{$mod}; - $CACHE{$mod} = $mtime; + delete $INC{$mod}; + delete $CACHE{$mod}; + $self->unload_subs($file); return ($self); -} +}; =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat($_[1]) )[1, 7, 9]; -} +}; +=head2 unload_subs $file -=head2 cleanup_subs filename - -Wipe out subs defined in $file. +Wipe out subs defined in $file. =cut - -sub cleanup_subs { +sub unload_subs { my $self = shift; my $file = shift; - # Find all the entries in %DB::sub whose keys match "$file:" and wack em foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { undef &$sym; delete $DB::sub{$sym}; } - return ($self); + return $self; +}; + +# "Anonymize" all our subroutines into unnamed closures; so we can safely +# refresh this very package. +BEGIN { + no strict 'refs'; + foreach my $sym (sort keys %{__PACKAGE__.'::'}) { + my $code = __PACKAGE__->can($sym) or next; + delete ${__PACKAGE__.'::'}{$sym}; + *$sym = sub { goto &$code }; + } } +1; + =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table. -=head1 AUTHOR +=head1 SEE ALSO -Jesse Vincent <[email protected]> +L<Apache::StatINC>, L<Module::Reload> -8 November, 2004, Hua Lien, Taiwan +=head1 COPYRIGHT +Copyright 2004 by Jesse Vincent E<lt>[email protected]<gt>, +Autrijus Tang E<lt>[email protected]<gt> -=head1 SEE ALSO +This program is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. -L<Module::Refresh>, which does much the same thing, with a little less efficiency -up front. (And doesn't have the API for manual expiry. +See L<http://www.perl.com/perl/misc/Artistic.html> =cut - -1; diff --git a/t/1api.t b/t/1api.t index 3cf4a1f..dede22a 100755 --- a/t/1api.t +++ b/t/1api.t @@ -1,67 +1,67 @@ #!/usr/bin/perl -w use strict; use Test::More qw/no_plan/; use File::Spec; my $tmp = File::Spec->tmpdir; -my $module = File::Spec->catfile($tmp, 'FooBar.pm'); +my $file = File::Spec->catfile($tmp, 'FooBar.pm'); push @INC, $tmp; write_out(<<"."); package Foo::Bar; sub foo { 'bar' } 1; . use_ok('Module::Refresh'); my $r = Module::Refresh->new(); use_ok('FooBar', "Required our dummy module"); # is our non-file-based method available? can_ok('Foo::Bar', 'not_in_foobarpm'); is(Foo::Bar->foo, 'bar', "We got the right result"); write_out(<<"."); package Foo::Bar; sub foo { 'baz' } 1; . is(Foo::Bar->foo, 'bar', "We got the right result, still"); -$r->refresh_updated; +$r->refresh; is(Foo::Bar->foo, 'baz', "We got the right new result,"); # After a refresh, did we blow away our non-file-based comp? can_ok('Foo::Bar', 'not_in_foobarpm'); -$r->cleanup_subs($module); +$r->unload_subs($file); ok(!defined(&Foo::Bar::foo), "We cleaned out the 'foo' method'"); #ok(!UNIVERSAL::can('Foo::Bar', 'foo'), "We cleaned out the 'foo' method'"); #require "FooBar.pm"; #is(Foo::Bar->foo, 'baz', "We got the right new result,"); sub write_out { local *FH; - open FH, "> $module" or die "Cannot open $module: $!"; + open FH, "> $file" or die "Cannot open $file: $!"; print FH $_[0]; close FH; } package Foo::Bar; sub not_in_foobarpm { return "woo"; } 1;
bestpractical/module-refresh
3cf7df19a3f3d1ccb5c6f12f97fb305958254fd5
Minor doc fix
diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index b475762..fe5b362 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,163 +1,163 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); $VERSION = "0.02"; # Turn on the debugger's symbol source tracing BEGIN {$^P |= 0x10}; =head1 SYNOPSIS my $refresher = Module::Refresh->new(); $refresher->refresh_updated(); # each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: - $refresher->refresh_module('Apache::Current'); + $refresher->refresh_module('Acme::Current'); =head1 DESCRIPTION This module is a generalization of the functionality provided by Apache::StatINC. It's designed to make it easy to do simple iterative development when working in a persistent environment. To that end =cut =head2 new Initialize the module refresher; =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->initialize; return $self; } =head2 initialize When we start up, set the mtime of each module to I<now>, so we don't go about refreshing and refreshing everything. =cut sub initialize { my $self = shift; $CACHE{$_} = $self->mtime($INC{$_}) for ( keys %INC ); return ($self); } =head2 refresh_updated refresh all modules that have mtimes on disk newer than the newest ones we've got. =cut sub refresh_updated { my $self = shift; foreach my $mod (sort keys %INC) { if ( !$CACHE{$mod} or ( $self->mtime($INC{$mod}) ne $CACHE{$mod} ) ) { $self->refresh_module($mod); } } return ($self); } =head2 refresh_module $mod refresh module $mod. It doesn't matter if it's already up to date. Just do it. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->cache_mtime( $mod => $self->mtime( $INC{$mod} ) ); return ($self); } sub unload_module { my $self = shift; my $file = shift; my $path = $INC{$file}; delete $INC{$file}; delete $CACHE{$file}; $self->cleanup_subs($path); return ($self); } sub cache_mtime { my $self = shift; my $mod = shift; my $mtime = shift; $CACHE{$mod} = $mtime; return ($self); } =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat($_[1]) )[1, 7, 9]; } =head2 cleanup_subs filename Wipe out subs defined in $file. =cut sub cleanup_subs { my $self = shift; my $file = shift; # Find all the entries in %DB::sub whose keys match "$file:" and wack em foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { undef &$sym; delete $DB::sub{$sym}; } return ($self); } =head1 BUGS When we walk the symbol table to whack reloaded subroutines, we don't have a good way to invalidate the symbol table. =head1 AUTHOR Jesse Vincent <[email protected]> 8 November, 2004, Hua Lien, Taiwan =head1 SEE ALSO L<Module::Refresh>, which does much the same thing, with a little less efficiency up front. (And doesn't have the API for manual expiry. =cut 1;
bestpractical/module-refresh
f7e517dbdb07f19a18754991610e7f1ce8d9988b
minor doc updates
diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index 9dc91d6..b475762 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,165 +1,163 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); $VERSION = "0.02"; # Turn on the debugger's symbol source tracing BEGIN {$^P |= 0x10}; =head1 SYNOPSIS my $refresher = Module::Refresh->new(); $refresher->refresh_updated(); # each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Apache::Current'); =head1 DESCRIPTION This module is a generalization of the functionality provided by Apache::StatINC. It's designed to make it easy to do simple iterative development when working in a persistent environment. To that end =cut =head2 new Initialize the module refresher; =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->initialize; return $self; } =head2 initialize When we start up, set the mtime of each module to I<now>, so we don't go about refreshing and refreshing everything. =cut sub initialize { my $self = shift; $CACHE{$_} = $self->mtime($INC{$_}) for ( keys %INC ); return ($self); } =head2 refresh_updated refresh all modules that have mtimes on disk newer than the newest ones we've got. =cut sub refresh_updated { my $self = shift; foreach my $mod (sort keys %INC) { if ( !$CACHE{$mod} or ( $self->mtime($INC{$mod}) ne $CACHE{$mod} ) ) { $self->refresh_module($mod); } } return ($self); } =head2 refresh_module $mod refresh module $mod. It doesn't matter if it's already up to date. Just do it. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->cache_mtime( $mod => $self->mtime( $INC{$mod} ) ); return ($self); } sub unload_module { my $self = shift; my $file = shift; my $path = $INC{$file}; delete $INC{$file}; delete $CACHE{$file}; $self->cleanup_subs($path); return ($self); } sub cache_mtime { my $self = shift; my $mod = shift; my $mtime = shift; $CACHE{$mod} = $mtime; return ($self); } =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat($_[1]) )[1, 7, 9]; } =head2 cleanup_subs filename Wipe out subs defined in $file. =cut sub cleanup_subs { my $self = shift; my $file = shift; # Find all the entries in %DB::sub whose keys match "$file:" and wack em foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { undef &$sym; delete $DB::sub{$sym}; } return ($self); } =head1 BUGS -The module warns for each reloaded subroutine. We _could_ -(and probably _should_) walk the symbol table and whack -the old versions of the symbols - +When we walk the symbol table to whack reloaded subroutines, we don't have a good way +to invalidate the symbol table. =head1 AUTHOR Jesse Vincent <[email protected]> 8 November, 2004, Hua Lien, Taiwan =head1 SEE ALSO L<Module::Refresh>, which does much the same thing, with a little less efficiency up front. (And doesn't have the API for manual expiry. =cut 1;
bestpractical/module-refresh
5dfda843c7c771509877e10497b41621b351f3bc
Bumped to 0.02
diff --git a/Changes b/Changes index e604e4e..111a419 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,7 @@ +0.02 Wed Nov 10 18:28:12 CST 2004 + + - Now we clean out subroutines loaded by the package we're unloading. + 0.01 Mon Nov 8 19:48:00 CST 2004 - Initial release diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index a87eeaa..9dc91d6 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,165 +1,165 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); -$VERSION = 0.01; +$VERSION = "0.02"; # Turn on the debugger's symbol source tracing BEGIN {$^P |= 0x10}; =head1 SYNOPSIS my $refresher = Module::Refresh->new(); $refresher->refresh_updated(); # each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Apache::Current'); =head1 DESCRIPTION This module is a generalization of the functionality provided by Apache::StatINC. It's designed to make it easy to do simple iterative development when working in a persistent environment. To that end =cut =head2 new Initialize the module refresher; =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->initialize; return $self; } =head2 initialize When we start up, set the mtime of each module to I<now>, so we don't go about refreshing and refreshing everything. =cut sub initialize { my $self = shift; $CACHE{$_} = $self->mtime($INC{$_}) for ( keys %INC ); return ($self); } =head2 refresh_updated refresh all modules that have mtimes on disk newer than the newest ones we've got. =cut sub refresh_updated { my $self = shift; foreach my $mod (sort keys %INC) { if ( !$CACHE{$mod} or ( $self->mtime($INC{$mod}) ne $CACHE{$mod} ) ) { $self->refresh_module($mod); } } return ($self); } =head2 refresh_module $mod refresh module $mod. It doesn't matter if it's already up to date. Just do it. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->cache_mtime( $mod => $self->mtime( $INC{$mod} ) ); return ($self); } sub unload_module { my $self = shift; my $file = shift; my $path = $INC{$file}; delete $INC{$file}; delete $CACHE{$file}; $self->cleanup_subs($path); return ($self); } sub cache_mtime { my $self = shift; my $mod = shift; my $mtime = shift; $CACHE{$mod} = $mtime; return ($self); } =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat($_[1]) )[1, 7, 9]; } =head2 cleanup_subs filename Wipe out subs defined in $file. =cut sub cleanup_subs { my $self = shift; my $file = shift; # Find all the entries in %DB::sub whose keys match "$file:" and wack em foreach my $sym ( grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub ) { undef &$sym; delete $DB::sub{$sym}; } return ($self); } =head1 BUGS The module warns for each reloaded subroutine. We _could_ (and probably _should_) walk the symbol table and whack the old versions of the symbols =head1 AUTHOR Jesse Vincent <[email protected]> 8 November, 2004, Hua Lien, Taiwan =head1 SEE ALSO L<Module::Refresh>, which does much the same thing, with a little less efficiency up front. (And doesn't have the API for manual expiry. =cut 1;
bestpractical/module-refresh
de50e521a4f08803c9c0e3eeec78a921275eb1e3
* ->cleanup_subs now actually work as advertised. :)
diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index 344f426..a87eeaa 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,161 +1,165 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); $VERSION = 0.01; # Turn on the debugger's symbol source tracing BEGIN {$^P |= 0x10}; =head1 SYNOPSIS my $refresher = Module::Refresh->new(); $refresher->refresh_updated(); # each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Apache::Current'); =head1 DESCRIPTION This module is a generalization of the functionality provided by Apache::StatINC. It's designed to make it easy to do simple iterative development when working in a persistent environment. To that end =cut =head2 new Initialize the module refresher; =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->initialize; return $self; } =head2 initialize When we start up, set the mtime of each module to I<now>, so we don't go about refreshing and refreshing everything. =cut sub initialize { my $self = shift; $CACHE{$_} = $self->mtime($INC{$_}) for ( keys %INC ); return ($self); } =head2 refresh_updated refresh all modules that have mtimes on disk newer than the newest ones we've got. =cut sub refresh_updated { my $self = shift; foreach my $mod (sort keys %INC) { if ( !$CACHE{$mod} or ( $self->mtime($INC{$mod}) ne $CACHE{$mod} ) ) { $self->refresh_module($mod); } } return ($self); } =head2 refresh_module $mod refresh module $mod. It doesn't matter if it's already up to date. Just do it. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->cache_mtime( $mod => $self->mtime( $INC{$mod} ) ); return ($self); } sub unload_module { my $self = shift; my $file = shift; my $path = $INC{$file}; delete $INC{$file}; delete $CACHE{$file}; $self->cleanup_subs($path); return ($self); } sub cache_mtime { my $self = shift; my $mod = shift; my $mtime = shift; $CACHE{$mod} = $mtime; return ($self); } =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat($_[1]) )[1, 7, 9]; } =head2 cleanup_subs filename Wipe out subs defined in $file. =cut sub cleanup_subs { my $self = shift; my $file = shift; # Find all the entries in %DB::sub whose keys match "$file:" and wack em - foreach my $sym ( grep { $DB::sub{$_} =~ qr{^\Q$file:\E} } keys %DB::sub ) { - warn $sym; - undef &{$sym}; + foreach my $sym ( + grep { index( $DB::sub{$_}, "$file:" ) == 0 } keys %DB::sub + ) { + undef &$sym; + delete $DB::sub{$sym}; } + + return ($self); } =head1 BUGS The module warns for each reloaded subroutine. We _could_ (and probably _should_) walk the symbol table and whack the old versions of the symbols =head1 AUTHOR Jesse Vincent <[email protected]> 8 November, 2004, Hua Lien, Taiwan =head1 SEE ALSO L<Module::Refresh>, which does much the same thing, with a little less efficiency up front. (And doesn't have the API for manual expiry. =cut 1; diff --git a/t/1api.t b/t/1api.t index cf319a8..3cf4a1f 100755 --- a/t/1api.t +++ b/t/1api.t @@ -1,68 +1,67 @@ #!/usr/bin/perl -w use strict; use Test::More qw/no_plan/; use File::Spec; my $tmp = File::Spec->tmpdir; my $module = File::Spec->catfile($tmp, 'FooBar.pm'); push @INC, $tmp; write_out(<<"."); package Foo::Bar; sub foo { 'bar' } 1; . use_ok('Module::Refresh'); my $r = Module::Refresh->new(); use_ok('FooBar', "Required our dummy module"); # is our non-file-based method available? can_ok('Foo::Bar', 'not_in_foobarpm'); is(Foo::Bar->foo, 'bar', "We got the right result"); write_out(<<"."); package Foo::Bar; sub foo { 'baz' } 1; . is(Foo::Bar->foo, 'bar', "We got the right result, still"); $r->refresh_updated; is(Foo::Bar->foo, 'baz', "We got the right new result,"); # After a refresh, did we blow away our non-file-based comp? can_ok('Foo::Bar', 'not_in_foobarpm'); -delete $INC{'FooBar.pm'}; +$r->cleanup_subs($module); +ok(!defined(&Foo::Bar::foo), "We cleaned out the 'foo' method'"); -ok(!UNIVERSAL::can('Foo::Bar', 'foo'), "We cleaned out the 'foo' method'"); - -require "FooBar.pm"; - -is(Foo::Bar->foo, 'baz', "We got the right new result,"); +#ok(!UNIVERSAL::can('Foo::Bar', 'foo'), "We cleaned out the 'foo' method'"); +#require "FooBar.pm"; +#is(Foo::Bar->foo, 'baz', "We got the right new result,"); sub write_out { local *FH; open FH, "> $module" or die "Cannot open $module: $!"; print FH $_[0]; close FH; } package Foo::Bar; sub not_in_foobarpm { return "woo"; } 1;
bestpractical/module-refresh
7291e643e039309d45818a2e4da8df6a5d7cdf64
r9018@tinbook: jesse | 2004-11-10T10:01:29.891706Z First cut at actual symbol deletion
diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index 98bfb1b..344f426 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,153 +1,161 @@ package Module::Refresh; use strict; use vars qw( $VERSION %CACHE ); $VERSION = 0.01; +# Turn on the debugger's symbol source tracing +BEGIN {$^P |= 0x10}; + =head1 SYNOPSIS my $refresher = Module::Refresh->new(); $refresher->refresh_updated(); # each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Apache::Current'); =head1 DESCRIPTION This module is a generalization of the functionality provided by Apache::StatINC. It's designed to make it easy to do simple iterative development when working in a persistent environment. To that end =cut =head2 new Initialize the module refresher; =cut sub new { my $proto = shift; my $self = ref($proto) || $proto; $self->initialize; return $self; } =head2 initialize When we start up, set the mtime of each module to I<now>, so we don't go about refreshing and refreshing everything. =cut sub initialize { my $self = shift; $CACHE{$_} = $self->mtime($INC{$_}) for ( keys %INC ); return ($self); } =head2 refresh_updated refresh all modules that have mtimes on disk newer than the newest ones we've got. =cut sub refresh_updated { my $self = shift; foreach my $mod (sort keys %INC) { if ( !$CACHE{$mod} or ( $self->mtime($INC{$mod}) ne $CACHE{$mod} ) ) { $self->refresh_module($mod); } } return ($self); } =head2 refresh_module $mod refresh module $mod. It doesn't matter if it's already up to date. Just do it. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); local $@; eval { require $mod; 1 } or warn $@; $self->cache_mtime( $mod => $self->mtime( $INC{$mod} ) ); return ($self); } sub unload_module { my $self = shift; my $file = shift; + my $path = $INC{$file}; delete $INC{$file}; delete $CACHE{$file}; + $self->cleanup_subs($path); return ($self); } sub cache_mtime { my $self = shift; my $mod = shift; my $mtime = shift; $CACHE{$mod} = $mtime; return ($self); } =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { return join ' ', ( stat($_[1]) )[1, 7, 9]; } =head2 cleanup_subs filename Wipe out subs defined in $file. - =cut sub cleanup_subs { - my $self = shift; my $file = shift; -} + # Find all the entries in %DB::sub whose keys match "$file:" and wack em + foreach my $sym ( grep { $DB::sub{$_} =~ qr{^\Q$file:\E} } keys %DB::sub ) { + warn $sym; + undef &{$sym}; + } +} =head1 BUGS The module warns for each reloaded subroutine. We _could_ (and probably _should_) walk the symbol table and whack the old versions of the symbols =head1 AUTHOR Jesse Vincent <[email protected]> 8 November, 2004, Hua Lien, Taiwan =head1 SEE ALSO L<Module::Refresh>, which does much the same thing, with a little less efficiency up front. (And doesn't have the API for manual expiry. =cut 1; diff --git a/t/1api.t~ b/t/1api.t~ index 2c11b05..3968fe7 100755 --- a/t/1api.t~ +++ b/t/1api.t~ @@ -1,53 +1,56 @@ #!/usr/bin/perl -w use strict; use Test::More qw/no_plan/; use lib qw{/tmp}; `echo "package Foo::Bar; sub foo { 'bar'}\n1;" > /tmp/FooBar.pm`; use_ok('Module::Refresh'); my $r = Module::Refresh->new(); use_ok('FooBar', "Required our dummy module"); # is our non-file-based method available? can_ok('Foo::Bar', 'not_in_foobarpm'); is(Foo::Bar->foo, 'bar', "We got the right result"); `echo "package Foo::Bar; sub foo { 'baz'}\n1;" > /tmp/FooBar.pm`; is(Foo::Bar->foo, 'bar', "We got the right result, still"); $r->refresh_updated; sleep (2); # we only have second-level granularity is(Foo::Bar->foo, 'baz', "We got the right new result,"); # After a refresh, did we blow away our non-file-based comp? can_ok('Foo::Bar', 'not_in_foobarpm'); delete $INC{'FooBar.pm'}; ok(!UNIVERSAL::can('Foo::Bar', 'foo'), "We cleaned out the 'foo' method'"); require "FooBar.pm"; is(Foo::Bar->foo, 'baz', "We got the right new result,"); +use YAML; +YAML::Dump (\%DB::sub); + package Foo::Bar; sub not_in_foobarpm { return "woo"; } 1;
bestpractical/module-refresh
c71a5c471efc1d0af94045b4053f55dc275b0e44
* Various cleanups to make it 5.005-friendly. * Use (inode, size, mtime) as the cache value instead of mtime alone.
diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index 80431e7..98bfb1b 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,166 +1,153 @@ -use warnings; -use strict; - package Module::Refresh; -our $VERSION = '0.01'; +use strict; +use vars qw( $VERSION %CACHE ); -our %CACHE; +$VERSION = 0.01; -=head1 DESCRIPTION +=head1 SYNOPSIS -This module is a generalization of the functionality provided by Apache::StatINC. It's designed to make it easy to do simple iterative development when working in a persistent environment. To that end + my $refresher = Module::Refresh->new(); -=head1 EXAMPLE + $refresher->refresh_updated(); + # each night at midnight, you automatically download the latest + # Acme::Current from CPAN. Use this snippet to make your running + # program pick it up off disk: -my $refresher = Inc::Refresh->new(); + $refresher->refresh_module('Apache::Current'); -$refresher->refresh_updated(); - -# each night at midnight, you automatically download the latest -# Acme::Current from CPAN. Use this snippet to make your running -# program pick it up off disk: +=head1 DESCRIPTION -$refresher->refresh_module('Apache::Current'); +This module is a generalization of the functionality provided by Apache::StatINC. It's designed to make it easy to do simple iterative development when working in a persistent environment. To that end =cut =head2 new Initialize the module refresher; =cut sub new { my $proto = shift; - my $class = ref($proto) || $proto; - - my $self = {}; - bless $self, $class; - - $self->_initialize_cache(); - return ($self); + my $self = ref($proto) || $proto; + $self->initialize; + return $self; } -=head2 _initialize_cache +=head2 initialize -When we start up, set the mtime of each module to I<now>, so we don't go about refreshing - and refreshing everything. +When we start up, set the mtime of each module to I<now>, so we don't go about +refreshing and refreshing everything. =cut -sub _initialize_cache { +sub initialize { my $self = shift; - my $time = time(); - - $CACHE{$_} = $time for ( keys %INC ); - + $CACHE{$_} = $self->mtime($INC{$_}) for ( keys %INC ); return ($self); } =head2 refresh_updated refresh all modules that have mtimes on disk newer than the newest ones we've got. =cut sub refresh_updated { my $self = shift; - while ( my ( $mod, $path ) = each %INC ) { - if ( !$CACHE{$mod} || $self->mtime($path) > $CACHE{$mod} ) { + foreach my $mod (sort keys %INC) { + if ( !$CACHE{$mod} or ( $self->mtime($INC{$mod}) ne $CACHE{$mod} ) ) { $self->refresh_module($mod); } } return ($self); } =head2 refresh_module $mod refresh module $mod. It doesn't matter if it's already up to date. Just do it. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); - eval { - require $mod - }; - warn $@ if ($@); + local $@; + eval { require $mod; 1 } or warn $@; + $self->cache_mtime( $mod => $self->mtime( $INC{$mod} ) ); return ($self); } sub unload_module { my $self = shift; - my $mod = shift; - delete $INC{$mod}; - $self->cache_mtime( $mod => 0 ); - + my $file = shift; + delete $INC{$file}; + delete $CACHE{$file}; + return ($self); } sub cache_mtime { my $self = shift; my $mod = shift; my $mtime = shift; $CACHE{$mod} = $mtime; return ($self); } =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { - my $self = shift; - my $filename = shift; - return ( stat($filename) )[9]; + return join ' ', ( stat($_[1]) )[1, 7, 9]; } =head2 cleanup_subs filename Wipe out subs defined in $file. =cut sub cleanup_subs { my $self = shift; my $file = shift; } =head1 BUGS The module warns for each reloaded subroutine. We _could_ (and probably _should_) walk the symbol table and whack the old versions of the symbols =head1 AUTHOR Jesse Vincent <[email protected]> 8 November, 2004, Hua Lien, Taiwan =head1 SEE ALSO L<Module::Refresh>, which does much the same thing, with a little less efficiency up front. (And doesn't have the API for manual expiry. =cut 1; diff --git a/t/1api.t b/t/1api.t index 2c11b05..cf319a8 100755 --- a/t/1api.t +++ b/t/1api.t @@ -1,53 +1,68 @@ #!/usr/bin/perl -w use strict; use Test::More qw/no_plan/; +use File::Spec; -use lib qw{/tmp}; +my $tmp = File::Spec->tmpdir; +my $module = File::Spec->catfile($tmp, 'FooBar.pm'); +push @INC, $tmp; -`echo "package Foo::Bar; sub foo { 'bar'}\n1;" > /tmp/FooBar.pm`; +write_out(<<"."); +package Foo::Bar; +sub foo { 'bar' } +1; +. use_ok('Module::Refresh'); my $r = Module::Refresh->new(); use_ok('FooBar', "Required our dummy module"); # is our non-file-based method available? can_ok('Foo::Bar', 'not_in_foobarpm'); is(Foo::Bar->foo, 'bar', "We got the right result"); -`echo "package Foo::Bar; sub foo { 'baz'}\n1;" > /tmp/FooBar.pm`; +write_out(<<"."); +package Foo::Bar; +sub foo { 'baz' } +1; +. + is(Foo::Bar->foo, 'bar', "We got the right result, still"); $r->refresh_updated; -sleep (2); # we only have second-level granularity is(Foo::Bar->foo, 'baz', "We got the right new result,"); # After a refresh, did we blow away our non-file-based comp? can_ok('Foo::Bar', 'not_in_foobarpm'); delete $INC{'FooBar.pm'}; ok(!UNIVERSAL::can('Foo::Bar', 'foo'), "We cleaned out the 'foo' method'"); require "FooBar.pm"; is(Foo::Bar->foo, 'baz', "We got the right new result,"); +sub write_out { + local *FH; + open FH, "> $module" or die "Cannot open $module: $!"; + print FH $_[0]; + close FH; +} package Foo::Bar; sub not_in_foobarpm { return "woo"; } 1; - -
bestpractical/module-refresh
80d76684bfd71f35c2ce4b007ae50465892b9d99
More tests that fail!
diff --git a/Makefile b/Makefile index 2c02cae..248a3f7 100644 --- a/Makefile +++ b/Makefile @@ -1,745 +1,745 @@ # This Makefile is for the Module::Refresh extension to perl. # # It was generated automatically by MakeMaker version # 6.12 (Revision: 1.124) from the contents of # Makefile.PL. Don't edit this file, edit Makefile.PL instead. # # ANY CHANGES MADE HERE WILL BE LOST! # # MakeMaker ARGV: () # # MakeMaker Parameters: # AUTHOR => q[Jesse Vincent <[email protected]>] # DIR => [] # DISTNAME => q[Module-Refresh] # NAME => q[Module::Refresh] # NO_META => q[1] # PL_FILES => { } # PREREQ_PM => { Test::More=>q[0] } # VERSION => q[0.01] # dist => { PREOP=>q[$(PERL) -I. -MModule::Install::Admin -e "dist_preop(q($(DISTVNAME)))"] } # --- MakeMaker post_initialize section: # --- MakeMaker const_config section: # These definitions are from config.sh (via /System/Library/Perl/5.8.1/darwin-thread-multi-2level/Config.pm) # They may have been overridden via Makefile.PL or on the command line AR = ar CC = cc CCCDLFLAGS = CCDLFLAGS = DLEXT = bundle DLSRC = dl_dyld.xs LD = MACOSX_DEPLOYMENT_TARGET=10.3 cc LDDLFLAGS = -bundle -undefined dynamic_lookup -L/usr/local/lib LDFLAGS = -L/usr/local/lib LIBC = /usr/lib/libc.dylib LIB_EXT = .a OBJ_EXT = .o OSNAME = darwin OSVERS = 7.0 RANLIB = /usr/bin/ar ts SITELIBEXP = /Library/Perl/5.8.1 SITEARCHEXP = /Library/Perl/5.8.1/darwin-thread-multi-2level SO = dylib EXE_EXT = FULL_AR = /usr/bin/ar VENDORARCHEXP = /Network/Library/Perl/5.8.1/darwin-thread-multi-2level VENDORLIBEXP = /Network/Library/Perl/5.8.1 # --- MakeMaker constants section: AR_STATIC_ARGS = cr DIRFILESEP = / NAME = Module::Refresh NAME_SYM = Module_Refresh VERSION = 0.01 VERSION_MACRO = VERSION VERSION_SYM = 0_01 DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\" XS_VERSION = 0.01 XS_VERSION_MACRO = XS_VERSION XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\" INST_ARCHLIB = blib/arch INST_SCRIPT = blib/script INST_BIN = blib/bin INST_LIB = blib/lib INST_MAN1DIR = blib/man1 INST_MAN3DIR = blib/man3 MAN1EXT = 1 MAN3EXT = 3pm INSTALLDIRS = site DESTDIR = PREFIX = PERLPREFIX = / SITEPREFIX = / VENDORPREFIX = /usr/local INSTALLPRIVLIB = $(PERLPREFIX)//System/Library/Perl/5.8.1 DESTINSTALLPRIVLIB = $(DESTDIR)$(INSTALLPRIVLIB) INSTALLSITELIB = $(SITEPREFIX)//Library/Perl/5.8.1 DESTINSTALLSITELIB = $(DESTDIR)$(INSTALLSITELIB) INSTALLVENDORLIB = /Network/Library/Perl/5.8.1 DESTINSTALLVENDORLIB = $(DESTDIR)$(INSTALLVENDORLIB) INSTALLARCHLIB = $(PERLPREFIX)//System/Library/Perl/5.8.1/darwin-thread-multi-2level DESTINSTALLARCHLIB = $(DESTDIR)$(INSTALLARCHLIB) INSTALLSITEARCH = $(SITEPREFIX)//Library/Perl/5.8.1/darwin-thread-multi-2level DESTINSTALLSITEARCH = $(DESTDIR)$(INSTALLSITEARCH) INSTALLVENDORARCH = /Network/Library/Perl/5.8.1/darwin-thread-multi-2level DESTINSTALLVENDORARCH = $(DESTDIR)$(INSTALLVENDORARCH) INSTALLBIN = $(PERLPREFIX)//usr/bin DESTINSTALLBIN = $(DESTDIR)$(INSTALLBIN) INSTALLSITEBIN = $(SITEPREFIX)//usr/local/bin DESTINSTALLSITEBIN = $(DESTDIR)$(INSTALLSITEBIN) INSTALLVENDORBIN = $(VENDORPREFIX)/bin DESTINSTALLVENDORBIN = $(DESTDIR)$(INSTALLVENDORBIN) INSTALLSCRIPT = $(PERLPREFIX)//usr/bin DESTINSTALLSCRIPT = $(DESTDIR)$(INSTALLSCRIPT) INSTALLMAN1DIR = $(PERLPREFIX)//usr/share/man/man1 DESTINSTALLMAN1DIR = $(DESTDIR)$(INSTALLMAN1DIR) INSTALLSITEMAN1DIR = $(SITEPREFIX)//man/man1 DESTINSTALLSITEMAN1DIR = $(DESTDIR)$(INSTALLSITEMAN1DIR) INSTALLVENDORMAN1DIR = $(VENDORPREFIX)/man/man1 DESTINSTALLVENDORMAN1DIR = $(DESTDIR)$(INSTALLVENDORMAN1DIR) INSTALLMAN3DIR = $(PERLPREFIX)//usr/share/man/man3 DESTINSTALLMAN3DIR = $(DESTDIR)$(INSTALLMAN3DIR) INSTALLSITEMAN3DIR = $(SITEPREFIX)//man/man3 DESTINSTALLSITEMAN3DIR = $(DESTDIR)$(INSTALLSITEMAN3DIR) INSTALLVENDORMAN3DIR = $(VENDORPREFIX)/man/man3 DESTINSTALLVENDORMAN3DIR = $(DESTDIR)$(INSTALLVENDORMAN3DIR) PERL_LIB = /System/Library/Perl/5.8.1 PERL_ARCHLIB = /System/Library/Perl/5.8.1/darwin-thread-multi-2level LIBPERL_A = libperl.a FIRST_MAKEFILE = Makefile MAKEFILE_OLD = $(FIRST_MAKEFILE).old MAKE_APERL_FILE = $(FIRST_MAKEFILE).aperl PERLMAINCC = $(CC) PERL_INC = /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE PERL = /usr/bin/perl -Iinc FULLPERL = /usr/bin/perl -Iinc ABSPERL = $(PERL) PERLRUN = $(PERL) FULLPERLRUN = $(FULLPERL) ABSPERLRUN = $(ABSPERL) PERLRUNINST = $(PERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" FULLPERLRUNINST = $(FULLPERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" ABSPERLRUNINST = $(ABSPERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" PERL_CORE = 0 PERM_RW = 644 PERM_RWX = 755 MAKEMAKER = /System/Library/Perl/5.8.1/ExtUtils/MakeMaker.pm MM_VERSION = 6.12 MM_REVISION = 1.124 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) # DLBASE = Basename part of dynamic library. May be just equal BASEEXT. FULLEXT = Module/Refresh BASEEXT = Refresh PARENT_NAME = Module DLBASE = $(BASEEXT) VERSION_FROM = OBJECT = LDFROM = $(OBJECT) LINKTYPE = dynamic # Handy lists of source code files: XS_FILES = C_FILES = O_FILES = H_FILES = MAN1PODS = MAN3PODS = lib/Module/Refresh.pm # Where is the Config information that we are using/depend on CONFIGDEP = $(PERL_ARCHLIB)$(DIRFILESEP)Config.pm $(PERL_INC)$(DIRFILESEP)config.h # Where to build things INST_LIBDIR = $(INST_LIB)/Module INST_ARCHLIBDIR = $(INST_ARCHLIB)/Module INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT) INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT) INST_STATIC = INST_DYNAMIC = INST_BOOT = # Extra linker info EXPORT_LIST = PERL_ARCHIVE = PERL_ARCHIVE_AFTER = TO_INST_PM = lib/Module/Refresh.pm PM_TO_BLIB = lib/Module/Refresh.pm \ blib/lib/Module/Refresh.pm # --- MakeMaker platform_constants section: MM_Unix_VERSION = 1.39 PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc # --- MakeMaker tool_autosplit section: # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto AUTOSPLITFILE = $(PERLRUN) -e 'use AutoSplit; autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)' # --- MakeMaker tool_xsubpp section: # --- MakeMaker tools_other section: SHELL = /bin/sh CHMOD = chmod CP = cp MV = mv NOOP = $(SHELL) -c true NOECHO = @ RM_F = rm -f RM_RF = rm -rf TEST_F = test -f TOUCH = touch UMASK_NULL = umask 0 DEV_NULL = > /dev/null 2>&1 MKPATH = $(PERLRUN) "-MExtUtils::Command" -e mkpath EQUALIZE_TIMESTAMP = $(PERLRUN) "-MExtUtils::Command" -e eqtime ECHO = echo ECHO_N = echo -n UNINST = 0 VERBINST = 0 MOD_INSTALL = $(PERLRUN) -MExtUtils::Install -e 'install({@ARGV}, '\''$(VERBINST)'\'', 0, '\''$(UNINST)'\'');' DOC_INSTALL = $(PERLRUN) "-MExtUtils::Command::MM" -e perllocal_install UNINSTALL = $(PERLRUN) "-MExtUtils::Command::MM" -e uninstall WARN_IF_OLD_PACKLIST = $(PERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist # --- MakeMaker makemakerdflt section: makemakerdflt: all $(NOECHO) $(NOOP) # --- MakeMaker dist section: TAR = tar TARFLAGS = cvf ZIP = zip ZIPFLAGS = -r COMPRESS = gzip --best SUFFIX = .gz SHAR = shar PREOP = $(PERL) -I. -MModule::Install::Admin -e "dist_preop(q($(DISTVNAME)))" POSTOP = $(NOECHO) $(NOOP) TO_UNIX = $(NOECHO) $(NOOP) CI = ci -u RCS_LABEL = rcs -Nv$(VERSION_SYM): -q DIST_CP = best DIST_DEFAULT = tardist DISTNAME = Module-Refresh DISTVNAME = Module-Refresh-0.01 # --- MakeMaker macro section: # --- MakeMaker depend section: # --- MakeMaker cflags section: # --- MakeMaker const_loadlibs section: # --- MakeMaker const_cccmd section: # --- MakeMaker post_constants section: # --- MakeMaker pasthru section: PASTHRU = LIB="$(LIB)"\ LIBPERL_A="$(LIBPERL_A)"\ LINKTYPE="$(LINKTYPE)"\ PREFIX="$(PREFIX)"\ OPTIMIZE="$(OPTIMIZE)"\ PASTHRU_DEFINE="$(PASTHRU_DEFINE)"\ PASTHRU_INC="$(PASTHRU_INC)" # --- MakeMaker special_targets section: .SUFFIXES: .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT) .PHONY: all config static dynamic test linkext manifest # --- MakeMaker c_o section: # --- MakeMaker xs_c section: # --- MakeMaker xs_o section: # --- MakeMaker top_targets section: all :: pure_all manifypods $(NOECHO) $(NOOP) pure_all :: config pm_to_blib subdirs linkext $(NOECHO) $(NOOP) subdirs :: $(MYEXTLIB) $(NOECHO) $(NOOP) config :: $(FIRST_MAKEFILE) $(INST_LIBDIR)$(DIRFILESEP).exists $(NOECHO) $(NOOP) config :: $(INST_ARCHAUTODIR)$(DIRFILESEP).exists $(NOECHO) $(NOOP) config :: $(INST_AUTODIR)$(DIRFILESEP).exists $(NOECHO) $(NOOP) $(INST_AUTODIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(NOECHO) $(MKPATH) $(INST_AUTODIR) $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_AUTODIR)/.exists -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_AUTODIR) $(INST_LIBDIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(NOECHO) $(MKPATH) $(INST_LIBDIR) $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_LIBDIR)/.exists -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_LIBDIR) $(INST_ARCHAUTODIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR) $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_ARCHAUTODIR)/.exists -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_ARCHAUTODIR) config :: $(INST_MAN3DIR)$(DIRFILESEP).exists $(NOECHO) $(NOOP) $(INST_MAN3DIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(NOECHO) $(MKPATH) $(INST_MAN3DIR) $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_MAN3DIR)/.exists -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_MAN3DIR) help: perldoc ExtUtils::MakeMaker # --- MakeMaker linkext section: linkext :: $(LINKTYPE) $(NOECHO) $(NOOP) # --- MakeMaker dlsyms section: # --- MakeMaker dynamic section: ## $(INST_PM) has been moved to the all: target. ## It remains here for awhile to allow for old usage: "make dynamic" dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT) $(NOECHO) $(NOOP) # --- MakeMaker dynamic_bs section: BOOTSTRAP = # --- MakeMaker dynamic_lib section: # --- MakeMaker static section: ## $(INST_PM) has been moved to the all: target. ## It remains here for awhile to allow for old usage: "make static" static :: $(FIRST_MAKEFILE) $(INST_STATIC) $(NOECHO) $(NOOP) # --- MakeMaker static_lib section: # --- MakeMaker manifypods section: # --- Begin manifypods section: POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--" manifypods : pure_all \ lib/Module/Refresh.pm \ lib/Module/Refresh.pm $(NOECHO) $(POD2MAN_EXE) --section=3 --perm_rw=$(PERM_RW)\ lib/Module/Refresh.pm $(INST_MAN3DIR)/Module::Refresh.$(MAN3EXT) # --- End manifypods section --- # # --- MakeMaker processPL section: # --- MakeMaker installbin section: # --- MakeMaker subdirs section: # none # --- MakeMaker clean_subdirs section: clean_subdirs : $(NOECHO) $(NOOP) # --- MakeMaker clean section: # Delete temporary files but do not touch installed files. We don't delete # the Makefile here so a later make realclean still has a makefile to use. clean :: clean_subdirs -$(RM_RF) ./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all perlmain.c tmon.out mon.out so_locations pm_to_blib *$(OBJ_EXT) *$(LIB_EXT) perl.exe perl perl$(EXE_EXT) $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def lib$(BASEEXT).def $(BASEEXT).exp $(BASEEXT).x core core.*perl.*.? *perl.core core.[0-9] core.[0-9][0-9] core.[0-9][0-9][0-9] core.[0-9][0-9][0-9][0-9] core.[0-9][0-9][0-9][0-9][0-9] -$(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL) # --- MakeMaker realclean_subdirs section: realclean_subdirs : $(NOECHO) $(NOOP) # --- MakeMaker realclean section: # Delete temporary files (via clean) and also delete installed files realclean purge :: clean realclean_subdirs $(RM_RF) $(INST_AUTODIR) $(INST_ARCHAUTODIR) $(RM_RF) $(DISTVNAME) - $(RM_F) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) blib/lib/Module/Refresh.pm + $(RM_F) $(MAKEFILE_OLD) blib/lib/Module/Refresh.pm $(FIRST_MAKEFILE) # --- MakeMaker metafile section: metafile: $(NOECHO) $(NOOP) # --- MakeMaker metafile_addtomanifest section: metafile_addtomanifest: $(NOECHO) $(NOOP) # --- MakeMaker dist_basics section: distclean :: realclean distcheck $(NOECHO) $(NOOP) distcheck : $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck skipcheck : $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck manifest : $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest veryclean : realclean $(RM_F) *~ *.orig */*~ */*.orig # --- MakeMaker dist_core section: dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE) $(NOECHO) $(PERLRUN) -l -e 'print '\''Warning: Makefile possibly out of date with $(VERSION_FROM)'\''' \ -e ' if -e '\''$(VERSION_FROM)'\'' and -M '\''$(VERSION_FROM)'\'' < -M '\''$(FIRST_MAKEFILE)'\'';' tardist : $(DISTVNAME).tar$(SUFFIX) $(NOECHO) $(NOOP) uutardist : $(DISTVNAME).tar$(SUFFIX) uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu $(DISTVNAME).tar$(SUFFIX) : distdir $(PREOP) $(TO_UNIX) $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME) $(RM_RF) $(DISTVNAME) $(COMPRESS) $(DISTVNAME).tar $(POSTOP) zipdist : $(DISTVNAME).zip $(NOECHO) $(NOOP) $(DISTVNAME).zip : distdir $(PREOP) $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME) $(RM_RF) $(DISTVNAME) $(POSTOP) shdist : distdir $(PREOP) $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar $(RM_RF) $(DISTVNAME) $(POSTOP) # --- MakeMaker distdir section: distdir : metafile metafile_addtomanifest $(RM_RF) $(DISTVNAME) $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \ -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');" # --- MakeMaker dist_test section: disttest : distdir cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL cd $(DISTVNAME) && $(MAKE) $(PASTHRU) cd $(DISTVNAME) && $(MAKE) test $(PASTHRU) # --- MakeMaker dist_ci section: ci : $(PERLRUN) "-MExtUtils::Manifest=maniread" \ -e "@all = keys %{ maniread() };" \ -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \ -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});" # --- MakeMaker install section: install :: all pure_install doc_install install_perl :: all pure_perl_install doc_perl_install install_site :: all pure_site_install doc_site_install install_vendor :: all pure_vendor_install doc_vendor_install pure_install :: pure_$(INSTALLDIRS)_install doc_install :: doc_$(INSTALLDIRS)_install pure__install : pure_site_install $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site doc__install : doc_site_install $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site pure_perl_install :: $(NOECHO) $(MOD_INSTALL) \ read $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist \ write $(DESTINSTALLARCHLIB)/auto/$(FULLEXT)/.packlist \ $(INST_LIB) $(DESTINSTALLPRIVLIB) \ $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \ $(INST_BIN) $(DESTINSTALLBIN) \ $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \ $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR) $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ $(SITEARCHEXP)/auto/$(FULLEXT) pure_site_install :: $(NOECHO) $(MOD_INSTALL) \ read $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist \ write $(DESTINSTALLSITEARCH)/auto/$(FULLEXT)/.packlist \ $(INST_LIB) $(DESTINSTALLSITELIB) \ $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \ $(INST_BIN) $(DESTINSTALLSITEBIN) \ $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \ $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR) $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ $(PERL_ARCHLIB)/auto/$(FULLEXT) pure_vendor_install :: $(NOECHO) $(MOD_INSTALL) \ read $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist \ write $(DESTINSTALLVENDORARCH)/auto/$(FULLEXT)/.packlist \ $(INST_LIB) $(DESTINSTALLVENDORLIB) \ $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \ $(INST_BIN) $(DESTINSTALLVENDORBIN) \ $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \ $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR) doc_perl_install :: $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) -$(NOECHO) $(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLPRIVLIB)" \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ >> $(DESTINSTALLARCHLIB)/perllocal.pod doc_site_install :: $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) -$(NOECHO) $(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLSITELIB)" \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ >> $(DESTINSTALLARCHLIB)/perllocal.pod doc_vendor_install :: $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) -$(NOECHO) $(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLVENDORLIB)" \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ >> $(DESTINSTALLARCHLIB)/perllocal.pod uninstall :: uninstall_from_$(INSTALLDIRS)dirs uninstall_from_perldirs :: $(NOECHO) $(UNINSTALL) $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist uninstall_from_sitedirs :: $(NOECHO) $(UNINSTALL) $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist uninstall_from_vendordirs :: $(NOECHO) $(UNINSTALL) $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist # --- MakeMaker force section: # Phony target to force checking subdirectories. FORCE: $(NOECHO) $(NOOP) # --- MakeMaker perldepend section: # --- MakeMaker makefile section: # We take a very conservative approach here, but it's worth it. # We move Makefile to Makefile.old here to avoid gnu make looping. $(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP) $(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?" $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..." $(NOECHO) $(RM_F) $(MAKEFILE_OLD) $(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) -$(MAKE) -f $(MAKEFILE_OLD) clean $(DEV_NULL) || $(NOOP) $(PERLRUN) Makefile.PL $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <==" $(NOECHO) $(ECHO) "==> Please rerun the make command. <==" false # --- MakeMaker staticmake section: # --- MakeMaker makeaperl section --- MAP_TARGET = perl FULLPERL = /usr/bin/perl $(MAP_TARGET) :: static $(MAKE_APERL_FILE) $(MAKE) -f $(MAKE_APERL_FILE) $@ $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) $(NOECHO) $(PERLRUNINST) \ Makefile.PL DIR= \ MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ MAKEAPERL=1 NORECURS=1 CCCDLFLAGS= # --- MakeMaker test section: TEST_VERBOSE=0 TEST_TYPE=test_$(LINKTYPE) TEST_FILE = test.pl TEST_FILES = t/*.t TESTDB_SW = -d testdb :: testdb_$(LINKTYPE) test :: $(TEST_TYPE) test_dynamic :: pure_all PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), 'inc', '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES) testdb_dynamic :: pure_all PERL_DL_NONLAZY=1 $(FULLPERLRUN) $(TESTDB_SW) "-Iinc" "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE) test_ : test_dynamic test_static :: test_dynamic testdb_static :: testdb_dynamic # --- MakeMaker ppd section: # Creates a PPD (Perl Package Description) for a binary distribution. ppd: $(NOECHO) $(ECHO) '<SOFTPKG NAME="$(DISTNAME)" VERSION="0,01,0,0">' > $(DISTNAME).ppd $(NOECHO) $(ECHO) ' <TITLE>$(DISTNAME)</TITLE>' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' <ABSTRACT></ABSTRACT>' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' <AUTHOR>Jesse Vincent &lt;[email protected]&gt;</AUTHOR>' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' <IMPLEMENTATION>' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' <DEPENDENCY NAME="Test-More" VERSION="0,0,0,0" />' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' <OS NAME="$(OSNAME)" />' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' <ARCHITECTURE NAME="darwin-thread-multi-2level" />' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' <CODEBASE HREF="" />' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' </IMPLEMENTATION>' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) '</SOFTPKG>' >> $(DISTNAME).ppd # --- MakeMaker pm_to_blib section: pm_to_blib: $(TO_INST_PM) $(NOECHO) $(PERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', '\''$(PM_FILTER)'\'')'\ lib/Module/Refresh.pm blib/lib/Module/Refresh.pm $(NOECHO) $(TOUCH) $@ # --- MakeMaker selfdocument section: # --- MakeMaker postamble section: # End. # Postamble by Module::Install 0.36 # --- Module::Install::Admin::Makefile section: realclean purge :: $(RM_F) $(DISTVNAME).tar$(SUFFIX) $(RM_RF) inc MANIFEST.bak _build $(PERL) -I. -MModule::Install::Admin -e "remove_meta()" reset :: purge upload :: test dist cpan-upload -verbose $(DISTVNAME).tar$(SUFFIX) grok :: perldoc Module::Install distsign :: cpansign -s diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index 865fe37..80431e7 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,150 +1,166 @@ use warnings; use strict; package Module::Refresh; our $VERSION = '0.01'; our %CACHE; =head1 DESCRIPTION This module is a generalization of the functionality provided by Apache::StatINC. It's designed to make it easy to do simple iterative development when working in a persistent environment. To that end =head1 EXAMPLE my $refresher = Inc::Refresh->new(); $refresher->refresh_updated(); # each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Apache::Current'); =cut =head2 new Initialize the module refresher; =cut sub new { my $proto = shift; my $class = ref($proto) || $proto; my $self = {}; bless $self, $class; $self->_initialize_cache(); return ($self); } =head2 _initialize_cache When we start up, set the mtime of each module to I<now>, so we don't go about refreshing and refreshing everything. =cut sub _initialize_cache { my $self = shift; my $time = time(); $CACHE{$_} = $time for ( keys %INC ); return ($self); } =head2 refresh_updated refresh all modules that have mtimes on disk newer than the newest ones we've got. =cut sub refresh_updated { my $self = shift; while ( my ( $mod, $path ) = each %INC ) { if ( !$CACHE{$mod} || $self->mtime($path) > $CACHE{$mod} ) { $self->refresh_module($mod); } } return ($self); } =head2 refresh_module $mod refresh module $mod. It doesn't matter if it's already up to date. Just do it. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); eval { require $mod }; warn $@ if ($@); $self->cache_mtime( $mod => $self->mtime( $INC{$mod} ) ); return ($self); } sub unload_module { my $self = shift; my $mod = shift; delete $INC{$mod}; $self->cache_mtime( $mod => 0 ); } sub cache_mtime { my $self = shift; my $mod = shift; my $mtime = shift; $CACHE{$mod} = $mtime; return ($self); } =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { my $self = shift; my $filename = shift; return ( stat($filename) )[9]; } + +=head2 cleanup_subs filename + +Wipe out subs defined in $file. + + +=cut + + +sub cleanup_subs { + + my $self = shift; + my $file = shift; +} + + =head1 BUGS The module warns for each reloaded subroutine. We _could_ (and probably _should_) walk the symbol table and whack the old versions of the symbols =head1 AUTHOR Jesse Vincent <[email protected]> 8 November, 2004, Hua Lien, Taiwan =head1 SEE ALSO L<Module::Refresh>, which does much the same thing, with a little less efficiency up front. (And doesn't have the API for manual expiry. =cut 1; diff --git a/t/1api.t b/t/1api.t index 8d3e487..2c11b05 100755 --- a/t/1api.t +++ b/t/1api.t @@ -1,31 +1,53 @@ #!/usr/bin/perl -w use strict; use Test::More qw/no_plan/; use lib qw{/tmp}; `echo "package Foo::Bar; sub foo { 'bar'}\n1;" > /tmp/FooBar.pm`; use_ok('Module::Refresh'); my $r = Module::Refresh->new(); use_ok('FooBar', "Required our dummy module"); +# is our non-file-based method available? + +can_ok('Foo::Bar', 'not_in_foobarpm'); + + is(Foo::Bar->foo, 'bar', "We got the right result"); `echo "package Foo::Bar; sub foo { 'baz'}\n1;" > /tmp/FooBar.pm`; is(Foo::Bar->foo, 'bar', "We got the right result, still"); $r->refresh_updated; sleep (2); # we only have second-level granularity is(Foo::Bar->foo, 'baz', "We got the right new result,"); +# After a refresh, did we blow away our non-file-based comp? +can_ok('Foo::Bar', 'not_in_foobarpm'); + delete $INC{'FooBar.pm'}; + +ok(!UNIVERSAL::can('Foo::Bar', 'foo'), "We cleaned out the 'foo' method'"); + require "FooBar.pm"; is(Foo::Bar->foo, 'baz', "We got the right new result,"); + + +package Foo::Bar; + +sub not_in_foobarpm { + return "woo"; +} + +1; + + diff --git a/t/1api.t~ b/t/1api.t~ index a09bdc2..2c11b05 100755 --- a/t/1api.t~ +++ b/t/1api.t~ @@ -1,31 +1,53 @@ #!/usr/bin/perl -w use strict; use Test::More qw/no_plan/; use lib qw{/tmp}; `echo "package Foo::Bar; sub foo { 'bar'}\n1;" > /tmp/FooBar.pm`; use_ok('Module::Refresh'); my $r = Module::Refresh->new(); use_ok('FooBar', "Required our dummy module"); +# is our non-file-based method available? + +can_ok('Foo::Bar', 'not_in_foobarpm'); + + is(Foo::Bar->foo, 'bar', "We got the right result"); `echo "package Foo::Bar; sub foo { 'baz'}\n1;" > /tmp/FooBar.pm`; is(Foo::Bar->foo, 'bar', "We got the right result, still"); -$r->reload_updated; +$r->refresh_updated; sleep (2); # we only have second-level granularity is(Foo::Bar->foo, 'baz', "We got the right new result,"); +# After a refresh, did we blow away our non-file-based comp? +can_ok('Foo::Bar', 'not_in_foobarpm'); + delete $INC{'FooBar.pm'}; + +ok(!UNIVERSAL::can('Foo::Bar', 'foo'), "We cleaned out the 'foo' method'"); + require "FooBar.pm"; is(Foo::Bar->foo, 'baz', "We got the right new result,"); + + +package Foo::Bar; + +sub not_in_foobarpm { + return "woo"; +} + +1; + +
bestpractical/module-refresh
aa7fccdb2b9ba9250cb2a50bec32c76a670a7f96
prepping for release
diff --git a/Changes b/Changes new file mode 100644 index 0000000..e604e4e --- /dev/null +++ b/Changes @@ -0,0 +1,3 @@ +0.01 Mon Nov 8 19:48:00 CST 2004 + + - Initial release diff --git a/META.yml b/META.yml index 3ef9f32..e109212 100644 --- a/META.yml +++ b/META.yml @@ -1,11 +1,11 @@ -name: Inc-Refresh +name: Module-Refresh version: 0.01 author: Jesse Vincent <[email protected]> license: perl distribution_type: module build_requires: Test::More: 0 no_index: directory: - inc generated_by: Module::Install version 0.36 diff --git a/Makefile b/Makefile index 7894ab4..2c02cae 100644 --- a/Makefile +++ b/Makefile @@ -1,726 +1,745 @@ # This Makefile is for the Module::Refresh extension to perl. # # It was generated automatically by MakeMaker version # 6.12 (Revision: 1.124) from the contents of # Makefile.PL. Don't edit this file, edit Makefile.PL instead. # # ANY CHANGES MADE HERE WILL BE LOST! # # MakeMaker ARGV: () # # MakeMaker Parameters: # AUTHOR => q[Jesse Vincent <[email protected]>] # DIR => [] # DISTNAME => q[Module-Refresh] # NAME => q[Module::Refresh] # NO_META => q[1] # PL_FILES => { } # PREREQ_PM => { Test::More=>q[0] } # VERSION => q[0.01] +# dist => { PREOP=>q[$(PERL) -I. -MModule::Install::Admin -e "dist_preop(q($(DISTVNAME)))"] } # --- MakeMaker post_initialize section: # --- MakeMaker const_config section: # These definitions are from config.sh (via /System/Library/Perl/5.8.1/darwin-thread-multi-2level/Config.pm) # They may have been overridden via Makefile.PL or on the command line AR = ar CC = cc CCCDLFLAGS = CCDLFLAGS = DLEXT = bundle DLSRC = dl_dyld.xs LD = MACOSX_DEPLOYMENT_TARGET=10.3 cc LDDLFLAGS = -bundle -undefined dynamic_lookup -L/usr/local/lib LDFLAGS = -L/usr/local/lib LIBC = /usr/lib/libc.dylib LIB_EXT = .a OBJ_EXT = .o OSNAME = darwin OSVERS = 7.0 RANLIB = /usr/bin/ar ts SITELIBEXP = /Library/Perl/5.8.1 SITEARCHEXP = /Library/Perl/5.8.1/darwin-thread-multi-2level SO = dylib EXE_EXT = FULL_AR = /usr/bin/ar VENDORARCHEXP = /Network/Library/Perl/5.8.1/darwin-thread-multi-2level VENDORLIBEXP = /Network/Library/Perl/5.8.1 # --- MakeMaker constants section: AR_STATIC_ARGS = cr DIRFILESEP = / NAME = Module::Refresh NAME_SYM = Module_Refresh VERSION = 0.01 VERSION_MACRO = VERSION VERSION_SYM = 0_01 DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\" XS_VERSION = 0.01 XS_VERSION_MACRO = XS_VERSION XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\" INST_ARCHLIB = blib/arch INST_SCRIPT = blib/script INST_BIN = blib/bin INST_LIB = blib/lib INST_MAN1DIR = blib/man1 INST_MAN3DIR = blib/man3 MAN1EXT = 1 MAN3EXT = 3pm INSTALLDIRS = site DESTDIR = PREFIX = PERLPREFIX = / SITEPREFIX = / VENDORPREFIX = /usr/local INSTALLPRIVLIB = $(PERLPREFIX)//System/Library/Perl/5.8.1 DESTINSTALLPRIVLIB = $(DESTDIR)$(INSTALLPRIVLIB) INSTALLSITELIB = $(SITEPREFIX)//Library/Perl/5.8.1 DESTINSTALLSITELIB = $(DESTDIR)$(INSTALLSITELIB) INSTALLVENDORLIB = /Network/Library/Perl/5.8.1 DESTINSTALLVENDORLIB = $(DESTDIR)$(INSTALLVENDORLIB) INSTALLARCHLIB = $(PERLPREFIX)//System/Library/Perl/5.8.1/darwin-thread-multi-2level DESTINSTALLARCHLIB = $(DESTDIR)$(INSTALLARCHLIB) INSTALLSITEARCH = $(SITEPREFIX)//Library/Perl/5.8.1/darwin-thread-multi-2level DESTINSTALLSITEARCH = $(DESTDIR)$(INSTALLSITEARCH) INSTALLVENDORARCH = /Network/Library/Perl/5.8.1/darwin-thread-multi-2level DESTINSTALLVENDORARCH = $(DESTDIR)$(INSTALLVENDORARCH) INSTALLBIN = $(PERLPREFIX)//usr/bin DESTINSTALLBIN = $(DESTDIR)$(INSTALLBIN) INSTALLSITEBIN = $(SITEPREFIX)//usr/local/bin DESTINSTALLSITEBIN = $(DESTDIR)$(INSTALLSITEBIN) INSTALLVENDORBIN = $(VENDORPREFIX)/bin DESTINSTALLVENDORBIN = $(DESTDIR)$(INSTALLVENDORBIN) INSTALLSCRIPT = $(PERLPREFIX)//usr/bin DESTINSTALLSCRIPT = $(DESTDIR)$(INSTALLSCRIPT) INSTALLMAN1DIR = $(PERLPREFIX)//usr/share/man/man1 DESTINSTALLMAN1DIR = $(DESTDIR)$(INSTALLMAN1DIR) INSTALLSITEMAN1DIR = $(SITEPREFIX)//man/man1 DESTINSTALLSITEMAN1DIR = $(DESTDIR)$(INSTALLSITEMAN1DIR) INSTALLVENDORMAN1DIR = $(VENDORPREFIX)/man/man1 DESTINSTALLVENDORMAN1DIR = $(DESTDIR)$(INSTALLVENDORMAN1DIR) INSTALLMAN3DIR = $(PERLPREFIX)//usr/share/man/man3 DESTINSTALLMAN3DIR = $(DESTDIR)$(INSTALLMAN3DIR) INSTALLSITEMAN3DIR = $(SITEPREFIX)//man/man3 DESTINSTALLSITEMAN3DIR = $(DESTDIR)$(INSTALLSITEMAN3DIR) INSTALLVENDORMAN3DIR = $(VENDORPREFIX)/man/man3 DESTINSTALLVENDORMAN3DIR = $(DESTDIR)$(INSTALLVENDORMAN3DIR) PERL_LIB = /System/Library/Perl/5.8.1 PERL_ARCHLIB = /System/Library/Perl/5.8.1/darwin-thread-multi-2level LIBPERL_A = libperl.a FIRST_MAKEFILE = Makefile MAKEFILE_OLD = $(FIRST_MAKEFILE).old MAKE_APERL_FILE = $(FIRST_MAKEFILE).aperl PERLMAINCC = $(CC) PERL_INC = /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE PERL = /usr/bin/perl -Iinc FULLPERL = /usr/bin/perl -Iinc ABSPERL = $(PERL) PERLRUN = $(PERL) FULLPERLRUN = $(FULLPERL) ABSPERLRUN = $(ABSPERL) PERLRUNINST = $(PERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" FULLPERLRUNINST = $(FULLPERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" ABSPERLRUNINST = $(ABSPERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" PERL_CORE = 0 PERM_RW = 644 PERM_RWX = 755 MAKEMAKER = /System/Library/Perl/5.8.1/ExtUtils/MakeMaker.pm MM_VERSION = 6.12 MM_REVISION = 1.124 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) # DLBASE = Basename part of dynamic library. May be just equal BASEEXT. FULLEXT = Module/Refresh BASEEXT = Refresh PARENT_NAME = Module DLBASE = $(BASEEXT) VERSION_FROM = OBJECT = LDFROM = $(OBJECT) LINKTYPE = dynamic # Handy lists of source code files: XS_FILES = C_FILES = O_FILES = H_FILES = MAN1PODS = MAN3PODS = lib/Module/Refresh.pm # Where is the Config information that we are using/depend on CONFIGDEP = $(PERL_ARCHLIB)$(DIRFILESEP)Config.pm $(PERL_INC)$(DIRFILESEP)config.h # Where to build things INST_LIBDIR = $(INST_LIB)/Module INST_ARCHLIBDIR = $(INST_ARCHLIB)/Module INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT) INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT) INST_STATIC = INST_DYNAMIC = INST_BOOT = # Extra linker info EXPORT_LIST = PERL_ARCHIVE = PERL_ARCHIVE_AFTER = TO_INST_PM = lib/Module/Refresh.pm PM_TO_BLIB = lib/Module/Refresh.pm \ blib/lib/Module/Refresh.pm # --- MakeMaker platform_constants section: MM_Unix_VERSION = 1.39 PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc # --- MakeMaker tool_autosplit section: # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto AUTOSPLITFILE = $(PERLRUN) -e 'use AutoSplit; autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)' # --- MakeMaker tool_xsubpp section: # --- MakeMaker tools_other section: SHELL = /bin/sh CHMOD = chmod CP = cp MV = mv NOOP = $(SHELL) -c true NOECHO = @ RM_F = rm -f RM_RF = rm -rf TEST_F = test -f TOUCH = touch UMASK_NULL = umask 0 DEV_NULL = > /dev/null 2>&1 MKPATH = $(PERLRUN) "-MExtUtils::Command" -e mkpath EQUALIZE_TIMESTAMP = $(PERLRUN) "-MExtUtils::Command" -e eqtime ECHO = echo ECHO_N = echo -n UNINST = 0 VERBINST = 0 MOD_INSTALL = $(PERLRUN) -MExtUtils::Install -e 'install({@ARGV}, '\''$(VERBINST)'\'', 0, '\''$(UNINST)'\'');' DOC_INSTALL = $(PERLRUN) "-MExtUtils::Command::MM" -e perllocal_install UNINSTALL = $(PERLRUN) "-MExtUtils::Command::MM" -e uninstall WARN_IF_OLD_PACKLIST = $(PERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist # --- MakeMaker makemakerdflt section: makemakerdflt: all $(NOECHO) $(NOOP) # --- MakeMaker dist section: TAR = tar TARFLAGS = cvf ZIP = zip ZIPFLAGS = -r COMPRESS = gzip --best SUFFIX = .gz SHAR = shar -PREOP = $(NOECHO) $(NOOP) +PREOP = $(PERL) -I. -MModule::Install::Admin -e "dist_preop(q($(DISTVNAME)))" POSTOP = $(NOECHO) $(NOOP) TO_UNIX = $(NOECHO) $(NOOP) CI = ci -u RCS_LABEL = rcs -Nv$(VERSION_SYM): -q DIST_CP = best DIST_DEFAULT = tardist DISTNAME = Module-Refresh DISTVNAME = Module-Refresh-0.01 # --- MakeMaker macro section: # --- MakeMaker depend section: # --- MakeMaker cflags section: # --- MakeMaker const_loadlibs section: # --- MakeMaker const_cccmd section: # --- MakeMaker post_constants section: # --- MakeMaker pasthru section: PASTHRU = LIB="$(LIB)"\ LIBPERL_A="$(LIBPERL_A)"\ LINKTYPE="$(LINKTYPE)"\ PREFIX="$(PREFIX)"\ OPTIMIZE="$(OPTIMIZE)"\ PASTHRU_DEFINE="$(PASTHRU_DEFINE)"\ PASTHRU_INC="$(PASTHRU_INC)" # --- MakeMaker special_targets section: .SUFFIXES: .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT) .PHONY: all config static dynamic test linkext manifest # --- MakeMaker c_o section: # --- MakeMaker xs_c section: # --- MakeMaker xs_o section: # --- MakeMaker top_targets section: all :: pure_all manifypods $(NOECHO) $(NOOP) pure_all :: config pm_to_blib subdirs linkext $(NOECHO) $(NOOP) subdirs :: $(MYEXTLIB) $(NOECHO) $(NOOP) config :: $(FIRST_MAKEFILE) $(INST_LIBDIR)$(DIRFILESEP).exists $(NOECHO) $(NOOP) config :: $(INST_ARCHAUTODIR)$(DIRFILESEP).exists $(NOECHO) $(NOOP) config :: $(INST_AUTODIR)$(DIRFILESEP).exists $(NOECHO) $(NOOP) $(INST_AUTODIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(NOECHO) $(MKPATH) $(INST_AUTODIR) $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_AUTODIR)/.exists -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_AUTODIR) $(INST_LIBDIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(NOECHO) $(MKPATH) $(INST_LIBDIR) $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_LIBDIR)/.exists -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_LIBDIR) $(INST_ARCHAUTODIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR) $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_ARCHAUTODIR)/.exists -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_ARCHAUTODIR) config :: $(INST_MAN3DIR)$(DIRFILESEP).exists $(NOECHO) $(NOOP) $(INST_MAN3DIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(NOECHO) $(MKPATH) $(INST_MAN3DIR) $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_MAN3DIR)/.exists -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_MAN3DIR) help: perldoc ExtUtils::MakeMaker # --- MakeMaker linkext section: linkext :: $(LINKTYPE) $(NOECHO) $(NOOP) # --- MakeMaker dlsyms section: # --- MakeMaker dynamic section: ## $(INST_PM) has been moved to the all: target. ## It remains here for awhile to allow for old usage: "make dynamic" dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT) $(NOECHO) $(NOOP) # --- MakeMaker dynamic_bs section: BOOTSTRAP = # --- MakeMaker dynamic_lib section: # --- MakeMaker static section: ## $(INST_PM) has been moved to the all: target. ## It remains here for awhile to allow for old usage: "make static" static :: $(FIRST_MAKEFILE) $(INST_STATIC) $(NOECHO) $(NOOP) # --- MakeMaker static_lib section: # --- MakeMaker manifypods section: # --- Begin manifypods section: POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--" manifypods : pure_all \ lib/Module/Refresh.pm \ lib/Module/Refresh.pm $(NOECHO) $(POD2MAN_EXE) --section=3 --perm_rw=$(PERM_RW)\ lib/Module/Refresh.pm $(INST_MAN3DIR)/Module::Refresh.$(MAN3EXT) # --- End manifypods section --- # # --- MakeMaker processPL section: # --- MakeMaker installbin section: # --- MakeMaker subdirs section: # none # --- MakeMaker clean_subdirs section: clean_subdirs : $(NOECHO) $(NOOP) # --- MakeMaker clean section: # Delete temporary files but do not touch installed files. We don't delete # the Makefile here so a later make realclean still has a makefile to use. clean :: clean_subdirs -$(RM_RF) ./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all perlmain.c tmon.out mon.out so_locations pm_to_blib *$(OBJ_EXT) *$(LIB_EXT) perl.exe perl perl$(EXE_EXT) $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def lib$(BASEEXT).def $(BASEEXT).exp $(BASEEXT).x core core.*perl.*.? *perl.core core.[0-9] core.[0-9][0-9] core.[0-9][0-9][0-9] core.[0-9][0-9][0-9][0-9] core.[0-9][0-9][0-9][0-9][0-9] -$(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL) # --- MakeMaker realclean_subdirs section: realclean_subdirs : $(NOECHO) $(NOOP) # --- MakeMaker realclean section: # Delete temporary files (via clean) and also delete installed files realclean purge :: clean realclean_subdirs $(RM_RF) $(INST_AUTODIR) $(INST_ARCHAUTODIR) $(RM_RF) $(DISTVNAME) - $(RM_F) $(MAKEFILE_OLD) blib/lib/Module/Refresh.pm $(FIRST_MAKEFILE) + $(RM_F) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) blib/lib/Module/Refresh.pm # --- MakeMaker metafile section: metafile: $(NOECHO) $(NOOP) # --- MakeMaker metafile_addtomanifest section: metafile_addtomanifest: $(NOECHO) $(NOOP) # --- MakeMaker dist_basics section: distclean :: realclean distcheck $(NOECHO) $(NOOP) distcheck : $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck skipcheck : $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck manifest : $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest veryclean : realclean $(RM_F) *~ *.orig */*~ */*.orig # --- MakeMaker dist_core section: dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE) $(NOECHO) $(PERLRUN) -l -e 'print '\''Warning: Makefile possibly out of date with $(VERSION_FROM)'\''' \ -e ' if -e '\''$(VERSION_FROM)'\'' and -M '\''$(VERSION_FROM)'\'' < -M '\''$(FIRST_MAKEFILE)'\'';' tardist : $(DISTVNAME).tar$(SUFFIX) $(NOECHO) $(NOOP) uutardist : $(DISTVNAME).tar$(SUFFIX) uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu $(DISTVNAME).tar$(SUFFIX) : distdir $(PREOP) $(TO_UNIX) $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME) $(RM_RF) $(DISTVNAME) $(COMPRESS) $(DISTVNAME).tar $(POSTOP) zipdist : $(DISTVNAME).zip $(NOECHO) $(NOOP) $(DISTVNAME).zip : distdir $(PREOP) $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME) $(RM_RF) $(DISTVNAME) $(POSTOP) shdist : distdir $(PREOP) $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar $(RM_RF) $(DISTVNAME) $(POSTOP) # --- MakeMaker distdir section: distdir : metafile metafile_addtomanifest $(RM_RF) $(DISTVNAME) $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \ -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');" # --- MakeMaker dist_test section: disttest : distdir cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL cd $(DISTVNAME) && $(MAKE) $(PASTHRU) cd $(DISTVNAME) && $(MAKE) test $(PASTHRU) # --- MakeMaker dist_ci section: ci : $(PERLRUN) "-MExtUtils::Manifest=maniread" \ -e "@all = keys %{ maniread() };" \ -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \ -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});" # --- MakeMaker install section: install :: all pure_install doc_install install_perl :: all pure_perl_install doc_perl_install install_site :: all pure_site_install doc_site_install install_vendor :: all pure_vendor_install doc_vendor_install pure_install :: pure_$(INSTALLDIRS)_install doc_install :: doc_$(INSTALLDIRS)_install pure__install : pure_site_install $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site doc__install : doc_site_install $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site pure_perl_install :: $(NOECHO) $(MOD_INSTALL) \ read $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist \ write $(DESTINSTALLARCHLIB)/auto/$(FULLEXT)/.packlist \ $(INST_LIB) $(DESTINSTALLPRIVLIB) \ $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \ $(INST_BIN) $(DESTINSTALLBIN) \ $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \ $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR) $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ $(SITEARCHEXP)/auto/$(FULLEXT) pure_site_install :: $(NOECHO) $(MOD_INSTALL) \ read $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist \ write $(DESTINSTALLSITEARCH)/auto/$(FULLEXT)/.packlist \ $(INST_LIB) $(DESTINSTALLSITELIB) \ $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \ $(INST_BIN) $(DESTINSTALLSITEBIN) \ $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \ $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR) $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ $(PERL_ARCHLIB)/auto/$(FULLEXT) pure_vendor_install :: $(NOECHO) $(MOD_INSTALL) \ read $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist \ write $(DESTINSTALLVENDORARCH)/auto/$(FULLEXT)/.packlist \ $(INST_LIB) $(DESTINSTALLVENDORLIB) \ $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \ $(INST_BIN) $(DESTINSTALLVENDORBIN) \ $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \ $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR) doc_perl_install :: $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) -$(NOECHO) $(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLPRIVLIB)" \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ >> $(DESTINSTALLARCHLIB)/perllocal.pod doc_site_install :: $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) -$(NOECHO) $(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLSITELIB)" \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ >> $(DESTINSTALLARCHLIB)/perllocal.pod doc_vendor_install :: $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) -$(NOECHO) $(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLVENDORLIB)" \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ >> $(DESTINSTALLARCHLIB)/perllocal.pod uninstall :: uninstall_from_$(INSTALLDIRS)dirs uninstall_from_perldirs :: $(NOECHO) $(UNINSTALL) $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist uninstall_from_sitedirs :: $(NOECHO) $(UNINSTALL) $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist uninstall_from_vendordirs :: $(NOECHO) $(UNINSTALL) $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist # --- MakeMaker force section: # Phony target to force checking subdirectories. FORCE: $(NOECHO) $(NOOP) # --- MakeMaker perldepend section: # --- MakeMaker makefile section: # We take a very conservative approach here, but it's worth it. # We move Makefile to Makefile.old here to avoid gnu make looping. $(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP) $(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?" $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..." $(NOECHO) $(RM_F) $(MAKEFILE_OLD) $(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) -$(MAKE) -f $(MAKEFILE_OLD) clean $(DEV_NULL) || $(NOOP) $(PERLRUN) Makefile.PL $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <==" $(NOECHO) $(ECHO) "==> Please rerun the make command. <==" false # --- MakeMaker staticmake section: # --- MakeMaker makeaperl section --- MAP_TARGET = perl FULLPERL = /usr/bin/perl $(MAP_TARGET) :: static $(MAKE_APERL_FILE) $(MAKE) -f $(MAKE_APERL_FILE) $@ $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) $(NOECHO) $(PERLRUNINST) \ Makefile.PL DIR= \ MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ MAKEAPERL=1 NORECURS=1 CCCDLFLAGS= # --- MakeMaker test section: TEST_VERBOSE=0 TEST_TYPE=test_$(LINKTYPE) TEST_FILE = test.pl TEST_FILES = t/*.t TESTDB_SW = -d testdb :: testdb_$(LINKTYPE) test :: $(TEST_TYPE) test_dynamic :: pure_all PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), 'inc', '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES) testdb_dynamic :: pure_all PERL_DL_NONLAZY=1 $(FULLPERLRUN) $(TESTDB_SW) "-Iinc" "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE) test_ : test_dynamic test_static :: test_dynamic testdb_static :: testdb_dynamic # --- MakeMaker ppd section: # Creates a PPD (Perl Package Description) for a binary distribution. ppd: $(NOECHO) $(ECHO) '<SOFTPKG NAME="$(DISTNAME)" VERSION="0,01,0,0">' > $(DISTNAME).ppd $(NOECHO) $(ECHO) ' <TITLE>$(DISTNAME)</TITLE>' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' <ABSTRACT></ABSTRACT>' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' <AUTHOR>Jesse Vincent &lt;[email protected]&gt;</AUTHOR>' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' <IMPLEMENTATION>' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' <DEPENDENCY NAME="Test-More" VERSION="0,0,0,0" />' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' <OS NAME="$(OSNAME)" />' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' <ARCHITECTURE NAME="darwin-thread-multi-2level" />' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' <CODEBASE HREF="" />' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' </IMPLEMENTATION>' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) '</SOFTPKG>' >> $(DISTNAME).ppd # --- MakeMaker pm_to_blib section: pm_to_blib: $(TO_INST_PM) $(NOECHO) $(PERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', '\''$(PM_FILTER)'\'')'\ lib/Module/Refresh.pm blib/lib/Module/Refresh.pm $(NOECHO) $(TOUCH) $@ # --- MakeMaker selfdocument section: # --- MakeMaker postamble section: # End. # Postamble by Module::Install 0.36 +# --- Module::Install::Admin::Makefile section: + +realclean purge :: + $(RM_F) $(DISTVNAME).tar$(SUFFIX) + $(RM_RF) inc MANIFEST.bak _build + $(PERL) -I. -MModule::Install::Admin -e "remove_meta()" + +reset :: purge + +upload :: test dist + cpan-upload -verbose $(DISTVNAME).tar$(SUFFIX) + +grok :: + perldoc Module::Install + +distsign :: + cpansign -s + diff --git a/Makefile.PL b/Makefile.PL index bd200a1..a88a1d1 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,8 +1,8 @@ use inc::Module::Install; name('Module-Refresh'); author('Jesse Vincent <[email protected]>'); license('perl'); -version('0.01'); +version_from('lib/Module/Refresh.pm'); build_requires ('Test::More' => 0); &WriteAll; diff --git a/Makefile.old b/Makefile.old deleted file mode 100644 index ab90f41..0000000 --- a/Makefile.old +++ /dev/null @@ -1,726 +0,0 @@ -# This Makefile is for the Module::Refresh extension to perl. -# -# It was generated automatically by MakeMaker version -# 6.12 (Revision: 1.124) from the contents of -# Makefile.PL. Don't edit this file, edit Makefile.PL instead. -# -# ANY CHANGES MADE HERE WILL BE LOST! -# -# MakeMaker ARGV: () -# -# MakeMaker Parameters: - -# AUTHOR => q[Jesse Vincent <[email protected]>] -# DIR => [] -# DISTNAME => q[Module-Refresh] -# NAME => q[Module::Refresh] -# NO_META => q[1] -# PL_FILES => { } -# PREREQ_PM => { Test::More=>q[0] } -# VERSION => q[0.01] - -# --- MakeMaker post_initialize section: - - -# --- MakeMaker const_config section: - -# These definitions are from config.sh (via /System/Library/Perl/5.8.1/darwin-thread-multi-2level/Config.pm) - -# They may have been overridden via Makefile.PL or on the command line -AR = ar -CC = cc -CCCDLFLAGS = -CCDLFLAGS = -DLEXT = bundle -DLSRC = dl_dyld.xs -LD = MACOSX_DEPLOYMENT_TARGET=10.3 cc -LDDLFLAGS = -bundle -undefined dynamic_lookup -L/usr/local/lib -LDFLAGS = -L/usr/local/lib -LIBC = /usr/lib/libc.dylib -LIB_EXT = .a -OBJ_EXT = .o -OSNAME = darwin -OSVERS = 7.0 -RANLIB = /usr/bin/ar ts -SITELIBEXP = /Library/Perl/5.8.1 -SITEARCHEXP = /Library/Perl/5.8.1/darwin-thread-multi-2level -SO = dylib -EXE_EXT = -FULL_AR = /usr/bin/ar -VENDORARCHEXP = /Network/Library/Perl/5.8.1/darwin-thread-multi-2level -VENDORLIBEXP = /Network/Library/Perl/5.8.1 - - -# --- MakeMaker constants section: -AR_STATIC_ARGS = cr -DIRFILESEP = / -NAME = Module::Refresh -NAME_SYM = Module_Refresh -VERSION = 0.01 -VERSION_MACRO = VERSION -VERSION_SYM = 0_01 -DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\" -XS_VERSION = 0.01 -XS_VERSION_MACRO = XS_VERSION -XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\" -INST_ARCHLIB = blib/arch -INST_SCRIPT = blib/script -INST_BIN = blib/bin -INST_LIB = blib/lib -INST_MAN1DIR = blib/man1 -INST_MAN3DIR = blib/man3 -MAN1EXT = 1 -MAN3EXT = 3pm -INSTALLDIRS = site -DESTDIR = -PREFIX = -PERLPREFIX = / -SITEPREFIX = / -VENDORPREFIX = /usr/local -INSTALLPRIVLIB = $(PERLPREFIX)//System/Library/Perl/5.8.1 -DESTINSTALLPRIVLIB = $(DESTDIR)$(INSTALLPRIVLIB) -INSTALLSITELIB = $(SITEPREFIX)//Library/Perl/5.8.1 -DESTINSTALLSITELIB = $(DESTDIR)$(INSTALLSITELIB) -INSTALLVENDORLIB = /Network/Library/Perl/5.8.1 -DESTINSTALLVENDORLIB = $(DESTDIR)$(INSTALLVENDORLIB) -INSTALLARCHLIB = $(PERLPREFIX)//System/Library/Perl/5.8.1/darwin-thread-multi-2level -DESTINSTALLARCHLIB = $(DESTDIR)$(INSTALLARCHLIB) -INSTALLSITEARCH = $(SITEPREFIX)//Library/Perl/5.8.1/darwin-thread-multi-2level -DESTINSTALLSITEARCH = $(DESTDIR)$(INSTALLSITEARCH) -INSTALLVENDORARCH = /Network/Library/Perl/5.8.1/darwin-thread-multi-2level -DESTINSTALLVENDORARCH = $(DESTDIR)$(INSTALLVENDORARCH) -INSTALLBIN = $(PERLPREFIX)//usr/bin -DESTINSTALLBIN = $(DESTDIR)$(INSTALLBIN) -INSTALLSITEBIN = $(SITEPREFIX)//usr/local/bin -DESTINSTALLSITEBIN = $(DESTDIR)$(INSTALLSITEBIN) -INSTALLVENDORBIN = $(VENDORPREFIX)/bin -DESTINSTALLVENDORBIN = $(DESTDIR)$(INSTALLVENDORBIN) -INSTALLSCRIPT = $(PERLPREFIX)//usr/bin -DESTINSTALLSCRIPT = $(DESTDIR)$(INSTALLSCRIPT) -INSTALLMAN1DIR = $(PERLPREFIX)//usr/share/man/man1 -DESTINSTALLMAN1DIR = $(DESTDIR)$(INSTALLMAN1DIR) -INSTALLSITEMAN1DIR = $(SITEPREFIX)//man/man1 -DESTINSTALLSITEMAN1DIR = $(DESTDIR)$(INSTALLSITEMAN1DIR) -INSTALLVENDORMAN1DIR = $(VENDORPREFIX)/man/man1 -DESTINSTALLVENDORMAN1DIR = $(DESTDIR)$(INSTALLVENDORMAN1DIR) -INSTALLMAN3DIR = $(PERLPREFIX)//usr/share/man/man3 -DESTINSTALLMAN3DIR = $(DESTDIR)$(INSTALLMAN3DIR) -INSTALLSITEMAN3DIR = $(SITEPREFIX)//man/man3 -DESTINSTALLSITEMAN3DIR = $(DESTDIR)$(INSTALLSITEMAN3DIR) -INSTALLVENDORMAN3DIR = $(VENDORPREFIX)/man/man3 -DESTINSTALLVENDORMAN3DIR = $(DESTDIR)$(INSTALLVENDORMAN3DIR) -PERL_LIB = /System/Library/Perl/5.8.1 -PERL_ARCHLIB = /System/Library/Perl/5.8.1/darwin-thread-multi-2level -LIBPERL_A = libperl.a -FIRST_MAKEFILE = Makefile -MAKEFILE_OLD = $(FIRST_MAKEFILE).old -MAKE_APERL_FILE = $(FIRST_MAKEFILE).aperl -PERLMAINCC = $(CC) -PERL_INC = /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE -PERL = /usr/bin/perl -Iinc -FULLPERL = /usr/bin/perl -Iinc -ABSPERL = $(PERL) -PERLRUN = $(PERL) -FULLPERLRUN = $(FULLPERL) -ABSPERLRUN = $(ABSPERL) -PERLRUNINST = $(PERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" -FULLPERLRUNINST = $(FULLPERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" -ABSPERLRUNINST = $(ABSPERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" -PERL_CORE = 0 -PERM_RW = 644 -PERM_RWX = 755 - -MAKEMAKER = /System/Library/Perl/5.8.1/ExtUtils/MakeMaker.pm -MM_VERSION = 6.12 -MM_REVISION = 1.124 - -# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). -# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) -# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) -# DLBASE = Basename part of dynamic library. May be just equal BASEEXT. -FULLEXT = Module/Refresh -BASEEXT = Refresh -PARENT_NAME = Module -DLBASE = $(BASEEXT) -VERSION_FROM = -OBJECT = -LDFROM = $(OBJECT) -LINKTYPE = dynamic - -# Handy lists of source code files: -XS_FILES = -C_FILES = -O_FILES = -H_FILES = -MAN1PODS = -MAN3PODS = lib/Module/Refresh.pm - -# Where is the Config information that we are using/depend on -CONFIGDEP = $(PERL_ARCHLIB)$(DIRFILESEP)Config.pm $(PERL_INC)$(DIRFILESEP)config.h - -# Where to build things -INST_LIBDIR = $(INST_LIB)/Module -INST_ARCHLIBDIR = $(INST_ARCHLIB)/Module - -INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT) -INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT) - -INST_STATIC = -INST_DYNAMIC = -INST_BOOT = - -# Extra linker info -EXPORT_LIST = -PERL_ARCHIVE = -PERL_ARCHIVE_AFTER = - - -TO_INST_PM = lib/Module/Refresh.pm - -PM_TO_BLIB = lib/Module/Refresh.pm \ - blib/lib/Module/Refresh.pm - - -# --- MakeMaker platform_constants section: -MM_Unix_VERSION = 1.39 -PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc - - -# --- MakeMaker tool_autosplit section: -# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto -AUTOSPLITFILE = $(PERLRUN) -e 'use AutoSplit; autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)' - - - -# --- MakeMaker tool_xsubpp section: - - -# --- MakeMaker tools_other section: -SHELL = /bin/sh -CHMOD = chmod -CP = cp -MV = mv -NOOP = $(SHELL) -c true -NOECHO = @ -RM_F = rm -f -RM_RF = rm -rf -TEST_F = test -f -TOUCH = touch -UMASK_NULL = umask 0 -DEV_NULL = > /dev/null 2>&1 -MKPATH = $(PERLRUN) "-MExtUtils::Command" -e mkpath -EQUALIZE_TIMESTAMP = $(PERLRUN) "-MExtUtils::Command" -e eqtime -ECHO = echo -ECHO_N = echo -n -UNINST = 0 -VERBINST = 0 -MOD_INSTALL = $(PERLRUN) -MExtUtils::Install -e 'install({@ARGV}, '\''$(VERBINST)'\'', 0, '\''$(UNINST)'\'');' -DOC_INSTALL = $(PERLRUN) "-MExtUtils::Command::MM" -e perllocal_install -UNINSTALL = $(PERLRUN) "-MExtUtils::Command::MM" -e uninstall -WARN_IF_OLD_PACKLIST = $(PERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist - - -# --- MakeMaker makemakerdflt section: -makemakerdflt: all - $(NOECHO) $(NOOP) - - -# --- MakeMaker dist section: -TAR = tar -TARFLAGS = cvf -ZIP = zip -ZIPFLAGS = -r -COMPRESS = gzip --best -SUFFIX = .gz -SHAR = shar -PREOP = $(NOECHO) $(NOOP) -POSTOP = $(NOECHO) $(NOOP) -TO_UNIX = $(NOECHO) $(NOOP) -CI = ci -u -RCS_LABEL = rcs -Nv$(VERSION_SYM): -q -DIST_CP = best -DIST_DEFAULT = tardist -DISTNAME = Module-Refresh -DISTVNAME = Module-Refresh-0.01 - - -# --- MakeMaker macro section: - - -# --- MakeMaker depend section: - - -# --- MakeMaker cflags section: - - -# --- MakeMaker const_loadlibs section: - - -# --- MakeMaker const_cccmd section: - - -# --- MakeMaker post_constants section: - - -# --- MakeMaker pasthru section: - -PASTHRU = LIB="$(LIB)"\ - LIBPERL_A="$(LIBPERL_A)"\ - LINKTYPE="$(LINKTYPE)"\ - PREFIX="$(PREFIX)"\ - OPTIMIZE="$(OPTIMIZE)"\ - PASTHRU_DEFINE="$(PASTHRU_DEFINE)"\ - PASTHRU_INC="$(PASTHRU_INC)" - - -# --- MakeMaker special_targets section: -.SUFFIXES: .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT) - -.PHONY: all config static dynamic test linkext manifest - - - -# --- MakeMaker c_o section: - - -# --- MakeMaker xs_c section: - - -# --- MakeMaker xs_o section: - - -# --- MakeMaker top_targets section: -all :: pure_all manifypods - $(NOECHO) $(NOOP) - - -pure_all :: config pm_to_blib subdirs linkext - $(NOECHO) $(NOOP) - -subdirs :: $(MYEXTLIB) - $(NOECHO) $(NOOP) - -config :: $(FIRST_MAKEFILE) $(INST_LIBDIR)$(DIRFILESEP).exists - $(NOECHO) $(NOOP) - -config :: $(INST_ARCHAUTODIR)$(DIRFILESEP).exists - $(NOECHO) $(NOOP) - -config :: $(INST_AUTODIR)$(DIRFILESEP).exists - $(NOECHO) $(NOOP) - -$(INST_AUTODIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h - $(NOECHO) $(MKPATH) $(INST_AUTODIR) - $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_AUTODIR)/.exists - - -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_AUTODIR) - -$(INST_LIBDIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h - $(NOECHO) $(MKPATH) $(INST_LIBDIR) - $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_LIBDIR)/.exists - - -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_LIBDIR) - -$(INST_ARCHAUTODIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h - $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR) - $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_ARCHAUTODIR)/.exists - - -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_ARCHAUTODIR) - -config :: $(INST_MAN3DIR)$(DIRFILESEP).exists - $(NOECHO) $(NOOP) - - -$(INST_MAN3DIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h - $(NOECHO) $(MKPATH) $(INST_MAN3DIR) - $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_MAN3DIR)/.exists - - -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_MAN3DIR) - -help: - perldoc ExtUtils::MakeMaker - - -# --- MakeMaker linkext section: - -linkext :: $(LINKTYPE) - $(NOECHO) $(NOOP) - - -# --- MakeMaker dlsyms section: - - -# --- MakeMaker dynamic section: - -## $(INST_PM) has been moved to the all: target. -## It remains here for awhile to allow for old usage: "make dynamic" -dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT) - $(NOECHO) $(NOOP) - - -# --- MakeMaker dynamic_bs section: - -BOOTSTRAP = - - -# --- MakeMaker dynamic_lib section: - - -# --- MakeMaker static section: - -## $(INST_PM) has been moved to the all: target. -## It remains here for awhile to allow for old usage: "make static" -static :: $(FIRST_MAKEFILE) $(INST_STATIC) - $(NOECHO) $(NOOP) - - -# --- MakeMaker static_lib section: - - -# --- MakeMaker manifypods section: - -# --- Begin manifypods section: -POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--" - - -manifypods : pure_all \ - lib/Module/Refresh.pm \ - lib/Module/Refresh.pm - $(NOECHO) $(POD2MAN_EXE) --section=3 --perm_rw=$(PERM_RW)\ - lib/Module/Refresh.pm $(INST_MAN3DIR)/Module::Refresh.$(MAN3EXT) - - -# --- End manifypods section --- # - - - -# --- MakeMaker processPL section: - - -# --- MakeMaker installbin section: - - -# --- MakeMaker subdirs section: - -# none - -# --- MakeMaker clean_subdirs section: -clean_subdirs : - $(NOECHO) $(NOOP) - - -# --- MakeMaker clean section: - -# Delete temporary files but do not touch installed files. We don't delete -# the Makefile here so a later make realclean still has a makefile to use. - -clean :: clean_subdirs - -$(RM_RF) ./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all perlmain.c tmon.out mon.out so_locations pm_to_blib *$(OBJ_EXT) *$(LIB_EXT) perl.exe perl perl$(EXE_EXT) $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def lib$(BASEEXT).def $(BASEEXT).exp $(BASEEXT).x core core.*perl.*.? *perl.core core.[0-9] core.[0-9][0-9] core.[0-9][0-9][0-9] core.[0-9][0-9][0-9][0-9] core.[0-9][0-9][0-9][0-9][0-9] - -$(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL) - - -# --- MakeMaker realclean_subdirs section: -realclean_subdirs : - $(NOECHO) $(NOOP) - - -# --- MakeMaker realclean section: - -# Delete temporary files (via clean) and also delete installed files -realclean purge :: clean realclean_subdirs - $(RM_RF) $(INST_AUTODIR) $(INST_ARCHAUTODIR) - $(RM_RF) $(DISTVNAME) - $(RM_F) $(MAKEFILE_OLD) $(FIRST_MAKEFILE) blib/lib/Module/Refresh.pm - - -# --- MakeMaker metafile section: -metafile: - $(NOECHO) $(NOOP) - - -# --- MakeMaker metafile_addtomanifest section: -metafile_addtomanifest: - $(NOECHO) $(NOOP) - - -# --- MakeMaker dist_basics section: -distclean :: realclean distcheck - $(NOECHO) $(NOOP) - -distcheck : - $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck - -skipcheck : - $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck - -manifest : - $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest - -veryclean : realclean - $(RM_F) *~ *.orig */*~ */*.orig - - - -# --- MakeMaker dist_core section: - -dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE) - $(NOECHO) $(PERLRUN) -l -e 'print '\''Warning: Makefile possibly out of date with $(VERSION_FROM)'\''' \ - -e ' if -e '\''$(VERSION_FROM)'\'' and -M '\''$(VERSION_FROM)'\'' < -M '\''$(FIRST_MAKEFILE)'\'';' - -tardist : $(DISTVNAME).tar$(SUFFIX) - $(NOECHO) $(NOOP) - -uutardist : $(DISTVNAME).tar$(SUFFIX) - uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu - -$(DISTVNAME).tar$(SUFFIX) : distdir - $(PREOP) - $(TO_UNIX) - $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME) - $(RM_RF) $(DISTVNAME) - $(COMPRESS) $(DISTVNAME).tar - $(POSTOP) - -zipdist : $(DISTVNAME).zip - $(NOECHO) $(NOOP) - -$(DISTVNAME).zip : distdir - $(PREOP) - $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME) - $(RM_RF) $(DISTVNAME) - $(POSTOP) - -shdist : distdir - $(PREOP) - $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar - $(RM_RF) $(DISTVNAME) - $(POSTOP) - - -# --- MakeMaker distdir section: -distdir : metafile metafile_addtomanifest - $(RM_RF) $(DISTVNAME) - $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \ - -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');" - - - -# --- MakeMaker dist_test section: - -disttest : distdir - cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL - cd $(DISTVNAME) && $(MAKE) $(PASTHRU) - cd $(DISTVNAME) && $(MAKE) test $(PASTHRU) - - -# --- MakeMaker dist_ci section: - -ci : - $(PERLRUN) "-MExtUtils::Manifest=maniread" \ - -e "@all = keys %{ maniread() };" \ - -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \ - -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});" - - -# --- MakeMaker install section: - -install :: all pure_install doc_install - -install_perl :: all pure_perl_install doc_perl_install - -install_site :: all pure_site_install doc_site_install - -install_vendor :: all pure_vendor_install doc_vendor_install - -pure_install :: pure_$(INSTALLDIRS)_install - -doc_install :: doc_$(INSTALLDIRS)_install - -pure__install : pure_site_install - $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site - -doc__install : doc_site_install - $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site - -pure_perl_install :: - $(NOECHO) $(MOD_INSTALL) \ - read $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist \ - write $(DESTINSTALLARCHLIB)/auto/$(FULLEXT)/.packlist \ - $(INST_LIB) $(DESTINSTALLPRIVLIB) \ - $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \ - $(INST_BIN) $(DESTINSTALLBIN) \ - $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ - $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \ - $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR) - $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ - $(SITEARCHEXP)/auto/$(FULLEXT) - - -pure_site_install :: - $(NOECHO) $(MOD_INSTALL) \ - read $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist \ - write $(DESTINSTALLSITEARCH)/auto/$(FULLEXT)/.packlist \ - $(INST_LIB) $(DESTINSTALLSITELIB) \ - $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \ - $(INST_BIN) $(DESTINSTALLSITEBIN) \ - $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ - $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \ - $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR) - $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ - $(PERL_ARCHLIB)/auto/$(FULLEXT) - -pure_vendor_install :: - $(NOECHO) $(MOD_INSTALL) \ - read $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist \ - write $(DESTINSTALLVENDORARCH)/auto/$(FULLEXT)/.packlist \ - $(INST_LIB) $(DESTINSTALLVENDORLIB) \ - $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \ - $(INST_BIN) $(DESTINSTALLVENDORBIN) \ - $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ - $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \ - $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR) - -doc_perl_install :: - $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod - -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) - -$(NOECHO) $(DOC_INSTALL) \ - "Module" "$(NAME)" \ - "installed into" "$(INSTALLPRIVLIB)" \ - LINKTYPE "$(LINKTYPE)" \ - VERSION "$(VERSION)" \ - EXE_FILES "$(EXE_FILES)" \ - >> $(DESTINSTALLARCHLIB)/perllocal.pod - -doc_site_install :: - $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod - -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) - -$(NOECHO) $(DOC_INSTALL) \ - "Module" "$(NAME)" \ - "installed into" "$(INSTALLSITELIB)" \ - LINKTYPE "$(LINKTYPE)" \ - VERSION "$(VERSION)" \ - EXE_FILES "$(EXE_FILES)" \ - >> $(DESTINSTALLARCHLIB)/perllocal.pod - -doc_vendor_install :: - $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod - -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) - -$(NOECHO) $(DOC_INSTALL) \ - "Module" "$(NAME)" \ - "installed into" "$(INSTALLVENDORLIB)" \ - LINKTYPE "$(LINKTYPE)" \ - VERSION "$(VERSION)" \ - EXE_FILES "$(EXE_FILES)" \ - >> $(DESTINSTALLARCHLIB)/perllocal.pod - - -uninstall :: uninstall_from_$(INSTALLDIRS)dirs - -uninstall_from_perldirs :: - $(NOECHO) $(UNINSTALL) $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist - -uninstall_from_sitedirs :: - $(NOECHO) $(UNINSTALL) $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist - -uninstall_from_vendordirs :: - $(NOECHO) $(UNINSTALL) $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist - - -# --- MakeMaker force section: -# Phony target to force checking subdirectories. -FORCE: - $(NOECHO) $(NOOP) - - -# --- MakeMaker perldepend section: - - -# --- MakeMaker makefile section: - -# We take a very conservative approach here, but it's worth it. -# We move Makefile to Makefile.old here to avoid gnu make looping. -$(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP) - $(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?" - $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..." - $(NOECHO) $(RM_F) $(MAKEFILE_OLD) - $(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) - -$(MAKE) -f $(MAKEFILE_OLD) clean $(DEV_NULL) || $(NOOP) - $(PERLRUN) Makefile.PL - $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <==" - $(NOECHO) $(ECHO) "==> Please rerun the make command. <==" - false - - - -# --- MakeMaker staticmake section: - -# --- MakeMaker makeaperl section --- -MAP_TARGET = perl -FULLPERL = /usr/bin/perl - -$(MAP_TARGET) :: static $(MAKE_APERL_FILE) - $(MAKE) -f $(MAKE_APERL_FILE) $@ - -$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) - $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) - $(NOECHO) $(PERLRUNINST) \ - Makefile.PL DIR= \ - MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ - MAKEAPERL=1 NORECURS=1 CCCDLFLAGS= - - -# --- MakeMaker test section: - -TEST_VERBOSE=0 -TEST_TYPE=test_$(LINKTYPE) -TEST_FILE = test.pl -TEST_FILES = t/*.t -TESTDB_SW = -d - -testdb :: testdb_$(LINKTYPE) - -test :: $(TEST_TYPE) - -test_dynamic :: pure_all - PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), 'inc', '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES) - -testdb_dynamic :: pure_all - PERL_DL_NONLAZY=1 $(FULLPERLRUN) $(TESTDB_SW) "-Iinc" "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE) - -test_ : test_dynamic - -test_static :: test_dynamic -testdb_static :: testdb_dynamic - - -# --- MakeMaker ppd section: -# Creates a PPD (Perl Package Description) for a binary distribution. -ppd: - $(NOECHO) $(ECHO) '<SOFTPKG NAME="$(DISTNAME)" VERSION="0,01,0,0">' > $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' <TITLE>$(DISTNAME)</TITLE>' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' <ABSTRACT></ABSTRACT>' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' <AUTHOR>Jesse Vincent &lt;[email protected]&gt;</AUTHOR>' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' <IMPLEMENTATION>' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' <DEPENDENCY NAME="Test-More" VERSION="0,0,0,0" />' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' <OS NAME="$(OSNAME)" />' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' <ARCHITECTURE NAME="darwin-thread-multi-2level" />' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' <CODEBASE HREF="" />' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' </IMPLEMENTATION>' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) '</SOFTPKG>' >> $(DISTNAME).ppd - - -# --- MakeMaker pm_to_blib section: - -pm_to_blib: $(TO_INST_PM) - $(NOECHO) $(PERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', '\''$(PM_FILTER)'\'')'\ - lib/Module/Refresh.pm blib/lib/Module/Refresh.pm - $(NOECHO) $(TOUCH) $@ - -# --- MakeMaker selfdocument section: - - -# --- MakeMaker postamble section: - - -# End. -# Postamble by Module::Install 0.36 diff --git a/inc/Module/Install.pm b/inc/Module/Install.pm index fc0c68e..ed08a92 100644 --- a/inc/Module/Install.pm +++ b/inc/Module/Install.pm @@ -1,169 +1,169 @@ -#line 1 "inc/Module/Install.pm - /opt/perl-5.8.5/lib/site_perl/5.8.5/Module/Install.pm" +#line 1 "inc/Module/Install.pm - /Library/Perl/5.8.1/Module/Install.pm" package Module::Install; $VERSION = '0.36'; die << "." unless $INC{join('/', inc => split(/::/, __PACKAGE__)).'.pm'}; Please invoke ${\__PACKAGE__} with: use inc::${\__PACKAGE__}; not: use ${\__PACKAGE__}; . use strict 'vars'; use Cwd (); use File::Find (); use File::Path (); @inc::Module::Install::ISA = 'Module::Install'; *inc::Module::Install::VERSION = *VERSION; #line 129 sub import { my $class = shift; my $self = $class->new(@_); if (not -f $self->{file}) { require "$self->{path}/$self->{dispatch}.pm"; File::Path::mkpath("$self->{prefix}/$self->{author}"); $self->{admin} = "$self->{name}::$self->{dispatch}"->new(_top => $self); $self->{admin}->init; @_ = ($class, _self => $self); goto &{"$self->{name}::import"}; } *{caller(0) . "::AUTOLOAD"} = $self->autoload; # Unregister loader and worker packages so subdirs can use them again delete $INC{"$self->{file}"}; delete $INC{"$self->{path}.pm"}; } #line 156 sub autoload { my $self = shift; my $caller = caller; my $cwd = Cwd::cwd(); my $sym = "$caller\::AUTOLOAD"; $sym->{$cwd} = sub { my $pwd = Cwd::cwd(); if (my $code = $sym->{$pwd}) { goto &$code unless $cwd eq $pwd; # delegate back to parent dirs } $$sym =~ /([^:]+)$/ or die "Cannot autoload $caller"; unshift @_, ($self, $1); goto &{$self->can('call')} unless uc($1) eq $1; }; } #line 181 sub new { my ($class, %args) = @_; return $args{_self} if $args{_self}; $args{dispatch} ||= 'Admin'; $args{prefix} ||= 'inc'; $args{author} ||= '.author'; $args{bundle} ||= 'inc/BUNDLES'; $class =~ s/^\Q$args{prefix}\E:://; $args{name} ||= $class; $args{version} ||= $class->VERSION; unless ($args{path}) { $args{path} = $args{name}; $args{path} =~ s!::!/!g; } $args{file} ||= "$args{prefix}/$args{path}.pm"; bless(\%args, $class); } #line 210 sub call { my $self = shift; my $method = shift; my $obj = $self->load($method) or return; unshift @_, $obj; goto &{$obj->can($method)}; } #line 225 sub load { my ($self, $method) = @_; $self->load_extensions( "$self->{prefix}/$self->{path}", $self ) unless $self->{extensions}; foreach my $obj (@{$self->{extensions}}) { return $obj if $obj->can($method); } my $admin = $self->{admin} or die << "END"; The '$method' method does not exist in the '$self->{prefix}' path! Please remove the '$self->{prefix}' directory and run $0 again to load it. END my $obj = $admin->load($method, 1); push @{$self->{extensions}}, $obj; $obj; } #line 255 sub load_extensions { my ($self, $path, $top_obj) = @_; unshift @INC, $self->{prefix} unless grep { $_ eq $self->{prefix} } @INC; local @INC = ($path, @INC); foreach my $rv ($self->find_extensions($path)) { my ($file, $pkg) = @{$rv}; next if $self->{pathnames}{$pkg}; eval { require $file; 1 } or (warn($@), next); $self->{pathnames}{$pkg} = delete $INC{$file}; push @{$self->{extensions}}, $pkg->new( _top => $top_obj ); } } #line 279 sub find_extensions { my ($self, $path) = @_; my @found; File::Find::find(sub { my $file = $File::Find::name; return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is; return if $1 eq $self->{dispatch}; $file = "$self->{path}/$1.pm"; my $pkg = "$self->{name}::$1"; $pkg =~ s!/!::!g; push @found, [$file, $pkg]; }, $path) if -d $path; @found; } 1; __END__ #line 617 diff --git a/inc/Module/Install/Base.pm b/inc/Module/Install/Base.pm index f8a52f3..826be07 100644 --- a/inc/Module/Install/Base.pm +++ b/inc/Module/Install/Base.pm @@ -1,54 +1,54 @@ -#line 1 "inc/Module/Install/Base.pm - /opt/perl-5.8.5/lib/site_perl/5.8.5/Module/Install/Base.pm" +#line 1 "inc/Module/Install/Base.pm - /Library/Perl/5.8.1/Module/Install/Base.pm" package Module::Install::Base; #line 28 sub new { my ($class, %args) = @_; foreach my $method (qw(call load)) { *{"$class\::$method"} = sub { +shift->_top->$method(@_); } unless defined &{"$class\::$method"}; } bless(\%args, $class); } #line 46 sub AUTOLOAD { my $self = shift; goto &{$self->_top->autoload}; } #line 57 sub _top { $_[0]->{_top} } #line 68 sub admin { my $self = shift; $self->_top->{admin} or Module::Install::Base::FakeAdmin->new; } sub is_admin { my $self = shift; $self->admin->VERSION; } sub DESTROY {} package Module::Install::Base::FakeAdmin; my $Fake; sub new { $Fake ||= bless(\@_, $_[0]) } sub AUTOLOAD {} sub DESTROY {} 1; __END__ #line 112 diff --git a/inc/Module/Install/Can.pm b/inc/Module/Install/Can.pm index 1cdaf50..64202a8 100644 --- a/inc/Module/Install/Can.pm +++ b/inc/Module/Install/Can.pm @@ -1,38 +1,38 @@ -#line 1 "inc/Module/Install/Can.pm - /opt/perl-5.8.5/lib/site_perl/5.8.5/Module/Install/Can.pm" +#line 1 "inc/Module/Install/Can.pm - /Library/Perl/5.8.1/Module/Install/Can.pm" package Module::Install::Can; use Module::Install::Base; @ISA = qw(Module::Install::Base); $VERSION = '0.01'; use strict; use Config (); use File::Spec (); use ExtUtils::MakeMaker (); # check if we can run some command sub can_run { my ($self, $cmd) = @_; my $_cmd = $cmd; return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd)); for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { my $abs = File::Spec->catfile($dir, $_[1]); return $abs if (-x $abs or $abs = MM->maybe_command($abs)); } return; } sub can_cc { my $self = shift; my @chunks = split(/ /, $Config::Config{cc}) or return; # $Config{cc} may contain args; try to find out the program part while (@chunks) { return $self->can_run("@chunks") || (pop(@chunks), next); } return; } 1; diff --git a/inc/Module/Install/Fetch.pm b/inc/Module/Install/Fetch.pm index 81478c3..9b76e7e 100644 --- a/inc/Module/Install/Fetch.pm +++ b/inc/Module/Install/Fetch.pm @@ -1,86 +1,86 @@ -#line 1 "inc/Module/Install/Fetch.pm - /opt/perl-5.8.5/lib/site_perl/5.8.5/Module/Install/Fetch.pm" +#line 1 "inc/Module/Install/Fetch.pm - /Library/Perl/5.8.1/Module/Install/Fetch.pm" package Module::Install::Fetch; use Module::Install::Base; @ISA = qw(Module::Install::Base); $VERSION = '0.01'; sub get_file { my ($self, %args) = @_; my ($scheme, $host, $path, $file) = $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; if ($scheme eq 'http' and !eval { require LWP::Simple; 1 }) { $args{url} = $args{ftp_url} or (warn("LWP support unavailable!\n"), return); ($scheme, $host, $path, $file) = $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; } $|++; print "Fetching '$file' from $host... "; unless (eval { require Socket; Socket::inet_aton($host) }) { warn "'$host' resolve failed!\n"; return; } return unless $scheme eq 'ftp' or $scheme eq 'http'; require Cwd; my $dir = Cwd::getcwd(); chdir $args{local_dir} or return if exists $args{local_dir}; if (eval { require LWP::Simple; 1 }) { LWP::Simple::mirror($args{url}, $file); } elsif (eval { require Net::FTP; 1 }) { eval { # use Net::FTP to get past firewall my $ftp = Net::FTP->new($host, Passive => 1, Timeout => 600); $ftp->login("anonymous", '[email protected]'); $ftp->cwd($path); $ftp->binary; $ftp->get($file) or (warn("$!\n"), return); $ftp->quit; } } elsif (my $ftp = $self->can_run('ftp')) { eval { # no Net::FTP, fallback to ftp.exe require FileHandle; my $fh = FileHandle->new; local $SIG{CHLD} = 'IGNORE'; unless ($fh->open("|$ftp -n")) { warn "Couldn't open ftp: $!\n"; chdir $dir; return; } my @dialog = split(/\n/, << "."); open $host user anonymous anonymous\@example.com cd $path binary get $file $file quit . foreach (@dialog) { $fh->print("$_\n") } $fh->close; } } else { warn "No working 'ftp' program available!\n"; chdir $dir; return; } unless (-f $file) { warn "Fetching failed: $@\n"; chdir $dir; return; } return if exists $args{size} and -s $file != $args{size}; system($args{run}) if exists $args{run}; unlink($file) if $args{remove}; print(((!exists $args{check_for} or -e $args{check_for}) ? "done!" : "failed! ($!)"), "\n"); chdir $dir; return !$?; } 1; diff --git a/inc/Module/Install/Makefile.pm b/inc/Module/Install/Makefile.pm index f656502..e2f7e39 100644 --- a/inc/Module/Install/Makefile.pm +++ b/inc/Module/Install/Makefile.pm @@ -1,143 +1,143 @@ -#line 1 "inc/Module/Install/Makefile.pm - /opt/perl-5.8.5/lib/site_perl/5.8.5/Module/Install/Makefile.pm" +#line 1 "inc/Module/Install/Makefile.pm - /Library/Perl/5.8.1/Module/Install/Makefile.pm" package Module::Install::Makefile; use Module::Install::Base; @ISA = qw(Module::Install::Base); $VERSION = '0.01'; use strict 'vars'; use vars '$VERSION'; use ExtUtils::MakeMaker (); sub Makefile { $_[0] } sub prompt { shift; goto &ExtUtils::MakeMaker::prompt; } sub makemaker_args { my $self = shift; my $args = ($self->{makemaker_args} ||= {}); %$args = ( %$args, @_ ) if @_; $args; } sub clean_files { my $self = shift; my $clean = $self->makemaker_args->{clean} ||= {}; %$clean = ( %$clean, FILES => join(" ", grep length, $clean->{FILES}, @_), ); } sub libs { my $self = shift; my $libs = ref $_[0] ? shift : [shift]; $self->makemaker_args( LIBS => $libs ); } sub inc { my $self = shift; $self->makemaker_args( INC => shift ); } sub write { my $self = shift; die "&Makefile->write() takes no arguments\n" if @_; my $args = $self->makemaker_args; $args->{DISTNAME} = $self->name; $args->{NAME} = $self->module_name || $self->name || $self->determine_NAME($args); $args->{VERSION} = $self->version || $self->determine_VERSION($args); $args->{NAME} =~ s/-/::/g; if ($] >= 5.005) { $args->{ABSTRACT} = $self->abstract; $args->{AUTHOR} = $self->author; } if ( eval($ExtUtils::MakeMaker::VERSION) >= 6.10 ) { $args->{NO_META} = 1; } if ( eval($ExtUtils::MakeMaker::VERSION) > 6.17 ) { $args->{SIGN} = 1 if $self->sign; } delete $args->{SIGN} unless $self->is_admin; # merge both kinds of requires into prereq_pm my $prereq = ($args->{PREREQ_PM} ||= {}); %$prereq = ( %$prereq, map { @$_ } map { @$_ } grep $_, ($self->build_requires, $self->requires) ); # merge both kinds of requires into prereq_pm my $dir = ($args->{DIR} ||= []); if ($self->bundles) { push @$dir, map "$_->[1]", @{$self->bundles}; delete $prereq->{$_->[0]} for @{$self->bundles}; } if (my $perl_version = $self->perl_version) { eval "use $perl_version; 1" or die "ERROR: perl: Version $] is installed, ". "but we need version >= $perl_version"; } my %args = map {($_ => $args->{$_})} grep {defined($args->{$_})} keys %$args; if ($self->admin->preop) { $args{dist} = $self->admin->preop; } ExtUtils::MakeMaker::WriteMakefile(%args); $self->fix_up_makefile(); } sub fix_up_makefile { my $self = shift; my $top_class = ref($self->_top) || ''; my $top_version = $self->_top->VERSION || ''; my $preamble = $self->preamble ? "# Preamble by $top_class $top_version\n" . $self->preamble : ''; my $postamble = "# Postamble by $top_class $top_version\n" . ($self->postamble || ''); open MAKEFILE, '< Makefile' or die $!; my $makefile = do { local $/; <MAKEFILE> }; close MAKEFILE; $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /; $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g; $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g; $makefile =~ s/^(FULLPERL = .*)/$1 -Iinc/m; $makefile =~ s/^(PERL = .*)/$1 -Iinc/m; open MAKEFILE, '> Makefile' or die $!; print MAKEFILE "$preamble$makefile$postamble"; close MAKEFILE; } sub preamble { my ($self, $text) = @_; $self->{preamble} = $text . $self->{preamble} if defined $text; $self->{preamble}; } sub postamble { my ($self, $text) = @_; $self->{postamble} ||= $self->admin->postamble; $self->{postamble} .= $text if defined $text; $self->{postamble} } 1; __END__ #line 273 diff --git a/inc/Module/Install/Metadata.pm b/inc/Module/Install/Metadata.pm index b35c7df..a839a10 100644 --- a/inc/Module/Install/Metadata.pm +++ b/inc/Module/Install/Metadata.pm @@ -1,187 +1,187 @@ -#line 1 "inc/Module/Install/Metadata.pm - /opt/perl-5.8.5/lib/site_perl/5.8.5/Module/Install/Metadata.pm" +#line 1 "inc/Module/Install/Metadata.pm - /Library/Perl/5.8.1/Module/Install/Metadata.pm" package Module::Install::Metadata; use Module::Install::Base; @ISA = qw(Module::Install::Base); $VERSION = '0.04'; use strict 'vars'; use vars qw($VERSION); sub Meta { shift } my @scalar_keys = qw( name module_name version abstract author license distribution_type sign perl_version ); my @tuple_keys = qw(build_requires requires recommends bundles); foreach my $key (@scalar_keys) { *$key = sub { my $self = shift; return $self->{'values'}{$key} unless @_; $self->{'values'}{$key} = shift; return $self; }; } foreach my $key (@tuple_keys) { *$key = sub { my $self = shift; return $self->{'values'}{$key} unless @_; my @rv; while (@_) { my $module = shift or last; my $version = shift || 0; if ($module eq 'perl') { $version =~ s{^(\d+)\.(\d+)\.(\d+)} {$1 + $2/1_000 + $3/1_000_000}e; $self->perl_version($version); next; } my $rv = [$module, $version]; push @{$self->{'values'}{$key}}, $rv; push @rv, $rv; } return @rv; }; } sub features { my $self = shift; while (my ($name, $mods) = splice(@_, 0, 2)) { my $count = 0; push @{$self->{'values'}{'features'}}, ($name => [ map { (++$count % 2 and ref($_) and ($count += $#$_)) ? @$_ : $_ } @$mods ] ); } return @{$self->{'values'}{'features'}}; } sub no_index { my $self = shift; my $type = shift; push @{$self->{'values'}{'no_index'}{$type}}, @_ if $type; return $self->{'values'}{'no_index'}; } sub _dump { my $self = shift; my $package = ref($self->_top); my $version = $self->_top->VERSION; my %values = %{$self->{'values'}}; delete $values{sign}; if (my $perl_version = delete $values{perl_version}) { # Always canonical to three-dot version $perl_version =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2), int($3))}e if $perl_version >= 5.006; $values{requires} = [ [perl => $perl_version], @{$values{requires}||[]}, ]; } warn "No license specified, setting license = 'unknown'\n" unless $values{license}; $values{license} ||= 'unknown'; $values{distribution_type} ||= 'module'; $values{name} ||= do { my $name = $values{module_name}; $name =~ s/::/-/g; $name; } if $values{module_name}; if ($values{name} =~ /::/) { my $name = $values{name}; $name =~ s/::/-/g; die "Error in name(): '$values{name}' should be '$name'!\n"; } my $dump = ''; foreach my $key (@scalar_keys) { $dump .= "$key: $values{$key}\n" if exists $values{$key}; } foreach my $key (@tuple_keys) { next unless exists $values{$key}; $dump .= "$key:\n"; foreach (@{$values{$key}}) { $dump .= " $_->[0]: $_->[1]\n"; } } if (my $no_index = $values{no_index}) { push @{$no_index->{'directory'}}, 'inc'; require YAML; local $YAML::UseHeader = 0; $dump .= YAML::Dump({ no_index => $no_index}); } else { $dump .= << "META"; no_index: directory: - inc META } $dump .= "generated_by: $package version $version\n"; return $dump; } sub read { my $self = shift; $self->include_deps( 'YAML', 0 ); require YAML; my $data = YAML::LoadFile( 'META.yml' ); # Call methods explicitly in case user has already set some values. while ( my ($key, $value) = each %$data ) { next unless $self->can( $key ); if (ref $value eq 'HASH') { while (my ($module, $version) = each %$value) { $self->$key( $module => $version ); } } else { $self->$key( $value ); } } return $self; } sub write { my $self = shift; return $self unless $self->is_admin; META_NOT_OURS: { local *FH; if (open FH, "META.yml") { while (<FH>) { last META_NOT_OURS if /^generated_by: Module::Install\b/; } return $self if -s FH; } } warn "Writing META.yml\n"; open META, "> META.yml" or warn "Cannot write to META.yml: $!"; print META $self->_dump; close META; return $self; } sub version_from { my ($self, $version_from) = @_; require ExtUtils::MM_Unix; $self->version(ExtUtils::MM_Unix->parse_version($version_from)); } sub abstract_from { my ($self, $abstract_from) = @_; require ExtUtils::MM_Unix; $self->abstract( bless( { DISTNAME => $self->name }, 'ExtUtils::MM_Unix') ->parse_abstract($abstract_from) ); } 1; diff --git a/inc/Module/Install/Win32.pm b/inc/Module/Install/Win32.pm index 833d68b..119ae8c 100644 --- a/inc/Module/Install/Win32.pm +++ b/inc/Module/Install/Win32.pm @@ -1,63 +1,63 @@ -#line 1 "inc/Module/Install/Win32.pm - /opt/perl-5.8.5/lib/site_perl/5.8.5/Module/Install/Win32.pm" +#line 1 "inc/Module/Install/Win32.pm - /Library/Perl/5.8.1/Module/Install/Win32.pm" package Module::Install::Win32; use Module::Install::Base; @ISA = qw(Module::Install::Base); $VERSION = '0.02'; use strict; # determine if the user needs nmake, and download it if needed sub check_nmake { my $self = shift; $self->load('can_run'); $self->load('get_file'); require Config; return unless ( $Config::Config{make} and $Config::Config{make} =~ /^nmake\b/i and $^O eq 'MSWin32' and !$self->can_run('nmake') ); print "The required 'nmake' executable not found, fetching it...\n"; require File::Basename; my $rv = $self->get_file( url => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe', ftp_url => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe', local_dir => File::Basename::dirname($^X), size => 51928, run => 'Nmake15.exe /o > nul', check_for => 'Nmake.exe', remove => 1, ); if (!$rv) { die << '.'; ------------------------------------------------------------------------------- Since you are using Microsoft Windows, you will need the 'nmake' utility before installation. It's available at: http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe or ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe Please download the file manually, save it to a directory in %PATH% (e.g. C:\WINDOWS\COMMAND\), then launch the MS-DOS command line shell, "cd" to that directory, and run "Nmake15.exe" from there; that will create the 'nmake.exe' file needed by this module. You may then resume the installation process described in README. ------------------------------------------------------------------------------- . } } 1; __END__ diff --git a/inc/Module/Install/WriteAll.pm b/inc/Module/Install/WriteAll.pm index a3191b4..b1ec113 100644 --- a/inc/Module/Install/WriteAll.pm +++ b/inc/Module/Install/WriteAll.pm @@ -1,36 +1,36 @@ -#line 1 "inc/Module/Install/WriteAll.pm - /opt/perl-5.8.5/lib/site_perl/5.8.5/Module/Install/WriteAll.pm" +#line 1 "inc/Module/Install/WriteAll.pm - /Library/Perl/5.8.1/Module/Install/WriteAll.pm" package Module::Install::WriteAll; use Module::Install::Base; @ISA = qw(Module::Install::Base); sub WriteAll { my $self = shift; my %args = ( meta => 1, sign => 0, inline => 0, check_nmake => 1, @_ ); $self->sign(1) if $args{sign}; $self->Meta->write if $args{meta}; $self->admin->WriteAll(%args) if $self->is_admin; if ($0 =~ /Build.PL$/i) { $self->Build->write; } else { $self->check_nmake if $args{check_nmake}; $self->makemaker_args( PL_FILES => {} ) unless $self->makemaker_args->{'PL_FILES'}; if ($args{inline}) { $self->Inline->write; } else { $self->Makefile->write; } } } 1; diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm index bf11a51..865fe37 100644 --- a/lib/Module/Refresh.pm +++ b/lib/Module/Refresh.pm @@ -1,134 +1,150 @@ use warnings; use strict; package Module::Refresh; +our $VERSION = '0.01'; + our %CACHE; =head1 DESCRIPTION This module is a generalization of the functionality provided by Apache::StatINC. It's designed to make it easy to do simple iterative development when working in a persistent environment. To that end =head1 EXAMPLE my $refresher = Inc::Refresh->new(); $refresher->refresh_updated(); # each night at midnight, you automatically download the latest # Acme::Current from CPAN. Use this snippet to make your running # program pick it up off disk: $refresher->refresh_module('Apache::Current'); =cut =head2 new Initialize the module refresher; =cut sub new { my $proto = shift; my $class = ref($proto) || $proto; my $self = {}; bless $self, $class; $self->_initialize_cache(); return ($self); } =head2 _initialize_cache When we start up, set the mtime of each module to I<now>, so we don't go about refreshing and refreshing everything. =cut sub _initialize_cache { my $self = shift; my $time = time(); $CACHE{$_} = $time for ( keys %INC ); return ($self); } =head2 refresh_updated refresh all modules that have mtimes on disk newer than the newest ones we've got. =cut sub refresh_updated { my $self = shift; while ( my ( $mod, $path ) = each %INC ) { if ( !$CACHE{$mod} || $self->mtime($path) > $CACHE{$mod} ) { $self->refresh_module($mod); } } return ($self); } =head2 refresh_module $mod refresh module $mod. It doesn't matter if it's already up to date. Just do it. =cut sub refresh_module { my $self = shift; my $mod = shift; $self->unload_module($mod); eval { require $mod }; warn $@ if ($@); $self->cache_mtime( $mod => $self->mtime( $INC{$mod} ) ); return ($self); } sub unload_module { my $self = shift; my $mod = shift; delete $INC{$mod}; $self->cache_mtime( $mod => 0 ); } sub cache_mtime { my $self = shift; my $mod = shift; my $mtime = shift; $CACHE{$mod} = $mtime; return ($self); } =head2 mtime $file Get the last modified time of $file in seconds since the epoch; =cut sub mtime { my $self = shift; my $filename = shift; return ( stat($filename) )[9]; } +=head1 BUGS + +The module warns for each reloaded subroutine. We _could_ +(and probably _should_) walk the symbol table and whack +the old versions of the symbols + + +=head1 AUTHOR + +Jesse Vincent <[email protected]> + +8 November, 2004, Hua Lien, Taiwan + + =head1 SEE ALSO L<Module::Refresh>, which does much the same thing, with a little less efficiency up front. (And doesn't have the API for manual expiry. =cut 1;
bestpractical/module-refresh
4f4663e5803143512bf2d0dc767284f6fc5f2f98
Directory for svk import. r8924@tinbook: jesse | 2004-11-08T11:45:52.449423Z Importing Module::Refresh
diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..6d3ff26 --- /dev/null +++ b/MANIFEST @@ -0,0 +1,14 @@ +inc/Module/Install.pm +inc/Module/Install/Base.pm +inc/Module/Install/Can.pm +inc/Module/Install/Fetch.pm +inc/Module/Install/Makefile.pm +inc/Module/Install/Metadata.pm +inc/Module/Install/Win32.pm +inc/Module/Install/WriteAll.pm +lib/Module/Refresh.pm +Makefile.PL +MANIFEST This list of files +META.yml +t/0-smoke.t +t/1api.t diff --git a/META.yml b/META.yml new file mode 100644 index 0000000..3ef9f32 --- /dev/null +++ b/META.yml @@ -0,0 +1,11 @@ +name: Inc-Refresh +version: 0.01 +author: Jesse Vincent <[email protected]> +license: perl +distribution_type: module +build_requires: + Test::More: 0 +no_index: + directory: + - inc +generated_by: Module::Install version 0.36 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7894ab4 --- /dev/null +++ b/Makefile @@ -0,0 +1,726 @@ +# This Makefile is for the Module::Refresh extension to perl. +# +# It was generated automatically by MakeMaker version +# 6.12 (Revision: 1.124) from the contents of +# Makefile.PL. Don't edit this file, edit Makefile.PL instead. +# +# ANY CHANGES MADE HERE WILL BE LOST! +# +# MakeMaker ARGV: () +# +# MakeMaker Parameters: + +# AUTHOR => q[Jesse Vincent <[email protected]>] +# DIR => [] +# DISTNAME => q[Module-Refresh] +# NAME => q[Module::Refresh] +# NO_META => q[1] +# PL_FILES => { } +# PREREQ_PM => { Test::More=>q[0] } +# VERSION => q[0.01] + +# --- MakeMaker post_initialize section: + + +# --- MakeMaker const_config section: + +# These definitions are from config.sh (via /System/Library/Perl/5.8.1/darwin-thread-multi-2level/Config.pm) + +# They may have been overridden via Makefile.PL or on the command line +AR = ar +CC = cc +CCCDLFLAGS = +CCDLFLAGS = +DLEXT = bundle +DLSRC = dl_dyld.xs +LD = MACOSX_DEPLOYMENT_TARGET=10.3 cc +LDDLFLAGS = -bundle -undefined dynamic_lookup -L/usr/local/lib +LDFLAGS = -L/usr/local/lib +LIBC = /usr/lib/libc.dylib +LIB_EXT = .a +OBJ_EXT = .o +OSNAME = darwin +OSVERS = 7.0 +RANLIB = /usr/bin/ar ts +SITELIBEXP = /Library/Perl/5.8.1 +SITEARCHEXP = /Library/Perl/5.8.1/darwin-thread-multi-2level +SO = dylib +EXE_EXT = +FULL_AR = /usr/bin/ar +VENDORARCHEXP = /Network/Library/Perl/5.8.1/darwin-thread-multi-2level +VENDORLIBEXP = /Network/Library/Perl/5.8.1 + + +# --- MakeMaker constants section: +AR_STATIC_ARGS = cr +DIRFILESEP = / +NAME = Module::Refresh +NAME_SYM = Module_Refresh +VERSION = 0.01 +VERSION_MACRO = VERSION +VERSION_SYM = 0_01 +DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\" +XS_VERSION = 0.01 +XS_VERSION_MACRO = XS_VERSION +XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\" +INST_ARCHLIB = blib/arch +INST_SCRIPT = blib/script +INST_BIN = blib/bin +INST_LIB = blib/lib +INST_MAN1DIR = blib/man1 +INST_MAN3DIR = blib/man3 +MAN1EXT = 1 +MAN3EXT = 3pm +INSTALLDIRS = site +DESTDIR = +PREFIX = +PERLPREFIX = / +SITEPREFIX = / +VENDORPREFIX = /usr/local +INSTALLPRIVLIB = $(PERLPREFIX)//System/Library/Perl/5.8.1 +DESTINSTALLPRIVLIB = $(DESTDIR)$(INSTALLPRIVLIB) +INSTALLSITELIB = $(SITEPREFIX)//Library/Perl/5.8.1 +DESTINSTALLSITELIB = $(DESTDIR)$(INSTALLSITELIB) +INSTALLVENDORLIB = /Network/Library/Perl/5.8.1 +DESTINSTALLVENDORLIB = $(DESTDIR)$(INSTALLVENDORLIB) +INSTALLARCHLIB = $(PERLPREFIX)//System/Library/Perl/5.8.1/darwin-thread-multi-2level +DESTINSTALLARCHLIB = $(DESTDIR)$(INSTALLARCHLIB) +INSTALLSITEARCH = $(SITEPREFIX)//Library/Perl/5.8.1/darwin-thread-multi-2level +DESTINSTALLSITEARCH = $(DESTDIR)$(INSTALLSITEARCH) +INSTALLVENDORARCH = /Network/Library/Perl/5.8.1/darwin-thread-multi-2level +DESTINSTALLVENDORARCH = $(DESTDIR)$(INSTALLVENDORARCH) +INSTALLBIN = $(PERLPREFIX)//usr/bin +DESTINSTALLBIN = $(DESTDIR)$(INSTALLBIN) +INSTALLSITEBIN = $(SITEPREFIX)//usr/local/bin +DESTINSTALLSITEBIN = $(DESTDIR)$(INSTALLSITEBIN) +INSTALLVENDORBIN = $(VENDORPREFIX)/bin +DESTINSTALLVENDORBIN = $(DESTDIR)$(INSTALLVENDORBIN) +INSTALLSCRIPT = $(PERLPREFIX)//usr/bin +DESTINSTALLSCRIPT = $(DESTDIR)$(INSTALLSCRIPT) +INSTALLMAN1DIR = $(PERLPREFIX)//usr/share/man/man1 +DESTINSTALLMAN1DIR = $(DESTDIR)$(INSTALLMAN1DIR) +INSTALLSITEMAN1DIR = $(SITEPREFIX)//man/man1 +DESTINSTALLSITEMAN1DIR = $(DESTDIR)$(INSTALLSITEMAN1DIR) +INSTALLVENDORMAN1DIR = $(VENDORPREFIX)/man/man1 +DESTINSTALLVENDORMAN1DIR = $(DESTDIR)$(INSTALLVENDORMAN1DIR) +INSTALLMAN3DIR = $(PERLPREFIX)//usr/share/man/man3 +DESTINSTALLMAN3DIR = $(DESTDIR)$(INSTALLMAN3DIR) +INSTALLSITEMAN3DIR = $(SITEPREFIX)//man/man3 +DESTINSTALLSITEMAN3DIR = $(DESTDIR)$(INSTALLSITEMAN3DIR) +INSTALLVENDORMAN3DIR = $(VENDORPREFIX)/man/man3 +DESTINSTALLVENDORMAN3DIR = $(DESTDIR)$(INSTALLVENDORMAN3DIR) +PERL_LIB = /System/Library/Perl/5.8.1 +PERL_ARCHLIB = /System/Library/Perl/5.8.1/darwin-thread-multi-2level +LIBPERL_A = libperl.a +FIRST_MAKEFILE = Makefile +MAKEFILE_OLD = $(FIRST_MAKEFILE).old +MAKE_APERL_FILE = $(FIRST_MAKEFILE).aperl +PERLMAINCC = $(CC) +PERL_INC = /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE +PERL = /usr/bin/perl -Iinc +FULLPERL = /usr/bin/perl -Iinc +ABSPERL = $(PERL) +PERLRUN = $(PERL) +FULLPERLRUN = $(FULLPERL) +ABSPERLRUN = $(ABSPERL) +PERLRUNINST = $(PERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" +FULLPERLRUNINST = $(FULLPERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" +ABSPERLRUNINST = $(ABSPERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" +PERL_CORE = 0 +PERM_RW = 644 +PERM_RWX = 755 + +MAKEMAKER = /System/Library/Perl/5.8.1/ExtUtils/MakeMaker.pm +MM_VERSION = 6.12 +MM_REVISION = 1.124 + +# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). +# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) +# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) +# DLBASE = Basename part of dynamic library. May be just equal BASEEXT. +FULLEXT = Module/Refresh +BASEEXT = Refresh +PARENT_NAME = Module +DLBASE = $(BASEEXT) +VERSION_FROM = +OBJECT = +LDFROM = $(OBJECT) +LINKTYPE = dynamic + +# Handy lists of source code files: +XS_FILES = +C_FILES = +O_FILES = +H_FILES = +MAN1PODS = +MAN3PODS = lib/Module/Refresh.pm + +# Where is the Config information that we are using/depend on +CONFIGDEP = $(PERL_ARCHLIB)$(DIRFILESEP)Config.pm $(PERL_INC)$(DIRFILESEP)config.h + +# Where to build things +INST_LIBDIR = $(INST_LIB)/Module +INST_ARCHLIBDIR = $(INST_ARCHLIB)/Module + +INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT) +INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT) + +INST_STATIC = +INST_DYNAMIC = +INST_BOOT = + +# Extra linker info +EXPORT_LIST = +PERL_ARCHIVE = +PERL_ARCHIVE_AFTER = + + +TO_INST_PM = lib/Module/Refresh.pm + +PM_TO_BLIB = lib/Module/Refresh.pm \ + blib/lib/Module/Refresh.pm + + +# --- MakeMaker platform_constants section: +MM_Unix_VERSION = 1.39 +PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc + + +# --- MakeMaker tool_autosplit section: +# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto +AUTOSPLITFILE = $(PERLRUN) -e 'use AutoSplit; autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)' + + + +# --- MakeMaker tool_xsubpp section: + + +# --- MakeMaker tools_other section: +SHELL = /bin/sh +CHMOD = chmod +CP = cp +MV = mv +NOOP = $(SHELL) -c true +NOECHO = @ +RM_F = rm -f +RM_RF = rm -rf +TEST_F = test -f +TOUCH = touch +UMASK_NULL = umask 0 +DEV_NULL = > /dev/null 2>&1 +MKPATH = $(PERLRUN) "-MExtUtils::Command" -e mkpath +EQUALIZE_TIMESTAMP = $(PERLRUN) "-MExtUtils::Command" -e eqtime +ECHO = echo +ECHO_N = echo -n +UNINST = 0 +VERBINST = 0 +MOD_INSTALL = $(PERLRUN) -MExtUtils::Install -e 'install({@ARGV}, '\''$(VERBINST)'\'', 0, '\''$(UNINST)'\'');' +DOC_INSTALL = $(PERLRUN) "-MExtUtils::Command::MM" -e perllocal_install +UNINSTALL = $(PERLRUN) "-MExtUtils::Command::MM" -e uninstall +WARN_IF_OLD_PACKLIST = $(PERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist + + +# --- MakeMaker makemakerdflt section: +makemakerdflt: all + $(NOECHO) $(NOOP) + + +# --- MakeMaker dist section: +TAR = tar +TARFLAGS = cvf +ZIP = zip +ZIPFLAGS = -r +COMPRESS = gzip --best +SUFFIX = .gz +SHAR = shar +PREOP = $(NOECHO) $(NOOP) +POSTOP = $(NOECHO) $(NOOP) +TO_UNIX = $(NOECHO) $(NOOP) +CI = ci -u +RCS_LABEL = rcs -Nv$(VERSION_SYM): -q +DIST_CP = best +DIST_DEFAULT = tardist +DISTNAME = Module-Refresh +DISTVNAME = Module-Refresh-0.01 + + +# --- MakeMaker macro section: + + +# --- MakeMaker depend section: + + +# --- MakeMaker cflags section: + + +# --- MakeMaker const_loadlibs section: + + +# --- MakeMaker const_cccmd section: + + +# --- MakeMaker post_constants section: + + +# --- MakeMaker pasthru section: + +PASTHRU = LIB="$(LIB)"\ + LIBPERL_A="$(LIBPERL_A)"\ + LINKTYPE="$(LINKTYPE)"\ + PREFIX="$(PREFIX)"\ + OPTIMIZE="$(OPTIMIZE)"\ + PASTHRU_DEFINE="$(PASTHRU_DEFINE)"\ + PASTHRU_INC="$(PASTHRU_INC)" + + +# --- MakeMaker special_targets section: +.SUFFIXES: .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT) + +.PHONY: all config static dynamic test linkext manifest + + + +# --- MakeMaker c_o section: + + +# --- MakeMaker xs_c section: + + +# --- MakeMaker xs_o section: + + +# --- MakeMaker top_targets section: +all :: pure_all manifypods + $(NOECHO) $(NOOP) + + +pure_all :: config pm_to_blib subdirs linkext + $(NOECHO) $(NOOP) + +subdirs :: $(MYEXTLIB) + $(NOECHO) $(NOOP) + +config :: $(FIRST_MAKEFILE) $(INST_LIBDIR)$(DIRFILESEP).exists + $(NOECHO) $(NOOP) + +config :: $(INST_ARCHAUTODIR)$(DIRFILESEP).exists + $(NOECHO) $(NOOP) + +config :: $(INST_AUTODIR)$(DIRFILESEP).exists + $(NOECHO) $(NOOP) + +$(INST_AUTODIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h + $(NOECHO) $(MKPATH) $(INST_AUTODIR) + $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_AUTODIR)/.exists + + -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_AUTODIR) + +$(INST_LIBDIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h + $(NOECHO) $(MKPATH) $(INST_LIBDIR) + $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_LIBDIR)/.exists + + -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_LIBDIR) + +$(INST_ARCHAUTODIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h + $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR) + $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_ARCHAUTODIR)/.exists + + -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_ARCHAUTODIR) + +config :: $(INST_MAN3DIR)$(DIRFILESEP).exists + $(NOECHO) $(NOOP) + + +$(INST_MAN3DIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h + $(NOECHO) $(MKPATH) $(INST_MAN3DIR) + $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_MAN3DIR)/.exists + + -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_MAN3DIR) + +help: + perldoc ExtUtils::MakeMaker + + +# --- MakeMaker linkext section: + +linkext :: $(LINKTYPE) + $(NOECHO) $(NOOP) + + +# --- MakeMaker dlsyms section: + + +# --- MakeMaker dynamic section: + +## $(INST_PM) has been moved to the all: target. +## It remains here for awhile to allow for old usage: "make dynamic" +dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT) + $(NOECHO) $(NOOP) + + +# --- MakeMaker dynamic_bs section: + +BOOTSTRAP = + + +# --- MakeMaker dynamic_lib section: + + +# --- MakeMaker static section: + +## $(INST_PM) has been moved to the all: target. +## It remains here for awhile to allow for old usage: "make static" +static :: $(FIRST_MAKEFILE) $(INST_STATIC) + $(NOECHO) $(NOOP) + + +# --- MakeMaker static_lib section: + + +# --- MakeMaker manifypods section: + +# --- Begin manifypods section: +POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--" + + +manifypods : pure_all \ + lib/Module/Refresh.pm \ + lib/Module/Refresh.pm + $(NOECHO) $(POD2MAN_EXE) --section=3 --perm_rw=$(PERM_RW)\ + lib/Module/Refresh.pm $(INST_MAN3DIR)/Module::Refresh.$(MAN3EXT) + + +# --- End manifypods section --- # + + + +# --- MakeMaker processPL section: + + +# --- MakeMaker installbin section: + + +# --- MakeMaker subdirs section: + +# none + +# --- MakeMaker clean_subdirs section: +clean_subdirs : + $(NOECHO) $(NOOP) + + +# --- MakeMaker clean section: + +# Delete temporary files but do not touch installed files. We don't delete +# the Makefile here so a later make realclean still has a makefile to use. + +clean :: clean_subdirs + -$(RM_RF) ./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all perlmain.c tmon.out mon.out so_locations pm_to_blib *$(OBJ_EXT) *$(LIB_EXT) perl.exe perl perl$(EXE_EXT) $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def lib$(BASEEXT).def $(BASEEXT).exp $(BASEEXT).x core core.*perl.*.? *perl.core core.[0-9] core.[0-9][0-9] core.[0-9][0-9][0-9] core.[0-9][0-9][0-9][0-9] core.[0-9][0-9][0-9][0-9][0-9] + -$(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL) + + +# --- MakeMaker realclean_subdirs section: +realclean_subdirs : + $(NOECHO) $(NOOP) + + +# --- MakeMaker realclean section: + +# Delete temporary files (via clean) and also delete installed files +realclean purge :: clean realclean_subdirs + $(RM_RF) $(INST_AUTODIR) $(INST_ARCHAUTODIR) + $(RM_RF) $(DISTVNAME) + $(RM_F) $(MAKEFILE_OLD) blib/lib/Module/Refresh.pm $(FIRST_MAKEFILE) + + +# --- MakeMaker metafile section: +metafile: + $(NOECHO) $(NOOP) + + +# --- MakeMaker metafile_addtomanifest section: +metafile_addtomanifest: + $(NOECHO) $(NOOP) + + +# --- MakeMaker dist_basics section: +distclean :: realclean distcheck + $(NOECHO) $(NOOP) + +distcheck : + $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck + +skipcheck : + $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck + +manifest : + $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest + +veryclean : realclean + $(RM_F) *~ *.orig */*~ */*.orig + + + +# --- MakeMaker dist_core section: + +dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE) + $(NOECHO) $(PERLRUN) -l -e 'print '\''Warning: Makefile possibly out of date with $(VERSION_FROM)'\''' \ + -e ' if -e '\''$(VERSION_FROM)'\'' and -M '\''$(VERSION_FROM)'\'' < -M '\''$(FIRST_MAKEFILE)'\'';' + +tardist : $(DISTVNAME).tar$(SUFFIX) + $(NOECHO) $(NOOP) + +uutardist : $(DISTVNAME).tar$(SUFFIX) + uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu + +$(DISTVNAME).tar$(SUFFIX) : distdir + $(PREOP) + $(TO_UNIX) + $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME) + $(RM_RF) $(DISTVNAME) + $(COMPRESS) $(DISTVNAME).tar + $(POSTOP) + +zipdist : $(DISTVNAME).zip + $(NOECHO) $(NOOP) + +$(DISTVNAME).zip : distdir + $(PREOP) + $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME) + $(RM_RF) $(DISTVNAME) + $(POSTOP) + +shdist : distdir + $(PREOP) + $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar + $(RM_RF) $(DISTVNAME) + $(POSTOP) + + +# --- MakeMaker distdir section: +distdir : metafile metafile_addtomanifest + $(RM_RF) $(DISTVNAME) + $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \ + -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');" + + + +# --- MakeMaker dist_test section: + +disttest : distdir + cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL + cd $(DISTVNAME) && $(MAKE) $(PASTHRU) + cd $(DISTVNAME) && $(MAKE) test $(PASTHRU) + + +# --- MakeMaker dist_ci section: + +ci : + $(PERLRUN) "-MExtUtils::Manifest=maniread" \ + -e "@all = keys %{ maniread() };" \ + -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \ + -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});" + + +# --- MakeMaker install section: + +install :: all pure_install doc_install + +install_perl :: all pure_perl_install doc_perl_install + +install_site :: all pure_site_install doc_site_install + +install_vendor :: all pure_vendor_install doc_vendor_install + +pure_install :: pure_$(INSTALLDIRS)_install + +doc_install :: doc_$(INSTALLDIRS)_install + +pure__install : pure_site_install + $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site + +doc__install : doc_site_install + $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site + +pure_perl_install :: + $(NOECHO) $(MOD_INSTALL) \ + read $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist \ + write $(DESTINSTALLARCHLIB)/auto/$(FULLEXT)/.packlist \ + $(INST_LIB) $(DESTINSTALLPRIVLIB) \ + $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \ + $(INST_BIN) $(DESTINSTALLBIN) \ + $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ + $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \ + $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR) + $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ + $(SITEARCHEXP)/auto/$(FULLEXT) + + +pure_site_install :: + $(NOECHO) $(MOD_INSTALL) \ + read $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist \ + write $(DESTINSTALLSITEARCH)/auto/$(FULLEXT)/.packlist \ + $(INST_LIB) $(DESTINSTALLSITELIB) \ + $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \ + $(INST_BIN) $(DESTINSTALLSITEBIN) \ + $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ + $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \ + $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR) + $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ + $(PERL_ARCHLIB)/auto/$(FULLEXT) + +pure_vendor_install :: + $(NOECHO) $(MOD_INSTALL) \ + read $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist \ + write $(DESTINSTALLVENDORARCH)/auto/$(FULLEXT)/.packlist \ + $(INST_LIB) $(DESTINSTALLVENDORLIB) \ + $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \ + $(INST_BIN) $(DESTINSTALLVENDORBIN) \ + $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ + $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \ + $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR) + +doc_perl_install :: + $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod + -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + -$(NOECHO) $(DOC_INSTALL) \ + "Module" "$(NAME)" \ + "installed into" "$(INSTALLPRIVLIB)" \ + LINKTYPE "$(LINKTYPE)" \ + VERSION "$(VERSION)" \ + EXE_FILES "$(EXE_FILES)" \ + >> $(DESTINSTALLARCHLIB)/perllocal.pod + +doc_site_install :: + $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod + -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + -$(NOECHO) $(DOC_INSTALL) \ + "Module" "$(NAME)" \ + "installed into" "$(INSTALLSITELIB)" \ + LINKTYPE "$(LINKTYPE)" \ + VERSION "$(VERSION)" \ + EXE_FILES "$(EXE_FILES)" \ + >> $(DESTINSTALLARCHLIB)/perllocal.pod + +doc_vendor_install :: + $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod + -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + -$(NOECHO) $(DOC_INSTALL) \ + "Module" "$(NAME)" \ + "installed into" "$(INSTALLVENDORLIB)" \ + LINKTYPE "$(LINKTYPE)" \ + VERSION "$(VERSION)" \ + EXE_FILES "$(EXE_FILES)" \ + >> $(DESTINSTALLARCHLIB)/perllocal.pod + + +uninstall :: uninstall_from_$(INSTALLDIRS)dirs + +uninstall_from_perldirs :: + $(NOECHO) $(UNINSTALL) $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist + +uninstall_from_sitedirs :: + $(NOECHO) $(UNINSTALL) $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist + +uninstall_from_vendordirs :: + $(NOECHO) $(UNINSTALL) $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist + + +# --- MakeMaker force section: +# Phony target to force checking subdirectories. +FORCE: + $(NOECHO) $(NOOP) + + +# --- MakeMaker perldepend section: + + +# --- MakeMaker makefile section: + +# We take a very conservative approach here, but it's worth it. +# We move Makefile to Makefile.old here to avoid gnu make looping. +$(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP) + $(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?" + $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..." + $(NOECHO) $(RM_F) $(MAKEFILE_OLD) + $(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) + -$(MAKE) -f $(MAKEFILE_OLD) clean $(DEV_NULL) || $(NOOP) + $(PERLRUN) Makefile.PL + $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <==" + $(NOECHO) $(ECHO) "==> Please rerun the make command. <==" + false + + + +# --- MakeMaker staticmake section: + +# --- MakeMaker makeaperl section --- +MAP_TARGET = perl +FULLPERL = /usr/bin/perl + +$(MAP_TARGET) :: static $(MAKE_APERL_FILE) + $(MAKE) -f $(MAKE_APERL_FILE) $@ + +$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) + $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) + $(NOECHO) $(PERLRUNINST) \ + Makefile.PL DIR= \ + MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ + MAKEAPERL=1 NORECURS=1 CCCDLFLAGS= + + +# --- MakeMaker test section: + +TEST_VERBOSE=0 +TEST_TYPE=test_$(LINKTYPE) +TEST_FILE = test.pl +TEST_FILES = t/*.t +TESTDB_SW = -d + +testdb :: testdb_$(LINKTYPE) + +test :: $(TEST_TYPE) + +test_dynamic :: pure_all + PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), 'inc', '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES) + +testdb_dynamic :: pure_all + PERL_DL_NONLAZY=1 $(FULLPERLRUN) $(TESTDB_SW) "-Iinc" "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE) + +test_ : test_dynamic + +test_static :: test_dynamic +testdb_static :: testdb_dynamic + + +# --- MakeMaker ppd section: +# Creates a PPD (Perl Package Description) for a binary distribution. +ppd: + $(NOECHO) $(ECHO) '<SOFTPKG NAME="$(DISTNAME)" VERSION="0,01,0,0">' > $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' <TITLE>$(DISTNAME)</TITLE>' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' <ABSTRACT></ABSTRACT>' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' <AUTHOR>Jesse Vincent &lt;[email protected]&gt;</AUTHOR>' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' <IMPLEMENTATION>' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' <DEPENDENCY NAME="Test-More" VERSION="0,0,0,0" />' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' <OS NAME="$(OSNAME)" />' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' <ARCHITECTURE NAME="darwin-thread-multi-2level" />' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' <CODEBASE HREF="" />' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' </IMPLEMENTATION>' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) '</SOFTPKG>' >> $(DISTNAME).ppd + + +# --- MakeMaker pm_to_blib section: + +pm_to_blib: $(TO_INST_PM) + $(NOECHO) $(PERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', '\''$(PM_FILTER)'\'')'\ + lib/Module/Refresh.pm blib/lib/Module/Refresh.pm + $(NOECHO) $(TOUCH) $@ + +# --- MakeMaker selfdocument section: + + +# --- MakeMaker postamble section: + + +# End. +# Postamble by Module::Install 0.36 diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..bd200a1 --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,8 @@ +use inc::Module::Install; + +name('Module-Refresh'); +author('Jesse Vincent <[email protected]>'); +license('perl'); +version('0.01'); +build_requires ('Test::More' => 0); +&WriteAll; diff --git a/Makefile.old b/Makefile.old new file mode 100644 index 0000000..ab90f41 --- /dev/null +++ b/Makefile.old @@ -0,0 +1,726 @@ +# This Makefile is for the Module::Refresh extension to perl. +# +# It was generated automatically by MakeMaker version +# 6.12 (Revision: 1.124) from the contents of +# Makefile.PL. Don't edit this file, edit Makefile.PL instead. +# +# ANY CHANGES MADE HERE WILL BE LOST! +# +# MakeMaker ARGV: () +# +# MakeMaker Parameters: + +# AUTHOR => q[Jesse Vincent <[email protected]>] +# DIR => [] +# DISTNAME => q[Module-Refresh] +# NAME => q[Module::Refresh] +# NO_META => q[1] +# PL_FILES => { } +# PREREQ_PM => { Test::More=>q[0] } +# VERSION => q[0.01] + +# --- MakeMaker post_initialize section: + + +# --- MakeMaker const_config section: + +# These definitions are from config.sh (via /System/Library/Perl/5.8.1/darwin-thread-multi-2level/Config.pm) + +# They may have been overridden via Makefile.PL or on the command line +AR = ar +CC = cc +CCCDLFLAGS = +CCDLFLAGS = +DLEXT = bundle +DLSRC = dl_dyld.xs +LD = MACOSX_DEPLOYMENT_TARGET=10.3 cc +LDDLFLAGS = -bundle -undefined dynamic_lookup -L/usr/local/lib +LDFLAGS = -L/usr/local/lib +LIBC = /usr/lib/libc.dylib +LIB_EXT = .a +OBJ_EXT = .o +OSNAME = darwin +OSVERS = 7.0 +RANLIB = /usr/bin/ar ts +SITELIBEXP = /Library/Perl/5.8.1 +SITEARCHEXP = /Library/Perl/5.8.1/darwin-thread-multi-2level +SO = dylib +EXE_EXT = +FULL_AR = /usr/bin/ar +VENDORARCHEXP = /Network/Library/Perl/5.8.1/darwin-thread-multi-2level +VENDORLIBEXP = /Network/Library/Perl/5.8.1 + + +# --- MakeMaker constants section: +AR_STATIC_ARGS = cr +DIRFILESEP = / +NAME = Module::Refresh +NAME_SYM = Module_Refresh +VERSION = 0.01 +VERSION_MACRO = VERSION +VERSION_SYM = 0_01 +DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\" +XS_VERSION = 0.01 +XS_VERSION_MACRO = XS_VERSION +XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\" +INST_ARCHLIB = blib/arch +INST_SCRIPT = blib/script +INST_BIN = blib/bin +INST_LIB = blib/lib +INST_MAN1DIR = blib/man1 +INST_MAN3DIR = blib/man3 +MAN1EXT = 1 +MAN3EXT = 3pm +INSTALLDIRS = site +DESTDIR = +PREFIX = +PERLPREFIX = / +SITEPREFIX = / +VENDORPREFIX = /usr/local +INSTALLPRIVLIB = $(PERLPREFIX)//System/Library/Perl/5.8.1 +DESTINSTALLPRIVLIB = $(DESTDIR)$(INSTALLPRIVLIB) +INSTALLSITELIB = $(SITEPREFIX)//Library/Perl/5.8.1 +DESTINSTALLSITELIB = $(DESTDIR)$(INSTALLSITELIB) +INSTALLVENDORLIB = /Network/Library/Perl/5.8.1 +DESTINSTALLVENDORLIB = $(DESTDIR)$(INSTALLVENDORLIB) +INSTALLARCHLIB = $(PERLPREFIX)//System/Library/Perl/5.8.1/darwin-thread-multi-2level +DESTINSTALLARCHLIB = $(DESTDIR)$(INSTALLARCHLIB) +INSTALLSITEARCH = $(SITEPREFIX)//Library/Perl/5.8.1/darwin-thread-multi-2level +DESTINSTALLSITEARCH = $(DESTDIR)$(INSTALLSITEARCH) +INSTALLVENDORARCH = /Network/Library/Perl/5.8.1/darwin-thread-multi-2level +DESTINSTALLVENDORARCH = $(DESTDIR)$(INSTALLVENDORARCH) +INSTALLBIN = $(PERLPREFIX)//usr/bin +DESTINSTALLBIN = $(DESTDIR)$(INSTALLBIN) +INSTALLSITEBIN = $(SITEPREFIX)//usr/local/bin +DESTINSTALLSITEBIN = $(DESTDIR)$(INSTALLSITEBIN) +INSTALLVENDORBIN = $(VENDORPREFIX)/bin +DESTINSTALLVENDORBIN = $(DESTDIR)$(INSTALLVENDORBIN) +INSTALLSCRIPT = $(PERLPREFIX)//usr/bin +DESTINSTALLSCRIPT = $(DESTDIR)$(INSTALLSCRIPT) +INSTALLMAN1DIR = $(PERLPREFIX)//usr/share/man/man1 +DESTINSTALLMAN1DIR = $(DESTDIR)$(INSTALLMAN1DIR) +INSTALLSITEMAN1DIR = $(SITEPREFIX)//man/man1 +DESTINSTALLSITEMAN1DIR = $(DESTDIR)$(INSTALLSITEMAN1DIR) +INSTALLVENDORMAN1DIR = $(VENDORPREFIX)/man/man1 +DESTINSTALLVENDORMAN1DIR = $(DESTDIR)$(INSTALLVENDORMAN1DIR) +INSTALLMAN3DIR = $(PERLPREFIX)//usr/share/man/man3 +DESTINSTALLMAN3DIR = $(DESTDIR)$(INSTALLMAN3DIR) +INSTALLSITEMAN3DIR = $(SITEPREFIX)//man/man3 +DESTINSTALLSITEMAN3DIR = $(DESTDIR)$(INSTALLSITEMAN3DIR) +INSTALLVENDORMAN3DIR = $(VENDORPREFIX)/man/man3 +DESTINSTALLVENDORMAN3DIR = $(DESTDIR)$(INSTALLVENDORMAN3DIR) +PERL_LIB = /System/Library/Perl/5.8.1 +PERL_ARCHLIB = /System/Library/Perl/5.8.1/darwin-thread-multi-2level +LIBPERL_A = libperl.a +FIRST_MAKEFILE = Makefile +MAKEFILE_OLD = $(FIRST_MAKEFILE).old +MAKE_APERL_FILE = $(FIRST_MAKEFILE).aperl +PERLMAINCC = $(CC) +PERL_INC = /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE +PERL = /usr/bin/perl -Iinc +FULLPERL = /usr/bin/perl -Iinc +ABSPERL = $(PERL) +PERLRUN = $(PERL) +FULLPERLRUN = $(FULLPERL) +ABSPERLRUN = $(ABSPERL) +PERLRUNINST = $(PERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" +FULLPERLRUNINST = $(FULLPERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" +ABSPERLRUNINST = $(ABSPERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" +PERL_CORE = 0 +PERM_RW = 644 +PERM_RWX = 755 + +MAKEMAKER = /System/Library/Perl/5.8.1/ExtUtils/MakeMaker.pm +MM_VERSION = 6.12 +MM_REVISION = 1.124 + +# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). +# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) +# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) +# DLBASE = Basename part of dynamic library. May be just equal BASEEXT. +FULLEXT = Module/Refresh +BASEEXT = Refresh +PARENT_NAME = Module +DLBASE = $(BASEEXT) +VERSION_FROM = +OBJECT = +LDFROM = $(OBJECT) +LINKTYPE = dynamic + +# Handy lists of source code files: +XS_FILES = +C_FILES = +O_FILES = +H_FILES = +MAN1PODS = +MAN3PODS = lib/Module/Refresh.pm + +# Where is the Config information that we are using/depend on +CONFIGDEP = $(PERL_ARCHLIB)$(DIRFILESEP)Config.pm $(PERL_INC)$(DIRFILESEP)config.h + +# Where to build things +INST_LIBDIR = $(INST_LIB)/Module +INST_ARCHLIBDIR = $(INST_ARCHLIB)/Module + +INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT) +INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT) + +INST_STATIC = +INST_DYNAMIC = +INST_BOOT = + +# Extra linker info +EXPORT_LIST = +PERL_ARCHIVE = +PERL_ARCHIVE_AFTER = + + +TO_INST_PM = lib/Module/Refresh.pm + +PM_TO_BLIB = lib/Module/Refresh.pm \ + blib/lib/Module/Refresh.pm + + +# --- MakeMaker platform_constants section: +MM_Unix_VERSION = 1.39 +PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc + + +# --- MakeMaker tool_autosplit section: +# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto +AUTOSPLITFILE = $(PERLRUN) -e 'use AutoSplit; autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)' + + + +# --- MakeMaker tool_xsubpp section: + + +# --- MakeMaker tools_other section: +SHELL = /bin/sh +CHMOD = chmod +CP = cp +MV = mv +NOOP = $(SHELL) -c true +NOECHO = @ +RM_F = rm -f +RM_RF = rm -rf +TEST_F = test -f +TOUCH = touch +UMASK_NULL = umask 0 +DEV_NULL = > /dev/null 2>&1 +MKPATH = $(PERLRUN) "-MExtUtils::Command" -e mkpath +EQUALIZE_TIMESTAMP = $(PERLRUN) "-MExtUtils::Command" -e eqtime +ECHO = echo +ECHO_N = echo -n +UNINST = 0 +VERBINST = 0 +MOD_INSTALL = $(PERLRUN) -MExtUtils::Install -e 'install({@ARGV}, '\''$(VERBINST)'\'', 0, '\''$(UNINST)'\'');' +DOC_INSTALL = $(PERLRUN) "-MExtUtils::Command::MM" -e perllocal_install +UNINSTALL = $(PERLRUN) "-MExtUtils::Command::MM" -e uninstall +WARN_IF_OLD_PACKLIST = $(PERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist + + +# --- MakeMaker makemakerdflt section: +makemakerdflt: all + $(NOECHO) $(NOOP) + + +# --- MakeMaker dist section: +TAR = tar +TARFLAGS = cvf +ZIP = zip +ZIPFLAGS = -r +COMPRESS = gzip --best +SUFFIX = .gz +SHAR = shar +PREOP = $(NOECHO) $(NOOP) +POSTOP = $(NOECHO) $(NOOP) +TO_UNIX = $(NOECHO) $(NOOP) +CI = ci -u +RCS_LABEL = rcs -Nv$(VERSION_SYM): -q +DIST_CP = best +DIST_DEFAULT = tardist +DISTNAME = Module-Refresh +DISTVNAME = Module-Refresh-0.01 + + +# --- MakeMaker macro section: + + +# --- MakeMaker depend section: + + +# --- MakeMaker cflags section: + + +# --- MakeMaker const_loadlibs section: + + +# --- MakeMaker const_cccmd section: + + +# --- MakeMaker post_constants section: + + +# --- MakeMaker pasthru section: + +PASTHRU = LIB="$(LIB)"\ + LIBPERL_A="$(LIBPERL_A)"\ + LINKTYPE="$(LINKTYPE)"\ + PREFIX="$(PREFIX)"\ + OPTIMIZE="$(OPTIMIZE)"\ + PASTHRU_DEFINE="$(PASTHRU_DEFINE)"\ + PASTHRU_INC="$(PASTHRU_INC)" + + +# --- MakeMaker special_targets section: +.SUFFIXES: .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT) + +.PHONY: all config static dynamic test linkext manifest + + + +# --- MakeMaker c_o section: + + +# --- MakeMaker xs_c section: + + +# --- MakeMaker xs_o section: + + +# --- MakeMaker top_targets section: +all :: pure_all manifypods + $(NOECHO) $(NOOP) + + +pure_all :: config pm_to_blib subdirs linkext + $(NOECHO) $(NOOP) + +subdirs :: $(MYEXTLIB) + $(NOECHO) $(NOOP) + +config :: $(FIRST_MAKEFILE) $(INST_LIBDIR)$(DIRFILESEP).exists + $(NOECHO) $(NOOP) + +config :: $(INST_ARCHAUTODIR)$(DIRFILESEP).exists + $(NOECHO) $(NOOP) + +config :: $(INST_AUTODIR)$(DIRFILESEP).exists + $(NOECHO) $(NOOP) + +$(INST_AUTODIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h + $(NOECHO) $(MKPATH) $(INST_AUTODIR) + $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_AUTODIR)/.exists + + -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_AUTODIR) + +$(INST_LIBDIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h + $(NOECHO) $(MKPATH) $(INST_LIBDIR) + $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_LIBDIR)/.exists + + -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_LIBDIR) + +$(INST_ARCHAUTODIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h + $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR) + $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_ARCHAUTODIR)/.exists + + -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_ARCHAUTODIR) + +config :: $(INST_MAN3DIR)$(DIRFILESEP).exists + $(NOECHO) $(NOOP) + + +$(INST_MAN3DIR)/.exists :: /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h + $(NOECHO) $(MKPATH) $(INST_MAN3DIR) + $(NOECHO) $(EQUALIZE_TIMESTAMP) /System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE/perl.h $(INST_MAN3DIR)/.exists + + -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_MAN3DIR) + +help: + perldoc ExtUtils::MakeMaker + + +# --- MakeMaker linkext section: + +linkext :: $(LINKTYPE) + $(NOECHO) $(NOOP) + + +# --- MakeMaker dlsyms section: + + +# --- MakeMaker dynamic section: + +## $(INST_PM) has been moved to the all: target. +## It remains here for awhile to allow for old usage: "make dynamic" +dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT) + $(NOECHO) $(NOOP) + + +# --- MakeMaker dynamic_bs section: + +BOOTSTRAP = + + +# --- MakeMaker dynamic_lib section: + + +# --- MakeMaker static section: + +## $(INST_PM) has been moved to the all: target. +## It remains here for awhile to allow for old usage: "make static" +static :: $(FIRST_MAKEFILE) $(INST_STATIC) + $(NOECHO) $(NOOP) + + +# --- MakeMaker static_lib section: + + +# --- MakeMaker manifypods section: + +# --- Begin manifypods section: +POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--" + + +manifypods : pure_all \ + lib/Module/Refresh.pm \ + lib/Module/Refresh.pm + $(NOECHO) $(POD2MAN_EXE) --section=3 --perm_rw=$(PERM_RW)\ + lib/Module/Refresh.pm $(INST_MAN3DIR)/Module::Refresh.$(MAN3EXT) + + +# --- End manifypods section --- # + + + +# --- MakeMaker processPL section: + + +# --- MakeMaker installbin section: + + +# --- MakeMaker subdirs section: + +# none + +# --- MakeMaker clean_subdirs section: +clean_subdirs : + $(NOECHO) $(NOOP) + + +# --- MakeMaker clean section: + +# Delete temporary files but do not touch installed files. We don't delete +# the Makefile here so a later make realclean still has a makefile to use. + +clean :: clean_subdirs + -$(RM_RF) ./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all perlmain.c tmon.out mon.out so_locations pm_to_blib *$(OBJ_EXT) *$(LIB_EXT) perl.exe perl perl$(EXE_EXT) $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def lib$(BASEEXT).def $(BASEEXT).exp $(BASEEXT).x core core.*perl.*.? *perl.core core.[0-9] core.[0-9][0-9] core.[0-9][0-9][0-9] core.[0-9][0-9][0-9][0-9] core.[0-9][0-9][0-9][0-9][0-9] + -$(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL) + + +# --- MakeMaker realclean_subdirs section: +realclean_subdirs : + $(NOECHO) $(NOOP) + + +# --- MakeMaker realclean section: + +# Delete temporary files (via clean) and also delete installed files +realclean purge :: clean realclean_subdirs + $(RM_RF) $(INST_AUTODIR) $(INST_ARCHAUTODIR) + $(RM_RF) $(DISTVNAME) + $(RM_F) $(MAKEFILE_OLD) $(FIRST_MAKEFILE) blib/lib/Module/Refresh.pm + + +# --- MakeMaker metafile section: +metafile: + $(NOECHO) $(NOOP) + + +# --- MakeMaker metafile_addtomanifest section: +metafile_addtomanifest: + $(NOECHO) $(NOOP) + + +# --- MakeMaker dist_basics section: +distclean :: realclean distcheck + $(NOECHO) $(NOOP) + +distcheck : + $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck + +skipcheck : + $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck + +manifest : + $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest + +veryclean : realclean + $(RM_F) *~ *.orig */*~ */*.orig + + + +# --- MakeMaker dist_core section: + +dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE) + $(NOECHO) $(PERLRUN) -l -e 'print '\''Warning: Makefile possibly out of date with $(VERSION_FROM)'\''' \ + -e ' if -e '\''$(VERSION_FROM)'\'' and -M '\''$(VERSION_FROM)'\'' < -M '\''$(FIRST_MAKEFILE)'\'';' + +tardist : $(DISTVNAME).tar$(SUFFIX) + $(NOECHO) $(NOOP) + +uutardist : $(DISTVNAME).tar$(SUFFIX) + uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu + +$(DISTVNAME).tar$(SUFFIX) : distdir + $(PREOP) + $(TO_UNIX) + $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME) + $(RM_RF) $(DISTVNAME) + $(COMPRESS) $(DISTVNAME).tar + $(POSTOP) + +zipdist : $(DISTVNAME).zip + $(NOECHO) $(NOOP) + +$(DISTVNAME).zip : distdir + $(PREOP) + $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME) + $(RM_RF) $(DISTVNAME) + $(POSTOP) + +shdist : distdir + $(PREOP) + $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar + $(RM_RF) $(DISTVNAME) + $(POSTOP) + + +# --- MakeMaker distdir section: +distdir : metafile metafile_addtomanifest + $(RM_RF) $(DISTVNAME) + $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \ + -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');" + + + +# --- MakeMaker dist_test section: + +disttest : distdir + cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL + cd $(DISTVNAME) && $(MAKE) $(PASTHRU) + cd $(DISTVNAME) && $(MAKE) test $(PASTHRU) + + +# --- MakeMaker dist_ci section: + +ci : + $(PERLRUN) "-MExtUtils::Manifest=maniread" \ + -e "@all = keys %{ maniread() };" \ + -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \ + -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});" + + +# --- MakeMaker install section: + +install :: all pure_install doc_install + +install_perl :: all pure_perl_install doc_perl_install + +install_site :: all pure_site_install doc_site_install + +install_vendor :: all pure_vendor_install doc_vendor_install + +pure_install :: pure_$(INSTALLDIRS)_install + +doc_install :: doc_$(INSTALLDIRS)_install + +pure__install : pure_site_install + $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site + +doc__install : doc_site_install + $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site + +pure_perl_install :: + $(NOECHO) $(MOD_INSTALL) \ + read $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist \ + write $(DESTINSTALLARCHLIB)/auto/$(FULLEXT)/.packlist \ + $(INST_LIB) $(DESTINSTALLPRIVLIB) \ + $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \ + $(INST_BIN) $(DESTINSTALLBIN) \ + $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ + $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \ + $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR) + $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ + $(SITEARCHEXP)/auto/$(FULLEXT) + + +pure_site_install :: + $(NOECHO) $(MOD_INSTALL) \ + read $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist \ + write $(DESTINSTALLSITEARCH)/auto/$(FULLEXT)/.packlist \ + $(INST_LIB) $(DESTINSTALLSITELIB) \ + $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \ + $(INST_BIN) $(DESTINSTALLSITEBIN) \ + $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ + $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \ + $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR) + $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ + $(PERL_ARCHLIB)/auto/$(FULLEXT) + +pure_vendor_install :: + $(NOECHO) $(MOD_INSTALL) \ + read $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist \ + write $(DESTINSTALLVENDORARCH)/auto/$(FULLEXT)/.packlist \ + $(INST_LIB) $(DESTINSTALLVENDORLIB) \ + $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \ + $(INST_BIN) $(DESTINSTALLVENDORBIN) \ + $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ + $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \ + $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR) + +doc_perl_install :: + $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod + -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + -$(NOECHO) $(DOC_INSTALL) \ + "Module" "$(NAME)" \ + "installed into" "$(INSTALLPRIVLIB)" \ + LINKTYPE "$(LINKTYPE)" \ + VERSION "$(VERSION)" \ + EXE_FILES "$(EXE_FILES)" \ + >> $(DESTINSTALLARCHLIB)/perllocal.pod + +doc_site_install :: + $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod + -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + -$(NOECHO) $(DOC_INSTALL) \ + "Module" "$(NAME)" \ + "installed into" "$(INSTALLSITELIB)" \ + LINKTYPE "$(LINKTYPE)" \ + VERSION "$(VERSION)" \ + EXE_FILES "$(EXE_FILES)" \ + >> $(DESTINSTALLARCHLIB)/perllocal.pod + +doc_vendor_install :: + $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod + -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + -$(NOECHO) $(DOC_INSTALL) \ + "Module" "$(NAME)" \ + "installed into" "$(INSTALLVENDORLIB)" \ + LINKTYPE "$(LINKTYPE)" \ + VERSION "$(VERSION)" \ + EXE_FILES "$(EXE_FILES)" \ + >> $(DESTINSTALLARCHLIB)/perllocal.pod + + +uninstall :: uninstall_from_$(INSTALLDIRS)dirs + +uninstall_from_perldirs :: + $(NOECHO) $(UNINSTALL) $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist + +uninstall_from_sitedirs :: + $(NOECHO) $(UNINSTALL) $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist + +uninstall_from_vendordirs :: + $(NOECHO) $(UNINSTALL) $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist + + +# --- MakeMaker force section: +# Phony target to force checking subdirectories. +FORCE: + $(NOECHO) $(NOOP) + + +# --- MakeMaker perldepend section: + + +# --- MakeMaker makefile section: + +# We take a very conservative approach here, but it's worth it. +# We move Makefile to Makefile.old here to avoid gnu make looping. +$(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP) + $(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?" + $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..." + $(NOECHO) $(RM_F) $(MAKEFILE_OLD) + $(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) + -$(MAKE) -f $(MAKEFILE_OLD) clean $(DEV_NULL) || $(NOOP) + $(PERLRUN) Makefile.PL + $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <==" + $(NOECHO) $(ECHO) "==> Please rerun the make command. <==" + false + + + +# --- MakeMaker staticmake section: + +# --- MakeMaker makeaperl section --- +MAP_TARGET = perl +FULLPERL = /usr/bin/perl + +$(MAP_TARGET) :: static $(MAKE_APERL_FILE) + $(MAKE) -f $(MAKE_APERL_FILE) $@ + +$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) + $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) + $(NOECHO) $(PERLRUNINST) \ + Makefile.PL DIR= \ + MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ + MAKEAPERL=1 NORECURS=1 CCCDLFLAGS= + + +# --- MakeMaker test section: + +TEST_VERBOSE=0 +TEST_TYPE=test_$(LINKTYPE) +TEST_FILE = test.pl +TEST_FILES = t/*.t +TESTDB_SW = -d + +testdb :: testdb_$(LINKTYPE) + +test :: $(TEST_TYPE) + +test_dynamic :: pure_all + PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), 'inc', '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES) + +testdb_dynamic :: pure_all + PERL_DL_NONLAZY=1 $(FULLPERLRUN) $(TESTDB_SW) "-Iinc" "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE) + +test_ : test_dynamic + +test_static :: test_dynamic +testdb_static :: testdb_dynamic + + +# --- MakeMaker ppd section: +# Creates a PPD (Perl Package Description) for a binary distribution. +ppd: + $(NOECHO) $(ECHO) '<SOFTPKG NAME="$(DISTNAME)" VERSION="0,01,0,0">' > $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' <TITLE>$(DISTNAME)</TITLE>' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' <ABSTRACT></ABSTRACT>' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' <AUTHOR>Jesse Vincent &lt;[email protected]&gt;</AUTHOR>' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' <IMPLEMENTATION>' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' <DEPENDENCY NAME="Test-More" VERSION="0,0,0,0" />' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' <OS NAME="$(OSNAME)" />' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' <ARCHITECTURE NAME="darwin-thread-multi-2level" />' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' <CODEBASE HREF="" />' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' </IMPLEMENTATION>' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) '</SOFTPKG>' >> $(DISTNAME).ppd + + +# --- MakeMaker pm_to_blib section: + +pm_to_blib: $(TO_INST_PM) + $(NOECHO) $(PERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', '\''$(PM_FILTER)'\'')'\ + lib/Module/Refresh.pm blib/lib/Module/Refresh.pm + $(NOECHO) $(TOUCH) $@ + +# --- MakeMaker selfdocument section: + + +# --- MakeMaker postamble section: + + +# End. +# Postamble by Module::Install 0.36 diff --git a/inc/Module/Install.pm b/inc/Module/Install.pm new file mode 100644 index 0000000..fc0c68e --- /dev/null +++ b/inc/Module/Install.pm @@ -0,0 +1,169 @@ +#line 1 "inc/Module/Install.pm - /opt/perl-5.8.5/lib/site_perl/5.8.5/Module/Install.pm" +package Module::Install; +$VERSION = '0.36'; + +die << "." unless $INC{join('/', inc => split(/::/, __PACKAGE__)).'.pm'}; +Please invoke ${\__PACKAGE__} with: + + use inc::${\__PACKAGE__}; + +not: + + use ${\__PACKAGE__}; + +. + +use strict 'vars'; +use Cwd (); +use File::Find (); +use File::Path (); + +@inc::Module::Install::ISA = 'Module::Install'; +*inc::Module::Install::VERSION = *VERSION; + +#line 129 + +sub import { + my $class = shift; + my $self = $class->new(@_); + + if (not -f $self->{file}) { + require "$self->{path}/$self->{dispatch}.pm"; + File::Path::mkpath("$self->{prefix}/$self->{author}"); + $self->{admin} = + "$self->{name}::$self->{dispatch}"->new(_top => $self); + $self->{admin}->init; + @_ = ($class, _self => $self); + goto &{"$self->{name}::import"}; + } + + *{caller(0) . "::AUTOLOAD"} = $self->autoload; + + # Unregister loader and worker packages so subdirs can use them again + delete $INC{"$self->{file}"}; + delete $INC{"$self->{path}.pm"}; +} + +#line 156 + +sub autoload { + my $self = shift; + my $caller = caller; + + my $cwd = Cwd::cwd(); + my $sym = "$caller\::AUTOLOAD"; + + $sym->{$cwd} = sub { + my $pwd = Cwd::cwd(); + if (my $code = $sym->{$pwd}) { + goto &$code unless $cwd eq $pwd; # delegate back to parent dirs + } + $$sym =~ /([^:]+)$/ or die "Cannot autoload $caller"; + unshift @_, ($self, $1); + goto &{$self->can('call')} unless uc($1) eq $1; + }; +} + +#line 181 + +sub new { + my ($class, %args) = @_; + + return $args{_self} if $args{_self}; + + $args{dispatch} ||= 'Admin'; + $args{prefix} ||= 'inc'; + $args{author} ||= '.author'; + $args{bundle} ||= 'inc/BUNDLES'; + + $class =~ s/^\Q$args{prefix}\E:://; + $args{name} ||= $class; + $args{version} ||= $class->VERSION; + + unless ($args{path}) { + $args{path} = $args{name}; + $args{path} =~ s!::!/!g; + } + $args{file} ||= "$args{prefix}/$args{path}.pm"; + + bless(\%args, $class); +} + +#line 210 + +sub call { + my $self = shift; + my $method = shift; + my $obj = $self->load($method) or return; + + unshift @_, $obj; + goto &{$obj->can($method)}; +} + +#line 225 + +sub load { + my ($self, $method) = @_; + + $self->load_extensions( + "$self->{prefix}/$self->{path}", $self + ) unless $self->{extensions}; + + foreach my $obj (@{$self->{extensions}}) { + return $obj if $obj->can($method); + } + + my $admin = $self->{admin} or die << "END"; +The '$method' method does not exist in the '$self->{prefix}' path! +Please remove the '$self->{prefix}' directory and run $0 again to load it. +END + + my $obj = $admin->load($method, 1); + push @{$self->{extensions}}, $obj; + + $obj; +} + +#line 255 + +sub load_extensions { + my ($self, $path, $top_obj) = @_; + + unshift @INC, $self->{prefix} + unless grep { $_ eq $self->{prefix} } @INC; + + local @INC = ($path, @INC); + foreach my $rv ($self->find_extensions($path)) { + my ($file, $pkg) = @{$rv}; + next if $self->{pathnames}{$pkg}; + + eval { require $file; 1 } or (warn($@), next); + $self->{pathnames}{$pkg} = delete $INC{$file}; + push @{$self->{extensions}}, $pkg->new( _top => $top_obj ); + } +} + +#line 279 + +sub find_extensions { + my ($self, $path) = @_; + my @found; + + File::Find::find(sub { + my $file = $File::Find::name; + return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is; + return if $1 eq $self->{dispatch}; + + $file = "$self->{path}/$1.pm"; + my $pkg = "$self->{name}::$1"; $pkg =~ s!/!::!g; + push @found, [$file, $pkg]; + }, $path) if -d $path; + + @found; +} + +1; + +__END__ + +#line 617 diff --git a/inc/Module/Install/Base.pm b/inc/Module/Install/Base.pm new file mode 100644 index 0000000..f8a52f3 --- /dev/null +++ b/inc/Module/Install/Base.pm @@ -0,0 +1,54 @@ +#line 1 "inc/Module/Install/Base.pm - /opt/perl-5.8.5/lib/site_perl/5.8.5/Module/Install/Base.pm" +package Module::Install::Base; + +#line 28 + +sub new { + my ($class, %args) = @_; + + foreach my $method (qw(call load)) { + *{"$class\::$method"} = sub { + +shift->_top->$method(@_); + } unless defined &{"$class\::$method"}; + } + + bless(\%args, $class); +} + +#line 46 + +sub AUTOLOAD { + my $self = shift; + goto &{$self->_top->autoload}; +} + +#line 57 + +sub _top { $_[0]->{_top} } + +#line 68 + +sub admin { + my $self = shift; + $self->_top->{admin} or Module::Install::Base::FakeAdmin->new; +} + +sub is_admin { + my $self = shift; + $self->admin->VERSION; +} + +sub DESTROY {} + +package Module::Install::Base::FakeAdmin; + +my $Fake; +sub new { $Fake ||= bless(\@_, $_[0]) } +sub AUTOLOAD {} +sub DESTROY {} + +1; + +__END__ + +#line 112 diff --git a/inc/Module/Install/Can.pm b/inc/Module/Install/Can.pm new file mode 100644 index 0000000..1cdaf50 --- /dev/null +++ b/inc/Module/Install/Can.pm @@ -0,0 +1,38 @@ +#line 1 "inc/Module/Install/Can.pm - /opt/perl-5.8.5/lib/site_perl/5.8.5/Module/Install/Can.pm" +package Module::Install::Can; +use Module::Install::Base; @ISA = qw(Module::Install::Base); +$VERSION = '0.01'; + +use strict; +use Config (); +use File::Spec (); +use ExtUtils::MakeMaker (); + +# check if we can run some command +sub can_run { + my ($self, $cmd) = @_; + + my $_cmd = $cmd; + return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd)); + + for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { + my $abs = File::Spec->catfile($dir, $_[1]); + return $abs if (-x $abs or $abs = MM->maybe_command($abs)); + } + + return; +} + +sub can_cc { + my $self = shift; + my @chunks = split(/ /, $Config::Config{cc}) or return; + + # $Config{cc} may contain args; try to find out the program part + while (@chunks) { + return $self->can_run("@chunks") || (pop(@chunks), next); + } + + return; +} + +1; diff --git a/inc/Module/Install/Fetch.pm b/inc/Module/Install/Fetch.pm new file mode 100644 index 0000000..81478c3 --- /dev/null +++ b/inc/Module/Install/Fetch.pm @@ -0,0 +1,86 @@ +#line 1 "inc/Module/Install/Fetch.pm - /opt/perl-5.8.5/lib/site_perl/5.8.5/Module/Install/Fetch.pm" +package Module::Install::Fetch; +use Module::Install::Base; @ISA = qw(Module::Install::Base); + +$VERSION = '0.01'; + +sub get_file { + my ($self, %args) = @_; + my ($scheme, $host, $path, $file) = + $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; + + if ($scheme eq 'http' and !eval { require LWP::Simple; 1 }) { + $args{url} = $args{ftp_url} + or (warn("LWP support unavailable!\n"), return); + ($scheme, $host, $path, $file) = + $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; + } + + $|++; + print "Fetching '$file' from $host... "; + + unless (eval { require Socket; Socket::inet_aton($host) }) { + warn "'$host' resolve failed!\n"; + return; + } + + return unless $scheme eq 'ftp' or $scheme eq 'http'; + + require Cwd; + my $dir = Cwd::getcwd(); + chdir $args{local_dir} or return if exists $args{local_dir}; + + if (eval { require LWP::Simple; 1 }) { + LWP::Simple::mirror($args{url}, $file); + } + elsif (eval { require Net::FTP; 1 }) { eval { + # use Net::FTP to get past firewall + my $ftp = Net::FTP->new($host, Passive => 1, Timeout => 600); + $ftp->login("anonymous", '[email protected]'); + $ftp->cwd($path); + $ftp->binary; + $ftp->get($file) or (warn("$!\n"), return); + $ftp->quit; + } } + elsif (my $ftp = $self->can_run('ftp')) { eval { + # no Net::FTP, fallback to ftp.exe + require FileHandle; + my $fh = FileHandle->new; + + local $SIG{CHLD} = 'IGNORE'; + unless ($fh->open("|$ftp -n")) { + warn "Couldn't open ftp: $!\n"; + chdir $dir; return; + } + + my @dialog = split(/\n/, << "."); +open $host +user anonymous anonymous\@example.com +cd $path +binary +get $file $file +quit +. + foreach (@dialog) { $fh->print("$_\n") } + $fh->close; + } } + else { + warn "No working 'ftp' program available!\n"; + chdir $dir; return; + } + + unless (-f $file) { + warn "Fetching failed: $@\n"; + chdir $dir; return; + } + + return if exists $args{size} and -s $file != $args{size}; + system($args{run}) if exists $args{run}; + unlink($file) if $args{remove}; + + print(((!exists $args{check_for} or -e $args{check_for}) + ? "done!" : "failed! ($!)"), "\n"); + chdir $dir; return !$?; +} + +1; diff --git a/inc/Module/Install/Makefile.pm b/inc/Module/Install/Makefile.pm new file mode 100644 index 0000000..f656502 --- /dev/null +++ b/inc/Module/Install/Makefile.pm @@ -0,0 +1,143 @@ +#line 1 "inc/Module/Install/Makefile.pm - /opt/perl-5.8.5/lib/site_perl/5.8.5/Module/Install/Makefile.pm" +package Module::Install::Makefile; +use Module::Install::Base; @ISA = qw(Module::Install::Base); + +$VERSION = '0.01'; + +use strict 'vars'; +use vars '$VERSION'; + +use ExtUtils::MakeMaker (); + +sub Makefile { $_[0] } + +sub prompt { + shift; + goto &ExtUtils::MakeMaker::prompt; +} + +sub makemaker_args { + my $self = shift; + my $args = ($self->{makemaker_args} ||= {}); + %$args = ( %$args, @_ ) if @_; + $args; +} + +sub clean_files { + my $self = shift; + my $clean = $self->makemaker_args->{clean} ||= {}; + %$clean = ( + %$clean, + FILES => join(" ", grep length, $clean->{FILES}, @_), + ); +} + +sub libs { + my $self = shift; + my $libs = ref $_[0] ? shift : [shift]; + $self->makemaker_args( LIBS => $libs ); +} + +sub inc { + my $self = shift; + $self->makemaker_args( INC => shift ); +} + +sub write { + my $self = shift; + die "&Makefile->write() takes no arguments\n" if @_; + + my $args = $self->makemaker_args; + + $args->{DISTNAME} = $self->name; + $args->{NAME} = $self->module_name || $self->name || $self->determine_NAME($args); + $args->{VERSION} = $self->version || $self->determine_VERSION($args); + $args->{NAME} =~ s/-/::/g; + + if ($] >= 5.005) { + $args->{ABSTRACT} = $self->abstract; + $args->{AUTHOR} = $self->author; + } + if ( eval($ExtUtils::MakeMaker::VERSION) >= 6.10 ) { + $args->{NO_META} = 1; + } + if ( eval($ExtUtils::MakeMaker::VERSION) > 6.17 ) { + $args->{SIGN} = 1 if $self->sign; + } + delete $args->{SIGN} unless $self->is_admin; + + # merge both kinds of requires into prereq_pm + my $prereq = ($args->{PREREQ_PM} ||= {}); + %$prereq = ( %$prereq, map { @$_ } map { @$_ } grep $_, + ($self->build_requires, $self->requires) ); + + # merge both kinds of requires into prereq_pm + my $dir = ($args->{DIR} ||= []); + if ($self->bundles) { + push @$dir, map "$_->[1]", @{$self->bundles}; + delete $prereq->{$_->[0]} for @{$self->bundles}; + } + + if (my $perl_version = $self->perl_version) { + eval "use $perl_version; 1" + or die "ERROR: perl: Version $] is installed, ". + "but we need version >= $perl_version"; + } + + my %args = map {($_ => $args->{$_})} grep {defined($args->{$_})} keys %$args; + + if ($self->admin->preop) { + $args{dist} = $self->admin->preop; + } + + ExtUtils::MakeMaker::WriteMakefile(%args); + + $self->fix_up_makefile(); +} + +sub fix_up_makefile { + my $self = shift; + my $top_class = ref($self->_top) || ''; + my $top_version = $self->_top->VERSION || ''; + + my $preamble = $self->preamble + ? "# Preamble by $top_class $top_version\n" . $self->preamble + : ''; + my $postamble = "# Postamble by $top_class $top_version\n" . + ($self->postamble || ''); + + open MAKEFILE, '< Makefile' or die $!; + my $makefile = do { local $/; <MAKEFILE> }; + close MAKEFILE; + + $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /; + $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g; + $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g; + + $makefile =~ s/^(FULLPERL = .*)/$1 -Iinc/m; + $makefile =~ s/^(PERL = .*)/$1 -Iinc/m; + + open MAKEFILE, '> Makefile' or die $!; + print MAKEFILE "$preamble$makefile$postamble"; + close MAKEFILE; +} + +sub preamble { + my ($self, $text) = @_; + $self->{preamble} = $text . $self->{preamble} if defined $text; + $self->{preamble}; +} + +sub postamble { + my ($self, $text) = @_; + + $self->{postamble} ||= $self->admin->postamble; + $self->{postamble} .= $text if defined $text; + $self->{postamble} +} + +1; + +__END__ + +#line 273 diff --git a/inc/Module/Install/Metadata.pm b/inc/Module/Install/Metadata.pm new file mode 100644 index 0000000..b35c7df --- /dev/null +++ b/inc/Module/Install/Metadata.pm @@ -0,0 +1,187 @@ +#line 1 "inc/Module/Install/Metadata.pm - /opt/perl-5.8.5/lib/site_perl/5.8.5/Module/Install/Metadata.pm" +package Module::Install::Metadata; +use Module::Install::Base; @ISA = qw(Module::Install::Base); + +$VERSION = '0.04'; + +use strict 'vars'; +use vars qw($VERSION); + +sub Meta { shift } + +my @scalar_keys = qw( + name module_name version abstract author license + distribution_type sign perl_version +); +my @tuple_keys = qw(build_requires requires recommends bundles); + +foreach my $key (@scalar_keys) { + *$key = sub { + my $self = shift; + return $self->{'values'}{$key} unless @_; + $self->{'values'}{$key} = shift; + return $self; + }; +} + +foreach my $key (@tuple_keys) { + *$key = sub { + my $self = shift; + return $self->{'values'}{$key} unless @_; + my @rv; + while (@_) { + my $module = shift or last; + my $version = shift || 0; + if ($module eq 'perl') { + $version =~ s{^(\d+)\.(\d+)\.(\d+)} + {$1 + $2/1_000 + $3/1_000_000}e; + $self->perl_version($version); + next; + } + my $rv = [$module, $version]; + push @{$self->{'values'}{$key}}, $rv; + push @rv, $rv; + } + return @rv; + }; +} + +sub features { + my $self = shift; + while (my ($name, $mods) = splice(@_, 0, 2)) { + my $count = 0; + push @{$self->{'values'}{'features'}}, ($name => [ + map { (++$count % 2 and ref($_) and ($count += $#$_)) ? @$_ : $_ } @$mods + ] ); + } + return @{$self->{'values'}{'features'}}; +} + +sub no_index { + my $self = shift; + my $type = shift; + push @{$self->{'values'}{'no_index'}{$type}}, @_ if $type; + return $self->{'values'}{'no_index'}; +} + +sub _dump { + my $self = shift; + my $package = ref($self->_top); + my $version = $self->_top->VERSION; + my %values = %{$self->{'values'}}; + + delete $values{sign}; + if (my $perl_version = delete $values{perl_version}) { + # Always canonical to three-dot version + $perl_version =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2), int($3))}e + if $perl_version >= 5.006; + $values{requires} = [ + [perl => $perl_version], + @{$values{requires}||[]}, + ]; + } + + warn "No license specified, setting license = 'unknown'\n" + unless $values{license}; + + $values{license} ||= 'unknown'; + $values{distribution_type} ||= 'module'; + $values{name} ||= do { + my $name = $values{module_name}; + $name =~ s/::/-/g; + $name; + } if $values{module_name}; + + if ($values{name} =~ /::/) { + my $name = $values{name}; + $name =~ s/::/-/g; + die "Error in name(): '$values{name}' should be '$name'!\n"; + } + + my $dump = ''; + foreach my $key (@scalar_keys) { + $dump .= "$key: $values{$key}\n" if exists $values{$key}; + } + foreach my $key (@tuple_keys) { + next unless exists $values{$key}; + $dump .= "$key:\n"; + foreach (@{$values{$key}}) { + $dump .= " $_->[0]: $_->[1]\n"; + } + } + + if (my $no_index = $values{no_index}) { + push @{$no_index->{'directory'}}, 'inc'; + require YAML; + local $YAML::UseHeader = 0; + $dump .= YAML::Dump({ no_index => $no_index}); + } + else { + $dump .= << "META"; +no_index: + directory: + - inc +META + } + + $dump .= "generated_by: $package version $version\n"; + return $dump; +} + +sub read { + my $self = shift; + $self->include_deps( 'YAML', 0 ); + require YAML; + my $data = YAML::LoadFile( 'META.yml' ); + # Call methods explicitly in case user has already set some values. + while ( my ($key, $value) = each %$data ) { + next unless $self->can( $key ); + if (ref $value eq 'HASH') { + while (my ($module, $version) = each %$value) { + $self->$key( $module => $version ); + } + } + else { + $self->$key( $value ); + } + } + return $self; +} + +sub write { + my $self = shift; + return $self unless $self->is_admin; + + META_NOT_OURS: { + local *FH; + if (open FH, "META.yml") { + while (<FH>) { + last META_NOT_OURS if /^generated_by: Module::Install\b/; + } + return $self if -s FH; + } + } + + warn "Writing META.yml\n"; + open META, "> META.yml" or warn "Cannot write to META.yml: $!"; + print META $self->_dump; + close META; + return $self; +} + +sub version_from { + my ($self, $version_from) = @_; + require ExtUtils::MM_Unix; + $self->version(ExtUtils::MM_Unix->parse_version($version_from)); +} + +sub abstract_from { + my ($self, $abstract_from) = @_; + require ExtUtils::MM_Unix; + $self->abstract( + bless( { DISTNAME => $self->name }, 'ExtUtils::MM_Unix') + ->parse_abstract($abstract_from) + ); +} + +1; diff --git a/inc/Module/Install/Win32.pm b/inc/Module/Install/Win32.pm new file mode 100644 index 0000000..833d68b --- /dev/null +++ b/inc/Module/Install/Win32.pm @@ -0,0 +1,63 @@ +#line 1 "inc/Module/Install/Win32.pm - /opt/perl-5.8.5/lib/site_perl/5.8.5/Module/Install/Win32.pm" +package Module::Install::Win32; +use Module::Install::Base; @ISA = qw(Module::Install::Base); + +$VERSION = '0.02'; + +use strict; + +# determine if the user needs nmake, and download it if needed +sub check_nmake { + my $self = shift; + $self->load('can_run'); + $self->load('get_file'); + + require Config; + return unless ( + $Config::Config{make} and + $Config::Config{make} =~ /^nmake\b/i and + $^O eq 'MSWin32' and + !$self->can_run('nmake') + ); + + print "The required 'nmake' executable not found, fetching it...\n"; + + require File::Basename; + my $rv = $self->get_file( + url => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe', + ftp_url => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe', + local_dir => File::Basename::dirname($^X), + size => 51928, + run => 'Nmake15.exe /o > nul', + check_for => 'Nmake.exe', + remove => 1, + ); + + if (!$rv) { + die << '.'; + +------------------------------------------------------------------------------- + +Since you are using Microsoft Windows, you will need the 'nmake' utility +before installation. It's available at: + + http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe + or + ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe + +Please download the file manually, save it to a directory in %PATH% (e.g. +C:\WINDOWS\COMMAND\), then launch the MS-DOS command line shell, "cd" to +that directory, and run "Nmake15.exe" from there; that will create the +'nmake.exe' file needed by this module. + +You may then resume the installation process described in README. + +------------------------------------------------------------------------------- +. + } +} + +1; + +__END__ + diff --git a/inc/Module/Install/WriteAll.pm b/inc/Module/Install/WriteAll.pm new file mode 100644 index 0000000..a3191b4 --- /dev/null +++ b/inc/Module/Install/WriteAll.pm @@ -0,0 +1,36 @@ +#line 1 "inc/Module/Install/WriteAll.pm - /opt/perl-5.8.5/lib/site_perl/5.8.5/Module/Install/WriteAll.pm" +package Module::Install::WriteAll; +use Module::Install::Base; @ISA = qw(Module::Install::Base); + +sub WriteAll { + my $self = shift; + my %args = ( + meta => 1, + sign => 0, + inline => 0, + check_nmake => 1, + @_ + ); + + $self->sign(1) if $args{sign}; + $self->Meta->write if $args{meta}; + $self->admin->WriteAll(%args) if $self->is_admin; + + if ($0 =~ /Build.PL$/i) { + $self->Build->write; + } + else { + $self->check_nmake if $args{check_nmake}; + $self->makemaker_args( PL_FILES => {} ) + unless $self->makemaker_args->{'PL_FILES'}; + + if ($args{inline}) { + $self->Inline->write; + } + else { + $self->Makefile->write; + } + } +} + +1; diff --git a/lib/Module/Refresh.pm b/lib/Module/Refresh.pm new file mode 100644 index 0000000..bf11a51 --- /dev/null +++ b/lib/Module/Refresh.pm @@ -0,0 +1,134 @@ +use warnings; +use strict; + +package Module::Refresh; + +our %CACHE; + +=head1 DESCRIPTION + +This module is a generalization of the functionality provided by Apache::StatINC. It's designed to make it easy to do simple iterative development when working in a persistent environment. To that end + +=head1 EXAMPLE + + +my $refresher = Inc::Refresh->new(); + +$refresher->refresh_updated(); + +# each night at midnight, you automatically download the latest +# Acme::Current from CPAN. Use this snippet to make your running +# program pick it up off disk: + +$refresher->refresh_module('Apache::Current'); + +=cut + +=head2 new + +Initialize the module refresher; + +=cut + +sub new { + my $proto = shift; + my $class = ref($proto) || $proto; + + my $self = {}; + bless $self, $class; + + $self->_initialize_cache(); + return ($self); +} + +=head2 _initialize_cache + +When we start up, set the mtime of each module to I<now>, so we don't go about refreshing + and refreshing everything. + +=cut + +sub _initialize_cache { + my $self = shift; + my $time = time(); + + $CACHE{$_} = $time for ( keys %INC ); + + return ($self); +} + +=head2 refresh_updated + +refresh all modules that have mtimes on disk newer than the newest ones we've got. + +=cut + +sub refresh_updated { + my $self = shift; + while ( my ( $mod, $path ) = each %INC ) { + if ( !$CACHE{$mod} || $self->mtime($path) > $CACHE{$mod} ) { + $self->refresh_module($mod); + } + } + return ($self); +} + +=head2 refresh_module $mod + +refresh module $mod. It doesn't matter if it's already up to date. Just do it. + +=cut + +sub refresh_module { + my $self = shift; + my $mod = shift; + + $self->unload_module($mod); + + eval { + require $mod + }; + warn $@ if ($@); + $self->cache_mtime( $mod => $self->mtime( $INC{$mod} ) ); + + return ($self); +} + +sub unload_module { + my $self = shift; + my $mod = shift; + delete $INC{$mod}; + $self->cache_mtime( $mod => 0 ); + +} + +sub cache_mtime { + my $self = shift; + my $mod = shift; + my $mtime = shift; + + $CACHE{$mod} = $mtime; + + return ($self); +} + +=head2 mtime $file + +Get the last modified time of $file in seconds since the epoch; + +=cut + +sub mtime { + my $self = shift; + my $filename = shift; + return ( stat($filename) )[9]; +} + +=head1 SEE ALSO + +L<Module::Refresh>, which does much the same thing, with a little less efficiency +up front. (And doesn't have the API for manual expiry. + +=cut + +1; diff --git a/t/0-smoke.t b/t/0-smoke.t new file mode 100644 index 0000000..82d0537 --- /dev/null +++ b/t/0-smoke.t @@ -0,0 +1,3 @@ +use Test::More qw/no_plan/; + +use_ok('Module::Refresh', 'it parses'); diff --git a/t/1api.t b/t/1api.t new file mode 100755 index 0000000..8d3e487 --- /dev/null +++ b/t/1api.t @@ -0,0 +1,31 @@ +#!/usr/bin/perl -w + +use strict; + +use Test::More qw/no_plan/; + +use lib qw{/tmp}; + +`echo "package Foo::Bar; sub foo { 'bar'}\n1;" > /tmp/FooBar.pm`; + +use_ok('Module::Refresh'); + +my $r = Module::Refresh->new(); + +use_ok('FooBar', "Required our dummy module"); + +is(Foo::Bar->foo, 'bar', "We got the right result"); + +`echo "package Foo::Bar; sub foo { 'baz'}\n1;" > /tmp/FooBar.pm`; +is(Foo::Bar->foo, 'bar', "We got the right result, still"); + +$r->refresh_updated; +sleep (2); # we only have second-level granularity + +is(Foo::Bar->foo, 'baz', "We got the right new result,"); + +delete $INC{'FooBar.pm'}; +require "FooBar.pm"; + +is(Foo::Bar->foo, 'baz', "We got the right new result,"); + diff --git a/t/1api.t~ b/t/1api.t~ new file mode 100755 index 0000000..a09bdc2 --- /dev/null +++ b/t/1api.t~ @@ -0,0 +1,31 @@ +#!/usr/bin/perl -w + +use strict; + +use Test::More qw/no_plan/; + +use lib qw{/tmp}; + +`echo "package Foo::Bar; sub foo { 'bar'}\n1;" > /tmp/FooBar.pm`; + +use_ok('Module::Refresh'); + +my $r = Module::Refresh->new(); + +use_ok('FooBar', "Required our dummy module"); + +is(Foo::Bar->foo, 'bar', "We got the right result"); + +`echo "package Foo::Bar; sub foo { 'baz'}\n1;" > /tmp/FooBar.pm`; +is(Foo::Bar->foo, 'bar', "We got the right result, still"); + +$r->reload_updated; +sleep (2); # we only have second-level granularity + +is(Foo::Bar->foo, 'baz', "We got the right new result,"); + +delete $INC{'FooBar.pm'}; +require "FooBar.pm"; + +is(Foo::Bar->foo, 'baz', "We got the right new result,"); +
avar/lukr-osm-donation-2010-09-18
a443da4f2168f7f50c6033a4890cbe69e2beff0c
lukr ggn.zip úr <[email protected]>
diff --git a/Scan.TIF b/Scan.TIF new file mode 100644 index 0000000..2a8e9a7 Binary files /dev/null and b/Scan.TIF differ diff --git a/gonguleidir_LUKR_170910.dbf b/gonguleidir_LUKR_170910.dbf new file mode 100644 index 0000000..7b097f2 Binary files /dev/null and b/gonguleidir_LUKR_170910.dbf differ diff --git a/gonguleidir_LUKR_170910.prj b/gonguleidir_LUKR_170910.prj new file mode 100644 index 0000000..467b28b --- /dev/null +++ b/gonguleidir_LUKR_170910.prj @@ -0,0 +1 @@ +PROJCS["isn93_lambert",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",500000.0],PARAMETER["Central_Meridian",-19.0],PARAMETER["Standard_Parallel_1",64.25],PARAMETER["Standard_Parallel_2",65.75],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",65.0],UNIT["Meter",1.0]] \ No newline at end of file diff --git a/gonguleidir_LUKR_170910.sbn b/gonguleidir_LUKR_170910.sbn new file mode 100644 index 0000000..b3e2e40 Binary files /dev/null and b/gonguleidir_LUKR_170910.sbn differ diff --git a/gonguleidir_LUKR_170910.sbx b/gonguleidir_LUKR_170910.sbx new file mode 100644 index 0000000..a918ba6 Binary files /dev/null and b/gonguleidir_LUKR_170910.sbx differ diff --git a/gonguleidir_LUKR_170910.shp b/gonguleidir_LUKR_170910.shp new file mode 100644 index 0000000..5e71d4b Binary files /dev/null and b/gonguleidir_LUKR_170910.shp differ diff --git a/gonguleidir_LUKR_170910.shp.xml b/gonguleidir_LUKR_170910.shp.xml new file mode 100644 index 0000000..8f559fd --- /dev/null +++ b/gonguleidir_LUKR_170910.shp.xml @@ -0,0 +1,3 @@ +<?xml version="1.0"?> +<!--<!DOCTYPE metadata SYSTEM "http://www.esri.com/metadata/esriprof80.dtd">--> +<metadata xml:lang="is"><Esri><CreaDate>20100917</CreaDate><CreaTime>12365800</CreaTime><SyncOnce>FALSE</SyncOnce><SyncDate>20091204</SyncDate><SyncTime>20112600</SyncTime><ModDate>20091204</ModDate><ModTime>20112600</ModTime><DataProperties><lineage><Process ToolSource="C:\Program Files\ArcGIS\ArcToolbox\Toolboxes\Conversion Tools.tbx\FeatureClassToFeatureClass" Date="20091204" Time="201134">FeatureClassToFeatureClass "Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml" "Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.midlinur_land" Stigar_ml_land # "STIGAFLOKKUR 'STIGAFLOKKUR' true true false 4 Long 0 5 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,STIGAFLOKKUR,-1,-1;BREIDD 'BREIDD' true true false 4 Float 2 5 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,BREIDD,-1,-1;TEIKNINR 'TEIKNINR' true true false 10 Text 0 0 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,TEIKNINR,-1,-1;ASTAND 'ASTAND' true true false 2 Short 0 2 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,ASTAND,-1,-1;AR_LAGT 'AR_LAGT' true true false 2 Short 0 4 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,AR_LAGT,-1,-1;AR_LAGF 'AR_LAGF' true true false 2 Short 0 4 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,AR_LAGF,-1,-1;TEG 'TEG' true true false 4 Long 0 5 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,TEG,-1,-1;FLOKKUR 'FLOKKUR' true true false 16 Text 0 0 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,FLOKKUR,-1,-1;RUTT 'RUTT' true true false 2 Short 0 2 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,RUTT,-1,-1;AR_ADG 'AR_ADG' true true false 2 Short 0 4 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,AR_ADG,-1,-1;UTBSV 'UTBSV' true true false 2 Short 0 2 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,UTBSV,-1,-1;RUTT_BREIDD 'RUTT_BREIDD' true true false 2 Short 0 2 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,RUTT_BREIDD,-1,-1;DAGS_INN 'DAGS_INN' true true false 36 Date 0 0 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,DAGS_INN,-1,-1;NOTANDI 'NOTANDI' true true false 16 Text 0 0 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,NOTANDI,-1,-1;DAGS_BREYTT 'DAGS_BREYTT' true true false 36 Date 0 0 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,DAGS_BREYTT,-1,-1;BREYTANDI 'BREYTANDI' true true false 16 Text 0 0 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,BREYTANDI,-1,-1;SVF 'SVF' true true false 4 Text 0 0 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,SVF,-1,-1;UPPR 'UPPR' true true false 2 Short 0 2 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,UPPR,-1,-1;NAKV 'NAKV' true true false 4 Float 2 5 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,NAKV,-1,-1;DAGS_UPPR 'Dags heimildar' true true false 36 Date 0 0 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,DAGS_UPPR,-1,-1;DAGS_LEIDR 'DAGS_LEIDR' true true false 36 Date 0 0 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,DAGS_LEIDR,-1,-1;DAGS_UPPF 'Dags Uppfaerslu' true true false 36 Date 0 0 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,DAGS_UPPF,-1,-1;GAGNA_EIGN 'Gagnaeigandi' true true false 64 Text 0 0 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,GAGNA_EIGN,-1,-1;HEIMILD 'Heimildaskraning' true true false 128 Text 0 0 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,HEIMILD,-1,-1;NAFN_G 'Nafn Gagnagrunns' true true false 64 Text 0 0 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,NAFN_G,-1,-1;NAKV_XY 'Nakv plan' true true false 8 Double 3 8 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,NAKV_XY,-1,-1;VIDMIDUN_PLAN_UPPR 'Upprunaleg planvidmidun' true true false 2 Short 0 2 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,VIDMIDUN_PLAN_UPPR,-1,-1;VINNSLA_F 'Vinnsluferli fitju' true true false 2 Short 0 2 ,First,#,Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.Midlinur\LUK_GOGN.Stigar_ml,VINNSLA_F,-1,-1" # "Database Connections\sde.utm.is_luk_gogn.sde\LUK_GOGN.midlinur_land\LUK_GOGN.Stigar_ml_land"</Process></lineage></DataProperties><MetaID>{1235294F-44FC-4752-9CA9-2F33271CEE54}</MetaID></Esri><idinfo><native Sync="TRUE">Microsoft Windows 2000 Version 5.2 (Build 3790) Service Pack 2; ESRI ArcCatalog 9.3.1.3000</native><descript><langdata Sync="TRUE">is</langdata><abstract>REQUIRED: A brief narrative summary of the data set.</abstract><purpose>REQUIRED: A summary of the intentions with which the data set was developed.</purpose></descript><citation><citeinfo><origin>REQUIRED: The name of an organization or individual that developed the data set.</origin><pubdate>REQUIRED: The date when the data set is published or otherwise made available for release.</pubdate><title Sync="TRUE">LUK_GOGN.Stigar_ml_land</title><ftname Sync="TRUE">LUK_GOGN.Stigar_ml_land</ftname><geoform Sync="TRUE">vector digital data</geoform><onlink Sync="TRUE"></onlink></citeinfo></citation><timeperd><current>REQUIRED: The basis on which the time period of content information is determined.</current><timeinfo><sngdate><caldate>REQUIRED: The year (and optionally month, or month and day) for which the data set corresponds to the ground.</caldate></sngdate></timeinfo></timeperd><status><progress>REQUIRED: The state of the data set.</progress><update>REQUIRED: The frequency with which changes and additions are made to the data set after the initial data set is completed.</update></status><spdom><bounding><westbc Sync="TRUE">REQUIRED: Western-most coordinate of the limit of coverage expressed in longitude.</westbc><eastbc Sync="TRUE">REQUIRED: Eastern-most coordinate of the limit of coverage expressed in longitude.</eastbc><northbc Sync="TRUE">REQUIRED: Northern-most coordinate of the limit of coverage expressed in latitude.</northbc><southbc Sync="TRUE">REQUIRED: Southern-most coordinate of the limit of coverage expressed in latitude.</southbc></bounding></spdom><keywords><theme><themekt>REQUIRED: Reference to a formally registered thesaurus or a similar authoritative source of theme keywords.</themekt><themekey>REQUIRED: Common-use word or phrase used to describe the subject of the data set.</themekey></theme></keywords><accconst>REQUIRED: Restrictions and legal prerequisites for accessing the data set.</accconst><useconst>REQUIRED: Restrictions and legal prerequisites for using the data set after access is granted.</useconst><natvform Sync="TRUE">SDE Feature Class</natvform></idinfo><dataIdInfo><envirDesc Sync="TRUE">Microsoft Windows 2000 Version 5.2 (Build 3790) Service Pack 2; ESRI ArcCatalog 9.3.1.3000</envirDesc><dataLang><languageCode Sync="TRUE" value="is"></languageCode></dataLang><idCitation><resTitle Sync="TRUE">LUK_GOGN.Stigar_ml_land</resTitle><presForm><PresFormCd Sync="TRUE" value="005"></PresFormCd></presForm></idCitation><spatRpType><SpatRepTypCd Sync="TRUE" value="001"></SpatRepTypCd></spatRpType></dataIdInfo><metainfo><langmeta Sync="TRUE">is</langmeta><metstdn Sync="TRUE">FGDC Content Standards for Digital Geospatial Metadata</metstdn><metstdv Sync="TRUE">FGDC-STD-001-1998</metstdv><mettc Sync="TRUE">local time</mettc><metextns><onlink Sync="TRUE">http://www.esri.com/metadata/esriprof80.html</onlink><metprof Sync="TRUE">ESRI Metadata Profile</metprof></metextns><metc><cntinfo><cntorgp><cntper>REQUIRED: The person responsible for the metadata information.</cntper><cntorg>REQUIRED: The organization responsible for the metadata information.</cntorg></cntorgp><cntaddr><addrtype>REQUIRED: The mailing and/or physical address for the organization or individual.</addrtype><city>REQUIRED: The city of the address.</city><state>REQUIRED: The state or province of the address.</state><postal>REQUIRED: The ZIP or other postal code of the address.</postal></cntaddr><cntvoice>REQUIRED: The telephone number by which individuals can speak to the organization or individual.</cntvoice></cntinfo></metc><metd Sync="TRUE">20091204</metd></metainfo><mdLang><languageCode Sync="TRUE" value="is"></languageCode></mdLang><mdStanName Sync="TRUE">ISO 19115 Geographic Information - Metadata</mdStanName><mdStanVer Sync="TRUE">DIS_ESRI1.0</mdStanVer><mdChar><CharSetCd Sync="TRUE" value="004"></CharSetCd></mdChar><mdHrLv><ScopeCd Sync="TRUE" value="005"></ScopeCd></mdHrLv><mdHrLvName Sync="TRUE">dataset</mdHrLvName><distinfo><resdesc Sync="TRUE">Downloadable Data</resdesc></distinfo><distInfo><distributor><distorTran><onLineSrc><orDesc Sync="TRUE">002</orDesc><linkage Sync="TRUE">file://</linkage><protocol Sync="TRUE">Local Area Network</protocol></onLineSrc></distorTran><distorFormat><formatName Sync="TRUE">SDE Feature Class</formatName></distorFormat></distributor></distInfo><spdoinfo><direct Sync="TRUE">Vector</direct><ptvctinf><esriterm Name="LUK_GOGN.Stigar_ml_land"><efeatyp Sync="TRUE">Simple</efeatyp><efeageom Sync="TRUE">Polyline</efeageom><esritopo Sync="TRUE">FALSE</esritopo><efeacnt Sync="TRUE">0</efeacnt><spindex Sync="TRUE">TRUE</spindex><linrefer Sync="TRUE">FALSE</linrefer></esriterm><sdtsterm Name="LUK_GOGN.Stigar_ml_land"><sdtstype Sync="TRUE">String</sdtstype><ptvctcnt Sync="TRUE">0</ptvctcnt></sdtsterm></ptvctinf></spdoinfo><spref><horizsys><cordsysn><geogcsn Sync="TRUE">GCS_WGS_1984</geogcsn><projcsn Sync="TRUE">isn93_lambert</projcsn></cordsysn><planar><mapproj><mapprojn Sync="TRUE">Lambert Conformal Conic</mapprojn><lambertc><stdparll Sync="TRUE">64.250000</stdparll><stdparll Sync="TRUE">65.750000</stdparll><longcm Sync="TRUE">-19.000000</longcm><latprjo Sync="TRUE">65.000000</latprjo><feast Sync="TRUE">500000.000000</feast><fnorth Sync="TRUE">500000.000000</fnorth></lambertc></mapproj><planci><plance Sync="TRUE">coordinate pair</plance><plandu Sync="TRUE">meters</plandu><coordrep><absres Sync="TRUE">0.000063</absres><ordres Sync="TRUE">0.000063</ordres></coordrep></planci></planar><geodetic><horizdn Sync="TRUE">D_WGS_1984</horizdn><ellips Sync="TRUE">WGS_1984</ellips><semiaxis Sync="TRUE">6378137.000000</semiaxis><denflat Sync="TRUE">298.257224</denflat></geodetic></horizsys><vertdef><altsys><altenc Sync="TRUE">Explicit elevation coordinate included with horizontal coordinates</altenc><altres Sync="TRUE">1.000000</altres></altsys></vertdef></spref><refSysInfo><RefSystem><refSysID><identCode Sync="TRUE">isn93_lambert</identCode></refSysID></RefSystem></refSysInfo><spatRepInfo><VectSpatRep><topLvl><TopoLevCd Sync="TRUE" value="001"></TopoLevCd></topLvl><geometObjs Name="LUK_GOGN.Stigar_ml_land"><geoObjTyp><GeoObjTypCd Sync="TRUE" value="001"></GeoObjTypCd></geoObjTyp><geoObjCnt Sync="TRUE">0</geoObjCnt></geometObjs></VectSpatRep></spatRepInfo><eainfo><detailed Name="LUK_GOGN.Stigar_ml_land"><enttyp><enttypl Sync="TRUE">LUK_GOGN.Stigar_ml_land</enttypl><enttypt Sync="TRUE">Feature Class</enttypt><enttypc Sync="TRUE">0</enttypc></enttyp><attr><attrlabl Sync="TRUE">OBJECTID</attrlabl><attalias Sync="TRUE">OBJECTID</attalias><attrtype Sync="TRUE">OID</attrtype><attwidth Sync="TRUE">4</attwidth><atprecis Sync="TRUE">10</atprecis><attscale Sync="TRUE">0</attscale><attrdef Sync="TRUE">Internal feature number.</attrdef><attrdefs Sync="TRUE">ESRI</attrdefs><attrdomv><udom Sync="TRUE">Sequential unique whole numbers that are automatically generated.</udom></attrdomv></attr><attr><attrlabl Sync="TRUE">STIGAFLOKKUR</attrlabl><attalias Sync="TRUE">STIGAFLOKKUR</attalias><attrtype Sync="TRUE">Integer</attrtype><attwidth Sync="TRUE">4</attwidth><atprecis Sync="TRUE">5</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">BREIDD</attrlabl><attalias Sync="TRUE">BREIDD</attalias><attrtype Sync="TRUE">Single</attrtype><attwidth Sync="TRUE">4</attwidth><atprecis Sync="TRUE">5</atprecis><attscale Sync="TRUE">2</attscale></attr><attr><attrlabl Sync="TRUE">TEIKNINR</attrlabl><attalias Sync="TRUE">TEIKNINR</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">10</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">ASTAND</attrlabl><attalias Sync="TRUE">ASTAND</attalias><attrtype Sync="TRUE">SmallInteger</attrtype><attwidth Sync="TRUE">2</attwidth><atprecis Sync="TRUE">2</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">AR_LAGT</attrlabl><attalias Sync="TRUE">AR_LAGT</attalias><attrtype Sync="TRUE">SmallInteger</attrtype><attwidth Sync="TRUE">2</attwidth><atprecis Sync="TRUE">4</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">AR_LAGF</attrlabl><attalias Sync="TRUE">AR_LAGF</attalias><attrtype Sync="TRUE">SmallInteger</attrtype><attwidth Sync="TRUE">2</attwidth><atprecis Sync="TRUE">4</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">TEG</attrlabl><attalias Sync="TRUE">TEG</attalias><attrtype Sync="TRUE">Integer</attrtype><attwidth Sync="TRUE">4</attwidth><atprecis Sync="TRUE">5</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">FLOKKUR</attrlabl><attalias Sync="TRUE">FLOKKUR</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">16</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">RUTT</attrlabl><attalias Sync="TRUE">RUTT</attalias><attrtype Sync="TRUE">SmallInteger</attrtype><attwidth Sync="TRUE">2</attwidth><atprecis Sync="TRUE">2</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">AR_ADG</attrlabl><attalias Sync="TRUE">AR_ADG</attalias><attrtype Sync="TRUE">SmallInteger</attrtype><attwidth Sync="TRUE">2</attwidth><atprecis Sync="TRUE">4</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">UTBSV</attrlabl><attalias Sync="TRUE">UTBSV</attalias><attrtype Sync="TRUE">SmallInteger</attrtype><attwidth Sync="TRUE">2</attwidth><atprecis Sync="TRUE">2</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">RUTT_BREIDD</attrlabl><attalias Sync="TRUE">RUTT_BREIDD</attalias><attrtype Sync="TRUE">SmallInteger</attrtype><attwidth Sync="TRUE">2</attwidth><atprecis Sync="TRUE">2</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">DAGS_INN</attrlabl><attalias Sync="TRUE">DAGS_INN</attalias><attrtype Sync="TRUE">Date</attrtype><attwidth Sync="TRUE">36</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">NOTANDI</attrlabl><attalias Sync="TRUE">NOTANDI</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">16</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">DAGS_BREYTT</attrlabl><attalias Sync="TRUE">DAGS_BREYTT</attalias><attrtype Sync="TRUE">Date</attrtype><attwidth Sync="TRUE">36</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">BREYTANDI</attrlabl><attalias Sync="TRUE">BREYTANDI</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">16</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">SVF</attrlabl><attalias Sync="TRUE">SVF</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">4</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">UPPR</attrlabl><attalias Sync="TRUE">UPPR</attalias><attrtype Sync="TRUE">SmallInteger</attrtype><attwidth Sync="TRUE">2</attwidth><atprecis Sync="TRUE">2</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">NAKV</attrlabl><attalias Sync="TRUE">NAKV</attalias><attrtype Sync="TRUE">Single</attrtype><attwidth Sync="TRUE">4</attwidth><atprecis Sync="TRUE">5</atprecis><attscale Sync="TRUE">2</attscale></attr><attr><attrlabl Sync="TRUE">DAGS_UPPR</attrlabl><attalias Sync="TRUE">Dags heimildar</attalias><attrtype Sync="TRUE">Date</attrtype><attwidth Sync="TRUE">36</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">DAGS_LEIDR</attrlabl><attalias Sync="TRUE">DAGS_LEIDR</attalias><attrtype Sync="TRUE">Date</attrtype><attwidth Sync="TRUE">36</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">DAGS_UPPF</attrlabl><attalias Sync="TRUE">Dags Uppfaerslu</attalias><attrtype Sync="TRUE">Date</attrtype><attwidth Sync="TRUE">36</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">GAGNA_EIGN</attrlabl><attalias Sync="TRUE">Gagnaeigandi</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">64</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">HEIMILD</attrlabl><attalias Sync="TRUE">Heimildaskraning</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">128</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">NAFN_G</attrlabl><attalias Sync="TRUE">Nafn Gagnagrunns</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">64</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">NAKV_XY</attrlabl><attalias Sync="TRUE">Nakv plan</attalias><attrtype Sync="TRUE">Double</attrtype><attwidth Sync="TRUE">8</attwidth><atprecis Sync="TRUE">8</atprecis><attscale Sync="TRUE">3</attscale></attr><attr><attrlabl Sync="TRUE">VIDMIDUN_PLAN_UPPR</attrlabl><attalias Sync="TRUE">Upprunaleg planvidmidun</attalias><attrtype Sync="TRUE">SmallInteger</attrtype><attwidth Sync="TRUE">2</attwidth><atprecis Sync="TRUE">2</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">VINNSLA_F</attrlabl><attalias Sync="TRUE">Vinnsluferli fitju</attalias><attrtype Sync="TRUE">SmallInteger</attrtype><attwidth Sync="TRUE">2</attwidth><atprecis Sync="TRUE">2</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">SHAPE</attrlabl><attalias Sync="TRUE">Shape</attalias><attrtype Sync="TRUE">Geometry</attrtype><attwidth Sync="TRUE">4</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale><attrdef Sync="TRUE">Feature geometry.</attrdef><attrdefs Sync="TRUE">ESRI</attrdefs><attrdomv><udom Sync="TRUE">Coordinates defining the features.</udom></attrdomv></attr><attr><attrlabl Sync="TRUE">SHAPE.LEN</attrlabl><attalias Sync="TRUE">SHAPE.LEN</attalias><attrtype Sync="TRUE">Double</attrtype><attwidth Sync="TRUE">0</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><subtype><stname Sync="TRUE">Aðalstígur</stname><stcode Sync="TRUE">1</stcode><stfield><stfldnm Sync="TRUE">STIGAFLOKKUR</stfldnm><stflddv Sync="TRUE">3</stflddv></stfield><stfield><stfldnm Sync="TRUE">ASTAND</stfldnm><stflddv Sync="TRUE">0</stflddv><stflddd><domname Sync="TRUE">gogn_stigar_ml_astand</domname><domdesc Sync="TRUE">Lén fyrir ástand stétta í miðlínum stíga</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">TEG</stfldnm><stflddd><domname Sync="TRUE">gogn_stigar_ml_teg</domname><domdesc Sync="TRUE">Lén fyrir tegund á miðlínum stíga</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">Integer</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">FLOKKUR</stfldnm><stflddv Sync="TRUE">215</stflddv><stflddd><domname Sync="TRUE">gogn_stigar_ml_fl</domname><domdesc Sync="TRUE">Lén fyrir flokk á miðlínu stíga</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">String</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">RUTT</stfldnm><stflddd><domname Sync="TRUE">gotur_samgp_rutt</domname><domdesc Sync="TRUE">Lén fyrir snjóruðning samgöngufláka</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Duplicate</splttype><domowner Sync="TRUE">luk_gotur</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">SVF</stfldnm><stflddv Sync="TRUE">0000</stflddv><stflddd><domname Sync="TRUE">lukr_svf</domname><domdesc Sync="TRUE">Lén fyrir nöfn sveitarfélaga</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Duplicate</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">String</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">UPPR</stfldnm><stflddv Sync="TRUE">1</stflddv><stflddd><domname Sync="TRUE">lukr_uppr</domname><domdesc Sync="TRUE">Lén fyrir uppruna gagna</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Duplicate</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">VIDMIDUN_PLAN_UPPR</stfldnm><stflddd><domname Sync="TRUE">LUKR_Vidmid_Plan_Uppr</domname><domdesc Sync="TRUE">Lén fyrir uppruna viðmiðunar í plani</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">SDE</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">VINNSLA_F</stfldnm><stflddd><domname Sync="TRUE">LUKR_Vinnsla_Fitju</domname><domdesc Sync="TRUE">Lén fyrir vinnslu (uppruna) fitju</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">SDE</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield></subtype><subtype><stname Sync="TRUE">Tengistígur</stname><stcode Sync="TRUE">2</stcode><stfield><stfldnm Sync="TRUE">STIGAFLOKKUR</stfldnm><stflddv Sync="TRUE">3</stflddv></stfield><stfield><stfldnm Sync="TRUE">ASTAND</stfldnm><stflddv Sync="TRUE">0</stflddv><stflddd><domname Sync="TRUE">gogn_stigar_ml_astand</domname><domdesc Sync="TRUE">Lén fyrir ástand stétta í miðlínum stíga</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">TEG</stfldnm><stflddd><domname Sync="TRUE">gogn_stigar_ml_teg</domname><domdesc Sync="TRUE">Lén fyrir tegund á miðlínum stíga</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">Integer</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">FLOKKUR</stfldnm><stflddv Sync="TRUE">215</stflddv><stflddd><domname Sync="TRUE">gogn_stigar_ml_fl</domname><domdesc Sync="TRUE">Lén fyrir flokk á miðlínu stíga</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">String</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">RUTT</stfldnm><stflddd><domname Sync="TRUE">gotur_samgp_rutt</domname><domdesc Sync="TRUE">Lén fyrir snjóruðning samgöngufláka</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Duplicate</splttype><domowner Sync="TRUE">luk_gotur</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">SVF</stfldnm><stflddv Sync="TRUE">0000</stflddv><stflddd><domname Sync="TRUE">lukr_svf</domname><domdesc Sync="TRUE">Lén fyrir nöfn sveitarfélaga</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Duplicate</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">String</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">UPPR</stfldnm><stflddv Sync="TRUE">1</stflddv><stflddd><domname Sync="TRUE">lukr_uppr</domname><domdesc Sync="TRUE">Lén fyrir uppruna gagna</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Duplicate</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">VIDMIDUN_PLAN_UPPR</stfldnm><stflddd><domname Sync="TRUE">LUKR_Vidmid_Plan_Uppr</domname><domdesc Sync="TRUE">Lén fyrir uppruna viðmiðunar í plani</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">SDE</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">VINNSLA_F</stfldnm><stflddd><domname Sync="TRUE">LUKR_Vinnsla_Fitju</domname><domdesc Sync="TRUE">Lén fyrir vinnslu (uppruna) fitju</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">SDE</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield></subtype><subtype><stname Sync="TRUE">Annar stígur</stname><stcode Sync="TRUE">3</stcode><stfield><stfldnm Sync="TRUE">STIGAFLOKKUR</stfldnm><stflddv Sync="TRUE">3</stflddv></stfield><stfield><stfldnm Sync="TRUE">ASTAND</stfldnm><stflddv Sync="TRUE">0</stflddv><stflddd><domname Sync="TRUE">gogn_stigar_ml_astand</domname><domdesc Sync="TRUE">Lén fyrir ástand stétta í miðlínum stíga</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">TEG</stfldnm><stflddd><domname Sync="TRUE">gogn_stigar_ml_teg</domname><domdesc Sync="TRUE">Lén fyrir tegund á miðlínum stíga</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">Integer</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">FLOKKUR</stfldnm><stflddv Sync="TRUE">215</stflddv><stflddd><domname Sync="TRUE">gogn_stigar_ml_fl</domname><domdesc Sync="TRUE">Lén fyrir flokk á miðlínu stíga</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">String</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">RUTT</stfldnm><stflddd><domname Sync="TRUE">gotur_samgp_rutt</domname><domdesc Sync="TRUE">Lén fyrir snjóruðning samgöngufláka</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Duplicate</splttype><domowner Sync="TRUE">luk_gotur</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">SVF</stfldnm><stflddv Sync="TRUE">0000</stflddv><stflddd><domname Sync="TRUE">lukr_svf</domname><domdesc Sync="TRUE">Lén fyrir nöfn sveitarfélaga</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Duplicate</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">String</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">UPPR</stfldnm><stflddv Sync="TRUE">1</stflddv><stflddd><domname Sync="TRUE">lukr_uppr</domname><domdesc Sync="TRUE">Lén fyrir uppruna gagna</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Duplicate</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">VIDMIDUN_PLAN_UPPR</stfldnm><stflddd><domname Sync="TRUE">LUKR_Vidmid_Plan_Uppr</domname><domdesc Sync="TRUE">Lén fyrir uppruna viðmiðunar í plani</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">SDE</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">VINNSLA_F</stfldnm><stflddd><domname Sync="TRUE">LUKR_Vinnsla_Fitju</domname><domdesc Sync="TRUE">Lén fyrir vinnslu (uppruna) fitju</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">SDE</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield></subtype><subtype><stname Sync="TRUE">Malarstígur</stname><stcode Sync="TRUE">4</stcode><stfield><stfldnm Sync="TRUE">STIGAFLOKKUR</stfldnm><stflddv Sync="TRUE">3</stflddv></stfield><stfield><stfldnm Sync="TRUE">ASTAND</stfldnm><stflddv Sync="TRUE">0</stflddv><stflddd><domname Sync="TRUE">gogn_stigar_ml_astand</domname><domdesc Sync="TRUE">Lén fyrir ástand stétta í miðlínum stíga</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">TEG</stfldnm><stflddd><domname Sync="TRUE">gogn_stigar_ml_teg</domname><domdesc Sync="TRUE">Lén fyrir tegund á miðlínum stíga</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">Integer</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">FLOKKUR</stfldnm><stflddv Sync="TRUE">215</stflddv><stflddd><domname Sync="TRUE">gogn_stigar_ml_fl</domname><domdesc Sync="TRUE">Lén fyrir flokk á miðlínu stíga</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">String</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">RUTT</stfldnm><stflddd><domname Sync="TRUE">gotur_samgp_rutt</domname><domdesc Sync="TRUE">Lén fyrir snjóruðning samgöngufláka</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Duplicate</splttype><domowner Sync="TRUE">luk_gotur</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">SVF</stfldnm><stflddv Sync="TRUE">0000</stflddv><stflddd><domname Sync="TRUE">lukr_svf</domname><domdesc Sync="TRUE">Lén fyrir nöfn sveitarfélaga</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Duplicate</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">String</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">UPPR</stfldnm><stflddv Sync="TRUE">1</stflddv><stflddd><domname Sync="TRUE">lukr_uppr</domname><domdesc Sync="TRUE">Lén fyrir uppruna gagna</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Duplicate</splttype><domowner Sync="TRUE">luk_gogn</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">VIDMIDUN_PLAN_UPPR</stfldnm><stflddd><domname Sync="TRUE">LUKR_Vidmid_Plan_Uppr</domname><domdesc Sync="TRUE">Lén fyrir uppruna viðmiðunar í plani</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">SDE</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield><stfield><stfldnm Sync="TRUE">VINNSLA_F</stfldnm><stflddd><domname Sync="TRUE">LUKR_Vinnsla_Fitju</domname><domdesc Sync="TRUE">Lén fyrir vinnslu (uppruna) fitju</domdesc><domtype Sync="TRUE">Coded Value</domtype><mrgtype Sync="TRUE">Default value</mrgtype><splttype Sync="TRUE">Default value</splttype><domowner Sync="TRUE">SDE</domowner><domfldtp Sync="TRUE">SmallInteger</domfldtp></stflddd></stfield></subtype></detailed></eainfo><mdDateSt Sync="TRUE">20091204</mdDateSt><dataqual><lineage><procstep><procdesc Sync="TRUE">Dataset copied.</procdesc><srcused Sync="TRUE">Server=sde.utm.is; Service=esri_sde; User=bv709; Version=BV709.bv709</srcused><procdate Sync="TRUE">20100917</procdate><proctime Sync="TRUE">12365900</proctime></procstep></lineage></dataqual></metadata> diff --git a/gonguleidir_LUKR_170910.shx b/gonguleidir_LUKR_170910.shx new file mode 100644 index 0000000..f292147 Binary files /dev/null and b/gonguleidir_LUKR_170910.shx differ
jwill/groovy-mongo
804e5b5bf721f664074ea0a59e6a24990ad4013d
forking of griffon mongo-db code into its own codebase to be used outside griffon
diff --git a/README b/README index e69de29..b69e638 100644 --- a/README +++ b/README @@ -0,0 +1,7 @@ +INSTALL: + +You must have the mongodb-driver library on the path for your app. + +USAGE: + +Running MongoUtils.decorateCollectionClass() will decorate collections with the generic versions that allow passing a map for find, insert, etc. MongoUtils.decorateCollection(collectionName) will decorate a specific class instance with the dynamic finder handlers. diff --git a/src/MongoUtils.groovy b/src/MongoUtils.groovy new file mode 100644 index 0000000..fbef4e4 --- /dev/null +++ b/src/MongoUtils.groovy @@ -0,0 +1,95 @@ +// Split out from the griffon-mongo-db plugin to allow use of dynamic finders +// with regular Groovy +// @author jwill + +import com.mongodb.* + +public class MongoUtils { + public static decorateCollectionClass() { + //meta programming convenience methods courtesy of jareed + DBCollection.metaClass { + findAll << { LinkedHashMap query -> delegate.find(query as BasicDBObject) } + findAll << { LinkedHashMap query, LinkedHashMap filter -> delegate.find(query as BasicDBObject, filter as BasicDBObject) } + find << { LinkedHashMap query -> delegate.find(query as BasicDBObject).find {true} } + find << { LinkedHashMap query, LinkedHashMap filter -> delegate.find(query as BasicDBObject, filter as BasicDBObject).find {true} } + insert << { LinkedHashMap doc -> delegate.insert(doc as BasicDBObject) } + update << { BasicDBObject doc, LinkedHashMap op -> delegate.update(doc, op as BasicDBObject) } + } + } + + + public static void decorateCollection(DBCollection collection) { + collection.metaClass.methodMissing = {String methodName, args -> + def operators = [ + "LessThan":'$lt', + "LessThanEquals":'$lte', + "GreaterThan":'$gt', + "GreaterThanEquals":'$gte', + "InList":'$in', + "NotInList":'$nin', + "Exists":'$exists', + "AllInList":'$all', + "NotEqual":'$ne', + "ArraySize":'$size', + //modifiers + "WithLimit":'$limit', + "WithSkip":'$skip' + ] + + def matcher = (methodName =~ /^(find)(\w+)$/) + if (matcher.matches()) { + def temp = matcher.group(2) - "By" + def list = temp.split("And") + def map = [:] + + for (item in list) { + def property + def operator + def hasOperator = false + + for (op in operators.keySet()) { + if (item.endsWith(op)) { + operator = operators[op] + property = item.replace(op,"").replace("_",".").toLowerCase() + if (operator.equals('$limit') || operator.equals('$skip')) { + if (!property.equals("")) + map.put(property, '$eq') + map.put(operator, "") + } else map.put(property.toLowerCase(), operator) + hasOperator = true + } + } + if (!hasOperator) { + def name = item.replace('_','.') + map.put(name.toLowerCase(), '$eq') + } + } + + // create function + def function = { arguments -> + def attrs = map + def query + def builder = BasicDBObjectBuilder.start() + builder.start() + map.entrySet().eachWithIndex { entry, i -> + if (!entry.value.equals("")) { + if (entry.value.equals('$eq')) + builder.append(entry.key, arguments[i]) + else builder.append(entry.key, [entry.value, arguments[i]] as BasicDBObject) + } + } + + query = builder.get() + def cursor = collection.find(query) + + // skip and limit + //TODO + return cursor + } + + collection.metaClass.(methodName.toString()) = function + function(args) + } + } + } +}
quiiver/node-slacker
6bf23d0c2fd3633bb6db32eae45407c09d32f48a
adding more tests, refactored the router to be more complete
diff --git a/lib/helpers.js b/lib/helpers.js index ef7dcc3..c4b8707 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -1,26 +1,26 @@ var sys = require('sys'); var errorHandler = function(req, res, error) { - inspect(arguments.callee); // is integer? if (error % 1 === 0) { res.writeHead(error, {'Content-Type': 'text/plain'}); res.write(error.toString()); res.end(); } else { errorHandler(req, res, 500); put(error.stack); } }; var put = function() { sys.puts(Array.prototype.slice.apply(arguments).join(", ")); }; var inspect = function(obj) { - sys.puts(sys.inspect(obj, false, null)); + put(sys.inspect(obj, false, null)); }; this.errorHandler = errorHandler; this.inspect = inspect; +this.put = put; diff --git a/lib/response.js b/lib/response.js new file mode 100644 index 0000000..3a4ee31 --- /dev/null +++ b/lib/response.js @@ -0,0 +1,36 @@ +var http = require("http"); +var templates = require('./templator'); + +var mu = require('./Mu/lib/mu'); + +mu.templateRoot = "./templates"; + +http.ServerResponse.prototype.toHTML = function(template, context, code) { + + var self = this; + + if (!code) { + code = 200; + } + + mu.render(template, context, {}, function(err, output) { + if (err) { + throw err; + } + + var buffer = ''; + + output + .addListener('data', function (c) {buffer += c; }) + .addListener('end', function () { + self.writeHead(statusCode, {'Content-Type': 'text/html'}); + self.write(buffer); + self.end(); + }); + + }); +} + +http.ServerResponse.prototype.toJSON = function(data) { + +}; diff --git a/lib/router.js b/lib/router.js index c55605d..b57832a 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1,93 +1,101 @@ (function() { var url = require('url'); var sys = require('sys'); module.exports = { - rootNode: {}, + routes: {}, + + reset: function() { + this.routes = {}; + }, testParam: function(param) { return (param.indexOf(":") === 0); }, cleanParam: function(param) { return param.substr(1); }, cleanURI: function(r) { var route = decodeURIComponent(r); + // special case for root. if (route == "/") return []; if (route.indexOf("/") === 0) return route.substr(1).split("/"); return route.split("/"); }, addRoutes: function(routes) { var self = this; routes.forEach(function(route) { self.addRoute.apply(self, route); }); }, - addRoute: function(method, route, view, validator) { + addRoute: function(method, route, view, guards) { var parts = this.cleanURI(route); - var cursor = this.rootNode; - parts.unshift(method); + var cursor = this.routes; for (var i = 0,part; part = parts[i]; i++) { var isParam = this.testParam(part); if (isParam) { - cursor._param = this.cleanParam(part); + var param = this.cleanParam(part); + cursor._param = cursor._param || { _name: param }; + cursor = cursor._param; } else { - if (!cursor[part]) { - cursor[part] = {}; - } + cursor[part] = cursor[part] || {}; cursor = cursor[part]; } } - cursor._view = view; - if (validator) { - cursor._validator = validator; + + cursor._methods = cursor._methods || {}; + cursor._methods[method] = { + view: view, + guards: guards || {} } + return cursor; }, find: function(request) { var uri = url.parse(request.url).pathname var parts = this.cleanURI(uri); var args = {}; - var cursor = this.rootNode; + var cursor = this.routes; var depth = 0; - parts.unshift(request.method); - for (p in parts) { var part = parts[p]; - // special case for root. - if (part === "" && parts.length == 1) depth++; if (cursor[part]) { cursor = cursor[part]; depth++; - } else if (cursor._param && !args[cursor._param]) { - args[cursor._param] = part; - depth++; + } else if (cursor._param) { + var p = cursor._param._name; + if(!args[p]) { + args[p] = part; + cursor = cursor._param; + depth++; + } } + } - if (!cursor._view - || (cursor._param && !args[cursor._param]) - || depth != parts.length) { + if (!cursor._methods || depth != parts.length) { throw new Error(404); } - return { - view: cursor._view, - args: args || {}, - validator: cursor._validator || {} - }; + if (!cursor._methods[request.method]) { + throw new Error(405) + } + + var ret = cursor._methods[request.method]; + ret.args = args; + return ret; } }; })(); diff --git a/lib/slacker.js b/lib/slacker.js index 95567ac..cec8475 100644 --- a/lib/slacker.js +++ b/lib/slacker.js @@ -1,45 +1,72 @@ var sys = require('sys'), url = require('url'), http = require('http'); -// app -var router = require('./router'); -var helpers = require('./helpers'); -var templates = require('./templator'); - -var Slacker = function() { - this.router = router; -} - -Slacker.prototype = { - get: function(route, callback) { - this.router.addRoute("GET", route, callback); - }, - post: function(route, callback) { - this.router.addRoute("POST", route, callback); - }, - put: function(route, callback) { - this.router.addRoute("PUT", route, callback); - }, - del: function(route, callback) { - this.router.addRoute("DELETE", route, callback); - }, - render: function() { - templates.render.apply(null, arguments); - }, - start: function(port) { - var self = this; - http.createServer(function (req, res) { +(function() { + + // app + var router = require('./router'); + var helpers = require('./helpers'); + + require('./response'); + + var inputGuards = {}; + var outputGuards = {}; + + var resetGuards = function() { + return inputGuards = outputGuards = {}; + }; + + var Slacker = function() { + this.router = router; + } + + Slacker.prototype = { + get: function(route, callback) { + this.router.addRoute("GET", route, callback, inputGuards); + return this; + }, + post: function(route, callback) { + this.router.addRoute("POST", route, callback, inputGuards); + return this; + }, + put: function(route, callback) { + this.router.addRoute("PUT", route, callback, inputGuards); + return this; + }, + del: function(route, callback) { + this.router.addRoute("DELETE", route, callback, inputGuards); + return this; + }, + consuming: function(guard) { + inputGuards["Accept"] = guard; + return this; + }, + producing: function(guard) { + outputGuards["Content-Type"] = guard; + return this; + }, + end: function() { + resetGuards(); + }, + errorHandler: helpers.errorHandler, + call: function(request, response) { try { - var route = router.find(req); - route.view.call(self, req, res, route.args || {}); + var route = router.find(request); + return route.view.call(this, request, response, route.args || {}); } catch (e) { - helpers.errorHandler(req, res, e); + return this.errorHandler(request, response, e); } - - }).listen(port); - sys.puts('Server running at http://127.0.0.1:'+ port +'/'); + }, + start: function(port) { + var self = this; + http.createServer(function (req, res) { + self.call(req, res); + }).listen(port); + sys.puts('Server running at http://127.0.0.1:'+ port +'/'); + } } -} -module.exports = new Slacker; + module.exports = new Slacker; + +})(); diff --git a/start.js b/start.js index e7df2ef..4b8ed95 100644 --- a/start.js +++ b/start.js @@ -1,7 +1,16 @@ var slacker = require('./lib/slacker'); -slacker.get("/", function(req, res) { - this.render('index', {title: 'wil.im'}, res); -}); +slacker + .consuming("application/json") + .producing("application/json") + + .get("/", function(request, response) { + response.toHTML('index', {title: 'wil.im'}, response.OK); + }) + + .post("/", function(request, response) { + response.toJson(body, response.OK) + }); + slacker.start(4200); diff --git a/test/router-test.js b/test/router-test.js index 056cabe..cc209b8 100644 --- a/test/router-test.js +++ b/test/router-test.js @@ -1,60 +1,67 @@ var vows = require('vows'), sys = require('sys'), assert = require('assert'); var router = require('../lib/router'); -var noop = function() {} +var noop = function() {}; var mockReq = function(method, path) { return { url: "http://localhost:23442" + path, method: method }; }; vows.describe('The Router').addBatch({ 'When given a new route': { - topic: router.addRoute("GET", "/", noop) , + topic: router.addRoute("GET", "/new", noop), 'should match given route': function () { - var callback = router.find(mockReq("GET", "/" )).view; - assert.equal(callback, noop, "callback function should equal noop"); + var callback = router.find(mockReq("GET", "/new" )).view; + assert.equal(callback, noop); } }, 'When given a new route with arguments': { topic: router.addRoute("GET", "/users/:user_id", noop), 'should return the arguments in an object': function (topic) { var args = router.find(mockReq("GET", "/users/123" )).args; assert.equal(args.user_id, '123', "user id should equal 123"); } }, + 'With multiple params': { + topic: router.addRoute("GET", "/blog/:slug/:date", noop), + 'it should return all params': function (topic) { + var args = router.find(mockReq("GET", "/blog/foo/bar" )).args; + assert.ok(("slug" in args) && ("date" in args)); + } + }, 'When given a list of routes': { topic: router.addRoutes([["GET", "/blog/:slug", noop], ["GET", '/admin', noop]]), 'it should return a route for one of the routes': function (topic) { var args = router.find(mockReq("GET", "/blog/foo" )).args; assert.equal(args.slug, 'foo', "slug should be foo"); } }, 'When calling Router#cleanParam': { topic: router.cleanParam(":user_id"), 'it should strip the `:` from the param' : function(topic) { assert.equal(topic.indexOf(":"), -1); } }, 'When calling Router#testParam': { topic: router.testParam(":user_id"), 'it should recognize a valid param' : function(topic) { assert.equal(topic, true); } }, 'When calling Router#cleanURI': { topic: router.cleanURI("/foo/bar/baz/bah"), 'the first element should be correct' : function(topic) { assert.equal(topic[0], "foo"); }, 'the length should be correct' : function(topic) { assert.equal(topic[0], "foo"); } } }).export(module); // Export the Suite diff --git a/test/slacker-test.js b/test/slacker-test.js index b8f1bd0..2fd10e7 100644 --- a/test/slacker-test.js +++ b/test/slacker-test.js @@ -1,32 +1,36 @@ var vows = require('vows'), sys = require('sys'), assert = require('assert'); var slacker = require('../lib/slacker'); var router = require('../lib/router'); -var noop = function() {} +var view = function() { return "testing123" } -var mockReq = function(method, path) { +var mockReq = function(method, path, headers) { return { url: "http://localhost:23442" + path, - method: method + method: method, + headers: headers || {} }; }; +slacker.errorHandler = function(rq, rs, e) { return e; } + vows.describe('Slacker').addBatch({ 'When using Slacker#get': { - topic: slacker.get('/', noop), + topic: slacker.get('/', view), 'it should should respond to a GET request': function () { - var callback = router.find(mockReq("GET", "/" )).view; - assert.equal(callback, noop, "callback function should equal noop"); + assert.equal(slacker.call(mockReq("GET", "/" )), "testing123"); }, 'it should throw an error for a non GET request': function () { - try{ - router.find(mockReq("POST", "/")) - assert.fail() - } catch (e) {} + var e = slacker.call(mockReq("POST", "/")); + assert.instanceOf(e, Error); + }, + 'it should throw a `405 Method not Allowed` for a non GET request': function () { + var e = slacker.call(mockReq("POST", "/")); + assert.equal(e.message, 405); } } -}).export(module); // Export the Suite +}).export(module);
quiiver/node-slacker
a59cb121cb37e5e0c26569a12b0b1342f92a9f1d
adding tests and fixing a few bugs
diff --git a/lib/router.js b/lib/router.js index ecd28bf..c55605d 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1,84 +1,93 @@ (function() { - exports.router = { + var url = require('url'); + var sys = require('sys'); + + module.exports = { rootNode: {}, testParam: function(param) { return (param.indexOf(":") === 0); }, cleanParam: function(param) { return param.substr(1); }, cleanURI: function(r) { var route = decodeURIComponent(r); + if (route == "/") return []; if (route.indexOf("/") === 0) return route.substr(1).split("/"); return route.split("/"); }, addRoutes: function(routes) { var self = this; routes.forEach(function(route) { self.addRoute.apply(self, route); }); }, - addRoute: function(route, view, validator) { + addRoute: function(method, route, view, validator) { var parts = this.cleanURI(route); var cursor = this.rootNode; + parts.unshift(method); + for (var i = 0,part; part = parts[i]; i++) { var isParam = this.testParam(part); if (isParam) { cursor._param = this.cleanParam(part); } else { if (!cursor[part]) { cursor[part] = {}; } cursor = cursor[part]; } } cursor._view = view; if (validator) { cursor._validator = validator; } return cursor; }, - find: function(uri) { + find: function(request) { + var uri = url.parse(request.url).pathname var parts = this.cleanURI(uri); var args = {}; var cursor = this.rootNode; var depth = 0; + parts.unshift(request.method); + for (p in parts) { var part = parts[p]; // special case for root. if (part === "" && parts.length == 1) depth++; if (cursor[part]) { cursor = cursor[part]; depth++; } else if (cursor._param && !args[cursor._param]) { args[cursor._param] = part; depth++; } } if (!cursor._view || (cursor._param && !args[cursor._param]) || depth != parts.length) { - throw 404; + throw new Error(404); } return { view: cursor._view, args: args || {}, validator: cursor._validator || {} }; } }; })(); diff --git a/lib/slacker.js b/lib/slacker.js index ac4554b..95567ac 100644 --- a/lib/slacker.js +++ b/lib/slacker.js @@ -1,37 +1,45 @@ var sys = require('sys'), url = require('url'), http = require('http'); // app -var router = require('./router').router; +var router = require('./router'); var helpers = require('./helpers'); var templates = require('./templator'); var Slacker = function() { this.router = router; } Slacker.prototype = { get: function(route, callback) { - this.router.addRoute(route, callback); + this.router.addRoute("GET", route, callback); + }, + post: function(route, callback) { + this.router.addRoute("POST", route, callback); + }, + put: function(route, callback) { + this.router.addRoute("PUT", route, callback); + }, + del: function(route, callback) { + this.router.addRoute("DELETE", route, callback); }, render: function() { templates.render.apply(null, arguments); }, start: function(port) { var self = this; http.createServer(function (req, res) { try { - var path = url.parse(req.url).pathname - var route = router.find(path); + var route = router.find(req); route.view.call(self, req, res, route.args || {}); } catch (e) { helpers.errorHandler(req, res, e); } }).listen(port); sys.puts('Server running at http://127.0.0.1:'+ port +'/'); } } module.exports = new Slacker; diff --git a/test/router-test.js b/test/router-test.js new file mode 100644 index 0000000..056cabe --- /dev/null +++ b/test/router-test.js @@ -0,0 +1,60 @@ +var vows = require('vows'), + sys = require('sys'), + assert = require('assert'); + +var router = require('../lib/router'); + +var noop = function() {} + +var mockReq = function(method, path) { + return { + url: "http://localhost:23442" + path, + method: method + }; +}; + +vows.describe('The Router').addBatch({ + 'When given a new route': { + topic: router.addRoute("GET", "/", noop) , + 'should match given route': function () { + var callback = router.find(mockReq("GET", "/" )).view; + assert.equal(callback, noop, "callback function should equal noop"); + } + }, + 'When given a new route with arguments': { + topic: router.addRoute("GET", "/users/:user_id", noop), + 'should return the arguments in an object': function (topic) { + var args = router.find(mockReq("GET", "/users/123" )).args; + assert.equal(args.user_id, '123', "user id should equal 123"); + } + }, + 'When given a list of routes': { + topic: router.addRoutes([["GET", "/blog/:slug", noop], ["GET", '/admin', noop]]), + 'it should return a route for one of the routes': function (topic) { + var args = router.find(mockReq("GET", "/blog/foo" )).args; + assert.equal(args.slug, 'foo', "slug should be foo"); + } + }, + 'When calling Router#cleanParam': { + topic: router.cleanParam(":user_id"), + 'it should strip the `:` from the param' : function(topic) { + assert.equal(topic.indexOf(":"), -1); + } + }, + 'When calling Router#testParam': { + topic: router.testParam(":user_id"), + 'it should recognize a valid param' : function(topic) { + assert.equal(topic, true); + } + }, + 'When calling Router#cleanURI': { + topic: router.cleanURI("/foo/bar/baz/bah"), + 'the first element should be correct' : function(topic) { + assert.equal(topic[0], "foo"); + }, + 'the length should be correct' : function(topic) { + assert.equal(topic[0], "foo"); + } + } +}).export(module); // Export the Suite + diff --git a/test/slacker-test.js b/test/slacker-test.js new file mode 100644 index 0000000..b8f1bd0 --- /dev/null +++ b/test/slacker-test.js @@ -0,0 +1,32 @@ +var vows = require('vows'), + sys = require('sys'), + assert = require('assert'); + +var slacker = require('../lib/slacker'); +var router = require('../lib/router'); + +var noop = function() {} + +var mockReq = function(method, path) { + return { + url: "http://localhost:23442" + path, + method: method + }; +}; + +vows.describe('Slacker').addBatch({ + 'When using Slacker#get': { + topic: slacker.get('/', noop), + 'it should should respond to a GET request': function () { + var callback = router.find(mockReq("GET", "/" )).view; + assert.equal(callback, noop, "callback function should equal noop"); + }, + 'it should throw an error for a non GET request': function () { + try{ + router.find(mockReq("POST", "/")) + assert.fail() + } catch (e) {} + } + } +}).export(module); // Export the Suite +
quiiver/node-slacker
d189672de3e1917e29e174e618a05de548ea7558
fixing require paths
diff --git a/lib/slacker.js b/lib/slacker.js index 4047e00..ac4554b 100644 --- a/lib/slacker.js +++ b/lib/slacker.js @@ -1,37 +1,37 @@ var sys = require('sys'), url = require('url'), http = require('http'); // app -var router = require('./lib/router').router; -var helpers = require('./lib/helpers'); -var templates = require('./lib/templator'); +var router = require('./router').router; +var helpers = require('./helpers'); +var templates = require('./templator'); var Slacker = function() { this.router = router; } Slacker.prototype = { get: function(route, callback) { this.router.addRoute(route, callback); }, render: function() { templates.render.apply(null, arguments); }, start: function(port) { var self = this; http.createServer(function (req, res) { try { var path = url.parse(req.url).pathname var route = router.find(path); route.view.call(self, req, res, route.args || {}); } catch (e) { helpers.errorHandler(req, res, e); } }).listen(port); sys.puts('Server running at http://127.0.0.1:'+ port +'/'); } } module.exports = new Slacker; diff --git a/start.js b/start.js index 92278f8..e7df2ef 100644 --- a/start.js +++ b/start.js @@ -1,7 +1,7 @@ -var slacker = require('./slacker'); +var slacker = require('./lib/slacker'); slacker.get("/", function(req, res) { this.render('index', {title: 'wil.im'}, res); }); slacker.start(4200);
quiiver/node-slacker
84adbbb2192dfb0e30192b77069c4e2f136d57ef
adding startup script and example
diff --git a/start.js b/start.js new file mode 100644 index 0000000..92278f8 --- /dev/null +++ b/start.js @@ -0,0 +1,7 @@ +var slacker = require('./slacker'); + +slacker.get("/", function(req, res) { + this.render('index', {title: 'wil.im'}, res); +}); + +slacker.start(4200);
quiiver/node-slacker
9de0faf4fad6f72aa434168bced786752a21a9c6
upgrading to latest node, adding Mu as a submodule
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..0a48bb2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/Mu"] + path = lib/Mu + url = http://github.com/raycmorgan/Mu.git diff --git a/lib/Mu b/lib/Mu new file mode 160000 index 0000000..3bd7403 --- /dev/null +++ b/lib/Mu @@ -0,0 +1 @@ +Subproject commit 3bd7403e9fb4624fd22aa3c92c1d4e697dddb162 diff --git a/lib/helpers.js b/lib/helpers.js index 56bf6e5..ef7dcc3 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -1,23 +1,26 @@ var sys = require('sys'); var errorHandler = function(req, res, error) { inspect(arguments.callee); + // is integer? if (error % 1 === 0) { - res.sendHeader(error, {'Content-Type': 'text/plain'}); - res.sendBody(error.toString()); - res.finish(); + res.writeHead(error, {'Content-Type': 'text/plain'}); + res.write(error.toString()); + res.end(); } else { errorHandler(req, res, 500); - sys.puts(error); + put(error.stack); } }; +var put = function() { + sys.puts(Array.prototype.slice.apply(arguments).join(", ")); +}; + var inspect = function(obj) { - for (x in obj) { - sys.debug(x + ": " + obj[x]); - } + sys.puts(sys.inspect(obj, false, null)); }; -exports.errorHandler = errorHandler; -exports.inspect = inspect; +this.errorHandler = errorHandler; +this.inspect = inspect; diff --git a/lib/mojo.js b/lib/mojo.js deleted file mode 120000 index 145e84a..0000000 --- a/lib/mojo.js +++ /dev/null @@ -1 +0,0 @@ -/home/wil/node/packages/mojo/lib/mojo.js \ No newline at end of file diff --git a/lib/router.js b/lib/router.js index 5fb041b..ecd28bf 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1,84 +1,84 @@ (function() { exports.router = { - rootNode: {}, + rootNode: {}, - testParam: function(param) { + testParam: function(param) { return (param.indexOf(":") === 0); }, cleanParam: function(param) { return param.substr(1); }, cleanURI: function(r) { var route = decodeURIComponent(r); if (route.indexOf("/") === 0) return route.substr(1).split("/"); return route.split("/"); }, addRoutes: function(routes) { var self = this; routes.forEach(function(route) { self.addRoute.apply(self, route); }); }, addRoute: function(route, view, validator) { var parts = this.cleanURI(route); var cursor = this.rootNode; for (var i = 0,part; part = parts[i]; i++) { var isParam = this.testParam(part); if (isParam) { cursor._param = this.cleanParam(part); } else { if (!cursor[part]) { cursor[part] = {}; } cursor = cursor[part]; } } cursor._view = view; if (validator) { cursor._validator = validator; } return cursor; }, find: function(uri) { var parts = this.cleanURI(uri); var args = {}; var cursor = this.rootNode; var depth = 0; for (p in parts) { var part = parts[p]; // special case for root. if (part === "" && parts.length == 1) depth++; if (cursor[part]) { cursor = cursor[part]; depth++; } else if (cursor._param && !args[cursor._param]) { args[cursor._param] = part; depth++; } } if (!cursor._view || (cursor._param && !args[cursor._param]) || depth != parts.length) { throw 404; } return { view: cursor._view, args: args || {}, validator: cursor._validator || {} }; } }; })(); diff --git a/lib/slacker.js b/lib/slacker.js new file mode 100644 index 0000000..4047e00 --- /dev/null +++ b/lib/slacker.js @@ -0,0 +1,37 @@ +var sys = require('sys'), + url = require('url'), + http = require('http'); + +// app +var router = require('./lib/router').router; +var helpers = require('./lib/helpers'); +var templates = require('./lib/templator'); + +var Slacker = function() { + this.router = router; +} + +Slacker.prototype = { + get: function(route, callback) { + this.router.addRoute(route, callback); + }, + render: function() { + templates.render.apply(null, arguments); + }, + start: function(port) { + var self = this; + http.createServer(function (req, res) { + try { + var path = url.parse(req.url).pathname + var route = router.find(path); + route.view.call(self, req, res, route.args || {}); + } catch (e) { + helpers.errorHandler(req, res, e); + } + + }).listen(port); + sys.puts('Server running at http://127.0.0.1:'+ port +'/'); + } +} + +module.exports = new Slacker; diff --git a/lib/templator.js b/lib/templator.js index 847061a..9859649 100644 --- a/lib/templator.js +++ b/lib/templator.js @@ -1,85 +1,27 @@ -var posix = require('posix'); -var sys = require('sys'); +var mu = require('./Mu/lib/mu'); -var Mojo = require('./mojo').Mojo; -var BASE_DIR = process.ENV.SLACKER_ROOT || '.'; -var TEMPLATE_PATH = BASE_DIR + '/templates'; -var AUTO_RELOAD = true; +mu.templateRoot = "./templates"; -// this needs to be done on start up. -// or a reload event. BLOCKING -var templates = {}; -var re = /(.*)\.html$/; -// helper methods -var isFile = function(path) { - try { - var stats = posix.stat(path).wait(); - return stats.isFile(); - } catch(e) { - return false; +this.render = function(template, context, response, statusCode) { + if (!statusCode) { + statusCode = 200; } -} - -var rmFile = function(path) { - posix.unlink(path).wait(); -} - -var generate = function(inPath, outPath) { - outPath = outPath || inPath + '.js'; - var command = 'mojo < '+ inPath + ' > ' + outPath; - sys.exec(command).wait(); -} - -var read = function(path) { - var fd = posix.open(path, process.O_RDONLY, 0666).wait(); - return posix.read(fd, 10240, 0).wait(); -} - -var reload = function(inPath, outPath) { - var match = inPath.match(re); - generate(inPath, outPath); - templates[match[0]] = read(outPath); -} - -var load = function() { - var files = posix.readdir(TEMPLATE_PATH).wait(); - for (var i in files) { - - var t = files[i]; - var match = t.match(re); - var inPath = [TEMPLATE_PATH, t].join('/'); - var outPath = inPath + '.js'; - - // filter files - if (!match) continue; - - if (isFile(outPath) && !AUTO_RELOAD) { - data = read(outPath); - } else { - generate(inPath, outPath); - data = read(outPath); + mu.render(template, context, {}, function(err, output) { + if (err) { + throw err; } - if (AUTO_RELOAD) { - // capture scope - (function() { - var input = inPath, output = outPath; - process.watchFile(input, function() { - reload(input, output) - }); - })(); - } + var buffer = ''; - templates[match[1]] = data[0]; - } -} -load(); - - -this.render = function(res, statusCode, template, o) { - res.sendHeader(statusCode, {'Content-Type': 'text/html'}); - res.sendBody(eval(templates[template])); - res.finish(); + output + .addListener('data', function (c) {buffer += c; }) + .addListener('end', function () { + response.writeHead(statusCode, {'Content-Type': 'text/html'}); + response.write(buffer); + response.end(); + }); + + }); } diff --git a/slacker.js b/slacker.js deleted file mode 100644 index 85e1439..0000000 --- a/slacker.js +++ /dev/null @@ -1,22 +0,0 @@ -var sys = require('sys'), - http = require('http'); - -// app -var views = require('./views').views; -var router = require('./lib/router').router; -var routes = require('./routes').routes; -var helpers = require('./lib/helpers'); - -router.addRoutes(routes); - -http.createServer(function (req, res) { - try { - var route = router.find(req.uri.path); - var view = eval(route.view); - view(req, res, route.args || {}); - } catch (e) { - helpers.errorHandler(req, res, e); - } - -}).listen(80); -sys.puts('Server running at http://127.0.0.1:80/'); diff --git a/templates/index.html.js b/templates/index.html.js deleted file mode 100644 index cbc24d9..0000000 --- a/templates/index.html.js +++ /dev/null @@ -1,13 +0,0 @@ -'<!DOCTYPE html>\n\ -<html>\n\ -<head>\n\ - <meta charset=utf-8 />\n\ - <title>' + (Mojo.escape(Mojo.normalize(o.title))) + '</title>\n\ -</head>\n\ -<body>\n\ -\n\ - <h1>' + (Mojo.escape(Mojo.normalize(o.title))) + '</h1>\n\ -\n\ -</body>\n\ -</html>\n\ -' \ No newline at end of file diff --git a/templates/index.html b/templates/index.mu similarity index 100% rename from templates/index.html rename to templates/index.mu
quiiver/node-slacker
8ec06795f5d2da6c5283b46868b10e8abe0d780b
fixing up the start/stop script
diff --git a/bin/slacker b/bin/slacker new file mode 100755 index 0000000..6cbd768 --- /dev/null +++ b/bin/slacker @@ -0,0 +1,42 @@ +#!/bin/bash + +export SLACKER_ROOT="$HOME/node/slacker" +NAME=slacker +PIDFILE=/var/run/$NAME.pid +DAEMON=/usr/local/bin/node +DAEMON_OPTS="$SLACKER_ROOT/slacker.js" + +export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" + +start() { + echo -n "Starting $NAME" + start-stop-daemon --start -b --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS + echo "." +} + +stop() { + echo -n "Stopping $NAME" + start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE + echo "." +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + echo -n "Restarting "$NAME + start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $PIDFILE + start-stop-daemon --start -b --quiet --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS + echo "." + ;; + + *) + echo "Usage: $NAME {start|stop|restart}" + exit 1 +esac + +exit 0 diff --git a/bin/start b/bin/start deleted file mode 100755 index 7b043a6..0000000 --- a/bin/start +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -sudo start-stop-daemon -b -x /usr/local/bin/node -S -- $HOME/node/slacker/main.js diff --git a/bin/stop b/bin/stop deleted file mode 100755 index 78064f3..0000000 --- a/bin/stop +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -sudo start-stop-daemon -x /usr/local/bin/node -K -- $HOME/node/slacker/main.js diff --git a/lib/templator.js b/lib/templator.js index 1490c95..847061a 100644 --- a/lib/templator.js +++ b/lib/templator.js @@ -1,84 +1,85 @@ var posix = require('posix'); var sys = require('sys'); var Mojo = require('./mojo').Mojo; -var TEMPLATE_PATH = './templates'; +var BASE_DIR = process.ENV.SLACKER_ROOT || '.'; +var TEMPLATE_PATH = BASE_DIR + '/templates'; var AUTO_RELOAD = true; // this needs to be done on start up. // or a reload event. BLOCKING var templates = {}; var re = /(.*)\.html$/; // helper methods var isFile = function(path) { try { var stats = posix.stat(path).wait(); return stats.isFile(); } catch(e) { return false; } } var rmFile = function(path) { posix.unlink(path).wait(); } var generate = function(inPath, outPath) { outPath = outPath || inPath + '.js'; var command = 'mojo < '+ inPath + ' > ' + outPath; sys.exec(command).wait(); } var read = function(path) { var fd = posix.open(path, process.O_RDONLY, 0666).wait(); return posix.read(fd, 10240, 0).wait(); } var reload = function(inPath, outPath) { var match = inPath.match(re); generate(inPath, outPath); templates[match[0]] = read(outPath); } var load = function() { var files = posix.readdir(TEMPLATE_PATH).wait(); for (var i in files) { var t = files[i]; var match = t.match(re); var inPath = [TEMPLATE_PATH, t].join('/'); var outPath = inPath + '.js'; // filter files if (!match) continue; if (isFile(outPath) && !AUTO_RELOAD) { data = read(outPath); } else { generate(inPath, outPath); data = read(outPath); } if (AUTO_RELOAD) { // capture scope (function() { var input = inPath, output = outPath; process.watchFile(input, function() { reload(input, output) }); })(); } templates[match[1]] = data[0]; } } load(); this.render = function(res, statusCode, template, o) { res.sendHeader(statusCode, {'Content-Type': 'text/html'}); res.sendBody(eval(templates[template])); res.finish(); } diff --git a/main.js b/slacker.js similarity index 100% rename from main.js rename to slacker.js
quiiver/node-slacker
08d3e807e2c33f1f6b69ef4df5a57544b03ec274
added auto reload for templates
diff --git a/lib/templator.js b/lib/templator.js index a8c7305..1490c95 100644 --- a/lib/templator.js +++ b/lib/templator.js @@ -1,44 +1,84 @@ var posix = require('posix'); -var repl = require('repl'); var sys = require('sys'); var Mojo = require('./mojo').Mojo; var TEMPLATE_PATH = './templates'; +var AUTO_RELOAD = true; // this needs to be done on start up. // or a reload event. BLOCKING var templates = {}; +var re = /(.*)\.html$/; + +// helper methods +var isFile = function(path) { + try { + var stats = posix.stat(path).wait(); + return stats.isFile(); + } catch(e) { + return false; + } +} + +var rmFile = function(path) { + posix.unlink(path).wait(); +} + +var generate = function(inPath, outPath) { + outPath = outPath || inPath + '.js'; + var command = 'mojo < '+ inPath + ' > ' + outPath; + sys.exec(command).wait(); +} + +var read = function(path) { + var fd = posix.open(path, process.O_RDONLY, 0666).wait(); + return posix.read(fd, 10240, 0).wait(); +} + +var reload = function(inPath, outPath) { + var match = inPath.match(re); + generate(inPath, outPath); + templates[match[0]] = read(outPath); +} + var load = function() { - var re = /(.*)\.html$/; var files = posix.readdir(TEMPLATE_PATH).wait(); - var read = function(path) { - var fd = posix.open(path, process.O_RDONLY, 0666).wait(); - return posix.read(fd, 10240, 0).wait(); - } - for (i in files) { + for (var i in files) { + var t = files[i]; - var match = t.match(re); + var match = t.match(re); + var inPath = [TEMPLATE_PATH, t].join('/'); + var outPath = inPath + '.js'; + + // filter files if (!match) continue; - try { - var path = [TEMPLATE_PATH, t + '.js'].join('/'); - var data = read(path); - } catch (e) { - // compile the template - var inputPath = [TEMPLATE_PATH, t].join('/'); - var outputPath = [TEMPLATE_PATH, t + '.js'].join('/'); - var command = 'mojo < '+ inputPath + ' > ' + outputPath; - - sys.exec(command).wait(); - var data = read(outputPath); + + if (isFile(outPath) && !AUTO_RELOAD) { + data = read(outPath); + } else { + generate(inPath, outPath); + data = read(outPath); } + + if (AUTO_RELOAD) { + // capture scope + (function() { + var input = inPath, output = outPath; + process.watchFile(input, function() { + reload(input, output) + }); + })(); + } + templates[match[1]] = data[0]; } } load(); this.render = function(res, statusCode, template, o) { res.sendHeader(statusCode, {'Content-Type': 'text/html'}); res.sendBody(eval(templates[template])); res.finish(); } + diff --git a/templates/index.html b/templates/index.html index 3eaec58..f5458da 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,12 +1,12 @@ <!DOCTYPE html> <html> <head> <meta charset=utf-8 /> - <title>wil.im</title> + <title>{{title}}</title> </head> <body> <h1>{{title}}</h1> </body> </html> diff --git a/templates/index.html.js b/templates/index.html.js index d9951bd..cbc24d9 100644 --- a/templates/index.html.js +++ b/templates/index.html.js @@ -1,13 +1,13 @@ '<!DOCTYPE html>\n\ <html>\n\ <head>\n\ <meta charset=utf-8 />\n\ - <title>wil.im</title>\n\ + <title>' + (Mojo.escape(Mojo.normalize(o.title))) + '</title>\n\ </head>\n\ <body>\n\ \n\ <h1>' + (Mojo.escape(Mojo.normalize(o.title))) + '</h1>\n\ \n\ </body>\n\ </html>\n\ ' \ No newline at end of file
quiiver/node-slacker
dd29a5453235fcc50a653862b64bf6e8c19a7646
added template support
diff --git a/lib/router.js b/lib/router.js index 464fb4e..5fb041b 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1,96 +1,84 @@ (function() { - var sys = require('sys'); - var routes = require('../routes').routes; - - var Router = function() { - this.rootNode = {}; - }; - - - Router.prototype = { - - testParam: function(param) { + exports.router = { + + rootNode: {}, + + testParam: function(param) { return (param.indexOf(":") === 0); }, cleanParam: function(param) { return param.substr(1); }, cleanURI: function(r) { var route = decodeURIComponent(r); if (route.indexOf("/") === 0) return route.substr(1).split("/"); return route.split("/"); }, addRoutes: function(routes) { var self = this; routes.forEach(function(route) { self.addRoute.apply(self, route); }); }, addRoute: function(route, view, validator) { var parts = this.cleanURI(route); var cursor = this.rootNode; for (var i = 0,part; part = parts[i]; i++) { var isParam = this.testParam(part); if (isParam) { cursor._param = this.cleanParam(part); } else { if (!cursor[part]) { cursor[part] = {}; } cursor = cursor[part]; } } cursor._view = view; if (validator) { cursor._validator = validator; } return cursor; }, find: function(uri) { var parts = this.cleanURI(uri); var args = {}; var cursor = this.rootNode; var depth = 0; for (p in parts) { var part = parts[p]; // special case for root. if (part === "" && parts.length == 1) depth++; if (cursor[part]) { cursor = cursor[part]; depth++; } else if (cursor._param && !args[cursor._param]) { args[cursor._param] = part; depth++; } } if (!cursor._view || (cursor._param && !args[cursor._param]) || depth != parts.length) { throw 404; } return { view: cursor._view, args: args || {}, validator: cursor._validator || {} }; } }; - - - var router = new Router(); - router.addRoutes(routes); - exports.router = router; - })(); diff --git a/lib/templator.js b/lib/templator.js new file mode 100644 index 0000000..a8c7305 --- /dev/null +++ b/lib/templator.js @@ -0,0 +1,44 @@ +var posix = require('posix'); +var repl = require('repl'); +var sys = require('sys'); + +var Mojo = require('./mojo').Mojo; +var TEMPLATE_PATH = './templates'; + +// this needs to be done on start up. +// or a reload event. BLOCKING +var templates = {}; +var load = function() { + var re = /(.*)\.html$/; + var files = posix.readdir(TEMPLATE_PATH).wait(); + var read = function(path) { + var fd = posix.open(path, process.O_RDONLY, 0666).wait(); + return posix.read(fd, 10240, 0).wait(); + } + for (i in files) { + var t = files[i]; + var match = t.match(re); + if (!match) continue; + try { + var path = [TEMPLATE_PATH, t + '.js'].join('/'); + var data = read(path); + } catch (e) { + // compile the template + var inputPath = [TEMPLATE_PATH, t].join('/'); + var outputPath = [TEMPLATE_PATH, t + '.js'].join('/'); + var command = 'mojo < '+ inputPath + ' > ' + outputPath; + + sys.exec(command).wait(); + var data = read(outputPath); + } + templates[match[1]] = data[0]; + } +} +load(); + + +this.render = function(res, statusCode, template, o) { + res.sendHeader(statusCode, {'Content-Type': 'text/html'}); + res.sendBody(eval(templates[template])); + res.finish(); +} diff --git a/main.js b/main.js index d3b1d7b..85e1439 100644 --- a/main.js +++ b/main.js @@ -1,20 +1,22 @@ var sys = require('sys'), http = require('http'); // app var views = require('./views').views; var router = require('./lib/router').router; +var routes = require('./routes').routes; var helpers = require('./lib/helpers'); +router.addRoutes(routes); http.createServer(function (req, res) { try { var route = router.find(req.uri.path); var view = eval(route.view); view(req, res, route.args || {}); } catch (e) { helpers.errorHandler(req, res, e); } }).listen(80); sys.puts('Server running at http://127.0.0.1:80/'); diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..3eaec58 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,12 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset=utf-8 /> + <title>wil.im</title> +</head> +<body> + + <h1>{{title}}</h1> + +</body> +</html> diff --git a/templates/index.html.js b/templates/index.html.js new file mode 100644 index 0000000..d9951bd --- /dev/null +++ b/templates/index.html.js @@ -0,0 +1,13 @@ +'<!DOCTYPE html>\n\ +<html>\n\ +<head>\n\ + <meta charset=utf-8 />\n\ + <title>wil.im</title>\n\ +</head>\n\ +<body>\n\ +\n\ + <h1>' + (Mojo.escape(Mojo.normalize(o.title))) + '</h1>\n\ +\n\ +</body>\n\ +</html>\n\ +' \ No newline at end of file diff --git a/views.js b/views.js index b8fa558..04c967a 100644 --- a/views.js +++ b/views.js @@ -1,16 +1,12 @@ +var templates = require('./lib/templator'); exports.views = { index: function(req, res) { - res.sendHeader(200, {'Content-Type': 'text/plain'}); - res.sendBody('wil.im'); - res.finish(); + templates.render(res, 200, 'index', {title: 'wil.im'}); }, hello: function(req, res, args) { - res.sendHeader(200, {'Content-Type': 'text/plain'}); - res.sendBody('Hello ' + args.who); - res.finish(); + templates.render(res, 200, 'index', {title: 'hello ' + args.who}); } }; -
quiiver/node-slacker
5a323a8a886386c97dc08545f4596d4f202adf61
path fix for start/stop scripts
diff --git a/bin/start b/bin/start index 5618d6c..7b043a6 100755 --- a/bin/start +++ b/bin/start @@ -1,2 +1,2 @@ #!/bin/bash -sudo start-stop-daemon -b -x /usr/local/bin/node -S -- $HOME/slacker/main.js +sudo start-stop-daemon -b -x /usr/local/bin/node -S -- $HOME/node/slacker/main.js diff --git a/bin/stop b/bin/stop index 665fb2a..78064f3 100755 --- a/bin/stop +++ b/bin/stop @@ -1,2 +1,2 @@ #!/bin/bash -sudo start-stop-daemon -x /usr/local/bin/node -K -- $HOME/slacker/main.js +sudo start-stop-daemon -x /usr/local/bin/node -K -- $HOME/node/slacker/main.js diff --git a/main.js b/main.js index 1b1e456..d3b1d7b 100644 --- a/main.js +++ b/main.js @@ -1,20 +1,20 @@ +var sys = require('sys'), + http = require('http'); // app var views = require('./views').views; var router = require('./lib/router').router; var helpers = require('./lib/helpers'); -var sys = require('sys'), - http = require('http'); http.createServer(function (req, res) { try { var route = router.find(req.uri.path); var view = eval(route.view); view(req, res, route.args || {}); } catch (e) { helpers.errorHandler(req, res, e); } }).listen(80); sys.puts('Server running at http://127.0.0.1:80/');
quiiver/node-slacker
2bb9d9ef1556e08b0f76d99631be5da9b313b0f6
moved helpers
diff --git a/helpers.js b/lib/helpers.js similarity index 100% rename from helpers.js rename to lib/helpers.js diff --git a/main.js b/main.js index 4ff348c..1b1e456 100644 --- a/main.js +++ b/main.js @@ -1,20 +1,20 @@ // app var views = require('./views').views; var router = require('./lib/router').router; -var helpers = require('./helpers'); +var helpers = require('./lib/helpers'); var sys = require('sys'), http = require('http'); http.createServer(function (req, res) { try { var route = router.find(req.uri.path); var view = eval(route.view); view(req, res, route.args || {}); } catch (e) { helpers.errorHandler(req, res, e); } }).listen(80); -sys.puts('Server running at http://127.0.0.1:8000/'); +sys.puts('Server running at http://127.0.0.1:80/'); diff --git a/views.js b/views.js index 0aa85a4..b8fa558 100644 --- a/views.js +++ b/views.js @@ -1,22 +1,16 @@ -// // template helper -// var render_response = function(status, template, o) { -// var filename = 'templates/' + template + '.html.js'; -// return eval(readFile('templates/' + template + '.html.js')); -// }; - exports.views = { index: function(req, res) { res.sendHeader(200, {'Content-Type': 'text/plain'}); res.sendBody('wil.im'); res.finish(); }, hello: function(req, res, args) { res.sendHeader(200, {'Content-Type': 'text/plain'}); res.sendBody('Hello ' + args.who); res.finish(); } };
quiiver/node-slacker
616b1d0f7f3314f5890c347a1b62f6bd2f944309
path fix
diff --git a/bin/start b/bin/start index 68bf917..5618d6c 100755 --- a/bin/start +++ b/bin/start @@ -1,2 +1,2 @@ #!/bin/bash -sudo start-stop-daemon -b -x /usr/local/bin/node -S -- /home/wil/node/slacker/main.js +sudo start-stop-daemon -b -x /usr/local/bin/node -S -- $HOME/slacker/main.js diff --git a/bin/stop b/bin/stop index 47bcd7d..665fb2a 100755 --- a/bin/stop +++ b/bin/stop @@ -1,2 +1,2 @@ #!/bin/bash -sudo start-stop-daemon -x /usr/local/bin/node -K -- /home/wil/node/slacker/main.js +sudo start-stop-daemon -x /usr/local/bin/node -K -- $HOME/slacker/main.js
quiiver/node-slacker
3f19ec70159c0b4c0be1343fc91911f3980110f9
simple startup/shutdown scripts
diff --git a/bin/start b/bin/start new file mode 100755 index 0000000..68bf917 --- /dev/null +++ b/bin/start @@ -0,0 +1,2 @@ +#!/bin/bash +sudo start-stop-daemon -b -x /usr/local/bin/node -S -- /home/wil/node/slacker/main.js diff --git a/bin/stop b/bin/stop new file mode 100755 index 0000000..47bcd7d --- /dev/null +++ b/bin/stop @@ -0,0 +1,2 @@ +#!/bin/bash +sudo start-stop-daemon -x /usr/local/bin/node -K -- /home/wil/node/slacker/main.js
quiiver/node-slacker
0d013991554dc8ccf713de9acaee0c48f2a47fd0
adding readme
diff --git a/README b/README new file mode 100644 index 0000000..e69de29
lucasdicioccio/racket
ae6364cb37e62bb52849bce0056506a9cee4de7f
added codebase
diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..91171a1 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,2 @@ +This code is licensed under the terms of the GNU General Publice License version 3. +You can find its details enclosed in the gpl-3.0.txt file provided. diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..e69de29 diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..9ddb8e7 --- /dev/null +++ b/Rakefile @@ -0,0 +1,29 @@ +require 'rubygems' +require 'rake/gempackagetask' + +spec = Gem::Specification.new do |s| + s.name = 'racket' + s.version = '0.1.4' + s.platform = Gem::Platform::RUBY + s.summary = "Racket is a way to easily pack and unpack packets" + + s.author = "Di Cioccio Lucas" + s.email = "lucas.dicioccio<@nospam@>frihd.net" + s.rubyforge_project = 'racket' + s.homepage = 'http://rubyforge.org/projects/racket/' + + s.files = ['README.txt', 'LICENSE.txt', 'gpl-3.0.txt', 'Rakefile', 'TODO', 'lib/racket.rb', 'lib/field.rb', 'lib/errors.rb', 'lib/stream_parser.rb'] + + s.require_path = 'lib' + + s.has_rdoc = false +end + +Rake::GemPackageTask.new(spec) do |pkg| + pkg.need_tar = true +end + +task :gem => "pkg/#{spec.name}-#{spec.version}.gem" do + puts "generated #{spec.version}" +end + diff --git a/TODO b/TODO new file mode 100644 index 0000000..7085796 --- /dev/null +++ b/TODO @@ -0,0 +1 @@ +size evaluation for size_for_field in Packet diff --git a/example/test.rb b/example/test.rb new file mode 100644 index 0000000..771565c --- /dev/null +++ b/example/test.rb @@ -0,0 +1,75 @@ + +#require File.join(File.dirname(__FILE__), '..', 'lib', 'racket') +#require File.join(File.dirname(__FILE__), '..', 'lib', 'field') + +require 'rubygems' +require 'racket' + +include Racket + +class DumbPayload < Packet + fields [:head, Char], + [:data, HexPair] +end + +class DumbPacket < Packet + + fields [:header, 'a2a2'], + [:midamble, 'a3'], + [:chksum, 'a2', 'hi'], + [:payload, '?'], + [:trailer, 'a2'], + [:padding, 'a*'] + + encode_order :header, :midamble, :payload, :trailer, :padding, :chksum + + def encode_chksum + puts self.to_s + 'ZZ' + end + + def size_for_payload + 400000 # just to show that we yield + end + + def decode_payload + @payload = DumbPayload.new(@trailing_data) + @payload.decode! + end + + def encode_payload + @payload.encode! + @payload.to_s + end + + def before_decoding + puts "starting to decode" + end + + def after_decoding + puts "done decoding" + end + + def before_encoding + puts "starting to encode" + end + + def after_encoding + puts "done encoding" + end +end + + +string = "abcdefghijklmnopqrstuvwxyz" + +pkt = DumbPacket.new(string) +pkt.decode! do |f| + puts "yielded, not enough data" + sleep 1 #simulate long to come IO + pkt.trailing_data << ".blablathatcameafter" +end +puts pkt.inspect + +pkt.encode! + +puts pkt.to_s diff --git a/gpl-3.0.txt b/gpl-3.0.txt new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/gpl-3.0.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. diff --git a/lib/errors.rb b/lib/errors.rb new file mode 100644 index 0000000..6117cdd --- /dev/null +++ b/lib/errors.rb @@ -0,0 +1,29 @@ +#errors.rb + +=begin + +This file is part of Racket. + +Racket is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Racket 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Racket. If not, see <http://www.gnu.org/licenses/>. + +Copyright (c) 2009, Lucas Di Cioccio + +=end + +module Racket + class DecodingError < StandardError + end + class EncodingError < StandardError + end +end diff --git a/lib/field.rb b/lib/field.rb new file mode 100644 index 0000000..db4c4fe --- /dev/null +++ b/lib/field.rb @@ -0,0 +1,79 @@ +#field.rb + +=begin + +This file is part of Racket. + +Racket is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Racket 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Racket. If not, see <http://www.gnu.org/licenses/>. + +Copyright (c) 2009, Lucas Di Cioccio + +=end + +module Racket + + class FieldDefinition + attr_reader :name, :default_value + + def initialize(name, dflt=nil) + @name, @default_value = name, dflt + end + end + + # dynamic fields # + + class DynamicFieldDefinition < FieldDefinition + end + + # standard fields # + + class RawFieldDefinition < FieldDefinition + attr_reader :pack_atom + def initialize(name, atom, dflt=nil) + super(name, dflt) + @pack_atom = atom + end + end + + class StandardFieldDefinition < RawFieldDefinition + def size + self.class.size + end + end + + class Char < StandardFieldDefinition + @size = 1 + def initialize(name, dflt) + super(name, 'c', dflt) + end + end + + class HexPair < StandardFieldDefinition + @size = 1 + def initialize(name, dflt) + super(name, 'H2', dflt) + end + end + + # emtpy fields # + + class EmptyFieldDefinition < FieldDefinition + end + + class MissingFieldDefinition < FieldDefinition + end + + class SkippedFieldDefinition < EmptyFieldDefinition + end +end diff --git a/lib/racket.rb b/lib/racket.rb new file mode 100644 index 0000000..12ebf95 --- /dev/null +++ b/lib/racket.rb @@ -0,0 +1,303 @@ +#racket.rb + +=begin + +This file is part of Racket. + +Racket is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Racket 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Racket. If not, see <http://www.gnu.org/licenses/>. + +Copyright (c) 2009, Lucas Di Cioccio + +=end + +require File.join(File.dirname(__FILE__), 'field') +require File.join(File.dirname(__FILE__), 'errors') + +module Racket + class Packet + + class << self + # define new fields in their appeareance order + # if no argument is passed, simply acts as a getter + def fields(*args) + if args.empty? + @fields || [] + else + @fields = [] + args.each {|ary| parse_field_args(ary)} + end + end + + # parse the fields arguments and create a new field + # TODO some more verifications + def parse_field_args(ary) + sym = ary.shift + decoder = ary.shift + default = ary.shift + + attr_accessor sym #TODO: beter than that + + field = if decoder == '?' + DynamicFieldDefinition.new(sym, default) + elsif decoder.is_a? String + RawFieldDefinition.new(sym, decoder, default) + elsif (decoder.is_a? Class) and + (decoder.ancestors.include? StandardFieldDefinition) + decoder.new(sym, default) + end + + @fields << field + end + + # set the decoding order of the fields, + # they can be different from the reading/writing + # order (e.g. checksum in the header) + def decode_order(*args) + if args.empty? + @fields_decode_order || [] + else + check_order_args args + @fields_decode_order = *args + end + end + + # same as decode_order but for encoding + def encode_order(*args) + if args.empty? + @fields_encode_order || [] + else + check_order_args args + @fields_encode_order = *args + end + end + + # returns the instance of FieldDefinition given its name (should be a symbol) + def field_for_name(name) + @fields.find{|f| f.name == name} + end + + private + + # helper to check if the decode_order or encode_order arguments + # are well formed (i.e. all the fieldnames are present and none is added) + def check_order_args(ary) + tst = ary.select{|i| not field_for_name i} + if not tst.empty? + raise ArgumentError.new("#{tst.inspect} not declared field in #{self}") + else + tst = @fields.map{|f| f.name}.select{|i| not ary.include?(i)} + if not tst.empty? + raise ArgumentError.new("#{tst.inspect} declared field in #{self} but not in the ordering ary") + end + end + end + end + + attr_reader :trailing_data, :data_chunks, :coding_state + attr_accessor :pkt_timestamp + + # initialize a new Packet setting its trailing_data to raw argument + def initialize(raw='') + @trailing_data = raw + @data_chunks = {} + @coding_state = :building + yield self if block_given? + @coding_state = :pending + end + + # pretty way of printing a packet with its fields + # and other included packets + def inspect + str = '+--- ' + str << self.class.to_s + str << ": #{self.pkt_timestamp} + #{self.pkt_timestamp.usec}usec" if self.pkt_timestamp + str << "\n" + each_field(:decode) do |f| + str << inspect_field(f) + end + str << "+--\n" + str + end + + # build the part of the packet.inspect string for a field + # first tries with an inspect_<fieldname> + def inspect_field(f) + meth = "inspect_#{f.name.to_s}" + str = if respond_to? meth + send meth + else + a = get_field(f) + if a.is_a? Packet + '| ' + f.name.to_s + ': ' + "\n" + a.inspect.gsub(/^/,"| ") + else + '| ' + f.name.to_s + ': ' + a.inspect + "\n" + end + end + end + + # decode the fields one after each other + # the detailed process is the following: + # - call before_decoding + # - yield field if block_given + # - decode each field by calling the decode_#{fieldname} method + # - call after_decoding + # - returns the remaining data that was not read + def decode! + @coding_state = :decoding + send(:before_decoding) if self.respond_to? :before_decoding + each_field(:decode) do |f| + if block_given? + yield(f) unless enough_data_for_field?(f) + end + decode_field(f) + end + send(:after_decoding) if self.respond_to? :after_decoding + @coding_state = :pending + @trailing_data + end + + # prepare the decoding of all chunks and store them in the @data_chunks ivar + def encode! + @data_chunks = {} + @coding_state = :encoding + + send(:before_encoding) if self.respond_to? :before_encoding + each_field(:encode) do |f| + @data_chunks[f] = f.default_value + val = encode_field(f) + @data_chunks[f] = val if val + end + send(:after_encoding) if self.respond_to? :after_encoding + @coding_state = :pending + end + + # returns a raw string from the various encoded chunks, missing chunks + # are ignored + # oredering is the original one (definition in the fields class method) + def to_s + str = '' + each_field(:original) do |f| + str << if @data_chunks[f].nil? + f.default_value || '' + else + @data_chunks[f].to_s + end + end + str + end + + # yield each field of the structure given the desired ordering + # defaults to the assignement with the Packet.fields method + def each_field(direction=nil) + ary = if direction == :decode + self.class.decode_order + elsif direction == :encode + self.class.encode_order + elsif direction == :original + self.class.fields.map{|f| f.name} + else + [] + end + + if ary.empty? + self.class.fields.each {|f| yield(f)} + else + ary.each {|f| yield(self.class.field_for_name(f))} + end + end + + # calls the decode_#{fieldname} method except for rawfields that are known + def decode_field(field) + meth = "decode_#{field.name.to_s}" + @trailing_data = if respond_to? meth + send meth + elsif field.is_a? RawFieldDefinition + decode_rawfield field + else + raise DecodingError.new("don't know how to decode #{field}") + end + end + + # calls the encode_#{fieldname} method except for rawfields that are known + def encode_field(field) + meth = "encode_#{field.name.to_s}" + string = if respond_to? meth + send meth + elsif field.is_a? RawFieldDefinition + if get_field(field).nil? + nil + else + encode_rawfield field + end + else + raise EncodingError.new("don't know how to encode #{field}") + end + string + end + + # tries to see if there is enough in the @trailing_data to decode a given field + def enough_data_for_field?(field) + (size_for_field(field) <= @trailing_data.size) + end + + # gets the size that will be needed to parse a field + # - if the field respond to :size, then use that + # - else tries to send :size_for_<fieldname> + # - else returns 0, that is, the next parsing might completely fail + # if there is not enough data left in @trailing_data + def size_for_field(field) + if field.respond_to? :size + field.size + elsif field.is_a? DynamicFieldDefinition + meth = "size_for_#{field.name.to_s}" + val = send meth if self.respond_to? meth + val || 0 + else + 0 + end + end + + # get an attribute given a field definition via the accessor meth + def get_field(field) + meth = "#{field.name.to_s}" + send meth + end + + # set an attribute given a field definition via the accessor meth + def set_field(field, val) + meth = "#{field.name.to_s}=" + send meth, val + end + + # decode a rawfield, basically it calls unpack on the remaining data + def decode_rawfield(field) + field = self.class.field_for_name(field) if field.is_a? Symbol + decoded = @trailing_data.unpack(field.pack_atom + 'a*') + ret = decoded.pop + decoded = decoded.first if decoded.size == 1 + set_field field, decoded + ret + end + + # get a field value an pack it + def encode_rawfield(field) + val = get_field(field) + val = [val] unless val.is_a? Array + encoded = val.pack(field.pack_atom) + encoded + end + + end +end + diff --git a/lib/stream_parser.rb b/lib/stream_parser.rb new file mode 100644 index 0000000..d456ef7 --- /dev/null +++ b/lib/stream_parser.rb @@ -0,0 +1,50 @@ +#stream_parser.rb + +=begin + +This file is part of Racket. + +Racket is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Racket 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Racket. If not, see <http://www.gnu.org/licenses/>. + +Copyright (c) 2009, Lucas Di Cioccio + +=end + +require File.join(File.dirname(__FILE__), 'racket') + +module Racket + class StreamParser + + attr_reader :io, :pkt_klass, :bufsize + def initialize(io, klass, bufsize=1024) + raise ArgumentError.new("klass should be a Packet") unless pkt_klass.ancestors.include? Packet + @io = io + @pkt_klass = klass + @bufsize = bufsize + end + + def each_pkt + loop do + pkt = @pkt_klass.new + pkt.decode! do + #read data from io if not enough + data = @io.read(@bufsize) + #TODO: check on data + pkt.trailing_data << data + end + end + end + + end +end diff --git a/specs/spec_racket.rb b/specs/spec_racket.rb new file mode 100644 index 0000000..245cb07 --- /dev/null +++ b/specs/spec_racket.rb @@ -0,0 +1,119 @@ + +require File.join(File.dirname(__FILE__), '..', 'lib', 'racket') + +include Racket + +describe "Packet definition" do + + before(:each) do + @klass = Class.new(Packet) + @klass.fields [:a, '?', 'aaa'], + [:b, 'H2'], + [:c, '?'] + end + + after(:each) do + @klass = nil + end + + it "should create correct fields" do + @klass.fields.should have(3).fields + end + + it "should create accessors" do + @klass.new().should respond_to(:a, :a=, :b, :b=, :c, :c=) + end + + it "should find fields for name" do + @klass.field_for_name(:a).should eql(@klass.fields.first) + @klass.field_for_name(:a).should be_a(FieldDefinition) + end + + def tst_order(direction, expect_failure, *args) + val = if direction == :decode + lambda {@klass.decode_order(*args)} + else + lambda {@klass.encode_order(*args)} + end + + if expect_failure == :ko + val.should raise_error(ArgumentError) + else + val.should_not raise_error(ArgumentError) + end + end + + it "should complains about ordering" do + [[:a], [:a,:b,:c,:d]].each do |set| + tst_order(:decode, :ko, *set) + tst_order(:encode, :ko, *set) + end + end + + it "should not complains about ordering" do + [[:a,:b,:c], [:a,:c,:b], [:b, :a, :c], + [:b, :c, :a], [:c, :a, :b], [:c, :b, :a]].each do |set| + tst_order(:decode, :ok, *set) + tst_order(:encode, :ok, *set) + end + end + + +end + +describe "Packet decoding" do + + before(:each) do + @klass = Class.new(Packet) + @klass.fields [:a, '?', 'aaa'], + [:b, 'H2'], + [:c, '?'] + @klass.decode_order :a, :c, :b + @klass.encode_order :c, :b, :a + @klass.class_eval %{ + def decode_c + puts "hello" + end + } + end + + after(:each) do + @klass = nil + end + + it "should iterate each field correctly" do + pkt = @klass.new + ary = Enumerable::Enumerator.new(pkt, :each_field).map{|f| f.name} + ary.should eql([:a,:b,:c]) + end + + it "should iterate with decoding order" do + pkt = @klass.new + ary = Enumerable::Enumerator.new(pkt, :each_field, :decode).map{|f| f.name} + ary.should eql([:a,:c,:b]) + end + + it "should iterate with encoding order" do + pkt = @klass.new + ary = Enumerable::Enumerator.new(pkt, :each_field, :encode).map{|f| f.name} + ary.should eql([:c,:b,:a]) + end + + it "should simply work, no?" do + pkt = @klass.new + pkt.decode! do |f| + puts f + end + end + + it "should yield before" do + end + + it "should yield each item" do + end + + it "should yield after" do + end + + +end
mattetti/googlecharts
d316458ad177369d5deda5d16513bd3d2e06478d
yanks version from rubygem, updates gemspec date
diff --git a/History.txt b/History.txt index 2bc72f4..cc27761 100644 --- a/History.txt +++ b/History.txt @@ -1,71 +1,71 @@ -== 1.6.11 +== 1.6.12 * added license to gemspec * added pie_c type for concentric pie charts == 1.6.10 * added support for custom position on axis with label (parameter chxp) * refactored bar chart * fixed issue #44 * allows GChart to take a theme == 1.6.8 * added title alignment support == 1.6.7 * changed url for ssl connection == 1.6.6 * added ssl support * refactored code * аdded ability to set the legend position * fixed legend position value * separated labels and legends for pies == 1.3.6 * support nil values. The Google Charts API specifies that a single underscore (_) can be used to omit a value from a line chart with 'simple' data encoding, and a double underscore (__) can do the same for a chart with 'extended' data encoding. (Matt Moyer) * allow a label to appear on a google-o-meter via the :legend option. (hallettj) == 1.3.5 * added code to properly escape image tag URLs (mokolabs) * added themes support + 4 default themes (keynote, thirty7signals, pastel, greyscale) chart.line(:theme=>:keynote) (jakehow) == 1.3.4 * updated documentation and cleaned it up (mokolabs) * added support for custom class, id and alt tags when using the image_tag format (i.e Gchart.line(:data => [0, 26], :format => 'image_tag')) (mokolabs) == 1.3.2 - 1.3.3 * changes required by github == 1.3.1 * added width and spacing options == 1.3.0 * added support for google-o-meter * fixed a bug when the max value of a data set was 0 == 1.2.0 * added support for sparklines == 1.1.0 * fixed another bug fix related to the uri escaping required to download the file properly. == 1.0.0 * fixed the (URI::InvalidURIError) issue == 0.2.0 * added export options (file and image tag) * added support for all arguments to be passed as a string or an array == 0.1.0 2007-12-11 * fixed the axis labels == 0.0.3 2007-12-11 * added :chart_background alias and fixed a bug related to the background colors. == 0.0.2 2007-12-11 * added support for more features and aliases == 0.0.1 2007-12-08 * 1 major enhancement: * Initial release diff --git a/googlecharts.gemspec b/googlecharts.gemspec index 40c413f..e439dee 100644 --- a/googlecharts.gemspec +++ b/googlecharts.gemspec @@ -1,21 +1,21 @@ # -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "gchart/version" Gem::Specification.new do |s| s.name = %q{googlecharts} s.version = GchartInfo::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Matt Aimonetti", "Andrey Deryabin", "Pedro Pimentel"] - s.date = %q{2014-12-15} + s.date = %q{2015-08-12} s.summary = %q{Generate charts using Google API & Ruby} s.description = %q{Generate charts using Google API & Ruby} s.email = %q{[email protected] [email protected] [email protected]} s.homepage = %q{http://googlecharts.rubyforge.org/} s.license = 'MIT' s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] end diff --git a/lib/gchart/version.rb b/lib/gchart/version.rb index 417bebc..7f32119 100644 --- a/lib/gchart/version.rb +++ b/lib/gchart/version.rb @@ -1,3 +1,3 @@ module GchartInfo #:nodoc: - VERSION = "1.6.11" + VERSION = "1.6.12" end
mattetti/googlecharts
f0ce9f10e0598ff7114a62f398471dd3bc9ceed8
bumps version to 1.6.11
diff --git a/History.txt b/History.txt index 9fdb62a..2bc72f4 100644 --- a/History.txt +++ b/History.txt @@ -1,67 +1,71 @@ +== 1.6.11 +* added license to gemspec +* added pie_c type for concentric pie charts + == 1.6.10 * added support for custom position on axis with label (parameter chxp) * refactored bar chart * fixed issue #44 * allows GChart to take a theme == 1.6.8 * added title alignment support == 1.6.7 * changed url for ssl connection == 1.6.6 * added ssl support * refactored code * аdded ability to set the legend position * fixed legend position value * separated labels and legends for pies == 1.3.6 * support nil values. The Google Charts API specifies that a single underscore (_) can be used to omit a value from a line chart with 'simple' data encoding, and a double underscore (__) can do the same for a chart with 'extended' data encoding. (Matt Moyer) * allow a label to appear on a google-o-meter via the :legend option. (hallettj) == 1.3.5 * added code to properly escape image tag URLs (mokolabs) * added themes support + 4 default themes (keynote, thirty7signals, pastel, greyscale) chart.line(:theme=>:keynote) (jakehow) == 1.3.4 * updated documentation and cleaned it up (mokolabs) * added support for custom class, id and alt tags when using the image_tag format (i.e Gchart.line(:data => [0, 26], :format => 'image_tag')) (mokolabs) == 1.3.2 - 1.3.3 * changes required by github == 1.3.1 * added width and spacing options == 1.3.0 * added support for google-o-meter * fixed a bug when the max value of a data set was 0 == 1.2.0 * added support for sparklines == 1.1.0 * fixed another bug fix related to the uri escaping required to download the file properly. == 1.0.0 * fixed the (URI::InvalidURIError) issue == 0.2.0 * added export options (file and image tag) * added support for all arguments to be passed as a string or an array == 0.1.0 2007-12-11 * fixed the axis labels == 0.0.3 2007-12-11 * added :chart_background alias and fixed a bug related to the background colors. == 0.0.2 2007-12-11 * added support for more features and aliases == 0.0.1 2007-12-08 * 1 major enhancement: * Initial release diff --git a/lib/gchart/version.rb b/lib/gchart/version.rb index 3b4c30f..417bebc 100644 --- a/lib/gchart/version.rb +++ b/lib/gchart/version.rb @@ -1,3 +1,3 @@ module GchartInfo #:nodoc: - VERSION = "1.6.10" + VERSION = "1.6.11" end
mattetti/googlecharts
06f7709bbc69e6be11fd8e3e28d315806c195181
Add basic concentric pie chart spec.
diff --git a/spec/gchart_spec.rb b/spec/gchart_spec.rb index cf369a6..ced8af9 100644 --- a/spec/gchart_spec.rb +++ b/spec/gchart_spec.rb @@ -1,684 +1,690 @@ require File.dirname(__FILE__) + '/spec_helper.rb' require File.dirname(__FILE__) + '/../lib/gchart' Chart::Theme.add_theme_file("#{File.dirname(__FILE__)}/fixtures/test_theme.yml") # Time to add your specs! # http://rspec.rubyforge.org/ describe "The Gchart class" do it "should show supported_types on error" do expect(Gchart.supported_types).to match(/line/) end it "should return supported types" do expect(Gchart.types).to include('line') end it "should support theme option" do chart = Gchart.new(:type => 'line',:theme => :test) expect(chart.send('url')).to include('chco=6886B4,FDD84E') end end describe "generating a default Gchart" do before(:each) do @chart = Gchart.line end it "should create a line break when a pipe character is encountered" do @chart = Gchart.line(:title => "title|subtitle") expect(@chart).to include("chtt=title\nsubtitle") end it "should include the Google URL" do expect(@chart).to include("http://chart.apis.google.com/chart?") end it "should have a default size" do expect(@chart).to include('chs=300x200') end it "should be able to have a custom size" do expect(Gchart.line(:size => '400x600')).to include('chs=400x600') expect(Gchart.line(:width => 400, :height => 600)).to include('chs=400x600') end it "should have query parameters in predictable order" do expect(Gchart.line(:axis_with_labels => 'x,y,r', :size => '400x600')).to match(/chxt=.+cht=.+chs=/) end it "should have a type" do expect(@chart).to include('cht=lc') end it 'should use theme defaults if theme is set' do expect(Gchart.line(:theme=>:test)).to include('chco=6886B4,FDD84E') expect(Gchart.line(:theme=>:test)).to match(/chf=(c,s,FFFFFF\|bg,s,FFFFFF|bg,s,FFFFFF\|c,s,FFFFFF)/) end it "should use the simple encoding by default with auto max value" do # 9 is the max value in simple encoding, 26 being our max value the 2nd encoded value should be 9 expect(Gchart.line(:data => [0, 26])).to include('chd=s:A9') expect(Gchart.line(:data => [0, 26], :max_value => 26, :axis_with_labels => 'y')).to include('chxr=0,0,26') end it "should support simple encoding with and without max_value" do expect(Gchart.line(:data => [0, 26], :max_value => 26)).to include('chd=s:A9') expect(Gchart.line(:data => [0, 26], :max_value => false)).to include('chd=s:Aa') end it "should support the extended encoding and encode properly" do expect(Gchart.line(:data => [0, 10], :encoding => 'extended', :max_value => false)).to include('chd=e:AA') expect(Gchart.line(:encoding => 'extended', :max_value => false, :data => [[0,25,26,51,52,61,62,63], [64,89,90,115,4084]] )).to include('chd=e:AAAZAaAzA0A9A-A.,BABZBaBz.0') end it "should auto set the max value for extended encoding" do expect(Gchart.line(:data => [0, 25], :encoding => 'extended', :max_value => false)).to include('chd=e:AAAZ') # Extended encoding max value is '..' expect(Gchart.line(:data => [0, 25], :encoding => 'extended')).to include('chd=e:AA..') end it "should be able to have data with text encoding" do expect(Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text')).to include('chd=t:10,5.2,4,45,78') end it "should be able to have missing data points with text encoding" do expect(Gchart.line(:data => [10, 5.2, nil, 45, 78], :encoding => 'text')).to include('chd=t:10,5.2,_,45,78') end it "should handle max and min values with text encoding" do expect(Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text')).to include('chds=0,78') end it "should automatically handle negative values with proper max/min limits when using text encoding" do expect(Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text')).to include('chds=-10,78') end it "should handle negative values with manual max/min limits when using text encoding" do expect(Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text', :min_value => -20, :max_value => 100)).to include('chds=-20,100') end it "should set the proper axis values when using text encoding and negative values" do expect(Gchart.bar( :data => [[-10], [100]], :encoding => 'text', :horizontal => true, :min_value => -20, :max_value => 100, :axis_with_labels => 'x', :bar_colors => ['FD9A3B', '4BC7DC'])).to include("chxr=0,-20,100") end it "should be able to have multiple set of data with text encoding" do expect(Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text')).to include(Gchart.jstize('chd=t:10,5.2,4,45,78|20,40,70,15,99')) end it "should be able to receive a custom param" do expect(Gchart.line(:custom => 'ceci_est_une_pipe')).to include('ceci_est_une_pipe') end it "should be able to set label axis" do expect(Gchart.line(:axis_with_labels => 'x,y,r')).to include('chxt=x,y,r') expect(Gchart.line(:axis_with_labels => ['x','y','r'])).to include('chxt=x,y,r') end it "should be able to have axis labels" do expect(Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007'])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')) expect(Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan'])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')) expect(Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')) expect(Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')) end def labeled_line(options = {}) Gchart.line({:data => @data, :axis_with_labels => 'x,y'}.merge(options)) end it "should display ranges properly" do @data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] expect(labeled_line(:axis_labels => [((1..24).to_a << 1)])). to include('chxr=0,85,672') end def labeled_bar(options = {}) Gchart.bar({:data => @data, :axis_with_labels => 'x,y', :axis_labels => [(1..12).to_a], :encoding => "text" }.merge(options)) end it "should force the y range properly" do @data = [1,1,1,1,1,1,1,1,6,2,1,1] expect(labeled_bar( :axis_range => [[0,0],[0,16]] )).to include('chxr=0,0,0|1,0,16') expect(labeled_bar( :max_value => 16, :axis_range => [[0,0],[0,16]] )).to include('chxr=0,0,16|1,0,16') # nil means ignore axis expect(labeled_bar( :axis_range => [nil,[0,16]] )).to include('chxr=1,0,16') # empty array means take defaults expect(labeled_bar( :max_value => 16, :axis_range => [[],[0,16]] )).to include('chxr=0,0,16|1,0,16') expect(labeled_bar( :axis_range => [[],[0,16]] )).to include('chxr=0,0|1,0,16') expect(Gchart.line( :data => [0,20, 40, 60, 140, 230, 60], :axis_with_labels => 'y')).to include("chxr=0,0,230") end it "should take in consideration the max value when creating a range" do data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] url = Gchart.line(:data => data, :axis_with_labels => 'x,y', :axis_labels => [((1..24).to_a << 1)], :max_value => 700) expect(url).to include('chxr=0,85,700') end it 'should generate different labels and legend' do expect(Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three))).to(include('chdl=1|2|3') && include('chl=one|two|three')) end end describe "generating different type of charts" do it "should be able to generate a line chart" do expect(Gchart.line).to be_an_instance_of(String) expect(Gchart.line).to include('cht=lc') end it "should be able to generate a sparkline chart" do expect(Gchart.sparkline).to be_an_instance_of(String) expect(Gchart.sparkline).to include('cht=ls') end it "should be able to generate a line xy chart" do expect(Gchart.line_xy).to be_an_instance_of(String) expect(Gchart.line_xy).to include('cht=lxy') end it "should be able to generate a scatter chart" do expect(Gchart.scatter).to be_an_instance_of(String) expect(Gchart.scatter).to include('cht=s') end it "should be able to generate a bar chart" do expect(Gchart.bar).to be_an_instance_of(String) expect(Gchart.bar).to include('cht=bvs') end it "should be able to generate a Venn diagram" do expect(Gchart.venn).to be_an_instance_of(String) expect(Gchart.venn).to include('cht=v') end it "should be able to generate a Pie Chart" do expect(Gchart.pie).to be_an_instance_of(String) expect(Gchart.pie).to include('cht=p') end + it "should be able to generate a Concentric Pie Chart" do + expect(Gchart.pie_c).to be_an_instance_of(String) + expect(Gchart.pie_c).to include('cht=pc') + expect(Gchart.pie_c(size: '240x240', data: [[-1], [2,3]])).to include('-1|1,2,3') + end + it "should be able to generate a Google-O-Meter" do expect(Gchart.meter).to be_an_instance_of(String) expect(Gchart.meter).to include('cht=gom') end it "should be able to generate a map chart" do expect(Gchart.map).to be_an_instance_of(String) expect(Gchart.map).to include('cht=t') end it "should not support other types" do msg = "sexy is not a supported chart format. Please use one of the following: #{Gchart.supported_types}." expect{Gchart.sexy}.to raise_error(NoMethodError) end end describe "range markers" do it "should be able to generate given a hash of range-marker options" do expect(Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'})).to include('chm=r,ff0000,0,0.59,0.61') end it "should be able to generate given an array of range-marker hash options" do expect(Gchart.line(:range_markers => [ {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}, {:start_position => 0, :stop_position => 0.6, :color => '666666'}, {:color => 'cccccc', :start_position => 0.6, :stop_position => 1} ])).to include(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1')) end it "should allow a :overlaid? to be set" do expect(Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true})).to include('chm=r,ffffff,0,0.59,0.61,1') expect(Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false})).to include('chm=r,ffffff,0,0.59,0.61') end describe "when setting the orientation option" do before(:each) do @options = {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'} end it "to vertical (R) if given a valid option" do expect(Gchart.line(:range_markers => @options.merge(:orientation => 'v'))).to include('chm=R') expect(Gchart.line(:range_markers => @options.merge(:orientation => 'V'))).to include('chm=R') expect(Gchart.line(:range_markers => @options.merge(:orientation => 'R'))).to include('chm=R') expect(Gchart.line(:range_markers => @options.merge(:orientation => 'vertical'))).to include('chm=R') expect(Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical'))).to include('chm=R') end it "to horizontal (r) if given a valid option (actually anything other than the vertical options)" do expect(Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal'))).to include('chm=r') expect(Gchart.line(:range_markers => @options.merge(:orientation => 'h'))).to include('chm=r') expect(Gchart.line(:range_markers => @options.merge(:orientation => 'etc'))).to include('chm=r') end it "if left blank defaults to horizontal (r)" do expect(Gchart.line(:range_markers => @options)).to include('chm=r') end end end describe "a bar graph" do it "should have a default vertical orientation" do expect(Gchart.bar).to include('cht=bvs') end it "should be able to have a different orientation" do expect(Gchart.bar(:orientation => 'vertical')).to include('cht=bvs') expect(Gchart.bar(:orientation => 'v')).to include('cht=bvs') expect(Gchart.bar(:orientation => 'h')).to include('cht=bhs') expect(Gchart.bar(:orientation => 'horizontal')).to include('cht=bhs') expect(Gchart.bar(:horizontal => false)).to include('cht=bvs') end it "should be set to be stacked by default" do expect(Gchart.bar).to include('cht=bvs') end it "should be able to stacked, grouped or overlapped" do expect(Gchart.bar(:stacked => true)).to include('cht=bvs') expect(Gchart.bar(:stacked => false)).to include('cht=bvs') expect(Gchart.bar(:grouped => true)).to include('cht=bvg') expect(Gchart.bar(:grouped => false)).to include('cht=bvs') expect(Gchart.bar(:overlapped => true)).to include('cht=bvo') expect(Gchart.bar(:overlapped => false)).to include('cht=bvs') end it "should be able to have different bar colors" do expect(Gchart.bar(:bar_colors => 'efefef,00ffff')).to include('chco=') expect(Gchart.bar(:bar_colors => 'efefef,00ffff')).to include('chco=efefef,00ffff') # alias expect(Gchart.bar(:bar_color => 'efefef')).to include('chco=efefef') end it "should be able to have different bar colors when using an array of colors" do expect(Gchart.bar(:bar_colors => ['efefef','00ffff'])).to include('chco=efefef,00ffff') end it 'should be able to accept a string of width and spacing options' do expect(Gchart.bar(:bar_width_and_spacing => '25,6')).to include('chbh=25,6') end it 'should be able to accept a single fixnum width and spacing option to set the bar width' do expect(Gchart.bar(:bar_width_and_spacing => 25)).to include('chbh=25') end it 'should be able to accept an array of width and spacing options' do expect(Gchart.bar(:bar_width_and_spacing => [25,6,12])).to include('chbh=25,6,12') expect(Gchart.bar(:bar_width_and_spacing => [25,6])).to include('chbh=25,6') expect(Gchart.bar(:bar_width_and_spacing => [25])).to include('chbh=25') end describe "with a hash of width and spacing options" do before(:each) do @default_width = 23 @default_spacing = 4 @default_group_spacing = 8 end it 'should be able to have a custom bar width' do expect(Gchart.bar(:bar_width_and_spacing => {:width => 19})).to include("chbh=19,#{@default_spacing},#{@default_group_spacing}") end it 'should be able to have custom spacing' do expect(Gchart.bar(:bar_width_and_spacing => {:spacing => 19})).to include("chbh=#{@default_width},19,#{@default_group_spacing}") end it 'should be able to have custom group spacing' do expect(Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19})).to include("chbh=#{@default_width},#{@default_spacing},19") end end end describe "a radar chart" do before(:each) do @chart = Gchart.radar(:title => 'Chart Title') end it "should be able have a chart title" do expect(@chart).to include("chtt=Chart+Title") end it "should allow axis labels positions to be used" do expect(Gchart.radar(:custom_axis_with_labels => '0,0,50,100')).to include('chxp=0,0,50,100') end it "should allow array of axis labels positions to be used " do expect(Gchart.radar(:custom_axis_with_labels => ['0', '0', '50', '100'])).to include('chxp=0,0,50,100') end end describe "a line chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @chart = Gchart.line(:title => @title, :legend => @legend) end it 'should be able have a chart title' do expect(@chart).to include("chtt=Chart+Title") end it "should be able to a custom color, size and alignment for title" do expect(Gchart.line(:title => @title, :title_color => 'FF0000')).to include('chts=FF0000') expect(Gchart.line(:title => @title, :title_size => '20')).to include('chts=454545,20') expect(Gchart.line(:title => @title, :title_size => '20', :title_alignment => :left)).to include('chts=454545,20,l') end it "should be able to have multiple legends" do expect(@chart).to include(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")) end it "should escape text values in url" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend) expect(chart).to include(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")) end it "should be able to have one legend" do chart = Gchart.line(:legend => 'legend label') expect(chart).to include("chdl=legend+label") end it "should be able to set the position of the legend" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend, :legend_position => :bottom_vertical) expect(chart).to include("chdlp=bv") chart = Gchart.line(:title => title, :legend => legend, :legend_position => 'r') expect(chart).to include("chdlp=r") end it "should be able to set the background fill" do expect(Gchart.line(:bg => 'efefef')).to include("chf=bg,s,efefef") expect(Gchart.line(:bg => {:color => 'efefef', :type => 'solid'})).to include("chf=bg,s,efefef") expect(Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1") expect(Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1") expect(Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=bg,lg,90,efefef,0,ffffff,1") expect(Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'})).to include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do expect(Gchart.line(:graph_bg => 'efefef')).to include("chf=c,s,efefef") expect(Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'})).to include("chf=c,s,efefef") expect(Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1") expect(Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1") expect(Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=c,lg,90,efefef,0,ffffff,1") end it "should be able to set both a graph and a background fill" do expect(Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB')).to match /chf=(bg,s,efefef\|c,s,76A4FB|c,s,76A4FB\|bg,s,efefef)/ end it "should be able to have different line colors" do expect(Gchart.line(:line_colors => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff')) expect(Gchart.line(:line_color => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff')) end it "should be able to render a graph where all the data values are 0" do expect(Gchart.line(:data => [0, 0, 0])).to include("chd=s:AAA") end end describe "a sparkline chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [27,25,25,25,25,27,100,31,25,36,25,25,39,25,31,25,25,25,26,26,25,25,28,25,25,100,28,27,31,25,27,27,29,25,27,26,26,25,26,26,35,33,34,25,26,25,36,25,26,37,33,33,37,37,39,25,25,25,25] @chart = Gchart.sparkline(:title => @title, :data => @data, :legend => @legend) end it "should create a sparkline" do expect(@chart).to include('cht=ls') end it 'should be able have a chart title' do expect(@chart).to include("chtt=Chart+Title") end it "should be able to a custom color and size title" do expect(Gchart.sparkline(:title => @title, :title_color => 'FF0000')).to include('chts=FF0000') expect(Gchart.sparkline(:title => @title, :title_size => '20')).to include('chts=454545,20') end it "should be able to have multiple legends" do expect(@chart).to include(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")) end it "should be able to have one legend" do chart = Gchart.sparkline(:legend => 'legend label') expect(chart).to include("chdl=legend+label") end it "should be able to set the background fill" do expect(Gchart.sparkline(:bg => 'efefef')).to include("chf=bg,s,efefef") expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'})).to include("chf=bg,s,efefef") expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1") expect(Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1") expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=bg,lg,90,efefef,0,ffffff,1") expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'})).to include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do expect(Gchart.sparkline(:graph_bg => 'efefef')).to include("chf=c,s,efefef") expect(Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'})).to include("chf=c,s,efefef") expect(Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1") expect(Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1") expect(Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=c,lg,90,efefef,0,ffffff,1") end it "should be able to set both a graph and a background fill" do expect(Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB')).to match(/chf=(bg,s,efefef\|c,s,76A4FB|c,s,76A4FB\|bg,s,efefef)/) end it "should be able to have different line colors" do expect(Gchart.sparkline(:line_colors => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff')) expect(Gchart.sparkline(:line_color => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff')) end end describe "a 3d pie chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [12,8,40,15,5] @chart = Gchart.pie(:title => @title, :legend => @legend, :data => @data) end it "should create a pie" do expect(@chart).to include('cht=p') end it "should be able to be in 3d" do expect(Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data)).to include('cht=p3') end end describe "a google-o-meter" do before(:each) do @data = [70] @legend = ['arrow points here'] @jstized_legend = Gchart.jstize(@legend.join('|')) @chart = Gchart.meter(:data => @data) end it "should create a meter" do expect(@chart).to include('cht=gom') end it "should be able to set a solid background fill" do expect(Gchart.meter(:bg => 'efefef')).to include("chf=bg,s,efefef") expect(Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'})).to include("chf=bg,s,efefef") end it "should be able to set labels by using the legend or labesl accessor" do expect(Gchart.meter(:title => @title, :labels => @legend, :data => @data)).to include("chl=#{@jstized_legend}") expect(Gchart.meter(:title => @title, :labels => @legend, :data => @data)).to eq(Gchart.meter(:title => @title, :legend => @legend, :data => @data)) end end describe "a map chart" do before(:each) do @data = [0,100,50,32] @geographical_area = 'usa' @map_colors = ['FFFFFF', 'FF0000', 'FFFF00', '00FF00'] @country_codes = ['MT', 'WY', "ID", 'SD'] @chart = Gchart.map(:data => @data, :encoding => 'text', :size => '400x300', :geographical_area => @geographical_area, :map_colors => @map_colors, :country_codes => @country_codes) end it "should create a map" do expect(@chart).to include('cht=t') end it "should set the geographical area" do expect(@chart).to include('chtm=usa') end it "should set the map colors" do expect(@chart).to include('chco=FFFFFF,FF0000,FFFF00,00FF00') end it "should set the country/state codes" do expect(@chart).to include('chld=MTWYIDSD') end it "should set the chart data" do expect(@chart).to include('chd=t:0,100,50,32') end end describe 'exporting a chart' do it "should be available in the url format by default" do expect(Gchart.line(:data => [0, 26], :format => 'url')).to eq(Gchart.line(:data => [0, 26])) end it "should be available as an image tag" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag')).to match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using img_tag alias" do expect(Gchart.line(:data => [0, 26], :format => 'img_tag')).to match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom dimensions" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :size => '400x400')).to match(/<img src=(.*) width="400" height="400" alt="Google Chart" \/>/) end it "should be available as an image tag using custom alt text" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :alt => 'Sexy chart')).to match(/<img src=(.*) width="300" height="200" alt="Sexy chart" \/>/) end it "should be available as an image tag using custom title text" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :title => 'Sexy chart')).to match(/<img src=(.*) width="300" height="200" alt="Google Chart" title="Sexy chart" \/>/) end it "should be available as an image tag using custom css id selector" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :id => 'chart')).to match(/<img id="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom css class selector" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart')).to match(/<img class="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should use ampersands to separate key/value pairs in URLs by default" do expect(Gchart.line(:data => [0, 26])).to include "&" expect(Gchart.line(:data => [0, 26])).not_to include "&amp;" end it "should escape ampersands in URLs when used as an image tag" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart')).to satisfy {|chart| expect(chart).to include "&amp;" } end it "should be available as a file" do File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file') expect(File.exist?('chart.png')).to be File.delete('chart.png') if File.exist?('chart.png') end it "should be available as a file using a custom file name" do File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') Gchart.line(:data => [0, 26], :format => 'file', :filename => 'custom_file_name.png') expect(File.exist?('custom_file_name.png')).to be File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') end it "should work even with multiple attrs" do File.delete('foo.png') if File.exist?('foo.png') Gchart.line(:size => '400x200', :data => [1,2,3,4,5], # :axis_labels => [[1,2,3,4, 5], %w[foo bar]], :axis_with_labels => 'x,r', :format => "file", :filename => "foo.png" ) expect(File.exist?('foo.png')).to be File.delete('foo.png') if File.exist?('foo.png') end end describe 'SSL support' do it 'should change url if is presented' do expect(Gchart.line(:use_ssl => true)).to include('https://chart.googleapis.com/chart?') end it "should be available as a file" do pending "unexpected error under Travis CI (should be fixed using http://martinottenwaelter.fr/2010/12/ruby19-and-the-ssl-error/)" File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file', :use_ssl => true) expect(File.exist?('chart.png')).to be_true File.delete('chart.png') if File.exist?('chart.png') end end
mattetti/googlecharts
2df68b5d029f229793d0a97657d00853b8466d19
Add pie_c type for concentric pie charts.
diff --git a/lib/gchart.rb b/lib/gchart.rb index 03f39d5..8b61268 100644 --- a/lib/gchart.rb +++ b/lib/gchart.rb @@ -1,736 +1,737 @@ $:.unshift File.dirname(__FILE__) require 'gchart/version' require 'gchart/theme' require "net/http" require "net/https" require "uri" require "cgi" require 'enumerator' class Gchart include GchartInfo def self.url(use_ssl = false) if use_ssl 'https://chart.googleapis.com/chart?' else 'http://chart.apis.google.com/chart?' end end def self.types - @types ||= ['line', 'line_xy', 'scatter', 'bar', 'venn', 'pie', 'pie_3d', 'jstize', 'sparkline', 'meter', 'map', 'radar'] + @types ||= ['line', 'line_xy', 'scatter', 'bar', 'venn', 'pie', 'pie_3d', 'pie_c', 'jstize', 'sparkline', 'meter', 'map', 'radar'] end def self.simple_chars @simple_chars ||= ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a end def self.chars @chars ||= simple_chars + ['-', '.'] end def self.ext_pairs @ext_pairs ||= chars.map { |char_1| chars.map { |char_2| char_1 + char_2 } }.flatten end def self.default_filename 'chart.png' end attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :overlapped, :legend, :legend_position, :labels, :data, :encoding, :bar_colors, :title_color, :title_size, :title_alignment, :custom, :axis_with_labels, :custom_axis_with_labels, :axis_labels, :bar_width_and_spacing, :id, :alt, :klass, :range_markers, :geographical_area, :map_colors, :country_codes, :axis_range, :filename, :min, :max, :colors, :usemap attr_accessor :bg_type, :bg_color, :bg_angle, :chart_type, :chart_color, :chart_angle, :axis_range, :thickness, :new_markers, :grid_lines, :use_ssl attr_accessor :min_value, :max_value types.each do |type| instance_eval <<-DYNCLASSMETH def #{type}(options = {}) # Start with theme defaults if a theme is set theme = options[:theme] options = theme ? Chart::Theme.load(theme).to_options.merge(options) : options # # Extract the format and optional filename, then clean the hash format = options[:format] || 'url' options[:filename] ||= default_filename options.delete(:format) #update map_colors to become bar_colors options.update(:bar_colors => options[:map_colors]) if options.has_key?(:map_colors) chart = new(options.merge!({:type => "#{type}"})) chart.send(format) end DYNCLASSMETH end def self.version VERSION::STRING end def self.method_missing(m, options={}) raise NoMethodError, "#{m} is not a supported chart format. Please use one of the following: #{supported_types}." end def initialize(options={}) # Allow Gchart to take a theme too @theme = options[:theme] options = @theme ? Chart::Theme.load(@theme).to_options.merge(options) : options options.delete(:theme) @type = options[:type] || 'line' @data = [] @width = 300 @height = 200 @curved = false @horizontal = false @grouped = false @overlapped = false @use_ssl = false @encoding = 'simple' # @max_value = 'auto' # @min_value defaults to nil meaning zero @filename = options[:filename] # Sets the alt tag when chart is exported as image tag @alt = 'Google Chart' # Sets the CSS id selector when chart is exported as image tag @id = false # Sets the CSS class selector when chart is exported as image tag @klass = options[:class] || false # set the options value if definable options.each do |attribute, value| send("#{attribute}=", value) if self.respond_to?("#{attribute}=") end end def self.supported_types self.types.join(' ') end # Defines the Graph size using the following format: # width X height def size=(size='300x200') @width, @height = size.split("x").map { |dimension| dimension.to_i } end def size "#{width}x#{height}" end def dimensions # TODO: maybe others? [:line_xy, :scatter].include?(type) ? 2 : 1 end # Sets the orientation of a bar graph def orientation=(orientation='h') if orientation == 'h' || orientation == 'horizontal' self.horizontal = true elsif orientation == 'v' || orientation == 'vertical' self.horizontal = false end end def bar_presentation if @overlapped 'o' elsif @grouped 'g' else 's' end end def bg=(options) if options.is_a?(String) @bg_color = options elsif options.is_a?(Hash) @bg_color = options[:color] @bg_type = options[:type] @bg_angle = options[:angle] end end def graph_bg=(options) if options.is_a?(String) @chart_color = options elsif options.is_a?(Hash) @chart_color = options[:color] @chart_type = options[:type] @chart_angle = options[:angle] end end def max_value=(max_v) if max_v =~ /false/ @max_value = false else @max_value = max_v end end def min_value=(min_v) if min_v =~ /false/ @min_value = false else @min_value = min_v end end # returns the full data range as an array # it also sets the data range if not defined def full_data_range(ds) return if max_value == false ds.each_with_index do |mds, mds_index| mds[:min_value] ||= min_value mds[:max_value] ||= max_value if mds_index == 0 && type.to_s == 'bar' # TODO: unless you specify a zero line (using chp or chds), # the min_value of a bar chart is always 0. #mds[:min_value] ||= mds[:data].first.to_a.compact.min mds[:min_value] ||= 0 end if (mds_index == 0 && type.to_s == 'bar' && !grouped && mds[:data].first.is_a?(Array)) totals = [] mds[:data].each do |l| l.each_with_index do |v, index| next if v.nil? totals[index] ||= 0 totals[index] += v end end mds[:max_value] ||= totals.compact.max else all = mds[:data].flatten.compact # default min value should be 0 unless set to auto if mds[:min_value] == 'auto' mds[:min_value] = all.min else min = all.min mds[:min_value] ||= (min && min < 0 ? min : 0) end mds[:max_value] ||= all.max end end unless axis_range @calculated_axis_range = true @axis_range = ds.map{|mds| [mds[:min_value], mds[:max_value]]} if dimensions == 1 && (type.to_s != 'bar' || horizontal) tmp = axis_range.fetch(0, []) @axis_range[0] = axis_range.fetch(1, []) @axis_range[1] = tmp end end # return [min, max] unless (min.nil? || max.nil?) # @max = (max_value.nil? || max_value == 'auto') ? ds.compact.map{|mds| mds.compact.max}.max : max_value # # if min_value.nil? # min_ds_value = ds.compact.map{|mds| mds.compact.min}.min || 0 # @min = (min_ds_value < 0) ? min_ds_value : 0 # else # @min = min_value == 'auto' ? ds.compact.map{|mds| mds.compact.min}.min || 0 : min_value # end # @axis_range = [[min,max]] end def dataset if @dataset @dataset else @dataset = convert_dataset(data || []) full_data_range(@dataset) # unless axis_range @dataset end end # Sets of data to handle multiple sets def datasets datasets = [] dataset.each do |d| if d[:data].first.is_a?(Array) datasets += d[:data] else datasets << d[:data] end end datasets end def self.jstize(string) # See http://github.com/mattetti/googlecharts/issues#issue/27 #URI.escape( string ).gsub("%7C", "|") # See discussion: http://github.com/mattetti/googlecharts/commit/9b5cfb93aa51aae06611057668e631cd515ec4f3#comment_51347 string.gsub(' ', '+').gsub(/\[|\{|\}|\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} #string.gsub(' ', '+').gsub(/\[|\{|\}|\||\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} end # load all the custom aliases require 'gchart/aliases' # Returns the chart's generated PNG as a blob. (borrowed from John's gchart.rubyforge.org) def fetch url = URI.parse(self.class.url(use_ssl)) req = Net::HTTP::Post.new(url.path) req.body = query_builder req.content_type = 'application/x-www-form-urlencoded' http = Net::HTTP.new(url.host, url.port) http.verify_mode = OpenSSL::SSL::VERIFY_PEER if use_ssl http.use_ssl = use_ssl http.start {|resp| resp.request(req) }.body end # Writes the chart's generated PNG to a file. (borrowed from John's gchart.rubyforge.org) def write io_or_file = filename || self.class.default_filename return io_or_file.write(fetch) if io_or_file.respond_to?(:write) open(io_or_file, "wb+") { |io| io.write(fetch) } end # Format def image_tag image = "<img" image += " id=\"#{id}\"" if id image += " class=\"#{klass}\"" if klass image += " src=\"#{url_builder(:html)}\"" image += " width=\"#{width}\"" image += " height=\"#{height}\"" image += " alt=\"#{alt}\"" image += " title=\"#{title}\"" if title image += " usemap=\"#{usemap}\"" if usemap image += " />" end alias_method :img_tag, :image_tag def url url_builder end def file write end # def jstize(string) self.class.jstize(string) end private # The title size cannot be set without specifying a color. # A dark key will be used for the title color if no color is specified def set_title title_params = "chtt=#{title}".gsub(/\|/,"\n") unless (title_color.nil? && title_size.nil? && title_alignment.nil?) title_params << "&chts=" + (color, size, alignment = (title_color || '454545'), title_size, (title_alignment.to_s[0,1] || 'c')).compact.join(',') end title_params end def set_size "chs=#{size}" end def set_data data = send("#{@encoding}_encoding") "chd=#{data}" end def set_colors @bg_type = fill_type(bg_type) || 's' if bg_color @chart_type = fill_type(chart_type) || 's' if chart_color "chf=" + {'bg' => fill_for(bg_type, bg_color, bg_angle), 'c' => fill_for(chart_type, chart_color, chart_angle)}.map{|k,v| "#{k},#{v}" unless v.nil?}.compact.join('|') end # set bar, line colors def set_bar_colors @bar_colors = bar_colors.join(',') if bar_colors.is_a?(Array) "chco=#{bar_colors}" end def set_country_codes @country_codes = country_codes.join() if country_codes.is_a?(Array) "chld=#{country_codes}" end # set bar spacing # chbh= # <bar width in pixels>, # <optional space between bars in a group>, # <optional space between groups> def set_bar_width_and_spacing width_and_spacing_values = case bar_width_and_spacing when String bar_width_and_spacing when Array bar_width_and_spacing.join(',') when Hash width = bar_width_and_spacing[:width] || 23 spacing = bar_width_and_spacing[:spacing] || 4 group_spacing = bar_width_and_spacing[:group_spacing] || 8 [width,spacing,group_spacing].join(',') else bar_width_and_spacing.to_s end "chbh=#{width_and_spacing_values}" end def set_range_markers markers = case range_markers when Hash set_range_marker(range_markers) when Array range_markers.collect{|marker| set_range_marker(marker)}.join('|') end "chm=#{markers}" end def set_range_marker(options) orientation = ['vertical', 'Vertical', 'V', 'v', 'R'].include?(options[:orientation]) ? 'R' : 'r' "#{orientation},#{options[:color]},0,#{options[:start_position]},#{options[:stop_position]}#{',1' if options[:overlaid?]}" end def fill_for(type=nil, color='', angle=nil) unless type.nil? case type when 'lg' angle ||= 0 color = "#{color},0,ffffff,1" if color.split(',').size == 1 "#{type},#{angle},#{color}" when 'ls' angle ||= 90 color = "#{color},0.2,ffffff,0.2" if color.split(',').size == 1 "#{type},#{angle},#{color}" else "#{type},#{color}" end end end # A chart can have one or many legends. # Gchart.line(:legend => 'label') # or # Gchart.line(:legend => ['first label', 'last label']) def set_legend if type.to_s =~ /meter/ @labels = legend return set_labels end if legend.is_a?(Array) "chdl=#{@legend.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chdl=#{legend}" end end def set_legend_position case @legend_position.to_s when /(bottom|b)$/ "chdlp=b" when /(bottom_vertical|bv)$/ "chdlp=bv" when /(top|t)$/ "chdlp=t" when /(top_vertical|tv)$/ "chdlp=tv" when /(right|r)$/ "chdlp=r" when /(left|l)$/ "chdlp=l" end end def set_line_thickness "chls=#{thickness}" end def set_line_markers "chm=#{new_markers}" end def set_grid_lines "chg=#{grid_lines}" end def set_labels if labels.is_a?(Array) "chl=#{@labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chl=#{@labels}" end end def set_axis_with_labels @axis_with_labels = axis_with_labels.join(',') if @axis_with_labels.is_a?(Array) "chxt=#{axis_with_labels}" end def set_custom_axis_with_labels @custom_axis_with_labels = custom_axis_with_labels.join(',') if @custom_axis_with_labels.is_a?(Array) "chxp=#{custom_axis_with_labels}" end def set_axis_labels if axis_labels.is_a?(Array) if RUBY_VERSION.to_f < 1.9 labels_arr = axis_labels.enum_with_index.map{|labels,index| [index,labels]} else labels_arr = axis_labels.map.with_index.map{|labels,index| [index,labels]} end elsif axis_labels.is_a?(Hash) labels_arr = axis_labels.to_a end labels_arr.map! do |index,labels| if labels.is_a?(Array) "#{index}:|#{labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "#{index}:|#{labels}" end end "chxl=#{labels_arr.join('|')}" end # http://code.google.com/apis/chart/labels.html#axis_range # Specify a range for axis labels def set_axis_range # a passed axis_range should look like: # [[10,100]] or [[10,100,4]] or [[10,100], [20,300]] # in the second example, 4 is the interval set = @calculated_axis_range ? datasets : axis_range || datasets return unless set && set.respond_to?(:each) && set.find {|o| o}.respond_to?(:each) 'chxr=' + set.enum_for(:each_with_index).map do |axis_range, index| next nil if axis_range.nil? # ignore this axis min, max, step = axis_range if axis_range.size > 3 || step && max && step > max # this is a full series max = axis_range.compact.max step = nil end [index, (min_value || min || 0), (max_value || max), step].compact.join(',') end.compact.join("|") end def set_geographical_area "chtm=#{geographical_area}" end def set_type 'cht=' + case type.to_s when 'line' then "lc" when 'line_xy' then "lxy" when 'pie_3d' then "p3" + when 'pie_c' then "pc" when 'pie' then "p" when 'venn' then "v" when 'scatter' then "s" when 'sparkline' then "ls" when 'meter' then "gom" when 'map' then "t" when 'radar' "r" + (curved? ? 's' : '') when 'bar' "b" + (horizontal? ? "h" : "v") + bar_presentation end end def fill_type(type) case type when 'solid' then 's' when 'gradient' then 'lg' when 'stripes' then 'ls' end end def number_visible n = 0 dataset.each do |mds| return n.to_s if mds[:invisible] == true if mds[:data].first.is_a?(Array) n += mds[:data].length else n += 1 end end "" end # Turns input into an array of axis hashes, dependent on the chart type def convert_dataset(ds) if dimensions == 2 # valid inputs include: # an array of >=2 arrays, or an array of >=2 hashes ds = ds.map do |d| d.is_a?(Hash) ? d : {:data => d} end elsif dimensions == 1 # valid inputs include: # a hash, an array of data, an array of >=1 array, or an array of >=1 hash if ds.is_a?(Hash) ds = [ds] elsif not ds.first.is_a?(Hash) ds = [{:data => ds}] end end ds end # just an alias def axis_set dataset end def convert_to_simple_value(number) if number.nil? "_" else value = self.class.simple_chars[number.to_i] value.nil? ? "_" : value end end def convert_to_extended_value(number) if number.nil? '__' else value = self.class.ext_pairs[number.to_i] value.nil? ? "__" : value end end def encode_scaled_dataset(chars, nil_char) dsets = [] dataset.each do |ds| if max_value != false range = ds[:max_value] - ds[:min_value] range = 1 if range == 0 end unless ds[:data].first.is_a?(Array) ldatasets = [ds[:data]] else ldatasets = ds[:data] end ldatasets.each do |l| dsets << l.map do |number| if number.nil? nil_char else unless range.nil? || range.zero? number = chars.size * (number - ds[:min_value]) / range.to_f number = [number, chars.size - 1].min end chars[number.to_i] end end.join end end dsets.join(',') end # http://code.google.com/apis/chart/#simple # Simple encoding has a resolution of 62 different values. # Allowing five pixels per data point, this is sufficient for line and bar charts up # to about 300 pixels. Simple encoding is suitable for all other types of chart regardless of size. def simple_encoding "s" + number_visible + ":" + encode_scaled_dataset(self.class.simple_chars, '_') end # http://code.google.com/apis/chart/#text # Text encoding with data scaling lets you specify arbitrary positive or # negative floating point numbers, in combination with a scaling parameter # that lets you specify a custom range for your chart. This chart is useful # when you don't want to worry about limiting your data to a specific range, # or do the calculations to scale your data down or up to fit nicely inside # a chart. # # Valid values range from (+/-)9.999e(+/-)100, and only four non-zero digits are supported (that is, 123400, 1234, 12.34, and 0.1234 are valid, but 12345, 123.45 and 123400.5 are not). # # This encoding is not available for maps. # def text_encoding chds = dataset.map{|ds| "#{ds[:min_value]},#{ds[:max_value]}" }.join(",") "t" + number_visible + ":" + datasets.map{ |ds| ds.map{|e|e||'_'}.join(',') }.join('|') + "&chds=" + chds end # http://code.google.com/apis/chart/#extended # Extended encoding has a resolution of 4,096 different values # and is best used for large charts where a large data range is required. def extended_encoding "e" + number_visible + ":" + encode_scaled_dataset(self.class.ext_pairs, '__') end def url_builder(options="") self.class.url(use_ssl) + query_builder(options) end def query_builder(options="") query_params = instance_variables.sort.map do |var| case var.to_s when '@data' set_data unless data == [] # Set the graph size when '@width' set_size unless width.nil? || height.nil? when '@type' set_type when '@title' set_title unless title.nil? when '@legend' set_legend unless legend.nil? when '@labels' set_labels unless labels.nil? when '@legend_position' set_legend_position unless legend_position.nil? when '@thickness' set_line_thickness when '@new_markers' set_line_markers when '@bg_color' set_colors when '@chart_color' set_colors if bg_color.nil? when '@bar_colors' set_bar_colors when '@bar_width_and_spacing' set_bar_width_and_spacing when '@axis_with_labels' set_axis_with_labels when '@axis_labels' set_axis_labels when '@range_markers' set_range_markers when '@grid_lines' set_grid_lines when '@custom_axis_with_labels' set_custom_axis_with_labels when '@geographical_area' set_geographical_area when '@country_codes' set_country_codes when '@custom' custom end end.compact query_params << set_axis_range # Use ampersand as default delimiter unless options == :html delimiter = '&' # Escape ampersand for html image tags else delimiter = '&amp;' end jstize(query_params.join(delimiter)) end end
mattetti/googlecharts
a1d0c04fd6923c3c6ff2713a91c5b219044114ca
Add license to gemspec
diff --git a/googlecharts.gemspec b/googlecharts.gemspec index 12b32ff..40c413f 100644 --- a/googlecharts.gemspec +++ b/googlecharts.gemspec @@ -1,20 +1,21 @@ # -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "gchart/version" Gem::Specification.new do |s| s.name = %q{googlecharts} s.version = GchartInfo::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Matt Aimonetti", "Andrey Deryabin", "Pedro Pimentel"] s.date = %q{2014-12-15} s.summary = %q{Generate charts using Google API & Ruby} s.description = %q{Generate charts using Google API & Ruby} s.email = %q{[email protected] [email protected] [email protected]} s.homepage = %q{http://googlecharts.rubyforge.org/} + s.license = 'MIT' s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] end
mattetti/googlecharts
ed8f5d7d54cd139b91119f21011e70a7c9de8c5b
fixes gemspec, yanks 1.6.9 from rubygems, bumps version to 1.6.10
diff --git a/History.txt b/History.txt index eb94e51..9fdb62a 100644 --- a/History.txt +++ b/History.txt @@ -1,67 +1,67 @@ -== 1.6.9 +== 1.6.10 * added support for custom position on axis with label (parameter chxp) * refactored bar chart * fixed issue #44 * allows GChart to take a theme == 1.6.8 * added title alignment support == 1.6.7 * changed url for ssl connection == 1.6.6 * added ssl support * refactored code * аdded ability to set the legend position * fixed legend position value * separated labels and legends for pies == 1.3.6 * support nil values. The Google Charts API specifies that a single underscore (_) can be used to omit a value from a line chart with 'simple' data encoding, and a double underscore (__) can do the same for a chart with 'extended' data encoding. (Matt Moyer) * allow a label to appear on a google-o-meter via the :legend option. (hallettj) == 1.3.5 * added code to properly escape image tag URLs (mokolabs) * added themes support + 4 default themes (keynote, thirty7signals, pastel, greyscale) chart.line(:theme=>:keynote) (jakehow) == 1.3.4 * updated documentation and cleaned it up (mokolabs) * added support for custom class, id and alt tags when using the image_tag format (i.e Gchart.line(:data => [0, 26], :format => 'image_tag')) (mokolabs) == 1.3.2 - 1.3.3 * changes required by github == 1.3.1 * added width and spacing options == 1.3.0 * added support for google-o-meter * fixed a bug when the max value of a data set was 0 == 1.2.0 * added support for sparklines == 1.1.0 * fixed another bug fix related to the uri escaping required to download the file properly. == 1.0.0 * fixed the (URI::InvalidURIError) issue == 0.2.0 * added export options (file and image tag) * added support for all arguments to be passed as a string or an array == 0.1.0 2007-12-11 * fixed the axis labels == 0.0.3 2007-12-11 * added :chart_background alias and fixed a bug related to the background colors. == 0.0.2 2007-12-11 * added support for more features and aliases == 0.0.1 2007-12-08 * 1 major enhancement: * Initial release diff --git a/googlecharts.gemspec b/googlecharts.gemspec index e4c8e02..12b32ff 100644 --- a/googlecharts.gemspec +++ b/googlecharts.gemspec @@ -1,20 +1,20 @@ # -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "gchart/version" Gem::Specification.new do |s| s.name = %q{googlecharts} s.version = GchartInfo::VERSION s.platform = Gem::Platform::RUBY - s.authors = ["Matt Aimonetti", "Andrey Deryabin"] - s.date = %q{2011-05-21} + s.authors = ["Matt Aimonetti", "Andrey Deryabin", "Pedro Pimentel"] + s.date = %q{2014-12-15} s.summary = %q{Generate charts using Google API & Ruby} s.description = %q{Generate charts using Google API & Ruby} - s.email = %q{[email protected] [email protected]} + s.email = %q{[email protected] [email protected] [email protected]} s.homepage = %q{http://googlecharts.rubyforge.org/} s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] end diff --git a/lib/gchart/version.rb b/lib/gchart/version.rb index b64f9fe..3b4c30f 100644 --- a/lib/gchart/version.rb +++ b/lib/gchart/version.rb @@ -1,3 +1,3 @@ module GchartInfo #:nodoc: - VERSION = "1.6.9" + VERSION = "1.6.10" end
mattetti/googlecharts
be7309f6bf495c0e51ed4d0d3882e047e9a6f5d6
Bumps version
diff --git a/History.txt b/History.txt index d1da183..eb94e51 100644 --- a/History.txt +++ b/History.txt @@ -1,61 +1,67 @@ +== 1.6.9 +* added support for custom position on axis with label (parameter chxp) +* refactored bar chart +* fixed issue #44 +* allows GChart to take a theme + == 1.6.8 * added title alignment support == 1.6.7 * changed url for ssl connection == 1.6.6 * added ssl support * refactored code * аdded ability to set the legend position * fixed legend position value * separated labels and legends for pies == 1.3.6 * support nil values. The Google Charts API specifies that a single underscore (_) can be used to omit a value from a line chart with 'simple' data encoding, and a double underscore (__) can do the same for a chart with 'extended' data encoding. (Matt Moyer) * allow a label to appear on a google-o-meter via the :legend option. (hallettj) == 1.3.5 * added code to properly escape image tag URLs (mokolabs) * added themes support + 4 default themes (keynote, thirty7signals, pastel, greyscale) chart.line(:theme=>:keynote) (jakehow) == 1.3.4 * updated documentation and cleaned it up (mokolabs) * added support for custom class, id and alt tags when using the image_tag format (i.e Gchart.line(:data => [0, 26], :format => 'image_tag')) (mokolabs) == 1.3.2 - 1.3.3 * changes required by github == 1.3.1 * added width and spacing options == 1.3.0 * added support for google-o-meter * fixed a bug when the max value of a data set was 0 == 1.2.0 * added support for sparklines == 1.1.0 * fixed another bug fix related to the uri escaping required to download the file properly. == 1.0.0 * fixed the (URI::InvalidURIError) issue == 0.2.0 * added export options (file and image tag) * added support for all arguments to be passed as a string or an array == 0.1.0 2007-12-11 * fixed the axis labels == 0.0.3 2007-12-11 * added :chart_background alias and fixed a bug related to the background colors. == 0.0.2 2007-12-11 * added support for more features and aliases == 0.0.1 2007-12-08 * 1 major enhancement: * Initial release diff --git a/lib/gchart/version.rb b/lib/gchart/version.rb index a71d158..b64f9fe 100644 --- a/lib/gchart/version.rb +++ b/lib/gchart/version.rb @@ -1,3 +1,3 @@ module GchartInfo #:nodoc: - VERSION = "1.6.8" + VERSION = "1.6.9" end
mattetti/googlecharts
01864c9db6dcf3f61912124623e0d153f08bd027
Adds support for custom position on axis with label (parameter chxp)
diff --git a/lib/gchart.rb b/lib/gchart.rb index b275bc3..03f39d5 100644 --- a/lib/gchart.rb +++ b/lib/gchart.rb @@ -1,729 +1,736 @@ $:.unshift File.dirname(__FILE__) require 'gchart/version' require 'gchart/theme' require "net/http" require "net/https" require "uri" require "cgi" require 'enumerator' class Gchart include GchartInfo def self.url(use_ssl = false) if use_ssl 'https://chart.googleapis.com/chart?' else 'http://chart.apis.google.com/chart?' end end def self.types @types ||= ['line', 'line_xy', 'scatter', 'bar', 'venn', 'pie', 'pie_3d', 'jstize', 'sparkline', 'meter', 'map', 'radar'] end def self.simple_chars @simple_chars ||= ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a end def self.chars @chars ||= simple_chars + ['-', '.'] end def self.ext_pairs @ext_pairs ||= chars.map { |char_1| chars.map { |char_2| char_1 + char_2 } }.flatten end def self.default_filename 'chart.png' end attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :overlapped, :legend, :legend_position, :labels, :data, :encoding, :bar_colors, - :title_color, :title_size, :title_alignment, :custom, :axis_with_labels, :axis_labels, :bar_width_and_spacing, :id, :alt, :klass, + :title_color, :title_size, :title_alignment, :custom, :axis_with_labels, :custom_axis_with_labels, :axis_labels, :bar_width_and_spacing, :id, :alt, :klass, :range_markers, :geographical_area, :map_colors, :country_codes, :axis_range, :filename, :min, :max, :colors, :usemap attr_accessor :bg_type, :bg_color, :bg_angle, :chart_type, :chart_color, :chart_angle, :axis_range, :thickness, :new_markers, :grid_lines, :use_ssl attr_accessor :min_value, :max_value types.each do |type| instance_eval <<-DYNCLASSMETH def #{type}(options = {}) # Start with theme defaults if a theme is set theme = options[:theme] options = theme ? Chart::Theme.load(theme).to_options.merge(options) : options # # Extract the format and optional filename, then clean the hash format = options[:format] || 'url' options[:filename] ||= default_filename options.delete(:format) #update map_colors to become bar_colors options.update(:bar_colors => options[:map_colors]) if options.has_key?(:map_colors) chart = new(options.merge!({:type => "#{type}"})) chart.send(format) end DYNCLASSMETH end def self.version VERSION::STRING end def self.method_missing(m, options={}) raise NoMethodError, "#{m} is not a supported chart format. Please use one of the following: #{supported_types}." end def initialize(options={}) # Allow Gchart to take a theme too @theme = options[:theme] options = @theme ? Chart::Theme.load(@theme).to_options.merge(options) : options options.delete(:theme) @type = options[:type] || 'line' @data = [] @width = 300 @height = 200 @curved = false @horizontal = false @grouped = false @overlapped = false @use_ssl = false @encoding = 'simple' # @max_value = 'auto' # @min_value defaults to nil meaning zero @filename = options[:filename] # Sets the alt tag when chart is exported as image tag @alt = 'Google Chart' # Sets the CSS id selector when chart is exported as image tag @id = false # Sets the CSS class selector when chart is exported as image tag @klass = options[:class] || false # set the options value if definable options.each do |attribute, value| send("#{attribute}=", value) if self.respond_to?("#{attribute}=") end end def self.supported_types self.types.join(' ') end # Defines the Graph size using the following format: # width X height def size=(size='300x200') @width, @height = size.split("x").map { |dimension| dimension.to_i } end def size "#{width}x#{height}" end def dimensions # TODO: maybe others? [:line_xy, :scatter].include?(type) ? 2 : 1 end # Sets the orientation of a bar graph def orientation=(orientation='h') if orientation == 'h' || orientation == 'horizontal' self.horizontal = true elsif orientation == 'v' || orientation == 'vertical' self.horizontal = false end end def bar_presentation if @overlapped 'o' elsif @grouped 'g' else 's' end end def bg=(options) if options.is_a?(String) @bg_color = options elsif options.is_a?(Hash) @bg_color = options[:color] @bg_type = options[:type] @bg_angle = options[:angle] end end def graph_bg=(options) if options.is_a?(String) @chart_color = options elsif options.is_a?(Hash) @chart_color = options[:color] @chart_type = options[:type] @chart_angle = options[:angle] end end def max_value=(max_v) if max_v =~ /false/ @max_value = false else @max_value = max_v end end def min_value=(min_v) if min_v =~ /false/ @min_value = false else @min_value = min_v end end # returns the full data range as an array # it also sets the data range if not defined def full_data_range(ds) return if max_value == false ds.each_with_index do |mds, mds_index| mds[:min_value] ||= min_value mds[:max_value] ||= max_value if mds_index == 0 && type.to_s == 'bar' # TODO: unless you specify a zero line (using chp or chds), # the min_value of a bar chart is always 0. #mds[:min_value] ||= mds[:data].first.to_a.compact.min mds[:min_value] ||= 0 end if (mds_index == 0 && type.to_s == 'bar' && !grouped && mds[:data].first.is_a?(Array)) totals = [] mds[:data].each do |l| l.each_with_index do |v, index| next if v.nil? totals[index] ||= 0 totals[index] += v end end mds[:max_value] ||= totals.compact.max else all = mds[:data].flatten.compact # default min value should be 0 unless set to auto if mds[:min_value] == 'auto' mds[:min_value] = all.min else min = all.min mds[:min_value] ||= (min && min < 0 ? min : 0) end mds[:max_value] ||= all.max end end unless axis_range @calculated_axis_range = true @axis_range = ds.map{|mds| [mds[:min_value], mds[:max_value]]} if dimensions == 1 && (type.to_s != 'bar' || horizontal) tmp = axis_range.fetch(0, []) @axis_range[0] = axis_range.fetch(1, []) @axis_range[1] = tmp end end # return [min, max] unless (min.nil? || max.nil?) # @max = (max_value.nil? || max_value == 'auto') ? ds.compact.map{|mds| mds.compact.max}.max : max_value # # if min_value.nil? # min_ds_value = ds.compact.map{|mds| mds.compact.min}.min || 0 # @min = (min_ds_value < 0) ? min_ds_value : 0 # else # @min = min_value == 'auto' ? ds.compact.map{|mds| mds.compact.min}.min || 0 : min_value # end # @axis_range = [[min,max]] end def dataset if @dataset @dataset else @dataset = convert_dataset(data || []) full_data_range(@dataset) # unless axis_range @dataset end end # Sets of data to handle multiple sets def datasets datasets = [] dataset.each do |d| if d[:data].first.is_a?(Array) datasets += d[:data] else datasets << d[:data] end end datasets end def self.jstize(string) # See http://github.com/mattetti/googlecharts/issues#issue/27 #URI.escape( string ).gsub("%7C", "|") # See discussion: http://github.com/mattetti/googlecharts/commit/9b5cfb93aa51aae06611057668e631cd515ec4f3#comment_51347 string.gsub(' ', '+').gsub(/\[|\{|\}|\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} #string.gsub(' ', '+').gsub(/\[|\{|\}|\||\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} end # load all the custom aliases require 'gchart/aliases' # Returns the chart's generated PNG as a blob. (borrowed from John's gchart.rubyforge.org) def fetch url = URI.parse(self.class.url(use_ssl)) req = Net::HTTP::Post.new(url.path) req.body = query_builder req.content_type = 'application/x-www-form-urlencoded' http = Net::HTTP.new(url.host, url.port) http.verify_mode = OpenSSL::SSL::VERIFY_PEER if use_ssl http.use_ssl = use_ssl http.start {|resp| resp.request(req) }.body end # Writes the chart's generated PNG to a file. (borrowed from John's gchart.rubyforge.org) def write io_or_file = filename || self.class.default_filename return io_or_file.write(fetch) if io_or_file.respond_to?(:write) open(io_or_file, "wb+") { |io| io.write(fetch) } end # Format def image_tag image = "<img" image += " id=\"#{id}\"" if id image += " class=\"#{klass}\"" if klass image += " src=\"#{url_builder(:html)}\"" image += " width=\"#{width}\"" image += " height=\"#{height}\"" image += " alt=\"#{alt}\"" image += " title=\"#{title}\"" if title image += " usemap=\"#{usemap}\"" if usemap image += " />" end alias_method :img_tag, :image_tag def url url_builder end def file write end # def jstize(string) self.class.jstize(string) end private # The title size cannot be set without specifying a color. # A dark key will be used for the title color if no color is specified def set_title title_params = "chtt=#{title}".gsub(/\|/,"\n") unless (title_color.nil? && title_size.nil? && title_alignment.nil?) title_params << "&chts=" + (color, size, alignment = (title_color || '454545'), title_size, (title_alignment.to_s[0,1] || 'c')).compact.join(',') end title_params end def set_size "chs=#{size}" end def set_data data = send("#{@encoding}_encoding") "chd=#{data}" end def set_colors @bg_type = fill_type(bg_type) || 's' if bg_color @chart_type = fill_type(chart_type) || 's' if chart_color "chf=" + {'bg' => fill_for(bg_type, bg_color, bg_angle), 'c' => fill_for(chart_type, chart_color, chart_angle)}.map{|k,v| "#{k},#{v}" unless v.nil?}.compact.join('|') end # set bar, line colors def set_bar_colors @bar_colors = bar_colors.join(',') if bar_colors.is_a?(Array) "chco=#{bar_colors}" end def set_country_codes @country_codes = country_codes.join() if country_codes.is_a?(Array) "chld=#{country_codes}" end # set bar spacing # chbh= # <bar width in pixels>, # <optional space between bars in a group>, # <optional space between groups> def set_bar_width_and_spacing width_and_spacing_values = case bar_width_and_spacing when String bar_width_and_spacing when Array bar_width_and_spacing.join(',') when Hash width = bar_width_and_spacing[:width] || 23 spacing = bar_width_and_spacing[:spacing] || 4 group_spacing = bar_width_and_spacing[:group_spacing] || 8 [width,spacing,group_spacing].join(',') else bar_width_and_spacing.to_s end "chbh=#{width_and_spacing_values}" end def set_range_markers markers = case range_markers when Hash set_range_marker(range_markers) when Array range_markers.collect{|marker| set_range_marker(marker)}.join('|') end "chm=#{markers}" end def set_range_marker(options) orientation = ['vertical', 'Vertical', 'V', 'v', 'R'].include?(options[:orientation]) ? 'R' : 'r' "#{orientation},#{options[:color]},0,#{options[:start_position]},#{options[:stop_position]}#{',1' if options[:overlaid?]}" end def fill_for(type=nil, color='', angle=nil) unless type.nil? case type when 'lg' angle ||= 0 color = "#{color},0,ffffff,1" if color.split(',').size == 1 "#{type},#{angle},#{color}" when 'ls' angle ||= 90 color = "#{color},0.2,ffffff,0.2" if color.split(',').size == 1 "#{type},#{angle},#{color}" else "#{type},#{color}" end end end # A chart can have one or many legends. # Gchart.line(:legend => 'label') # or # Gchart.line(:legend => ['first label', 'last label']) def set_legend if type.to_s =~ /meter/ @labels = legend return set_labels end if legend.is_a?(Array) "chdl=#{@legend.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chdl=#{legend}" end end def set_legend_position case @legend_position.to_s when /(bottom|b)$/ "chdlp=b" when /(bottom_vertical|bv)$/ "chdlp=bv" when /(top|t)$/ "chdlp=t" when /(top_vertical|tv)$/ "chdlp=tv" when /(right|r)$/ "chdlp=r" when /(left|l)$/ "chdlp=l" end end def set_line_thickness "chls=#{thickness}" end def set_line_markers "chm=#{new_markers}" end def set_grid_lines "chg=#{grid_lines}" end def set_labels if labels.is_a?(Array) "chl=#{@labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chl=#{@labels}" end end def set_axis_with_labels @axis_with_labels = axis_with_labels.join(',') if @axis_with_labels.is_a?(Array) "chxt=#{axis_with_labels}" end + def set_custom_axis_with_labels + @custom_axis_with_labels = custom_axis_with_labels.join(',') if @custom_axis_with_labels.is_a?(Array) + "chxp=#{custom_axis_with_labels}" + end + def set_axis_labels if axis_labels.is_a?(Array) if RUBY_VERSION.to_f < 1.9 labels_arr = axis_labels.enum_with_index.map{|labels,index| [index,labels]} else labels_arr = axis_labels.map.with_index.map{|labels,index| [index,labels]} end elsif axis_labels.is_a?(Hash) labels_arr = axis_labels.to_a end labels_arr.map! do |index,labels| if labels.is_a?(Array) "#{index}:|#{labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "#{index}:|#{labels}" end end "chxl=#{labels_arr.join('|')}" end # http://code.google.com/apis/chart/labels.html#axis_range # Specify a range for axis labels def set_axis_range # a passed axis_range should look like: # [[10,100]] or [[10,100,4]] or [[10,100], [20,300]] # in the second example, 4 is the interval set = @calculated_axis_range ? datasets : axis_range || datasets return unless set && set.respond_to?(:each) && set.find {|o| o}.respond_to?(:each) 'chxr=' + set.enum_for(:each_with_index).map do |axis_range, index| next nil if axis_range.nil? # ignore this axis min, max, step = axis_range if axis_range.size > 3 || step && max && step > max # this is a full series max = axis_range.compact.max step = nil end [index, (min_value || min || 0), (max_value || max), step].compact.join(',') end.compact.join("|") end def set_geographical_area "chtm=#{geographical_area}" end def set_type 'cht=' + case type.to_s when 'line' then "lc" when 'line_xy' then "lxy" when 'pie_3d' then "p3" when 'pie' then "p" when 'venn' then "v" when 'scatter' then "s" when 'sparkline' then "ls" when 'meter' then "gom" when 'map' then "t" when 'radar' "r" + (curved? ? 's' : '') when 'bar' "b" + (horizontal? ? "h" : "v") + bar_presentation end end def fill_type(type) case type when 'solid' then 's' when 'gradient' then 'lg' when 'stripes' then 'ls' end end def number_visible n = 0 dataset.each do |mds| return n.to_s if mds[:invisible] == true if mds[:data].first.is_a?(Array) n += mds[:data].length else n += 1 end end "" end # Turns input into an array of axis hashes, dependent on the chart type def convert_dataset(ds) if dimensions == 2 # valid inputs include: # an array of >=2 arrays, or an array of >=2 hashes ds = ds.map do |d| d.is_a?(Hash) ? d : {:data => d} end elsif dimensions == 1 # valid inputs include: # a hash, an array of data, an array of >=1 array, or an array of >=1 hash if ds.is_a?(Hash) ds = [ds] elsif not ds.first.is_a?(Hash) ds = [{:data => ds}] end end ds end # just an alias def axis_set dataset end def convert_to_simple_value(number) if number.nil? "_" else value = self.class.simple_chars[number.to_i] value.nil? ? "_" : value end end def convert_to_extended_value(number) if number.nil? '__' else value = self.class.ext_pairs[number.to_i] value.nil? ? "__" : value end end def encode_scaled_dataset(chars, nil_char) dsets = [] dataset.each do |ds| if max_value != false range = ds[:max_value] - ds[:min_value] range = 1 if range == 0 end unless ds[:data].first.is_a?(Array) ldatasets = [ds[:data]] else ldatasets = ds[:data] end ldatasets.each do |l| dsets << l.map do |number| if number.nil? nil_char else unless range.nil? || range.zero? number = chars.size * (number - ds[:min_value]) / range.to_f number = [number, chars.size - 1].min end chars[number.to_i] end end.join end end dsets.join(',') end # http://code.google.com/apis/chart/#simple # Simple encoding has a resolution of 62 different values. # Allowing five pixels per data point, this is sufficient for line and bar charts up # to about 300 pixels. Simple encoding is suitable for all other types of chart regardless of size. def simple_encoding "s" + number_visible + ":" + encode_scaled_dataset(self.class.simple_chars, '_') end # http://code.google.com/apis/chart/#text # Text encoding with data scaling lets you specify arbitrary positive or # negative floating point numbers, in combination with a scaling parameter # that lets you specify a custom range for your chart. This chart is useful # when you don't want to worry about limiting your data to a specific range, # or do the calculations to scale your data down or up to fit nicely inside # a chart. # # Valid values range from (+/-)9.999e(+/-)100, and only four non-zero digits are supported (that is, 123400, 1234, 12.34, and 0.1234 are valid, but 12345, 123.45 and 123400.5 are not). # # This encoding is not available for maps. # def text_encoding chds = dataset.map{|ds| "#{ds[:min_value]},#{ds[:max_value]}" }.join(",") "t" + number_visible + ":" + datasets.map{ |ds| ds.map{|e|e||'_'}.join(',') }.join('|') + "&chds=" + chds end # http://code.google.com/apis/chart/#extended # Extended encoding has a resolution of 4,096 different values # and is best used for large charts where a large data range is required. def extended_encoding "e" + number_visible + ":" + encode_scaled_dataset(self.class.ext_pairs, '__') end def url_builder(options="") self.class.url(use_ssl) + query_builder(options) end def query_builder(options="") query_params = instance_variables.sort.map do |var| case var.to_s when '@data' set_data unless data == [] # Set the graph size when '@width' set_size unless width.nil? || height.nil? when '@type' set_type when '@title' set_title unless title.nil? when '@legend' set_legend unless legend.nil? when '@labels' set_labels unless labels.nil? when '@legend_position' set_legend_position unless legend_position.nil? when '@thickness' set_line_thickness when '@new_markers' set_line_markers when '@bg_color' set_colors when '@chart_color' set_colors if bg_color.nil? when '@bar_colors' set_bar_colors when '@bar_width_and_spacing' set_bar_width_and_spacing when '@axis_with_labels' set_axis_with_labels when '@axis_labels' set_axis_labels when '@range_markers' set_range_markers when '@grid_lines' set_grid_lines + when '@custom_axis_with_labels' + set_custom_axis_with_labels when '@geographical_area' set_geographical_area when '@country_codes' set_country_codes when '@custom' custom end end.compact query_params << set_axis_range # Use ampersand as default delimiter unless options == :html delimiter = '&' # Escape ampersand for html image tags else delimiter = '&amp;' end jstize(query_params.join(delimiter)) end end diff --git a/spec/gchart_spec.rb b/spec/gchart_spec.rb index a7c073d..cf369a6 100644 --- a/spec/gchart_spec.rb +++ b/spec/gchart_spec.rb @@ -1,665 +1,684 @@ require File.dirname(__FILE__) + '/spec_helper.rb' require File.dirname(__FILE__) + '/../lib/gchart' Chart::Theme.add_theme_file("#{File.dirname(__FILE__)}/fixtures/test_theme.yml") # Time to add your specs! # http://rspec.rubyforge.org/ describe "The Gchart class" do it "should show supported_types on error" do expect(Gchart.supported_types).to match(/line/) end it "should return supported types" do expect(Gchart.types).to include('line') end it "should support theme option" do chart = Gchart.new(:type => 'line',:theme => :test) expect(chart.send('url')).to include('chco=6886B4,FDD84E') end end describe "generating a default Gchart" do before(:each) do @chart = Gchart.line end it "should create a line break when a pipe character is encountered" do @chart = Gchart.line(:title => "title|subtitle") expect(@chart).to include("chtt=title\nsubtitle") end it "should include the Google URL" do expect(@chart).to include("http://chart.apis.google.com/chart?") end it "should have a default size" do expect(@chart).to include('chs=300x200') end it "should be able to have a custom size" do expect(Gchart.line(:size => '400x600')).to include('chs=400x600') expect(Gchart.line(:width => 400, :height => 600)).to include('chs=400x600') end it "should have query parameters in predictable order" do expect(Gchart.line(:axis_with_labels => 'x,y,r', :size => '400x600')).to match(/chxt=.+cht=.+chs=/) end it "should have a type" do expect(@chart).to include('cht=lc') end it 'should use theme defaults if theme is set' do expect(Gchart.line(:theme=>:test)).to include('chco=6886B4,FDD84E') expect(Gchart.line(:theme=>:test)).to match(/chf=(c,s,FFFFFF\|bg,s,FFFFFF|bg,s,FFFFFF\|c,s,FFFFFF)/) end it "should use the simple encoding by default with auto max value" do # 9 is the max value in simple encoding, 26 being our max value the 2nd encoded value should be 9 expect(Gchart.line(:data => [0, 26])).to include('chd=s:A9') expect(Gchart.line(:data => [0, 26], :max_value => 26, :axis_with_labels => 'y')).to include('chxr=0,0,26') end it "should support simple encoding with and without max_value" do expect(Gchart.line(:data => [0, 26], :max_value => 26)).to include('chd=s:A9') expect(Gchart.line(:data => [0, 26], :max_value => false)).to include('chd=s:Aa') end it "should support the extended encoding and encode properly" do expect(Gchart.line(:data => [0, 10], :encoding => 'extended', :max_value => false)).to include('chd=e:AA') expect(Gchart.line(:encoding => 'extended', :max_value => false, :data => [[0,25,26,51,52,61,62,63], [64,89,90,115,4084]] )).to include('chd=e:AAAZAaAzA0A9A-A.,BABZBaBz.0') end it "should auto set the max value for extended encoding" do expect(Gchart.line(:data => [0, 25], :encoding => 'extended', :max_value => false)).to include('chd=e:AAAZ') # Extended encoding max value is '..' expect(Gchart.line(:data => [0, 25], :encoding => 'extended')).to include('chd=e:AA..') end it "should be able to have data with text encoding" do expect(Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text')).to include('chd=t:10,5.2,4,45,78') end it "should be able to have missing data points with text encoding" do expect(Gchart.line(:data => [10, 5.2, nil, 45, 78], :encoding => 'text')).to include('chd=t:10,5.2,_,45,78') end it "should handle max and min values with text encoding" do expect(Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text')).to include('chds=0,78') end it "should automatically handle negative values with proper max/min limits when using text encoding" do expect(Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text')).to include('chds=-10,78') end it "should handle negative values with manual max/min limits when using text encoding" do expect(Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text', :min_value => -20, :max_value => 100)).to include('chds=-20,100') end it "should set the proper axis values when using text encoding and negative values" do expect(Gchart.bar( :data => [[-10], [100]], :encoding => 'text', :horizontal => true, :min_value => -20, :max_value => 100, :axis_with_labels => 'x', :bar_colors => ['FD9A3B', '4BC7DC'])).to include("chxr=0,-20,100") end it "should be able to have multiple set of data with text encoding" do expect(Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text')).to include(Gchart.jstize('chd=t:10,5.2,4,45,78|20,40,70,15,99')) end it "should be able to receive a custom param" do expect(Gchart.line(:custom => 'ceci_est_une_pipe')).to include('ceci_est_une_pipe') end it "should be able to set label axis" do expect(Gchart.line(:axis_with_labels => 'x,y,r')).to include('chxt=x,y,r') expect(Gchart.line(:axis_with_labels => ['x','y','r'])).to include('chxt=x,y,r') end it "should be able to have axis labels" do expect(Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007'])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')) expect(Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan'])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')) expect(Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')) expect(Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')) end def labeled_line(options = {}) Gchart.line({:data => @data, :axis_with_labels => 'x,y'}.merge(options)) end it "should display ranges properly" do @data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] expect(labeled_line(:axis_labels => [((1..24).to_a << 1)])). to include('chxr=0,85,672') end def labeled_bar(options = {}) Gchart.bar({:data => @data, :axis_with_labels => 'x,y', :axis_labels => [(1..12).to_a], :encoding => "text" }.merge(options)) end it "should force the y range properly" do @data = [1,1,1,1,1,1,1,1,6,2,1,1] expect(labeled_bar( :axis_range => [[0,0],[0,16]] )).to include('chxr=0,0,0|1,0,16') expect(labeled_bar( :max_value => 16, :axis_range => [[0,0],[0,16]] )).to include('chxr=0,0,16|1,0,16') # nil means ignore axis expect(labeled_bar( :axis_range => [nil,[0,16]] )).to include('chxr=1,0,16') # empty array means take defaults expect(labeled_bar( :max_value => 16, :axis_range => [[],[0,16]] )).to include('chxr=0,0,16|1,0,16') expect(labeled_bar( :axis_range => [[],[0,16]] )).to include('chxr=0,0|1,0,16') expect(Gchart.line( :data => [0,20, 40, 60, 140, 230, 60], :axis_with_labels => 'y')).to include("chxr=0,0,230") end it "should take in consideration the max value when creating a range" do data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] url = Gchart.line(:data => data, :axis_with_labels => 'x,y', :axis_labels => [((1..24).to_a << 1)], :max_value => 700) expect(url).to include('chxr=0,85,700') end it 'should generate different labels and legend' do expect(Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three))).to(include('chdl=1|2|3') && include('chl=one|two|three')) end end describe "generating different type of charts" do it "should be able to generate a line chart" do expect(Gchart.line).to be_an_instance_of(String) expect(Gchart.line).to include('cht=lc') end it "should be able to generate a sparkline chart" do expect(Gchart.sparkline).to be_an_instance_of(String) expect(Gchart.sparkline).to include('cht=ls') end it "should be able to generate a line xy chart" do expect(Gchart.line_xy).to be_an_instance_of(String) expect(Gchart.line_xy).to include('cht=lxy') end it "should be able to generate a scatter chart" do expect(Gchart.scatter).to be_an_instance_of(String) expect(Gchart.scatter).to include('cht=s') end it "should be able to generate a bar chart" do expect(Gchart.bar).to be_an_instance_of(String) expect(Gchart.bar).to include('cht=bvs') end it "should be able to generate a Venn diagram" do expect(Gchart.venn).to be_an_instance_of(String) expect(Gchart.venn).to include('cht=v') end it "should be able to generate a Pie Chart" do expect(Gchart.pie).to be_an_instance_of(String) expect(Gchart.pie).to include('cht=p') end it "should be able to generate a Google-O-Meter" do expect(Gchart.meter).to be_an_instance_of(String) expect(Gchart.meter).to include('cht=gom') end it "should be able to generate a map chart" do expect(Gchart.map).to be_an_instance_of(String) expect(Gchart.map).to include('cht=t') end it "should not support other types" do msg = "sexy is not a supported chart format. Please use one of the following: #{Gchart.supported_types}." expect{Gchart.sexy}.to raise_error(NoMethodError) end end describe "range markers" do it "should be able to generate given a hash of range-marker options" do expect(Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'})).to include('chm=r,ff0000,0,0.59,0.61') end it "should be able to generate given an array of range-marker hash options" do expect(Gchart.line(:range_markers => [ {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}, {:start_position => 0, :stop_position => 0.6, :color => '666666'}, {:color => 'cccccc', :start_position => 0.6, :stop_position => 1} ])).to include(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1')) end it "should allow a :overlaid? to be set" do expect(Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true})).to include('chm=r,ffffff,0,0.59,0.61,1') expect(Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false})).to include('chm=r,ffffff,0,0.59,0.61') end describe "when setting the orientation option" do before(:each) do @options = {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'} end it "to vertical (R) if given a valid option" do expect(Gchart.line(:range_markers => @options.merge(:orientation => 'v'))).to include('chm=R') expect(Gchart.line(:range_markers => @options.merge(:orientation => 'V'))).to include('chm=R') expect(Gchart.line(:range_markers => @options.merge(:orientation => 'R'))).to include('chm=R') expect(Gchart.line(:range_markers => @options.merge(:orientation => 'vertical'))).to include('chm=R') expect(Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical'))).to include('chm=R') end it "to horizontal (r) if given a valid option (actually anything other than the vertical options)" do expect(Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal'))).to include('chm=r') expect(Gchart.line(:range_markers => @options.merge(:orientation => 'h'))).to include('chm=r') expect(Gchart.line(:range_markers => @options.merge(:orientation => 'etc'))).to include('chm=r') end it "if left blank defaults to horizontal (r)" do expect(Gchart.line(:range_markers => @options)).to include('chm=r') end end end describe "a bar graph" do it "should have a default vertical orientation" do expect(Gchart.bar).to include('cht=bvs') end it "should be able to have a different orientation" do expect(Gchart.bar(:orientation => 'vertical')).to include('cht=bvs') expect(Gchart.bar(:orientation => 'v')).to include('cht=bvs') expect(Gchart.bar(:orientation => 'h')).to include('cht=bhs') expect(Gchart.bar(:orientation => 'horizontal')).to include('cht=bhs') expect(Gchart.bar(:horizontal => false)).to include('cht=bvs') end it "should be set to be stacked by default" do expect(Gchart.bar).to include('cht=bvs') end it "should be able to stacked, grouped or overlapped" do expect(Gchart.bar(:stacked => true)).to include('cht=bvs') expect(Gchart.bar(:stacked => false)).to include('cht=bvs') expect(Gchart.bar(:grouped => true)).to include('cht=bvg') expect(Gchart.bar(:grouped => false)).to include('cht=bvs') expect(Gchart.bar(:overlapped => true)).to include('cht=bvo') expect(Gchart.bar(:overlapped => false)).to include('cht=bvs') end it "should be able to have different bar colors" do expect(Gchart.bar(:bar_colors => 'efefef,00ffff')).to include('chco=') expect(Gchart.bar(:bar_colors => 'efefef,00ffff')).to include('chco=efefef,00ffff') # alias expect(Gchart.bar(:bar_color => 'efefef')).to include('chco=efefef') end it "should be able to have different bar colors when using an array of colors" do expect(Gchart.bar(:bar_colors => ['efefef','00ffff'])).to include('chco=efefef,00ffff') end it 'should be able to accept a string of width and spacing options' do expect(Gchart.bar(:bar_width_and_spacing => '25,6')).to include('chbh=25,6') end it 'should be able to accept a single fixnum width and spacing option to set the bar width' do expect(Gchart.bar(:bar_width_and_spacing => 25)).to include('chbh=25') end it 'should be able to accept an array of width and spacing options' do expect(Gchart.bar(:bar_width_and_spacing => [25,6,12])).to include('chbh=25,6,12') expect(Gchart.bar(:bar_width_and_spacing => [25,6])).to include('chbh=25,6') expect(Gchart.bar(:bar_width_and_spacing => [25])).to include('chbh=25') end describe "with a hash of width and spacing options" do before(:each) do @default_width = 23 @default_spacing = 4 @default_group_spacing = 8 end it 'should be able to have a custom bar width' do expect(Gchart.bar(:bar_width_and_spacing => {:width => 19})).to include("chbh=19,#{@default_spacing},#{@default_group_spacing}") end it 'should be able to have custom spacing' do expect(Gchart.bar(:bar_width_and_spacing => {:spacing => 19})).to include("chbh=#{@default_width},19,#{@default_group_spacing}") end it 'should be able to have custom group spacing' do expect(Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19})).to include("chbh=#{@default_width},#{@default_spacing},19") end end end +describe "a radar chart" do + + before(:each) do + @chart = Gchart.radar(:title => 'Chart Title') + end + + it "should be able have a chart title" do + expect(@chart).to include("chtt=Chart+Title") + end + + it "should allow axis labels positions to be used" do + expect(Gchart.radar(:custom_axis_with_labels => '0,0,50,100')).to include('chxp=0,0,50,100') + end + + it "should allow array of axis labels positions to be used " do + expect(Gchart.radar(:custom_axis_with_labels => ['0', '0', '50', '100'])).to include('chxp=0,0,50,100') + end +end + describe "a line chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @chart = Gchart.line(:title => @title, :legend => @legend) end it 'should be able have a chart title' do expect(@chart).to include("chtt=Chart+Title") end it "should be able to a custom color, size and alignment for title" do expect(Gchart.line(:title => @title, :title_color => 'FF0000')).to include('chts=FF0000') expect(Gchart.line(:title => @title, :title_size => '20')).to include('chts=454545,20') expect(Gchart.line(:title => @title, :title_size => '20', :title_alignment => :left)).to include('chts=454545,20,l') end it "should be able to have multiple legends" do expect(@chart).to include(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")) end it "should escape text values in url" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend) expect(chart).to include(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")) end it "should be able to have one legend" do chart = Gchart.line(:legend => 'legend label') expect(chart).to include("chdl=legend+label") end it "should be able to set the position of the legend" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend, :legend_position => :bottom_vertical) expect(chart).to include("chdlp=bv") chart = Gchart.line(:title => title, :legend => legend, :legend_position => 'r') expect(chart).to include("chdlp=r") end it "should be able to set the background fill" do expect(Gchart.line(:bg => 'efefef')).to include("chf=bg,s,efefef") expect(Gchart.line(:bg => {:color => 'efefef', :type => 'solid'})).to include("chf=bg,s,efefef") expect(Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1") expect(Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1") expect(Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=bg,lg,90,efefef,0,ffffff,1") expect(Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'})).to include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do expect(Gchart.line(:graph_bg => 'efefef')).to include("chf=c,s,efefef") expect(Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'})).to include("chf=c,s,efefef") expect(Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1") expect(Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1") expect(Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=c,lg,90,efefef,0,ffffff,1") end it "should be able to set both a graph and a background fill" do expect(Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB')).to match /chf=(bg,s,efefef\|c,s,76A4FB|c,s,76A4FB\|bg,s,efefef)/ end it "should be able to have different line colors" do expect(Gchart.line(:line_colors => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff')) expect(Gchart.line(:line_color => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff')) end it "should be able to render a graph where all the data values are 0" do expect(Gchart.line(:data => [0, 0, 0])).to include("chd=s:AAA") end end describe "a sparkline chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [27,25,25,25,25,27,100,31,25,36,25,25,39,25,31,25,25,25,26,26,25,25,28,25,25,100,28,27,31,25,27,27,29,25,27,26,26,25,26,26,35,33,34,25,26,25,36,25,26,37,33,33,37,37,39,25,25,25,25] @chart = Gchart.sparkline(:title => @title, :data => @data, :legend => @legend) end it "should create a sparkline" do expect(@chart).to include('cht=ls') end it 'should be able have a chart title' do expect(@chart).to include("chtt=Chart+Title") end it "should be able to a custom color and size title" do expect(Gchart.sparkline(:title => @title, :title_color => 'FF0000')).to include('chts=FF0000') expect(Gchart.sparkline(:title => @title, :title_size => '20')).to include('chts=454545,20') end it "should be able to have multiple legends" do expect(@chart).to include(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")) end it "should be able to have one legend" do chart = Gchart.sparkline(:legend => 'legend label') expect(chart).to include("chdl=legend+label") end it "should be able to set the background fill" do expect(Gchart.sparkline(:bg => 'efefef')).to include("chf=bg,s,efefef") expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'})).to include("chf=bg,s,efefef") expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1") expect(Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1") expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=bg,lg,90,efefef,0,ffffff,1") expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'})).to include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do expect(Gchart.sparkline(:graph_bg => 'efefef')).to include("chf=c,s,efefef") expect(Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'})).to include("chf=c,s,efefef") expect(Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1") expect(Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1") expect(Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=c,lg,90,efefef,0,ffffff,1") end it "should be able to set both a graph and a background fill" do expect(Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB')).to match(/chf=(bg,s,efefef\|c,s,76A4FB|c,s,76A4FB\|bg,s,efefef)/) end it "should be able to have different line colors" do expect(Gchart.sparkline(:line_colors => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff')) expect(Gchart.sparkline(:line_color => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff')) end end describe "a 3d pie chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [12,8,40,15,5] @chart = Gchart.pie(:title => @title, :legend => @legend, :data => @data) end it "should create a pie" do expect(@chart).to include('cht=p') end it "should be able to be in 3d" do expect(Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data)).to include('cht=p3') end end describe "a google-o-meter" do before(:each) do @data = [70] @legend = ['arrow points here'] @jstized_legend = Gchart.jstize(@legend.join('|')) @chart = Gchart.meter(:data => @data) end it "should create a meter" do expect(@chart).to include('cht=gom') end it "should be able to set a solid background fill" do expect(Gchart.meter(:bg => 'efefef')).to include("chf=bg,s,efefef") expect(Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'})).to include("chf=bg,s,efefef") end it "should be able to set labels by using the legend or labesl accessor" do expect(Gchart.meter(:title => @title, :labels => @legend, :data => @data)).to include("chl=#{@jstized_legend}") expect(Gchart.meter(:title => @title, :labels => @legend, :data => @data)).to eq(Gchart.meter(:title => @title, :legend => @legend, :data => @data)) end end describe "a map chart" do before(:each) do @data = [0,100,50,32] @geographical_area = 'usa' @map_colors = ['FFFFFF', 'FF0000', 'FFFF00', '00FF00'] @country_codes = ['MT', 'WY', "ID", 'SD'] @chart = Gchart.map(:data => @data, :encoding => 'text', :size => '400x300', :geographical_area => @geographical_area, :map_colors => @map_colors, :country_codes => @country_codes) end it "should create a map" do expect(@chart).to include('cht=t') end it "should set the geographical area" do expect(@chart).to include('chtm=usa') end it "should set the map colors" do expect(@chart).to include('chco=FFFFFF,FF0000,FFFF00,00FF00') end it "should set the country/state codes" do expect(@chart).to include('chld=MTWYIDSD') end it "should set the chart data" do expect(@chart).to include('chd=t:0,100,50,32') end end describe 'exporting a chart' do it "should be available in the url format by default" do expect(Gchart.line(:data => [0, 26], :format => 'url')).to eq(Gchart.line(:data => [0, 26])) end it "should be available as an image tag" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag')).to match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using img_tag alias" do expect(Gchart.line(:data => [0, 26], :format => 'img_tag')).to match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom dimensions" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :size => '400x400')).to match(/<img src=(.*) width="400" height="400" alt="Google Chart" \/>/) end it "should be available as an image tag using custom alt text" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :alt => 'Sexy chart')).to match(/<img src=(.*) width="300" height="200" alt="Sexy chart" \/>/) end it "should be available as an image tag using custom title text" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :title => 'Sexy chart')).to match(/<img src=(.*) width="300" height="200" alt="Google Chart" title="Sexy chart" \/>/) end it "should be available as an image tag using custom css id selector" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :id => 'chart')).to match(/<img id="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom css class selector" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart')).to match(/<img class="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should use ampersands to separate key/value pairs in URLs by default" do expect(Gchart.line(:data => [0, 26])).to include "&" expect(Gchart.line(:data => [0, 26])).not_to include "&amp;" end it "should escape ampersands in URLs when used as an image tag" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart')).to satisfy {|chart| expect(chart).to include "&amp;" } end it "should be available as a file" do File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file') expect(File.exist?('chart.png')).to be File.delete('chart.png') if File.exist?('chart.png') end it "should be available as a file using a custom file name" do File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') Gchart.line(:data => [0, 26], :format => 'file', :filename => 'custom_file_name.png') expect(File.exist?('custom_file_name.png')).to be File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') end it "should work even with multiple attrs" do File.delete('foo.png') if File.exist?('foo.png') Gchart.line(:size => '400x200', :data => [1,2,3,4,5], # :axis_labels => [[1,2,3,4, 5], %w[foo bar]], :axis_with_labels => 'x,r', :format => "file", :filename => "foo.png" ) expect(File.exist?('foo.png')).to be File.delete('foo.png') if File.exist?('foo.png') end end describe 'SSL support' do it 'should change url if is presented' do expect(Gchart.line(:use_ssl => true)).to include('https://chart.googleapis.com/chart?') end it "should be available as a file" do pending "unexpected error under Travis CI (should be fixed using http://martinottenwaelter.fr/2010/12/ruby19-and-the-ssl-error/)" File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file', :use_ssl => true) expect(File.exist?('chart.png')).to be_true File.delete('chart.png') if File.exist?('chart.png') end end
mattetti/googlecharts
f2d80cdd2e40e49a38695c89e85705d125af6c81
Fix failing specs due to recent merge
diff --git a/spec/gchart_spec.rb b/spec/gchart_spec.rb index 1c27374..a7c073d 100644 --- a/spec/gchart_spec.rb +++ b/spec/gchart_spec.rb @@ -115,551 +115,551 @@ describe "generating a default Gchart" do it "should be able to have multiple set of data with text encoding" do expect(Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text')).to include(Gchart.jstize('chd=t:10,5.2,4,45,78|20,40,70,15,99')) end it "should be able to receive a custom param" do expect(Gchart.line(:custom => 'ceci_est_une_pipe')).to include('ceci_est_une_pipe') end it "should be able to set label axis" do expect(Gchart.line(:axis_with_labels => 'x,y,r')).to include('chxt=x,y,r') expect(Gchart.line(:axis_with_labels => ['x','y','r'])).to include('chxt=x,y,r') end it "should be able to have axis labels" do expect(Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007'])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')) expect(Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan'])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')) expect(Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')) expect(Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')) end def labeled_line(options = {}) Gchart.line({:data => @data, :axis_with_labels => 'x,y'}.merge(options)) end it "should display ranges properly" do @data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] expect(labeled_line(:axis_labels => [((1..24).to_a << 1)])). to include('chxr=0,85,672') end def labeled_bar(options = {}) Gchart.bar({:data => @data, :axis_with_labels => 'x,y', :axis_labels => [(1..12).to_a], :encoding => "text" }.merge(options)) end it "should force the y range properly" do @data = [1,1,1,1,1,1,1,1,6,2,1,1] expect(labeled_bar( :axis_range => [[0,0],[0,16]] )).to include('chxr=0,0,0|1,0,16') expect(labeled_bar( :max_value => 16, :axis_range => [[0,0],[0,16]] )).to include('chxr=0,0,16|1,0,16') # nil means ignore axis expect(labeled_bar( :axis_range => [nil,[0,16]] )).to include('chxr=1,0,16') # empty array means take defaults expect(labeled_bar( :max_value => 16, :axis_range => [[],[0,16]] )).to include('chxr=0,0,16|1,0,16') expect(labeled_bar( :axis_range => [[],[0,16]] )).to include('chxr=0,0|1,0,16') expect(Gchart.line( :data => [0,20, 40, 60, 140, 230, 60], :axis_with_labels => 'y')).to include("chxr=0,0,230") end it "should take in consideration the max value when creating a range" do data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] url = Gchart.line(:data => data, :axis_with_labels => 'x,y', :axis_labels => [((1..24).to_a << 1)], :max_value => 700) expect(url).to include('chxr=0,85,700') end it 'should generate different labels and legend' do expect(Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three))).to(include('chdl=1|2|3') && include('chl=one|two|three')) end end describe "generating different type of charts" do it "should be able to generate a line chart" do expect(Gchart.line).to be_an_instance_of(String) expect(Gchart.line).to include('cht=lc') end it "should be able to generate a sparkline chart" do expect(Gchart.sparkline).to be_an_instance_of(String) expect(Gchart.sparkline).to include('cht=ls') end it "should be able to generate a line xy chart" do expect(Gchart.line_xy).to be_an_instance_of(String) expect(Gchart.line_xy).to include('cht=lxy') end it "should be able to generate a scatter chart" do expect(Gchart.scatter).to be_an_instance_of(String) expect(Gchart.scatter).to include('cht=s') end it "should be able to generate a bar chart" do expect(Gchart.bar).to be_an_instance_of(String) expect(Gchart.bar).to include('cht=bvs') end it "should be able to generate a Venn diagram" do expect(Gchart.venn).to be_an_instance_of(String) expect(Gchart.venn).to include('cht=v') end it "should be able to generate a Pie Chart" do expect(Gchart.pie).to be_an_instance_of(String) expect(Gchart.pie).to include('cht=p') end it "should be able to generate a Google-O-Meter" do expect(Gchart.meter).to be_an_instance_of(String) expect(Gchart.meter).to include('cht=gom') end it "should be able to generate a map chart" do expect(Gchart.map).to be_an_instance_of(String) expect(Gchart.map).to include('cht=t') end it "should not support other types" do msg = "sexy is not a supported chart format. Please use one of the following: #{Gchart.supported_types}." expect{Gchart.sexy}.to raise_error(NoMethodError) end end describe "range markers" do it "should be able to generate given a hash of range-marker options" do expect(Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'})).to include('chm=r,ff0000,0,0.59,0.61') end it "should be able to generate given an array of range-marker hash options" do expect(Gchart.line(:range_markers => [ {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}, {:start_position => 0, :stop_position => 0.6, :color => '666666'}, {:color => 'cccccc', :start_position => 0.6, :stop_position => 1} ])).to include(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1')) end it "should allow a :overlaid? to be set" do expect(Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true})).to include('chm=r,ffffff,0,0.59,0.61,1') expect(Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false})).to include('chm=r,ffffff,0,0.59,0.61') end describe "when setting the orientation option" do before(:each) do @options = {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'} end it "to vertical (R) if given a valid option" do expect(Gchart.line(:range_markers => @options.merge(:orientation => 'v'))).to include('chm=R') expect(Gchart.line(:range_markers => @options.merge(:orientation => 'V'))).to include('chm=R') expect(Gchart.line(:range_markers => @options.merge(:orientation => 'R'))).to include('chm=R') expect(Gchart.line(:range_markers => @options.merge(:orientation => 'vertical'))).to include('chm=R') expect(Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical'))).to include('chm=R') end it "to horizontal (r) if given a valid option (actually anything other than the vertical options)" do expect(Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal'))).to include('chm=r') expect(Gchart.line(:range_markers => @options.merge(:orientation => 'h'))).to include('chm=r') expect(Gchart.line(:range_markers => @options.merge(:orientation => 'etc'))).to include('chm=r') end it "if left blank defaults to horizontal (r)" do expect(Gchart.line(:range_markers => @options)).to include('chm=r') end end end describe "a bar graph" do it "should have a default vertical orientation" do expect(Gchart.bar).to include('cht=bvs') end it "should be able to have a different orientation" do expect(Gchart.bar(:orientation => 'vertical')).to include('cht=bvs') expect(Gchart.bar(:orientation => 'v')).to include('cht=bvs') expect(Gchart.bar(:orientation => 'h')).to include('cht=bhs') expect(Gchart.bar(:orientation => 'horizontal')).to include('cht=bhs') expect(Gchart.bar(:horizontal => false)).to include('cht=bvs') end it "should be set to be stacked by default" do expect(Gchart.bar).to include('cht=bvs') end it "should be able to stacked, grouped or overlapped" do expect(Gchart.bar(:stacked => true)).to include('cht=bvs') expect(Gchart.bar(:stacked => false)).to include('cht=bvs') expect(Gchart.bar(:grouped => true)).to include('cht=bvg') expect(Gchart.bar(:grouped => false)).to include('cht=bvs') expect(Gchart.bar(:overlapped => true)).to include('cht=bvo') expect(Gchart.bar(:overlapped => false)).to include('cht=bvs') end it "should be able to have different bar colors" do expect(Gchart.bar(:bar_colors => 'efefef,00ffff')).to include('chco=') expect(Gchart.bar(:bar_colors => 'efefef,00ffff')).to include('chco=efefef,00ffff') # alias expect(Gchart.bar(:bar_color => 'efefef')).to include('chco=efefef') end it "should be able to have different bar colors when using an array of colors" do expect(Gchart.bar(:bar_colors => ['efefef','00ffff'])).to include('chco=efefef,00ffff') end it 'should be able to accept a string of width and spacing options' do expect(Gchart.bar(:bar_width_and_spacing => '25,6')).to include('chbh=25,6') end it 'should be able to accept a single fixnum width and spacing option to set the bar width' do expect(Gchart.bar(:bar_width_and_spacing => 25)).to include('chbh=25') end it 'should be able to accept an array of width and spacing options' do expect(Gchart.bar(:bar_width_and_spacing => [25,6,12])).to include('chbh=25,6,12') expect(Gchart.bar(:bar_width_and_spacing => [25,6])).to include('chbh=25,6') expect(Gchart.bar(:bar_width_and_spacing => [25])).to include('chbh=25') end describe "with a hash of width and spacing options" do before(:each) do @default_width = 23 @default_spacing = 4 @default_group_spacing = 8 end it 'should be able to have a custom bar width' do expect(Gchart.bar(:bar_width_and_spacing => {:width => 19})).to include("chbh=19,#{@default_spacing},#{@default_group_spacing}") end it 'should be able to have custom spacing' do expect(Gchart.bar(:bar_width_and_spacing => {:spacing => 19})).to include("chbh=#{@default_width},19,#{@default_group_spacing}") end it 'should be able to have custom group spacing' do expect(Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19})).to include("chbh=#{@default_width},#{@default_spacing},19") end end end describe "a line chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @chart = Gchart.line(:title => @title, :legend => @legend) end it 'should be able have a chart title' do expect(@chart).to include("chtt=Chart+Title") end it "should be able to a custom color, size and alignment for title" do expect(Gchart.line(:title => @title, :title_color => 'FF0000')).to include('chts=FF0000') expect(Gchart.line(:title => @title, :title_size => '20')).to include('chts=454545,20') expect(Gchart.line(:title => @title, :title_size => '20', :title_alignment => :left)).to include('chts=454545,20,l') end it "should be able to have multiple legends" do expect(@chart).to include(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")) end it "should escape text values in url" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend) expect(chart).to include(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")) end it "should be able to have one legend" do chart = Gchart.line(:legend => 'legend label') expect(chart).to include("chdl=legend+label") end it "should be able to set the position of the legend" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend, :legend_position => :bottom_vertical) expect(chart).to include("chdlp=bv") chart = Gchart.line(:title => title, :legend => legend, :legend_position => 'r') expect(chart).to include("chdlp=r") end it "should be able to set the background fill" do expect(Gchart.line(:bg => 'efefef')).to include("chf=bg,s,efefef") expect(Gchart.line(:bg => {:color => 'efefef', :type => 'solid'})).to include("chf=bg,s,efefef") expect(Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1") expect(Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1") expect(Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=bg,lg,90,efefef,0,ffffff,1") expect(Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'})).to include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do expect(Gchart.line(:graph_bg => 'efefef')).to include("chf=c,s,efefef") expect(Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'})).to include("chf=c,s,efefef") expect(Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1") expect(Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1") expect(Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=c,lg,90,efefef,0,ffffff,1") end it "should be able to set both a graph and a background fill" do expect(Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB')).to match /chf=(bg,s,efefef\|c,s,76A4FB|c,s,76A4FB\|bg,s,efefef)/ end it "should be able to have different line colors" do expect(Gchart.line(:line_colors => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff')) expect(Gchart.line(:line_color => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff')) end it "should be able to render a graph where all the data values are 0" do expect(Gchart.line(:data => [0, 0, 0])).to include("chd=s:AAA") end end describe "a sparkline chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [27,25,25,25,25,27,100,31,25,36,25,25,39,25,31,25,25,25,26,26,25,25,28,25,25,100,28,27,31,25,27,27,29,25,27,26,26,25,26,26,35,33,34,25,26,25,36,25,26,37,33,33,37,37,39,25,25,25,25] @chart = Gchart.sparkline(:title => @title, :data => @data, :legend => @legend) end it "should create a sparkline" do expect(@chart).to include('cht=ls') end it 'should be able have a chart title' do expect(@chart).to include("chtt=Chart+Title") end it "should be able to a custom color and size title" do expect(Gchart.sparkline(:title => @title, :title_color => 'FF0000')).to include('chts=FF0000') expect(Gchart.sparkline(:title => @title, :title_size => '20')).to include('chts=454545,20') end it "should be able to have multiple legends" do expect(@chart).to include(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")) end it "should be able to have one legend" do chart = Gchart.sparkline(:legend => 'legend label') expect(chart).to include("chdl=legend+label") end it "should be able to set the background fill" do expect(Gchart.sparkline(:bg => 'efefef')).to include("chf=bg,s,efefef") expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'})).to include("chf=bg,s,efefef") expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1") expect(Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1") expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=bg,lg,90,efefef,0,ffffff,1") expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'})).to include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do expect(Gchart.sparkline(:graph_bg => 'efefef')).to include("chf=c,s,efefef") expect(Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'})).to include("chf=c,s,efefef") expect(Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1") expect(Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1") expect(Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=c,lg,90,efefef,0,ffffff,1") end it "should be able to set both a graph and a background fill" do expect(Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB')).to match(/chf=(bg,s,efefef\|c,s,76A4FB|c,s,76A4FB\|bg,s,efefef)/) end it "should be able to have different line colors" do expect(Gchart.sparkline(:line_colors => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff')) expect(Gchart.sparkline(:line_color => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff')) end end describe "a 3d pie chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [12,8,40,15,5] @chart = Gchart.pie(:title => @title, :legend => @legend, :data => @data) end it "should create a pie" do expect(@chart).to include('cht=p') end it "should be able to be in 3d" do expect(Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data)).to include('cht=p3') end end describe "a google-o-meter" do before(:each) do @data = [70] @legend = ['arrow points here'] @jstized_legend = Gchart.jstize(@legend.join('|')) @chart = Gchart.meter(:data => @data) end it "should create a meter" do expect(@chart).to include('cht=gom') end it "should be able to set a solid background fill" do expect(Gchart.meter(:bg => 'efefef')).to include("chf=bg,s,efefef") expect(Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'})).to include("chf=bg,s,efefef") end it "should be able to set labels by using the legend or labesl accessor" do expect(Gchart.meter(:title => @title, :labels => @legend, :data => @data)).to include("chl=#{@jstized_legend}") expect(Gchart.meter(:title => @title, :labels => @legend, :data => @data)).to eq(Gchart.meter(:title => @title, :legend => @legend, :data => @data)) end end describe "a map chart" do before(:each) do @data = [0,100,50,32] @geographical_area = 'usa' @map_colors = ['FFFFFF', 'FF0000', 'FFFF00', '00FF00'] @country_codes = ['MT', 'WY', "ID", 'SD'] @chart = Gchart.map(:data => @data, :encoding => 'text', :size => '400x300', :geographical_area => @geographical_area, :map_colors => @map_colors, :country_codes => @country_codes) end it "should create a map" do expect(@chart).to include('cht=t') end it "should set the geographical area" do expect(@chart).to include('chtm=usa') end it "should set the map colors" do expect(@chart).to include('chco=FFFFFF,FF0000,FFFF00,00FF00') end it "should set the country/state codes" do expect(@chart).to include('chld=MTWYIDSD') end it "should set the chart data" do expect(@chart).to include('chd=t:0,100,50,32') end end describe 'exporting a chart' do it "should be available in the url format by default" do expect(Gchart.line(:data => [0, 26], :format => 'url')).to eq(Gchart.line(:data => [0, 26])) end it "should be available as an image tag" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag')).to match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using img_tag alias" do expect(Gchart.line(:data => [0, 26], :format => 'img_tag')).to match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom dimensions" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :size => '400x400')).to match(/<img src=(.*) width="400" height="400" alt="Google Chart" \/>/) end it "should be available as an image tag using custom alt text" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :alt => 'Sexy chart')).to match(/<img src=(.*) width="300" height="200" alt="Sexy chart" \/>/) end it "should be available as an image tag using custom title text" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :title => 'Sexy chart')).to match(/<img src=(.*) width="300" height="200" alt="Google Chart" title="Sexy chart" \/>/) end it "should be available as an image tag using custom css id selector" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :id => 'chart')).to match(/<img id="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom css class selector" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart')).to match(/<img class="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should use ampersands to separate key/value pairs in URLs by default" do expect(Gchart.line(:data => [0, 26])).to include "&" expect(Gchart.line(:data => [0, 26])).not_to include "&amp;" end it "should escape ampersands in URLs when used as an image tag" do expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart')).to satisfy {|chart| expect(chart).to include "&amp;" } end it "should be available as a file" do File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file') - expect(File.exist?('chart.png')).to be_true + expect(File.exist?('chart.png')).to be File.delete('chart.png') if File.exist?('chart.png') end it "should be available as a file using a custom file name" do File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') Gchart.line(:data => [0, 26], :format => 'file', :filename => 'custom_file_name.png') - expect(File.exist?('custom_file_name.png')).to be_true + expect(File.exist?('custom_file_name.png')).to be File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') end it "should work even with multiple attrs" do File.delete('foo.png') if File.exist?('foo.png') Gchart.line(:size => '400x200', :data => [1,2,3,4,5], # :axis_labels => [[1,2,3,4, 5], %w[foo bar]], :axis_with_labels => 'x,r', :format => "file", :filename => "foo.png" ) - expect(File.exist?('foo.png')).to be_true + expect(File.exist?('foo.png')).to be File.delete('foo.png') if File.exist?('foo.png') end end describe 'SSL support' do it 'should change url if is presented' do expect(Gchart.line(:use_ssl => true)).to include('https://chart.googleapis.com/chart?') end it "should be available as a file" do pending "unexpected error under Travis CI (should be fixed using http://martinottenwaelter.fr/2010/12/ruby19-and-the-ssl-error/)" File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file', :use_ssl => true) expect(File.exist?('chart.png')).to be_true File.delete('chart.png') if File.exist?('chart.png') end end
mattetti/googlecharts
8a0afd24a489fcb6195e395634a89b6657a4b2b1
refactored bar chart
diff --git a/lib/gchart.rb b/lib/gchart.rb index bfd3877..b275bc3 100644 --- a/lib/gchart.rb +++ b/lib/gchart.rb @@ -1,729 +1,729 @@ $:.unshift File.dirname(__FILE__) require 'gchart/version' require 'gchart/theme' require "net/http" require "net/https" require "uri" require "cgi" require 'enumerator' class Gchart include GchartInfo def self.url(use_ssl = false) if use_ssl 'https://chart.googleapis.com/chart?' else 'http://chart.apis.google.com/chart?' end end def self.types @types ||= ['line', 'line_xy', 'scatter', 'bar', 'venn', 'pie', 'pie_3d', 'jstize', 'sparkline', 'meter', 'map', 'radar'] end def self.simple_chars @simple_chars ||= ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a end def self.chars @chars ||= simple_chars + ['-', '.'] end def self.ext_pairs @ext_pairs ||= chars.map { |char_1| chars.map { |char_2| char_1 + char_2 } }.flatten end def self.default_filename 'chart.png' end - attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :overlapping, :legend, :legend_position, :labels, :data, :encoding, :bar_colors, + attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :overlapped, :legend, :legend_position, :labels, :data, :encoding, :bar_colors, :title_color, :title_size, :title_alignment, :custom, :axis_with_labels, :axis_labels, :bar_width_and_spacing, :id, :alt, :klass, :range_markers, :geographical_area, :map_colors, :country_codes, :axis_range, :filename, :min, :max, :colors, :usemap attr_accessor :bg_type, :bg_color, :bg_angle, :chart_type, :chart_color, :chart_angle, :axis_range, :thickness, :new_markers, :grid_lines, :use_ssl attr_accessor :min_value, :max_value - + types.each do |type| instance_eval <<-DYNCLASSMETH def #{type}(options = {}) # Start with theme defaults if a theme is set theme = options[:theme] options = theme ? Chart::Theme.load(theme).to_options.merge(options) : options # # Extract the format and optional filename, then clean the hash format = options[:format] || 'url' options[:filename] ||= default_filename options.delete(:format) #update map_colors to become bar_colors options.update(:bar_colors => options[:map_colors]) if options.has_key?(:map_colors) chart = new(options.merge!({:type => "#{type}"})) chart.send(format) end DYNCLASSMETH end def self.version VERSION::STRING end def self.method_missing(m, options={}) raise NoMethodError, "#{m} is not a supported chart format. Please use one of the following: #{supported_types}." end def initialize(options={}) # Allow Gchart to take a theme too @theme = options[:theme] options = @theme ? Chart::Theme.load(@theme).to_options.merge(options) : options options.delete(:theme) - + @type = options[:type] || 'line' @data = [] @width = 300 @height = 200 @curved = false @horizontal = false + @grouped = false - @overlapping = false + @overlapped = false + @use_ssl = false @encoding = 'simple' # @max_value = 'auto' # @min_value defaults to nil meaning zero @filename = options[:filename] # Sets the alt tag when chart is exported as image tag @alt = 'Google Chart' # Sets the CSS id selector when chart is exported as image tag @id = false # Sets the CSS class selector when chart is exported as image tag @klass = options[:class] || false # set the options value if definable options.each do |attribute, value| send("#{attribute}=", value) if self.respond_to?("#{attribute}=") end end def self.supported_types self.types.join(' ') end # Defines the Graph size using the following format: # width X height def size=(size='300x200') @width, @height = size.split("x").map { |dimension| dimension.to_i } end - + def size "#{width}x#{height}" end - + def dimensions # TODO: maybe others? [:line_xy, :scatter].include?(type) ? 2 : 1 end # Sets the orientation of a bar graph def orientation=(orientation='h') if orientation == 'h' || orientation == 'horizontal' self.horizontal = true elsif orientation == 'v' || orientation == 'vertical' self.horizontal = false end end - # Sets the bar graph presentation (stacked or grouped) - def stacked=(option=true) - @overlapping = false - @grouped = option ? false : true - end - - # Sets the bar graph presentation (overlapping or grouped) - def overlapping=(option=true) - @overlapping = option - @grouped = option ? false : true + def bar_presentation + if @overlapped + 'o' + elsif @grouped + 'g' + else + 's' + end end def bg=(options) if options.is_a?(String) @bg_color = options elsif options.is_a?(Hash) @bg_color = options[:color] @bg_type = options[:type] @bg_angle = options[:angle] end end def graph_bg=(options) if options.is_a?(String) @chart_color = options elsif options.is_a?(Hash) @chart_color = options[:color] @chart_type = options[:type] @chart_angle = options[:angle] end end - + def max_value=(max_v) if max_v =~ /false/ @max_value = false else @max_value = max_v end end def min_value=(min_v) if min_v =~ /false/ @min_value = false else @min_value = min_v end end # returns the full data range as an array # it also sets the data range if not defined def full_data_range(ds) return if max_value == false ds.each_with_index do |mds, mds_index| mds[:min_value] ||= min_value mds[:max_value] ||= max_value - + if mds_index == 0 && type.to_s == 'bar' # TODO: unless you specify a zero line (using chp or chds), # the min_value of a bar chart is always 0. #mds[:min_value] ||= mds[:data].first.to_a.compact.min mds[:min_value] ||= 0 end if (mds_index == 0 && type.to_s == 'bar' && !grouped && mds[:data].first.is_a?(Array)) totals = [] mds[:data].each do |l| l.each_with_index do |v, index| next if v.nil? totals[index] ||= 0 totals[index] += v end end mds[:max_value] ||= totals.compact.max else all = mds[:data].flatten.compact # default min value should be 0 unless set to auto if mds[:min_value] == 'auto' mds[:min_value] = all.min else min = all.min mds[:min_value] ||= (min && min < 0 ? min : 0) end mds[:max_value] ||= all.max end end unless axis_range @calculated_axis_range = true @axis_range = ds.map{|mds| [mds[:min_value], mds[:max_value]]} if dimensions == 1 && (type.to_s != 'bar' || horizontal) tmp = axis_range.fetch(0, []) @axis_range[0] = axis_range.fetch(1, []) @axis_range[1] = tmp end end # return [min, max] unless (min.nil? || max.nil?) # @max = (max_value.nil? || max_value == 'auto') ? ds.compact.map{|mds| mds.compact.max}.max : max_value # # if min_value.nil? # min_ds_value = ds.compact.map{|mds| mds.compact.min}.min || 0 # @min = (min_ds_value < 0) ? min_ds_value : 0 # else # @min = min_value == 'auto' ? ds.compact.map{|mds| mds.compact.min}.min || 0 : min_value # end # @axis_range = [[min,max]] end def dataset if @dataset @dataset else @dataset = convert_dataset(data || []) full_data_range(@dataset) # unless axis_range @dataset end end - + # Sets of data to handle multiple sets def datasets datasets = [] dataset.each do |d| if d[:data].first.is_a?(Array) datasets += d[:data] else datasets << d[:data] end end datasets end - + def self.jstize(string) # See http://github.com/mattetti/googlecharts/issues#issue/27 #URI.escape( string ).gsub("%7C", "|") # See discussion: http://github.com/mattetti/googlecharts/commit/9b5cfb93aa51aae06611057668e631cd515ec4f3#comment_51347 string.gsub(' ', '+').gsub(/\[|\{|\}|\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} #string.gsub(' ', '+').gsub(/\[|\{|\}|\||\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} end # load all the custom aliases require 'gchart/aliases' # Returns the chart's generated PNG as a blob. (borrowed from John's gchart.rubyforge.org) def fetch url = URI.parse(self.class.url(use_ssl)) req = Net::HTTP::Post.new(url.path) req.body = query_builder req.content_type = 'application/x-www-form-urlencoded' http = Net::HTTP.new(url.host, url.port) http.verify_mode = OpenSSL::SSL::VERIFY_PEER if use_ssl http.use_ssl = use_ssl http.start {|resp| resp.request(req) }.body end # Writes the chart's generated PNG to a file. (borrowed from John's gchart.rubyforge.org) def write io_or_file = filename || self.class.default_filename return io_or_file.write(fetch) if io_or_file.respond_to?(:write) open(io_or_file, "wb+") { |io| io.write(fetch) } end # Format def image_tag image = "<img" image += " id=\"#{id}\"" if id image += " class=\"#{klass}\"" if klass image += " src=\"#{url_builder(:html)}\"" image += " width=\"#{width}\"" image += " height=\"#{height}\"" image += " alt=\"#{alt}\"" image += " title=\"#{title}\"" if title image += " usemap=\"#{usemap}\"" if usemap image += " />" end alias_method :img_tag, :image_tag def url url_builder end def file write end # def jstize(string) self.class.jstize(string) end private # The title size cannot be set without specifying a color. # A dark key will be used for the title color if no color is specified def set_title title_params = "chtt=#{title}".gsub(/\|/,"\n") unless (title_color.nil? && title_size.nil? && title_alignment.nil?) title_params << "&chts=" + (color, size, alignment = (title_color || '454545'), title_size, (title_alignment.to_s[0,1] || 'c')).compact.join(',') end title_params end def set_size "chs=#{size}" end def set_data data = send("#{@encoding}_encoding") "chd=#{data}" end def set_colors @bg_type = fill_type(bg_type) || 's' if bg_color @chart_type = fill_type(chart_type) || 's' if chart_color "chf=" + {'bg' => fill_for(bg_type, bg_color, bg_angle), 'c' => fill_for(chart_type, chart_color, chart_angle)}.map{|k,v| "#{k},#{v}" unless v.nil?}.compact.join('|') end # set bar, line colors def set_bar_colors @bar_colors = bar_colors.join(',') if bar_colors.is_a?(Array) "chco=#{bar_colors}" end def set_country_codes @country_codes = country_codes.join() if country_codes.is_a?(Array) "chld=#{country_codes}" end # set bar spacing # chbh= # <bar width in pixels>, # <optional space between bars in a group>, # <optional space between groups> def set_bar_width_and_spacing width_and_spacing_values = case bar_width_and_spacing when String bar_width_and_spacing when Array bar_width_and_spacing.join(',') when Hash width = bar_width_and_spacing[:width] || 23 spacing = bar_width_and_spacing[:spacing] || 4 group_spacing = bar_width_and_spacing[:group_spacing] || 8 [width,spacing,group_spacing].join(',') else bar_width_and_spacing.to_s end "chbh=#{width_and_spacing_values}" end def set_range_markers markers = case range_markers when Hash set_range_marker(range_markers) when Array range_markers.collect{|marker| set_range_marker(marker)}.join('|') end "chm=#{markers}" end def set_range_marker(options) orientation = ['vertical', 'Vertical', 'V', 'v', 'R'].include?(options[:orientation]) ? 'R' : 'r' "#{orientation},#{options[:color]},0,#{options[:start_position]},#{options[:stop_position]}#{',1' if options[:overlaid?]}" end def fill_for(type=nil, color='', angle=nil) unless type.nil? case type when 'lg' angle ||= 0 color = "#{color},0,ffffff,1" if color.split(',').size == 1 "#{type},#{angle},#{color}" when 'ls' angle ||= 90 color = "#{color},0.2,ffffff,0.2" if color.split(',').size == 1 "#{type},#{angle},#{color}" else "#{type},#{color}" end end end # A chart can have one or many legends. # Gchart.line(:legend => 'label') # or # Gchart.line(:legend => ['first label', 'last label']) def set_legend if type.to_s =~ /meter/ @labels = legend return set_labels end if legend.is_a?(Array) "chdl=#{@legend.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chdl=#{legend}" end end def set_legend_position case @legend_position.to_s when /(bottom|b)$/ "chdlp=b" when /(bottom_vertical|bv)$/ "chdlp=bv" when /(top|t)$/ "chdlp=t" when /(top_vertical|tv)$/ "chdlp=tv" when /(right|r)$/ "chdlp=r" when /(left|l)$/ "chdlp=l" end end def set_line_thickness "chls=#{thickness}" end def set_line_markers "chm=#{new_markers}" end def set_grid_lines "chg=#{grid_lines}" end def set_labels if labels.is_a?(Array) "chl=#{@labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chl=#{@labels}" end end def set_axis_with_labels @axis_with_labels = axis_with_labels.join(',') if @axis_with_labels.is_a?(Array) "chxt=#{axis_with_labels}" end def set_axis_labels if axis_labels.is_a?(Array) if RUBY_VERSION.to_f < 1.9 labels_arr = axis_labels.enum_with_index.map{|labels,index| [index,labels]} else labels_arr = axis_labels.map.with_index.map{|labels,index| [index,labels]} end elsif axis_labels.is_a?(Hash) labels_arr = axis_labels.to_a end labels_arr.map! do |index,labels| if labels.is_a?(Array) "#{index}:|#{labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "#{index}:|#{labels}" end end "chxl=#{labels_arr.join('|')}" end # http://code.google.com/apis/chart/labels.html#axis_range # Specify a range for axis labels def set_axis_range # a passed axis_range should look like: # [[10,100]] or [[10,100,4]] or [[10,100], [20,300]] # in the second example, 4 is the interval set = @calculated_axis_range ? datasets : axis_range || datasets return unless set && set.respond_to?(:each) && set.find {|o| o}.respond_to?(:each) 'chxr=' + set.enum_for(:each_with_index).map do |axis_range, index| next nil if axis_range.nil? # ignore this axis min, max, step = axis_range if axis_range.size > 3 || step && max && step > max # this is a full series max = axis_range.compact.max step = nil end [index, (min_value || min || 0), (max_value || max), step].compact.join(',') end.compact.join("|") end def set_geographical_area "chtm=#{geographical_area}" end def set_type 'cht=' + case type.to_s when 'line' then "lc" when 'line_xy' then "lxy" when 'pie_3d' then "p3" when 'pie' then "p" when 'venn' then "v" when 'scatter' then "s" when 'sparkline' then "ls" when 'meter' then "gom" when 'map' then "t" when 'radar' "r" + (curved? ? 's' : '') when 'bar' - "b" + (horizontal? ? "h" : "v") + (grouped? ? "g" : (overlapping? ? "o" : "s")) + "b" + (horizontal? ? "h" : "v") + bar_presentation end end def fill_type(type) case type when 'solid' then 's' when 'gradient' then 'lg' when 'stripes' then 'ls' end end - + def number_visible n = 0 dataset.each do |mds| return n.to_s if mds[:invisible] == true if mds[:data].first.is_a?(Array) n += mds[:data].length else n += 1 end end "" end - + # Turns input into an array of axis hashes, dependent on the chart type def convert_dataset(ds) if dimensions == 2 # valid inputs include: # an array of >=2 arrays, or an array of >=2 hashes ds = ds.map do |d| d.is_a?(Hash) ? d : {:data => d} end elsif dimensions == 1 # valid inputs include: # a hash, an array of data, an array of >=1 array, or an array of >=1 hash if ds.is_a?(Hash) ds = [ds] elsif not ds.first.is_a?(Hash) ds = [{:data => ds}] end end ds end - + # just an alias def axis_set dataset end def convert_to_simple_value(number) if number.nil? "_" else value = self.class.simple_chars[number.to_i] value.nil? ? "_" : value end end - + def convert_to_extended_value(number) if number.nil? '__' else value = self.class.ext_pairs[number.to_i] value.nil? ? "__" : value end end - + def encode_scaled_dataset(chars, nil_char) dsets = [] dataset.each do |ds| if max_value != false range = ds[:max_value] - ds[:min_value] range = 1 if range == 0 end unless ds[:data].first.is_a?(Array) ldatasets = [ds[:data]] else ldatasets = ds[:data] end ldatasets.each do |l| dsets << l.map do |number| if number.nil? nil_char else unless range.nil? || range.zero? number = chars.size * (number - ds[:min_value]) / range.to_f number = [number, chars.size - 1].min end chars[number.to_i] end end.join end end dsets.join(',') end # http://code.google.com/apis/chart/#simple # Simple encoding has a resolution of 62 different values. # Allowing five pixels per data point, this is sufficient for line and bar charts up # to about 300 pixels. Simple encoding is suitable for all other types of chart regardless of size. def simple_encoding "s" + number_visible + ":" + encode_scaled_dataset(self.class.simple_chars, '_') end # http://code.google.com/apis/chart/#text # Text encoding with data scaling lets you specify arbitrary positive or # negative floating point numbers, in combination with a scaling parameter # that lets you specify a custom range for your chart. This chart is useful # when you don't want to worry about limiting your data to a specific range, # or do the calculations to scale your data down or up to fit nicely inside # a chart. # # Valid values range from (+/-)9.999e(+/-)100, and only four non-zero digits are supported (that is, 123400, 1234, 12.34, and 0.1234 are valid, but 12345, 123.45 and 123400.5 are not). # # This encoding is not available for maps. # def text_encoding chds = dataset.map{|ds| "#{ds[:min_value]},#{ds[:max_value]}" }.join(",") "t" + number_visible + ":" + datasets.map{ |ds| ds.map{|e|e||'_'}.join(',') }.join('|') + "&chds=" + chds end # http://code.google.com/apis/chart/#extended # Extended encoding has a resolution of 4,096 different values # and is best used for large charts where a large data range is required. def extended_encoding "e" + number_visible + ":" + encode_scaled_dataset(self.class.ext_pairs, '__') end def url_builder(options="") self.class.url(use_ssl) + query_builder(options) end def query_builder(options="") query_params = instance_variables.sort.map do |var| case var.to_s - + when '@data' set_data unless data == [] # Set the graph size when '@width' set_size unless width.nil? || height.nil? when '@type' set_type when '@title' set_title unless title.nil? when '@legend' set_legend unless legend.nil? when '@labels' set_labels unless labels.nil? when '@legend_position' set_legend_position unless legend_position.nil? when '@thickness' set_line_thickness when '@new_markers' - set_line_markers + set_line_markers when '@bg_color' set_colors when '@chart_color' set_colors if bg_color.nil? when '@bar_colors' set_bar_colors when '@bar_width_and_spacing' set_bar_width_and_spacing when '@axis_with_labels' set_axis_with_labels when '@axis_labels' set_axis_labels when '@range_markers' set_range_markers when '@grid_lines' set_grid_lines when '@geographical_area' set_geographical_area when '@country_codes' set_country_codes when '@custom' custom end end.compact query_params << set_axis_range # Use ampersand as default delimiter unless options == :html delimiter = '&' # Escape ampersand for html image tags else delimiter = '&amp;' end jstize(query_params.join(delimiter)) end end diff --git a/lib/gchart/aliases.rb b/lib/gchart/aliases.rb index 69a7f47..42d4665 100644 --- a/lib/gchart/aliases.rb +++ b/lib/gchart/aliases.rb @@ -1,16 +1,14 @@ class Gchart alias_method :background=, :bg= alias_method :chart_bg=, :graph_bg= alias_method :chart_color=, :graph_bg= alias_method :chart_background=, :graph_bg= alias_method :bar_color=, :bar_colors= alias_method :line_colors=, :bar_colors= alias_method :line_color=, :bar_colors= alias_method :slice_colors=, :bar_colors= alias_method :horizontal?, :horizontal - alias_method :grouped?, :grouped - alias_method :overlapping?, :overlapping alias_method :curved?, :curved end diff --git a/spec/gchart_spec.rb b/spec/gchart_spec.rb index b45dba8..cdaae9d 100644 --- a/spec/gchart_spec.rb +++ b/spec/gchart_spec.rb @@ -1,665 +1,665 @@ require File.dirname(__FILE__) + '/spec_helper.rb' require File.dirname(__FILE__) + '/../lib/gchart' Chart::Theme.add_theme_file("#{File.dirname(__FILE__)}/fixtures/test_theme.yml") # Time to add your specs! # http://rspec.rubyforge.org/ describe "The Gchart class" do it "should show supported_types on error" do Gchart.supported_types.should match(/line/) end it "should return supported types" do Gchart.types.should include('line') end it "should support theme option" do chart = Gchart.new(:type => 'line',:theme => :test) chart.send('url').should include('chco=6886B4,FDD84E') end end describe "generating a default Gchart" do before(:each) do @chart = Gchart.line end it "should create a line break when a pipe character is encountered" do @chart = Gchart.line(:title => "title|subtitle") @chart.should include("chtt=title\nsubtitle") end it "should include the Google URL" do @chart.should include("http://chart.apis.google.com/chart?") end it "should have a default size" do @chart.should include('chs=300x200') end it "should be able to have a custom size" do Gchart.line(:size => '400x600').should include('chs=400x600') Gchart.line(:width => 400, :height => 600).should include('chs=400x600') end it "should have query parameters in predictable order" do Gchart.line(:axis_with_labels => 'x,y,r', :size => '400x600').should match(/chxt=.+cht=.+chs=/) end it "should have a type" do @chart.should include('cht=lc') end it 'should use theme defaults if theme is set' do Gchart.line(:theme=>:test).should include('chco=6886B4,FDD84E') Gchart.line(:theme=>:test).should match(/chf=(c,s,FFFFFF\|bg,s,FFFFFF|bg,s,FFFFFF\|c,s,FFFFFF)/) end it "should use the simple encoding by default with auto max value" do # 9 is the max value in simple encoding, 26 being our max value the 2nd encoded value should be 9 Gchart.line(:data => [0, 26]).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => 26, :axis_with_labels => 'y').should include('chxr=0,0,26') end it "should support simple encoding with and without max_value" do Gchart.line(:data => [0, 26], :max_value => 26).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => false).should include('chd=s:Aa') end it "should support the extended encoding and encode properly" do Gchart.line(:data => [0, 10], :encoding => 'extended', :max_value => false).should include('chd=e:AA') Gchart.line(:encoding => 'extended', :max_value => false, :data => [[0,25,26,51,52,61,62,63], [64,89,90,115,4084]] ).should include('chd=e:AAAZAaAzA0A9A-A.,BABZBaBz.0') end it "should auto set the max value for extended encoding" do Gchart.line(:data => [0, 25], :encoding => 'extended', :max_value => false).should include('chd=e:AAAZ') # Extended encoding max value is '..' Gchart.line(:data => [0, 25], :encoding => 'extended').should include('chd=e:AA..') end it "should be able to have data with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,4,45,78') end it "should be able to have missing data points with text encoding" do Gchart.line(:data => [10, 5.2, nil, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,_,45,78') end it "should handle max and min values with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=0,78') end it "should automatically handle negative values with proper max/min limits when using text encoding" do Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=-10,78') end it "should handle negative values with manual max/min limits when using text encoding" do Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text', :min_value => -20, :max_value => 100).should include('chds=-20,100') end it "should set the proper axis values when using text encoding and negative values" do Gchart.bar( :data => [[-10], [100]], :encoding => 'text', :horizontal => true, :min_value => -20, :max_value => 100, :axis_with_labels => 'x', :bar_colors => ['FD9A3B', '4BC7DC']).should include("chxr=0,-20,100") end it "should be able to have multiple set of data with text encoding" do Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text').should include(Gchart.jstize('chd=t:10,5.2,4,45,78|20,40,70,15,99')) end it "should be able to receive a custom param" do Gchart.line(:custom => 'ceci_est_une_pipe').should include('ceci_est_une_pipe') end it "should be able to set label axis" do Gchart.line(:axis_with_labels => 'x,y,r').should include('chxt=x,y,r') Gchart.line(:axis_with_labels => ['x','y','r']).should include('chxt=x,y,r') end it "should be able to have axis labels" do Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']).should include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')) Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan']).should include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')) Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']]).should include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')) Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']]).should include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')) end def labeled_line(options = {}) Gchart.line({:data => @data, :axis_with_labels => 'x,y'}.merge(options)) end it "should display ranges properly" do @data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] labeled_line(:axis_labels => [((1..24).to_a << 1)]). should include('chxr=0,85,672') end def labeled_bar(options = {}) Gchart.bar({:data => @data, :axis_with_labels => 'x,y', :axis_labels => [(1..12).to_a], :encoding => "text" }.merge(options)) end it "should force the y range properly" do @data = [1,1,1,1,1,1,1,1,6,2,1,1] labeled_bar( :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,0|1,0,16') labeled_bar( :max_value => 16, :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,16|1,0,16') # nil means ignore axis labeled_bar( :axis_range => [nil,[0,16]] ).should include('chxr=1,0,16') # empty array means take defaults labeled_bar( :max_value => 16, :axis_range => [[],[0,16]] ).should include('chxr=0,0,16|1,0,16') labeled_bar( :axis_range => [[],[0,16]] ).should include('chxr=0,0|1,0,16') Gchart.line( :data => [0,20, 40, 60, 140, 230, 60], :axis_with_labels => 'y').should include("chxr=0,0,230") end it "should take in consideration the max value when creating a range" do data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] url = Gchart.line(:data => data, :axis_with_labels => 'x,y', :axis_labels => [((1..24).to_a << 1)], :max_value => 700) url.should include('chxr=0,85,700') end it 'should generate different labels and legend' do Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three)).should(include('chdl=1|2|3') && include('chl=one|two|three')) end end describe "generating different type of charts" do it "should be able to generate a line chart" do Gchart.line.should be_an_instance_of(String) Gchart.line.should include('cht=lc') end it "should be able to generate a sparkline chart" do Gchart.sparkline.should be_an_instance_of(String) Gchart.sparkline.should include('cht=ls') end it "should be able to generate a line xy chart" do Gchart.line_xy.should be_an_instance_of(String) Gchart.line_xy.should include('cht=lxy') end it "should be able to generate a scatter chart" do Gchart.scatter.should be_an_instance_of(String) Gchart.scatter.should include('cht=s') end it "should be able to generate a bar chart" do Gchart.bar.should be_an_instance_of(String) Gchart.bar.should include('cht=bvs') end it "should be able to generate a Venn diagram" do Gchart.venn.should be_an_instance_of(String) Gchart.venn.should include('cht=v') end it "should be able to generate a Pie Chart" do Gchart.pie.should be_an_instance_of(String) Gchart.pie.should include('cht=p') end it "should be able to generate a Google-O-Meter" do Gchart.meter.should be_an_instance_of(String) Gchart.meter.should include('cht=gom') end it "should be able to generate a map chart" do Gchart.map.should be_an_instance_of(String) Gchart.map.should include('cht=t') end it "should not support other types" do msg = "sexy is not a supported chart format. Please use one of the following: #{Gchart.supported_types}." lambda{Gchart.sexy}.should raise_error(NoMethodError) end end describe "range markers" do it "should be able to generate given a hash of range-marker options" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}).should include('chm=r,ff0000,0,0.59,0.61') end it "should be able to generate given an array of range-marker hash options" do Gchart.line(:range_markers => [ {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}, {:start_position => 0, :stop_position => 0.6, :color => '666666'}, {:color => 'cccccc', :start_position => 0.6, :stop_position => 1} ]).should include(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1')) end it "should allow a :overlaid? to be set" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true}).should include('chm=r,ffffff,0,0.59,0.61,1') Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false}).should include('chm=r,ffffff,0,0.59,0.61') end describe "when setting the orientation option" do before(:each) do @options = {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'} end it "to vertical (R) if given a valid option" do Gchart.line(:range_markers => @options.merge(:orientation => 'v')).should include('chm=R') Gchart.line(:range_markers => @options.merge(:orientation => 'V')).should include('chm=R') Gchart.line(:range_markers => @options.merge(:orientation => 'R')).should include('chm=R') Gchart.line(:range_markers => @options.merge(:orientation => 'vertical')).should include('chm=R') Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical')).should include('chm=R') end it "to horizontal (r) if given a valid option (actually anything other than the vertical options)" do Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal')).should include('chm=r') Gchart.line(:range_markers => @options.merge(:orientation => 'h')).should include('chm=r') Gchart.line(:range_markers => @options.merge(:orientation => 'etc')).should include('chm=r') end it "if left blank defaults to horizontal (r)" do Gchart.line(:range_markers => @options).should include('chm=r') end end end describe "a bar graph" do it "should have a default vertical orientation" do Gchart.bar.should include('cht=bvs') end it "should be able to have a different orientation" do Gchart.bar(:orientation => 'vertical').should include('cht=bvs') Gchart.bar(:orientation => 'v').should include('cht=bvs') Gchart.bar(:orientation => 'h').should include('cht=bhs') Gchart.bar(:orientation => 'horizontal').should include('cht=bhs') Gchart.bar(:horizontal => false).should include('cht=bvs') end it "should be set to be stacked by default" do Gchart.bar.should include('cht=bvs') end - it "should be able to stacked, grouped or overlapping" do + it "should be able to stacked, grouped or overlapped" do Gchart.bar(:stacked => true).should include('cht=bvs') - Gchart.bar(:stacked => false).should include('cht=bvg') + Gchart.bar(:stacked => false).should include('cht=bvs') Gchart.bar(:grouped => true).should include('cht=bvg') Gchart.bar(:grouped => false).should include('cht=bvs') - Gchart.bar(:overlapping => true).should include('cht=bvo') - Gchart.bar(:overlapping => false).should include('cht=bvg') + Gchart.bar(:overlapped => true).should include('cht=bvo') + Gchart.bar(:overlapped => false).should include('cht=bvs') end it "should be able to have different bar colors" do Gchart.bar(:bar_colors => 'efefef,00ffff').should include('chco=') Gchart.bar(:bar_colors => 'efefef,00ffff').should include('chco=efefef,00ffff') # alias Gchart.bar(:bar_color => 'efefef').should include('chco=efefef') end it "should be able to have different bar colors when using an array of colors" do Gchart.bar(:bar_colors => ['efefef','00ffff']).should include('chco=efefef,00ffff') end it 'should be able to accept a string of width and spacing options' do Gchart.bar(:bar_width_and_spacing => '25,6').should include('chbh=25,6') end it 'should be able to accept a single fixnum width and spacing option to set the bar width' do Gchart.bar(:bar_width_and_spacing => 25).should include('chbh=25') end it 'should be able to accept an array of width and spacing options' do Gchart.bar(:bar_width_and_spacing => [25,6,12]).should include('chbh=25,6,12') Gchart.bar(:bar_width_and_spacing => [25,6]).should include('chbh=25,6') Gchart.bar(:bar_width_and_spacing => [25]).should include('chbh=25') end describe "with a hash of width and spacing options" do before(:each) do @default_width = 23 @default_spacing = 4 @default_group_spacing = 8 end it 'should be able to have a custom bar width' do Gchart.bar(:bar_width_and_spacing => {:width => 19}).should include("chbh=19,#{@default_spacing},#{@default_group_spacing}") end it 'should be able to have custom spacing' do Gchart.bar(:bar_width_and_spacing => {:spacing => 19}).should include("chbh=#{@default_width},19,#{@default_group_spacing}") end it 'should be able to have custom group spacing' do Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19}).should include("chbh=#{@default_width},#{@default_spacing},19") end end end describe "a line chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @chart = Gchart.line(:title => @title, :legend => @legend) end it 'should be able have a chart title' do @chart.should include("chtt=Chart+Title") end it "should be able to a custom color, size and alignment for title" do Gchart.line(:title => @title, :title_color => 'FF0000').should include('chts=FF0000') Gchart.line(:title => @title, :title_size => '20').should include('chts=454545,20') Gchart.line(:title => @title, :title_size => '20', :title_alignment => :left).should include('chts=454545,20,l') end it "should be able to have multiple legends" do @chart.should include(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")) end it "should escape text values in url" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend) chart.should include(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")) end it "should be able to have one legend" do chart = Gchart.line(:legend => 'legend label') chart.should include("chdl=legend+label") end it "should be able to set the position of the legend" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend, :legend_position => :bottom_vertical) chart.should include("chdlp=bv") chart = Gchart.line(:title => title, :legend => legend, :legend_position => 'r') chart.should include("chdlp=r") end it "should be able to set the background fill" do Gchart.line(:bg => 'efefef').should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=bg,lg,90,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'}).should include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do Gchart.line(:graph_bg => 'efefef').should include("chf=c,s,efefef") Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'}).should include("chf=c,s,efefef") Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=c,lg,0,efefef,0,ffffff,1") Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=c,lg,0,efefef,0,ffffff,1") Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=c,lg,90,efefef,0,ffffff,1") end it "should be able to set both a graph and a background fill" do Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').should match /chf=(bg,s,efefef\|c,s,76A4FB|c,s,76A4FB\|bg,s,efefef)/ end it "should be able to have different line colors" do Gchart.line(:line_colors => 'efefef|00ffff').should include(Gchart.jstize('chco=efefef|00ffff')) Gchart.line(:line_color => 'efefef|00ffff').should include(Gchart.jstize('chco=efefef|00ffff')) end it "should be able to render a graph where all the data values are 0" do Gchart.line(:data => [0, 0, 0]).should include("chd=s:AAA") end end describe "a sparkline chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [27,25,25,25,25,27,100,31,25,36,25,25,39,25,31,25,25,25,26,26,25,25,28,25,25,100,28,27,31,25,27,27,29,25,27,26,26,25,26,26,35,33,34,25,26,25,36,25,26,37,33,33,37,37,39,25,25,25,25] @chart = Gchart.sparkline(:title => @title, :data => @data, :legend => @legend) end it "should create a sparkline" do @chart.should include('cht=ls') end it 'should be able have a chart title' do @chart.should include("chtt=Chart+Title") end it "should be able to a custom color and size title" do Gchart.sparkline(:title => @title, :title_color => 'FF0000').should include('chts=FF0000') Gchart.sparkline(:title => @title, :title_size => '20').should include('chts=454545,20') end it "should be able to have multiple legends" do @chart.should include(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")) end it "should be able to have one legend" do chart = Gchart.sparkline(:legend => 'legend label') chart.should include("chdl=legend+label") end it "should be able to set the background fill" do Gchart.sparkline(:bg => 'efefef').should include("chf=bg,s,efefef") Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=bg,lg,90,efefef,0,ffffff,1") Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'}).should include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do Gchart.sparkline(:graph_bg => 'efefef').should include("chf=c,s,efefef") Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'}).should include("chf=c,s,efefef") Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=c,lg,0,efefef,0,ffffff,1") Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=c,lg,0,efefef,0,ffffff,1") Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=c,lg,90,efefef,0,ffffff,1") end it "should be able to set both a graph and a background fill" do Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').should match(/chf=(bg,s,efefef\|c,s,76A4FB|c,s,76A4FB\|bg,s,efefef)/) end it "should be able to have different line colors" do Gchart.sparkline(:line_colors => 'efefef|00ffff').should include(Gchart.jstize('chco=efefef|00ffff')) Gchart.sparkline(:line_color => 'efefef|00ffff').should include(Gchart.jstize('chco=efefef|00ffff')) end end describe "a 3d pie chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [12,8,40,15,5] @chart = Gchart.pie(:title => @title, :legend => @legend, :data => @data) end it "should create a pie" do @chart.should include('cht=p') end it "should be able to be in 3d" do Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data).should include('cht=p3') end end describe "a google-o-meter" do before(:each) do @data = [70] @legend = ['arrow points here'] @jstized_legend = Gchart.jstize(@legend.join('|')) @chart = Gchart.meter(:data => @data) end it "should create a meter" do @chart.should include('cht=gom') end it "should be able to set a solid background fill" do Gchart.meter(:bg => 'efefef').should include("chf=bg,s,efefef") Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") end it "should be able to set labels by using the legend or labesl accessor" do Gchart.meter(:title => @title, :labels => @legend, :data => @data).should include("chl=#{@jstized_legend}") Gchart.meter(:title => @title, :labels => @legend, :data => @data).should == Gchart.meter(:title => @title, :legend => @legend, :data => @data) end end describe "a map chart" do before(:each) do @data = [0,100,50,32] @geographical_area = 'usa' @map_colors = ['FFFFFF', 'FF0000', 'FFFF00', '00FF00'] @country_codes = ['MT', 'WY', "ID", 'SD'] @chart = Gchart.map(:data => @data, :encoding => 'text', :size => '400x300', :geographical_area => @geographical_area, :map_colors => @map_colors, :country_codes => @country_codes) end it "should create a map" do @chart.should include('cht=t') end it "should set the geographical area" do @chart.should include('chtm=usa') end it "should set the map colors" do @chart.should include('chco=FFFFFF,FF0000,FFFF00,00FF00') end it "should set the country/state codes" do @chart.should include('chld=MTWYIDSD') end it "should set the chart data" do @chart.should include('chd=t:0,100,50,32') end end describe 'exporting a chart' do it "should be available in the url format by default" do Gchart.line(:data => [0, 26], :format => 'url').should == Gchart.line(:data => [0, 26]) end it "should be available as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using img_tag alias" do Gchart.line(:data => [0, 26], :format => 'img_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom dimensions" do Gchart.line(:data => [0, 26], :format => 'image_tag', :size => '400x400').should match(/<img src=(.*) width="400" height="400" alt="Google Chart" \/>/) end it "should be available as an image tag using custom alt text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :alt => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Sexy chart" \/>/) end it "should be available as an image tag using custom title text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :title => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" title="Sexy chart" \/>/) end it "should be available as an image tag using custom css id selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :id => 'chart').should match(/<img id="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom css class selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should match(/<img class="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should use ampersands to separate key/value pairs in URLs by default" do Gchart.line(:data => [0, 26]).should include "&" Gchart.line(:data => [0, 26]).should_not include "&amp;" end it "should escape ampersands in URLs when used as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should satisfy {|chart| chart.should include "&amp;" } end it "should be available as a file" do File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file') File.exist?('chart.png').should be_true File.delete('chart.png') if File.exist?('chart.png') end it "should be available as a file using a custom file name" do File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') Gchart.line(:data => [0, 26], :format => 'file', :filename => 'custom_file_name.png') File.exist?('custom_file_name.png').should be_true File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') end it "should work even with multiple attrs" do File.delete('foo.png') if File.exist?('foo.png') Gchart.line(:size => '400x200', :data => [1,2,3,4,5], # :axis_labels => [[1,2,3,4, 5], %w[foo bar]], :axis_with_labels => 'x,r', :format => "file", :filename => "foo.png" ) File.exist?('foo.png').should be_true File.delete('foo.png') if File.exist?('foo.png') end end describe 'SSL support' do it 'should change url if is presented' do Gchart.line(:use_ssl => true).should include('https://chart.googleapis.com/chart?') end it "should be available as a file" do pending "unexpected error under Travis CI (should be fixed using http://martinottenwaelter.fr/2010/12/ruby19-and-the-ssl-error/)" File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file', :use_ssl => true) File.exist?('chart.png').should be_true File.delete('chart.png') if File.exist?('chart.png') end end
mattetti/googlecharts
a0b8ab2dee8483dd8e1df7d7b30770ca1d90186f
Adding an extra option for bar charts. In addition to grouped and stacked, they can also be overlapping. Please see documentation for reference: http://code.google.com/apis/chart/image/docs/gallery/bar_charts.html
diff --git a/lib/gchart.rb b/lib/gchart.rb index c597793..bfd3877 100644 --- a/lib/gchart.rb +++ b/lib/gchart.rb @@ -1,721 +1,729 @@ $:.unshift File.dirname(__FILE__) require 'gchart/version' require 'gchart/theme' require "net/http" require "net/https" require "uri" require "cgi" require 'enumerator' class Gchart include GchartInfo def self.url(use_ssl = false) if use_ssl 'https://chart.googleapis.com/chart?' else 'http://chart.apis.google.com/chart?' end end def self.types @types ||= ['line', 'line_xy', 'scatter', 'bar', 'venn', 'pie', 'pie_3d', 'jstize', 'sparkline', 'meter', 'map', 'radar'] end def self.simple_chars @simple_chars ||= ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a end def self.chars @chars ||= simple_chars + ['-', '.'] end def self.ext_pairs @ext_pairs ||= chars.map { |char_1| chars.map { |char_2| char_1 + char_2 } }.flatten end def self.default_filename 'chart.png' end - attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :legend, :legend_position, :labels, :data, :encoding, :bar_colors, + attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :overlapping, :legend, :legend_position, :labels, :data, :encoding, :bar_colors, :title_color, :title_size, :title_alignment, :custom, :axis_with_labels, :axis_labels, :bar_width_and_spacing, :id, :alt, :klass, :range_markers, :geographical_area, :map_colors, :country_codes, :axis_range, :filename, :min, :max, :colors, :usemap attr_accessor :bg_type, :bg_color, :bg_angle, :chart_type, :chart_color, :chart_angle, :axis_range, :thickness, :new_markers, :grid_lines, :use_ssl attr_accessor :min_value, :max_value types.each do |type| instance_eval <<-DYNCLASSMETH def #{type}(options = {}) # Start with theme defaults if a theme is set theme = options[:theme] options = theme ? Chart::Theme.load(theme).to_options.merge(options) : options # # Extract the format and optional filename, then clean the hash format = options[:format] || 'url' options[:filename] ||= default_filename options.delete(:format) #update map_colors to become bar_colors options.update(:bar_colors => options[:map_colors]) if options.has_key?(:map_colors) chart = new(options.merge!({:type => "#{type}"})) chart.send(format) end DYNCLASSMETH end def self.version VERSION::STRING end def self.method_missing(m, options={}) raise NoMethodError, "#{m} is not a supported chart format. Please use one of the following: #{supported_types}." end def initialize(options={}) # Allow Gchart to take a theme too @theme = options[:theme] options = @theme ? Chart::Theme.load(@theme).to_options.merge(options) : options options.delete(:theme) @type = options[:type] || 'line' @data = [] @width = 300 @height = 200 @curved = false @horizontal = false @grouped = false + @overlapping = false @use_ssl = false @encoding = 'simple' # @max_value = 'auto' # @min_value defaults to nil meaning zero @filename = options[:filename] # Sets the alt tag when chart is exported as image tag @alt = 'Google Chart' # Sets the CSS id selector when chart is exported as image tag @id = false # Sets the CSS class selector when chart is exported as image tag @klass = options[:class] || false # set the options value if definable options.each do |attribute, value| send("#{attribute}=", value) if self.respond_to?("#{attribute}=") end end def self.supported_types self.types.join(' ') end # Defines the Graph size using the following format: # width X height def size=(size='300x200') @width, @height = size.split("x").map { |dimension| dimension.to_i } end def size "#{width}x#{height}" end def dimensions # TODO: maybe others? [:line_xy, :scatter].include?(type) ? 2 : 1 end # Sets the orientation of a bar graph def orientation=(orientation='h') if orientation == 'h' || orientation == 'horizontal' self.horizontal = true elsif orientation == 'v' || orientation == 'vertical' self.horizontal = false end end # Sets the bar graph presentation (stacked or grouped) def stacked=(option=true) + @overlapping = false + @grouped = option ? false : true + end + + # Sets the bar graph presentation (overlapping or grouped) + def overlapping=(option=true) + @overlapping = option @grouped = option ? false : true end def bg=(options) if options.is_a?(String) @bg_color = options elsif options.is_a?(Hash) @bg_color = options[:color] @bg_type = options[:type] @bg_angle = options[:angle] end end def graph_bg=(options) if options.is_a?(String) @chart_color = options elsif options.is_a?(Hash) @chart_color = options[:color] @chart_type = options[:type] @chart_angle = options[:angle] end end def max_value=(max_v) if max_v =~ /false/ @max_value = false else @max_value = max_v end end def min_value=(min_v) if min_v =~ /false/ @min_value = false else @min_value = min_v end end # returns the full data range as an array # it also sets the data range if not defined def full_data_range(ds) return if max_value == false ds.each_with_index do |mds, mds_index| mds[:min_value] ||= min_value mds[:max_value] ||= max_value if mds_index == 0 && type.to_s == 'bar' # TODO: unless you specify a zero line (using chp or chds), # the min_value of a bar chart is always 0. #mds[:min_value] ||= mds[:data].first.to_a.compact.min mds[:min_value] ||= 0 end if (mds_index == 0 && type.to_s == 'bar' && !grouped && mds[:data].first.is_a?(Array)) totals = [] mds[:data].each do |l| l.each_with_index do |v, index| next if v.nil? totals[index] ||= 0 totals[index] += v end end mds[:max_value] ||= totals.compact.max else all = mds[:data].flatten.compact # default min value should be 0 unless set to auto if mds[:min_value] == 'auto' mds[:min_value] = all.min else min = all.min mds[:min_value] ||= (min && min < 0 ? min : 0) end mds[:max_value] ||= all.max end end unless axis_range @calculated_axis_range = true @axis_range = ds.map{|mds| [mds[:min_value], mds[:max_value]]} if dimensions == 1 && (type.to_s != 'bar' || horizontal) tmp = axis_range.fetch(0, []) @axis_range[0] = axis_range.fetch(1, []) @axis_range[1] = tmp end end # return [min, max] unless (min.nil? || max.nil?) # @max = (max_value.nil? || max_value == 'auto') ? ds.compact.map{|mds| mds.compact.max}.max : max_value # # if min_value.nil? # min_ds_value = ds.compact.map{|mds| mds.compact.min}.min || 0 # @min = (min_ds_value < 0) ? min_ds_value : 0 # else # @min = min_value == 'auto' ? ds.compact.map{|mds| mds.compact.min}.min || 0 : min_value # end # @axis_range = [[min,max]] end def dataset if @dataset @dataset else @dataset = convert_dataset(data || []) full_data_range(@dataset) # unless axis_range @dataset end end # Sets of data to handle multiple sets def datasets datasets = [] dataset.each do |d| if d[:data].first.is_a?(Array) datasets += d[:data] else datasets << d[:data] end end datasets end def self.jstize(string) # See http://github.com/mattetti/googlecharts/issues#issue/27 #URI.escape( string ).gsub("%7C", "|") # See discussion: http://github.com/mattetti/googlecharts/commit/9b5cfb93aa51aae06611057668e631cd515ec4f3#comment_51347 string.gsub(' ', '+').gsub(/\[|\{|\}|\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} #string.gsub(' ', '+').gsub(/\[|\{|\}|\||\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} end # load all the custom aliases require 'gchart/aliases' # Returns the chart's generated PNG as a blob. (borrowed from John's gchart.rubyforge.org) def fetch url = URI.parse(self.class.url(use_ssl)) req = Net::HTTP::Post.new(url.path) req.body = query_builder req.content_type = 'application/x-www-form-urlencoded' http = Net::HTTP.new(url.host, url.port) http.verify_mode = OpenSSL::SSL::VERIFY_PEER if use_ssl http.use_ssl = use_ssl http.start {|resp| resp.request(req) }.body end # Writes the chart's generated PNG to a file. (borrowed from John's gchart.rubyforge.org) def write io_or_file = filename || self.class.default_filename return io_or_file.write(fetch) if io_or_file.respond_to?(:write) open(io_or_file, "wb+") { |io| io.write(fetch) } end # Format def image_tag image = "<img" image += " id=\"#{id}\"" if id image += " class=\"#{klass}\"" if klass image += " src=\"#{url_builder(:html)}\"" image += " width=\"#{width}\"" image += " height=\"#{height}\"" image += " alt=\"#{alt}\"" image += " title=\"#{title}\"" if title image += " usemap=\"#{usemap}\"" if usemap image += " />" end alias_method :img_tag, :image_tag def url url_builder end def file write end # def jstize(string) self.class.jstize(string) end private # The title size cannot be set without specifying a color. # A dark key will be used for the title color if no color is specified def set_title title_params = "chtt=#{title}".gsub(/\|/,"\n") unless (title_color.nil? && title_size.nil? && title_alignment.nil?) title_params << "&chts=" + (color, size, alignment = (title_color || '454545'), title_size, (title_alignment.to_s[0,1] || 'c')).compact.join(',') end title_params end def set_size "chs=#{size}" end def set_data data = send("#{@encoding}_encoding") "chd=#{data}" end def set_colors @bg_type = fill_type(bg_type) || 's' if bg_color @chart_type = fill_type(chart_type) || 's' if chart_color "chf=" + {'bg' => fill_for(bg_type, bg_color, bg_angle), 'c' => fill_for(chart_type, chart_color, chart_angle)}.map{|k,v| "#{k},#{v}" unless v.nil?}.compact.join('|') end # set bar, line colors def set_bar_colors @bar_colors = bar_colors.join(',') if bar_colors.is_a?(Array) "chco=#{bar_colors}" end def set_country_codes @country_codes = country_codes.join() if country_codes.is_a?(Array) "chld=#{country_codes}" end # set bar spacing # chbh= # <bar width in pixels>, # <optional space between bars in a group>, # <optional space between groups> def set_bar_width_and_spacing width_and_spacing_values = case bar_width_and_spacing when String bar_width_and_spacing when Array bar_width_and_spacing.join(',') when Hash width = bar_width_and_spacing[:width] || 23 spacing = bar_width_and_spacing[:spacing] || 4 group_spacing = bar_width_and_spacing[:group_spacing] || 8 [width,spacing,group_spacing].join(',') else bar_width_and_spacing.to_s end "chbh=#{width_and_spacing_values}" end def set_range_markers markers = case range_markers when Hash set_range_marker(range_markers) when Array range_markers.collect{|marker| set_range_marker(marker)}.join('|') end "chm=#{markers}" end def set_range_marker(options) orientation = ['vertical', 'Vertical', 'V', 'v', 'R'].include?(options[:orientation]) ? 'R' : 'r' "#{orientation},#{options[:color]},0,#{options[:start_position]},#{options[:stop_position]}#{',1' if options[:overlaid?]}" end def fill_for(type=nil, color='', angle=nil) unless type.nil? case type when 'lg' angle ||= 0 color = "#{color},0,ffffff,1" if color.split(',').size == 1 "#{type},#{angle},#{color}" when 'ls' angle ||= 90 color = "#{color},0.2,ffffff,0.2" if color.split(',').size == 1 "#{type},#{angle},#{color}" else "#{type},#{color}" end end end # A chart can have one or many legends. # Gchart.line(:legend => 'label') # or # Gchart.line(:legend => ['first label', 'last label']) def set_legend if type.to_s =~ /meter/ @labels = legend return set_labels end if legend.is_a?(Array) "chdl=#{@legend.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chdl=#{legend}" end end def set_legend_position case @legend_position.to_s when /(bottom|b)$/ "chdlp=b" when /(bottom_vertical|bv)$/ "chdlp=bv" when /(top|t)$/ "chdlp=t" when /(top_vertical|tv)$/ "chdlp=tv" when /(right|r)$/ "chdlp=r" when /(left|l)$/ "chdlp=l" end end def set_line_thickness "chls=#{thickness}" end def set_line_markers "chm=#{new_markers}" end def set_grid_lines "chg=#{grid_lines}" end def set_labels if labels.is_a?(Array) "chl=#{@labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chl=#{@labels}" end end def set_axis_with_labels @axis_with_labels = axis_with_labels.join(',') if @axis_with_labels.is_a?(Array) "chxt=#{axis_with_labels}" end def set_axis_labels if axis_labels.is_a?(Array) if RUBY_VERSION.to_f < 1.9 labels_arr = axis_labels.enum_with_index.map{|labels,index| [index,labels]} else labels_arr = axis_labels.map.with_index.map{|labels,index| [index,labels]} end elsif axis_labels.is_a?(Hash) labels_arr = axis_labels.to_a end labels_arr.map! do |index,labels| if labels.is_a?(Array) "#{index}:|#{labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "#{index}:|#{labels}" end end "chxl=#{labels_arr.join('|')}" end # http://code.google.com/apis/chart/labels.html#axis_range # Specify a range for axis labels def set_axis_range # a passed axis_range should look like: # [[10,100]] or [[10,100,4]] or [[10,100], [20,300]] # in the second example, 4 is the interval set = @calculated_axis_range ? datasets : axis_range || datasets return unless set && set.respond_to?(:each) && set.find {|o| o}.respond_to?(:each) 'chxr=' + set.enum_for(:each_with_index).map do |axis_range, index| next nil if axis_range.nil? # ignore this axis min, max, step = axis_range if axis_range.size > 3 || step && max && step > max # this is a full series max = axis_range.compact.max step = nil end [index, (min_value || min || 0), (max_value || max), step].compact.join(',') end.compact.join("|") end def set_geographical_area "chtm=#{geographical_area}" end def set_type 'cht=' + case type.to_s when 'line' then "lc" when 'line_xy' then "lxy" when 'pie_3d' then "p3" when 'pie' then "p" when 'venn' then "v" when 'scatter' then "s" when 'sparkline' then "ls" when 'meter' then "gom" when 'map' then "t" when 'radar' "r" + (curved? ? 's' : '') when 'bar' - "b" + (horizontal? ? "h" : "v") + (grouped? ? "g" : "s") + "b" + (horizontal? ? "h" : "v") + (grouped? ? "g" : (overlapping? ? "o" : "s")) end end def fill_type(type) case type when 'solid' then 's' when 'gradient' then 'lg' when 'stripes' then 'ls' end end def number_visible n = 0 dataset.each do |mds| return n.to_s if mds[:invisible] == true if mds[:data].first.is_a?(Array) n += mds[:data].length else n += 1 end end "" end # Turns input into an array of axis hashes, dependent on the chart type def convert_dataset(ds) if dimensions == 2 # valid inputs include: # an array of >=2 arrays, or an array of >=2 hashes ds = ds.map do |d| d.is_a?(Hash) ? d : {:data => d} end elsif dimensions == 1 # valid inputs include: # a hash, an array of data, an array of >=1 array, or an array of >=1 hash if ds.is_a?(Hash) ds = [ds] elsif not ds.first.is_a?(Hash) ds = [{:data => ds}] end end ds end # just an alias def axis_set dataset end def convert_to_simple_value(number) if number.nil? "_" else value = self.class.simple_chars[number.to_i] value.nil? ? "_" : value end end def convert_to_extended_value(number) if number.nil? '__' else value = self.class.ext_pairs[number.to_i] value.nil? ? "__" : value end end def encode_scaled_dataset(chars, nil_char) dsets = [] dataset.each do |ds| if max_value != false range = ds[:max_value] - ds[:min_value] range = 1 if range == 0 end unless ds[:data].first.is_a?(Array) ldatasets = [ds[:data]] else ldatasets = ds[:data] end ldatasets.each do |l| dsets << l.map do |number| if number.nil? nil_char else unless range.nil? || range.zero? number = chars.size * (number - ds[:min_value]) / range.to_f number = [number, chars.size - 1].min end chars[number.to_i] end end.join end end dsets.join(',') end # http://code.google.com/apis/chart/#simple # Simple encoding has a resolution of 62 different values. # Allowing five pixels per data point, this is sufficient for line and bar charts up # to about 300 pixels. Simple encoding is suitable for all other types of chart regardless of size. def simple_encoding "s" + number_visible + ":" + encode_scaled_dataset(self.class.simple_chars, '_') end # http://code.google.com/apis/chart/#text # Text encoding with data scaling lets you specify arbitrary positive or # negative floating point numbers, in combination with a scaling parameter # that lets you specify a custom range for your chart. This chart is useful # when you don't want to worry about limiting your data to a specific range, # or do the calculations to scale your data down or up to fit nicely inside # a chart. # # Valid values range from (+/-)9.999e(+/-)100, and only four non-zero digits are supported (that is, 123400, 1234, 12.34, and 0.1234 are valid, but 12345, 123.45 and 123400.5 are not). # # This encoding is not available for maps. # def text_encoding chds = dataset.map{|ds| "#{ds[:min_value]},#{ds[:max_value]}" }.join(",") "t" + number_visible + ":" + datasets.map{ |ds| ds.map{|e|e||'_'}.join(',') }.join('|') + "&chds=" + chds end # http://code.google.com/apis/chart/#extended # Extended encoding has a resolution of 4,096 different values # and is best used for large charts where a large data range is required. def extended_encoding "e" + number_visible + ":" + encode_scaled_dataset(self.class.ext_pairs, '__') end def url_builder(options="") self.class.url(use_ssl) + query_builder(options) end def query_builder(options="") query_params = instance_variables.sort.map do |var| case var.to_s when '@data' set_data unless data == [] # Set the graph size when '@width' set_size unless width.nil? || height.nil? when '@type' set_type when '@title' set_title unless title.nil? when '@legend' set_legend unless legend.nil? when '@labels' set_labels unless labels.nil? when '@legend_position' set_legend_position unless legend_position.nil? when '@thickness' set_line_thickness when '@new_markers' set_line_markers when '@bg_color' set_colors when '@chart_color' set_colors if bg_color.nil? when '@bar_colors' set_bar_colors when '@bar_width_and_spacing' set_bar_width_and_spacing when '@axis_with_labels' set_axis_with_labels when '@axis_labels' set_axis_labels when '@range_markers' set_range_markers when '@grid_lines' set_grid_lines when '@geographical_area' set_geographical_area when '@country_codes' set_country_codes when '@custom' custom end end.compact query_params << set_axis_range # Use ampersand as default delimiter unless options == :html delimiter = '&' # Escape ampersand for html image tags else delimiter = '&amp;' end jstize(query_params.join(delimiter)) end end diff --git a/lib/gchart/aliases.rb b/lib/gchart/aliases.rb index 48d5627..69a7f47 100644 --- a/lib/gchart/aliases.rb +++ b/lib/gchart/aliases.rb @@ -1,15 +1,16 @@ class Gchart alias_method :background=, :bg= alias_method :chart_bg=, :graph_bg= alias_method :chart_color=, :graph_bg= alias_method :chart_background=, :graph_bg= alias_method :bar_color=, :bar_colors= alias_method :line_colors=, :bar_colors= alias_method :line_color=, :bar_colors= alias_method :slice_colors=, :bar_colors= alias_method :horizontal?, :horizontal alias_method :grouped?, :grouped + alias_method :overlapping?, :overlapping alias_method :curved?, :curved end diff --git a/spec/gchart_spec.rb b/spec/gchart_spec.rb index d361ef3..b45dba8 100644 --- a/spec/gchart_spec.rb +++ b/spec/gchart_spec.rb @@ -1,663 +1,665 @@ require File.dirname(__FILE__) + '/spec_helper.rb' require File.dirname(__FILE__) + '/../lib/gchart' Chart::Theme.add_theme_file("#{File.dirname(__FILE__)}/fixtures/test_theme.yml") # Time to add your specs! # http://rspec.rubyforge.org/ describe "The Gchart class" do it "should show supported_types on error" do Gchart.supported_types.should match(/line/) end it "should return supported types" do Gchart.types.should include('line') end it "should support theme option" do chart = Gchart.new(:type => 'line',:theme => :test) chart.send('url').should include('chco=6886B4,FDD84E') end end describe "generating a default Gchart" do before(:each) do @chart = Gchart.line end it "should create a line break when a pipe character is encountered" do @chart = Gchart.line(:title => "title|subtitle") @chart.should include("chtt=title\nsubtitle") end it "should include the Google URL" do @chart.should include("http://chart.apis.google.com/chart?") end it "should have a default size" do @chart.should include('chs=300x200') end it "should be able to have a custom size" do Gchart.line(:size => '400x600').should include('chs=400x600') Gchart.line(:width => 400, :height => 600).should include('chs=400x600') end it "should have query parameters in predictable order" do Gchart.line(:axis_with_labels => 'x,y,r', :size => '400x600').should match(/chxt=.+cht=.+chs=/) end it "should have a type" do @chart.should include('cht=lc') end it 'should use theme defaults if theme is set' do Gchart.line(:theme=>:test).should include('chco=6886B4,FDD84E') Gchart.line(:theme=>:test).should match(/chf=(c,s,FFFFFF\|bg,s,FFFFFF|bg,s,FFFFFF\|c,s,FFFFFF)/) end it "should use the simple encoding by default with auto max value" do # 9 is the max value in simple encoding, 26 being our max value the 2nd encoded value should be 9 Gchart.line(:data => [0, 26]).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => 26, :axis_with_labels => 'y').should include('chxr=0,0,26') end it "should support simple encoding with and without max_value" do Gchart.line(:data => [0, 26], :max_value => 26).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => false).should include('chd=s:Aa') end it "should support the extended encoding and encode properly" do Gchart.line(:data => [0, 10], :encoding => 'extended', :max_value => false).should include('chd=e:AA') Gchart.line(:encoding => 'extended', :max_value => false, :data => [[0,25,26,51,52,61,62,63], [64,89,90,115,4084]] ).should include('chd=e:AAAZAaAzA0A9A-A.,BABZBaBz.0') end it "should auto set the max value for extended encoding" do Gchart.line(:data => [0, 25], :encoding => 'extended', :max_value => false).should include('chd=e:AAAZ') # Extended encoding max value is '..' Gchart.line(:data => [0, 25], :encoding => 'extended').should include('chd=e:AA..') end it "should be able to have data with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,4,45,78') end it "should be able to have missing data points with text encoding" do Gchart.line(:data => [10, 5.2, nil, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,_,45,78') end it "should handle max and min values with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=0,78') end it "should automatically handle negative values with proper max/min limits when using text encoding" do Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=-10,78') end it "should handle negative values with manual max/min limits when using text encoding" do Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text', :min_value => -20, :max_value => 100).should include('chds=-20,100') end it "should set the proper axis values when using text encoding and negative values" do Gchart.bar( :data => [[-10], [100]], :encoding => 'text', :horizontal => true, :min_value => -20, :max_value => 100, :axis_with_labels => 'x', :bar_colors => ['FD9A3B', '4BC7DC']).should include("chxr=0,-20,100") end it "should be able to have multiple set of data with text encoding" do Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text').should include(Gchart.jstize('chd=t:10,5.2,4,45,78|20,40,70,15,99')) end it "should be able to receive a custom param" do Gchart.line(:custom => 'ceci_est_une_pipe').should include('ceci_est_une_pipe') end it "should be able to set label axis" do Gchart.line(:axis_with_labels => 'x,y,r').should include('chxt=x,y,r') Gchart.line(:axis_with_labels => ['x','y','r']).should include('chxt=x,y,r') end it "should be able to have axis labels" do Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']).should include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')) Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan']).should include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')) Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']]).should include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')) Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']]).should include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')) end def labeled_line(options = {}) Gchart.line({:data => @data, :axis_with_labels => 'x,y'}.merge(options)) end it "should display ranges properly" do @data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] labeled_line(:axis_labels => [((1..24).to_a << 1)]). should include('chxr=0,85,672') end def labeled_bar(options = {}) Gchart.bar({:data => @data, :axis_with_labels => 'x,y', :axis_labels => [(1..12).to_a], :encoding => "text" }.merge(options)) end it "should force the y range properly" do @data = [1,1,1,1,1,1,1,1,6,2,1,1] labeled_bar( :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,0|1,0,16') labeled_bar( :max_value => 16, :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,16|1,0,16') # nil means ignore axis labeled_bar( :axis_range => [nil,[0,16]] ).should include('chxr=1,0,16') # empty array means take defaults labeled_bar( :max_value => 16, :axis_range => [[],[0,16]] ).should include('chxr=0,0,16|1,0,16') labeled_bar( :axis_range => [[],[0,16]] ).should include('chxr=0,0|1,0,16') Gchart.line( :data => [0,20, 40, 60, 140, 230, 60], :axis_with_labels => 'y').should include("chxr=0,0,230") end it "should take in consideration the max value when creating a range" do data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] url = Gchart.line(:data => data, :axis_with_labels => 'x,y', :axis_labels => [((1..24).to_a << 1)], :max_value => 700) url.should include('chxr=0,85,700') end it 'should generate different labels and legend' do Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three)).should(include('chdl=1|2|3') && include('chl=one|two|three')) end end describe "generating different type of charts" do it "should be able to generate a line chart" do Gchart.line.should be_an_instance_of(String) Gchart.line.should include('cht=lc') end it "should be able to generate a sparkline chart" do Gchart.sparkline.should be_an_instance_of(String) Gchart.sparkline.should include('cht=ls') end it "should be able to generate a line xy chart" do Gchart.line_xy.should be_an_instance_of(String) Gchart.line_xy.should include('cht=lxy') end it "should be able to generate a scatter chart" do Gchart.scatter.should be_an_instance_of(String) Gchart.scatter.should include('cht=s') end it "should be able to generate a bar chart" do Gchart.bar.should be_an_instance_of(String) Gchart.bar.should include('cht=bvs') end it "should be able to generate a Venn diagram" do Gchart.venn.should be_an_instance_of(String) Gchart.venn.should include('cht=v') end it "should be able to generate a Pie Chart" do Gchart.pie.should be_an_instance_of(String) Gchart.pie.should include('cht=p') end it "should be able to generate a Google-O-Meter" do Gchart.meter.should be_an_instance_of(String) Gchart.meter.should include('cht=gom') end it "should be able to generate a map chart" do Gchart.map.should be_an_instance_of(String) Gchart.map.should include('cht=t') end it "should not support other types" do msg = "sexy is not a supported chart format. Please use one of the following: #{Gchart.supported_types}." lambda{Gchart.sexy}.should raise_error(NoMethodError) end end describe "range markers" do it "should be able to generate given a hash of range-marker options" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}).should include('chm=r,ff0000,0,0.59,0.61') end it "should be able to generate given an array of range-marker hash options" do Gchart.line(:range_markers => [ {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}, {:start_position => 0, :stop_position => 0.6, :color => '666666'}, {:color => 'cccccc', :start_position => 0.6, :stop_position => 1} ]).should include(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1')) end it "should allow a :overlaid? to be set" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true}).should include('chm=r,ffffff,0,0.59,0.61,1') Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false}).should include('chm=r,ffffff,0,0.59,0.61') end describe "when setting the orientation option" do before(:each) do @options = {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'} end it "to vertical (R) if given a valid option" do Gchart.line(:range_markers => @options.merge(:orientation => 'v')).should include('chm=R') Gchart.line(:range_markers => @options.merge(:orientation => 'V')).should include('chm=R') Gchart.line(:range_markers => @options.merge(:orientation => 'R')).should include('chm=R') Gchart.line(:range_markers => @options.merge(:orientation => 'vertical')).should include('chm=R') Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical')).should include('chm=R') end it "to horizontal (r) if given a valid option (actually anything other than the vertical options)" do Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal')).should include('chm=r') Gchart.line(:range_markers => @options.merge(:orientation => 'h')).should include('chm=r') Gchart.line(:range_markers => @options.merge(:orientation => 'etc')).should include('chm=r') end it "if left blank defaults to horizontal (r)" do Gchart.line(:range_markers => @options).should include('chm=r') end end end describe "a bar graph" do it "should have a default vertical orientation" do Gchart.bar.should include('cht=bvs') end it "should be able to have a different orientation" do Gchart.bar(:orientation => 'vertical').should include('cht=bvs') Gchart.bar(:orientation => 'v').should include('cht=bvs') Gchart.bar(:orientation => 'h').should include('cht=bhs') Gchart.bar(:orientation => 'horizontal').should include('cht=bhs') Gchart.bar(:horizontal => false).should include('cht=bvs') end it "should be set to be stacked by default" do Gchart.bar.should include('cht=bvs') end - it "should be able to stacked or grouped" do + it "should be able to stacked, grouped or overlapping" do Gchart.bar(:stacked => true).should include('cht=bvs') Gchart.bar(:stacked => false).should include('cht=bvg') Gchart.bar(:grouped => true).should include('cht=bvg') Gchart.bar(:grouped => false).should include('cht=bvs') + Gchart.bar(:overlapping => true).should include('cht=bvo') + Gchart.bar(:overlapping => false).should include('cht=bvg') end it "should be able to have different bar colors" do Gchart.bar(:bar_colors => 'efefef,00ffff').should include('chco=') Gchart.bar(:bar_colors => 'efefef,00ffff').should include('chco=efefef,00ffff') # alias Gchart.bar(:bar_color => 'efefef').should include('chco=efefef') end it "should be able to have different bar colors when using an array of colors" do Gchart.bar(:bar_colors => ['efefef','00ffff']).should include('chco=efefef,00ffff') end it 'should be able to accept a string of width and spacing options' do Gchart.bar(:bar_width_and_spacing => '25,6').should include('chbh=25,6') end it 'should be able to accept a single fixnum width and spacing option to set the bar width' do Gchart.bar(:bar_width_and_spacing => 25).should include('chbh=25') end it 'should be able to accept an array of width and spacing options' do Gchart.bar(:bar_width_and_spacing => [25,6,12]).should include('chbh=25,6,12') Gchart.bar(:bar_width_and_spacing => [25,6]).should include('chbh=25,6') Gchart.bar(:bar_width_and_spacing => [25]).should include('chbh=25') end describe "with a hash of width and spacing options" do before(:each) do @default_width = 23 @default_spacing = 4 @default_group_spacing = 8 end it 'should be able to have a custom bar width' do Gchart.bar(:bar_width_and_spacing => {:width => 19}).should include("chbh=19,#{@default_spacing},#{@default_group_spacing}") end it 'should be able to have custom spacing' do Gchart.bar(:bar_width_and_spacing => {:spacing => 19}).should include("chbh=#{@default_width},19,#{@default_group_spacing}") end it 'should be able to have custom group spacing' do Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19}).should include("chbh=#{@default_width},#{@default_spacing},19") end end end describe "a line chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @chart = Gchart.line(:title => @title, :legend => @legend) end it 'should be able have a chart title' do @chart.should include("chtt=Chart+Title") end it "should be able to a custom color, size and alignment for title" do Gchart.line(:title => @title, :title_color => 'FF0000').should include('chts=FF0000') Gchart.line(:title => @title, :title_size => '20').should include('chts=454545,20') Gchart.line(:title => @title, :title_size => '20', :title_alignment => :left).should include('chts=454545,20,l') end it "should be able to have multiple legends" do @chart.should include(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")) end it "should escape text values in url" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend) chart.should include(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")) end it "should be able to have one legend" do chart = Gchart.line(:legend => 'legend label') chart.should include("chdl=legend+label") end it "should be able to set the position of the legend" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend, :legend_position => :bottom_vertical) chart.should include("chdlp=bv") chart = Gchart.line(:title => title, :legend => legend, :legend_position => 'r') chart.should include("chdlp=r") end it "should be able to set the background fill" do Gchart.line(:bg => 'efefef').should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=bg,lg,90,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'}).should include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do Gchart.line(:graph_bg => 'efefef').should include("chf=c,s,efefef") Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'}).should include("chf=c,s,efefef") Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=c,lg,0,efefef,0,ffffff,1") Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=c,lg,0,efefef,0,ffffff,1") Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=c,lg,90,efefef,0,ffffff,1") end it "should be able to set both a graph and a background fill" do Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').should match /chf=(bg,s,efefef\|c,s,76A4FB|c,s,76A4FB\|bg,s,efefef)/ end it "should be able to have different line colors" do Gchart.line(:line_colors => 'efefef|00ffff').should include(Gchart.jstize('chco=efefef|00ffff')) Gchart.line(:line_color => 'efefef|00ffff').should include(Gchart.jstize('chco=efefef|00ffff')) end it "should be able to render a graph where all the data values are 0" do Gchart.line(:data => [0, 0, 0]).should include("chd=s:AAA") end end describe "a sparkline chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [27,25,25,25,25,27,100,31,25,36,25,25,39,25,31,25,25,25,26,26,25,25,28,25,25,100,28,27,31,25,27,27,29,25,27,26,26,25,26,26,35,33,34,25,26,25,36,25,26,37,33,33,37,37,39,25,25,25,25] @chart = Gchart.sparkline(:title => @title, :data => @data, :legend => @legend) end it "should create a sparkline" do @chart.should include('cht=ls') end it 'should be able have a chart title' do @chart.should include("chtt=Chart+Title") end it "should be able to a custom color and size title" do Gchart.sparkline(:title => @title, :title_color => 'FF0000').should include('chts=FF0000') Gchart.sparkline(:title => @title, :title_size => '20').should include('chts=454545,20') end it "should be able to have multiple legends" do @chart.should include(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")) end it "should be able to have one legend" do chart = Gchart.sparkline(:legend => 'legend label') chart.should include("chdl=legend+label") end it "should be able to set the background fill" do Gchart.sparkline(:bg => 'efefef').should include("chf=bg,s,efefef") Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=bg,lg,90,efefef,0,ffffff,1") Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'}).should include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do Gchart.sparkline(:graph_bg => 'efefef').should include("chf=c,s,efefef") Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'}).should include("chf=c,s,efefef") Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=c,lg,0,efefef,0,ffffff,1") Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=c,lg,0,efefef,0,ffffff,1") Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=c,lg,90,efefef,0,ffffff,1") end it "should be able to set both a graph and a background fill" do Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').should match(/chf=(bg,s,efefef\|c,s,76A4FB|c,s,76A4FB\|bg,s,efefef)/) end it "should be able to have different line colors" do Gchart.sparkline(:line_colors => 'efefef|00ffff').should include(Gchart.jstize('chco=efefef|00ffff')) Gchart.sparkline(:line_color => 'efefef|00ffff').should include(Gchart.jstize('chco=efefef|00ffff')) end end describe "a 3d pie chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [12,8,40,15,5] @chart = Gchart.pie(:title => @title, :legend => @legend, :data => @data) end it "should create a pie" do @chart.should include('cht=p') end it "should be able to be in 3d" do Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data).should include('cht=p3') end end describe "a google-o-meter" do before(:each) do @data = [70] @legend = ['arrow points here'] @jstized_legend = Gchart.jstize(@legend.join('|')) @chart = Gchart.meter(:data => @data) end it "should create a meter" do @chart.should include('cht=gom') end it "should be able to set a solid background fill" do Gchart.meter(:bg => 'efefef').should include("chf=bg,s,efefef") Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") end it "should be able to set labels by using the legend or labesl accessor" do Gchart.meter(:title => @title, :labels => @legend, :data => @data).should include("chl=#{@jstized_legend}") Gchart.meter(:title => @title, :labels => @legend, :data => @data).should == Gchart.meter(:title => @title, :legend => @legend, :data => @data) end end describe "a map chart" do before(:each) do @data = [0,100,50,32] @geographical_area = 'usa' @map_colors = ['FFFFFF', 'FF0000', 'FFFF00', '00FF00'] @country_codes = ['MT', 'WY', "ID", 'SD'] @chart = Gchart.map(:data => @data, :encoding => 'text', :size => '400x300', :geographical_area => @geographical_area, :map_colors => @map_colors, :country_codes => @country_codes) end it "should create a map" do @chart.should include('cht=t') end it "should set the geographical area" do @chart.should include('chtm=usa') end it "should set the map colors" do @chart.should include('chco=FFFFFF,FF0000,FFFF00,00FF00') end it "should set the country/state codes" do @chart.should include('chld=MTWYIDSD') end it "should set the chart data" do @chart.should include('chd=t:0,100,50,32') end end describe 'exporting a chart' do it "should be available in the url format by default" do Gchart.line(:data => [0, 26], :format => 'url').should == Gchart.line(:data => [0, 26]) end it "should be available as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using img_tag alias" do Gchart.line(:data => [0, 26], :format => 'img_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom dimensions" do Gchart.line(:data => [0, 26], :format => 'image_tag', :size => '400x400').should match(/<img src=(.*) width="400" height="400" alt="Google Chart" \/>/) end it "should be available as an image tag using custom alt text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :alt => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Sexy chart" \/>/) end it "should be available as an image tag using custom title text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :title => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" title="Sexy chart" \/>/) end it "should be available as an image tag using custom css id selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :id => 'chart').should match(/<img id="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom css class selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should match(/<img class="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should use ampersands to separate key/value pairs in URLs by default" do Gchart.line(:data => [0, 26]).should include "&" Gchart.line(:data => [0, 26]).should_not include "&amp;" end it "should escape ampersands in URLs when used as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should satisfy {|chart| chart.should include "&amp;" } end it "should be available as a file" do File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file') File.exist?('chart.png').should be_true File.delete('chart.png') if File.exist?('chart.png') end it "should be available as a file using a custom file name" do File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') Gchart.line(:data => [0, 26], :format => 'file', :filename => 'custom_file_name.png') File.exist?('custom_file_name.png').should be_true File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') end it "should work even with multiple attrs" do File.delete('foo.png') if File.exist?('foo.png') Gchart.line(:size => '400x200', :data => [1,2,3,4,5], # :axis_labels => [[1,2,3,4, 5], %w[foo bar]], :axis_with_labels => 'x,r', :format => "file", :filename => "foo.png" ) File.exist?('foo.png').should be_true File.delete('foo.png') if File.exist?('foo.png') end end describe 'SSL support' do it 'should change url if is presented' do Gchart.line(:use_ssl => true).should include('https://chart.googleapis.com/chart?') end it "should be available as a file" do pending "unexpected error under Travis CI (should be fixed using http://martinottenwaelter.fr/2010/12/ruby19-and-the-ssl-error/)" File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file', :use_ssl => true) File.exist?('chart.png').should be_true File.delete('chart.png') if File.exist?('chart.png') end end
mattetti/googlecharts
175633e9aaf7305aa83c38083d773d042eb87201
Travis CI widget
diff --git a/README.markdown b/README.markdown index f544d69..28f044d 100644 --- a/README.markdown +++ b/README.markdown @@ -1,317 +1,321 @@ +## Googlecharts + +[![Build Status](https://secure.travis-ci.org/aderyabin/googlecharts.png?branch=master)](http://travis-ci.org/aderyabin/googlecharts) + The goal of this Gem is to make the creation of Google Charts a simple and easy task. require 'googlecharts' Gchart.line( :size => '200x300', :title => "example title", :bg => 'efefef', :legend => ['first data set label', 'second data set label'], :data => [10, 30, 120, 45, 72]) Check out the [full documentation over there](http://googlecharts.rubyforge.org/) This gem is fully tested using Rspec, check the rspec folder for more examples. See at the bottom of this file who reported using this gem. Chart Type ------------- This gem supports the following types of charts: * line, * line_xy * sparkline * scatter * bar * venn * pie * pie_3d * google meter Googlecharts also supports graphical themes and you can easily load your own. To create a chart, simply require Gchart and call any of the existing type: require 'gchart' Gchart.pie Chart Title ------------- To add a title to a chart pass the title to your chart: Gchart.line(:title => 'Sexy Charts!') You can also specify the color and/or size Gchart.line(:title => 'Sexy Charts!', :title_color => 'FF0000', :title_size => '20') Colors ------------- Specify a color with at least a 6-letter string of hexadecimal values in the format RRGGBB. For example: * FF0000 = red * 00FF00 = green * 0000FF = blue * 000000 = black * FFFFFF = white You can optionally specify transparency by appending a value between 00 and FF where 00 is completely transparent and FF completely opaque. For example: * 0000FFFF = solid blue * 0000FF00 = transparent blue If you need to use multiple colors, check the doc. Usually you just need to pass :attribute => 'FF0000,00FF00' Some charts have more options than other, make sure to refer to the documentation. Background options: ------------- If you don't set the background option, your graph will be transparent. * You have 3 types of background http://code.google.com/apis/chart/#chart_or_background_fill - solid - gradient - stripes By default, if you set a background color, the fill will be solid: Gchart.bar(:bg => 'efefef') However you can specify another fill type such as: Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'}) In the above code, we decided to have a gradient background, however since we only passed one color, the chart will start by the specified color and transition to white. By the default, the gradient angle is 0. Change it as follows: Gchart.line(:title =>'bg example', :bg => {:color => 'efefef', :type => 'gradient', :angle => 90}) For a more advance use of colors, refer to http://code.google.com/apis/chart/#linear_gradient Gchart.line(:bg => {:color => '76A4FB,1,ffffff,0', :type => 'gradient'}) The same way you set the background color, you can also set the graph background: Gchart.line(:graph_bg => 'cccccc') or both Gchart.line(:bg => {:color => '76A4FB,1,ffffff,0', :type => 'gradient'}, :graph_bg => 'cccccc', :title => 'Sexy Chart') Another type of fill is stripes http://code.google.com/apis/chart/#linear_stripes Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'}) You can customize the amount of stripes, colors and width by changing the color value. Themes -------- Googlecharts comes with 4 themes: keynote, thirty7signals, pastel and greyscale. (ganked from [Gruff](http://github.com/topfunky/gruff/tree/master) Gchart.line( :theme => :keynote, :data => [[0,40,10,70,20],[41,10,80,50,40],[20,60,30,60,80],[5,23,35,10,56],[80,90,5,30,60]], :title => 'keynote' ) * keynote ![keynote](http://chart.apis.google.com/chart?chtt=keynote&chco=6886B4,FDD84E,72AE6E,D1695E,8A6EAF,EFAA43&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo&chf=c,s,FFFFFF|bg,s,000000) * thirty7signals ![37signals](http://chart.apis.google.com/chart?chtt=thirty7signals&chco=FFF804,336699,339933,ff0000,cc99cc,cf5910&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo&chf=bg,s,FFFFFF) * pastel ![pastel](http://chart.apis.google.com/chart?chtt=pastel&chco=a9dada,aedaa9,daaea9,dadaa9,a9a9da&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo) * greyscale ![greyscale](http://chart.apis.google.com/chart?chtt=greyscale&chco=282828,383838,686868,989898,c8c8c8,e8e8e8&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo) You can also use your own theme. Create a yml file using the same format as the themes located in lib/themes.yml Load your theme(s): Chart::Theme.add_theme_file("#{File.dirname(__FILE__)}/fixtures/another_test_theme.yml") And use the standard method signature to use your own theme: Gchart.line(:theme => :custom_theme, :data => [[0, 40, 10, 70, 20],[41, 10, 80, 50]], :title => 'greyscale') Legend & Labels ------------- You probably will want to use a legend or labels for your graph. Gchart.line(:legend => 'legend label') or Gchart.line(:legend => ['legend label 1', 'legend label 2']) Will do the trick. You can also use the labels alias (makes more sense when using the pie charts) chart = Gchart.pie(:labels => ['label 1', 'label 2']) Multiple axis labels ------------- Multiple axis labels are available for line charts, bar charts and scatter plots. * x = bottom x-axis * t = top x-axis * y = left y-axis * r = right y-axis Gchart.line(:axis_with_label => 'x,y,r,t') To add labels on these axis: Gchart.line(:axis_with_label => 'x,y,r,t', :axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']) Note that each array entry could also be an array but represent the labels for the corresponding axis. A question which comes back often is how do I only display the y axis label? Solution: Gchart.line( :data => [0,20, 40, 60, 140, 230, 60], :axis_with_labels => 'y') Custom axis ranges --------------- If you want to display a custom range for an axis, you need to set the range as described in the Google charts documentation: min, max, step: Gchart.line( :data => [17, 17, 11, 8, 2], :axis_with_labels => ['x', 'y'], :axis_labels => [['J', 'F', 'M', 'A', 'M']], :axis_range => [nil, [2,17,5]]) In this case, the custom axis range is only defined for y (second entry) with a minimum value of 2, max 17 and a step of 5. This is also valid if you want to set a x axis and automatically define the y labels. Data options ------------- Data are passed using an array or a nested array. Gchart.bar(:data => [1,2,4,67,100,41,234]) Gchart.bar(:data => [[1,2,4,67,100,41,234],[45,23,67,12,67,300, 250]]) By default, the graph is drawn with your max value representing 100% of the height or width of the graph. You can change that my passing the max value. Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => 300) Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => 'auto') or if you want to use the real values from your dataset: Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => false) You can also define a different encoding to add more granularity: Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'simple') Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'extended') Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'text') Pies: ------------- you have 2 type of pies: - Gchart.pie() the standard 2D pie _ Gchart.pie_3d() the fancy 3D pie To set labels, you can use one of these two options: @legend = ['Matt_fu', 'Rob_fu'] Gchart.pie_3d(:title => @title, :labels => @legend, :data => @data, :size => '400x200') Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data, :size => '400x200') Bars: ------------- A bar chart can accept options to set the width of the bars, spacing between bars and spacing between bar groups. To set these, you can either provide a string, array or hash. The Google API sets these options in the order of width, spacing, and group spacing, with both spacing values being optional. So, if you provide a string or array, provide them in that order: Gchart.bar(:data => @data, :bar_width_and_spacing => '25,6') # width of 25, spacing of 6 Gchart.bar(:data => @data, :bar_width_and_spacing => '25,6,12') # width of 25, spacing of 6, group spacing of 12 Gchart.bar(:data => @data, :bar_width_and_spacing => [25,6]) # width of 25, spacing of 6 Gchart.bar(:data => @data, :bar_width_and_spacing => 25) # width of 25 The hash lets you set these values directly, with the Google default values set for any options you don't include: Gchart.bar(:data => @data, :bar_width_and_spacing => {:width => 19}) Gchart.bar(:data => @data, :bar_width_and_spacing => {:spacing => 10, :group_spacing => 12}) Radar: ------------- In a Radar graph, the x-axis is circular. The points can be connected by straight lines or curved lines. Gchart.radar(:data => @data, :curved => true) Sparklines: ------------- A sparkline chart has exactly the same parameters as a line chart. The only difference is that the axes lines are not drawn for sparklines by default. Google-o-meter ------------- A Google-o-meter has a few restrictions. It may only use a solid filled background and it may only have one label. Record Chart PNG file in filesystem Sample : -------------------------------------------- Multi Lines Chart Sample : chart = Gchart.new( :type => 'line', :title => "example title", :theme => :keynote, :data => [[17, 17, 11, 8, 2],[10, 20, 15, 5, 7],[2, 3, 7, 9, 12]], :line_colors => 'e0440e,e62ae5,287eec', :legend => ['courbe 1','courbe 2','courbe 3'], :axis_with_labels => ['x', 'y'], :axis_range => [[0,100,20], [0,20,5]], :filename => "tmp/chart.png") # Record file in filesystem chart.file try yourself ------------- Gchart.bar( :data => [[1,2,4,67,100,41,234],[45,23,67,12,67,300, 250]], :title => 'SD Ruby Fu level', :legend => ['matt','patrick'], :bg => {:color => '76A4FB', :type => 'gradient'}, :bar_colors => 'ff0000,00ff00') "http://chart.apis.google.com/chart?chs=300x200&chdl=matt|patrick&chd=s:AAANUIv,JENCN9y&chtt=SDRuby+Fu+level&chf=bg,lg,0,76A4FB,0,ffffff,1&cht=bvs&chco=ff0000,00ff00" Gchart.pie(:data => [20,10,15,5,50], :title => 'SDRuby Fu level', :size => '400x200', :labels => ['matt', 'rob', 'patrick', 'ryan', 'jordan']) http://chart.apis.google.com/chart?cht=p&chs=400x200&chd=s:YMSG9&chtt=SDRuby+Fu+level&chl=matt|rob|patrick|ryan|jordan \ No newline at end of file
mattetti/googlecharts
4d1a8f3b3c13a9fd9f9d11cdf0e282ea6ad2c235
Travis CI integration
diff --git a/.gitignore b/.gitignore index 76eb170..ab1971e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,7 @@ .DS_Store log/* .manifest pkg .rspec .rvmrc -Gemfile Gemfile.lock \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d42d286 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: ruby +rvm: + - 1.8.7 + - ree + - 1.9.2 + - 1.9.3 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..bbffb97 --- /dev/null +++ b/Gemfile @@ -0,0 +1,10 @@ +source "http://rubygems.org" +gemspec + +group :test do + gem 'rspec' + gem 'rake', '>= 0.8.7' +end + + + diff --git a/Rakefile b/Rakefile index 441aae2..7aa5606 100644 --- a/Rakefile +++ b/Rakefile @@ -1 +1,12 @@ -require 'rubygems' \ No newline at end of file +require 'rspec/core/rake_task' + +desc 'Default: run specs.' +task :default => :spec + +desc "Run specs" +RSpec::Core::RakeTask.new do |task| + task.pattern = "**/spec/*_spec.rb" + task.rspec_opts = [] + task.rspec_opts << '--color' + task.rspec_opts << '-f documentation' +end \ No newline at end of file diff --git a/spec/gchart_spec.rb b/spec/gchart_spec.rb index c39fcfc..d361ef3 100644 --- a/spec/gchart_spec.rb +++ b/spec/gchart_spec.rb @@ -144,519 +144,520 @@ describe "generating a default Gchart" do def labeled_bar(options = {}) Gchart.bar({:data => @data, :axis_with_labels => 'x,y', :axis_labels => [(1..12).to_a], :encoding => "text" }.merge(options)) end it "should force the y range properly" do @data = [1,1,1,1,1,1,1,1,6,2,1,1] labeled_bar( :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,0|1,0,16') labeled_bar( :max_value => 16, :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,16|1,0,16') # nil means ignore axis labeled_bar( :axis_range => [nil,[0,16]] ).should include('chxr=1,0,16') # empty array means take defaults labeled_bar( :max_value => 16, :axis_range => [[],[0,16]] ).should include('chxr=0,0,16|1,0,16') labeled_bar( :axis_range => [[],[0,16]] ).should include('chxr=0,0|1,0,16') Gchart.line( :data => [0,20, 40, 60, 140, 230, 60], :axis_with_labels => 'y').should include("chxr=0,0,230") end it "should take in consideration the max value when creating a range" do data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] url = Gchart.line(:data => data, :axis_with_labels => 'x,y', :axis_labels => [((1..24).to_a << 1)], :max_value => 700) url.should include('chxr=0,85,700') end it 'should generate different labels and legend' do Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three)).should(include('chdl=1|2|3') && include('chl=one|two|three')) end end describe "generating different type of charts" do it "should be able to generate a line chart" do Gchart.line.should be_an_instance_of(String) Gchart.line.should include('cht=lc') end it "should be able to generate a sparkline chart" do Gchart.sparkline.should be_an_instance_of(String) Gchart.sparkline.should include('cht=ls') end it "should be able to generate a line xy chart" do Gchart.line_xy.should be_an_instance_of(String) Gchart.line_xy.should include('cht=lxy') end it "should be able to generate a scatter chart" do Gchart.scatter.should be_an_instance_of(String) Gchart.scatter.should include('cht=s') end it "should be able to generate a bar chart" do Gchart.bar.should be_an_instance_of(String) Gchart.bar.should include('cht=bvs') end it "should be able to generate a Venn diagram" do Gchart.venn.should be_an_instance_of(String) Gchart.venn.should include('cht=v') end it "should be able to generate a Pie Chart" do Gchart.pie.should be_an_instance_of(String) Gchart.pie.should include('cht=p') end it "should be able to generate a Google-O-Meter" do Gchart.meter.should be_an_instance_of(String) Gchart.meter.should include('cht=gom') end it "should be able to generate a map chart" do Gchart.map.should be_an_instance_of(String) Gchart.map.should include('cht=t') end it "should not support other types" do msg = "sexy is not a supported chart format. Please use one of the following: #{Gchart.supported_types}." lambda{Gchart.sexy}.should raise_error(NoMethodError) end end describe "range markers" do it "should be able to generate given a hash of range-marker options" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}).should include('chm=r,ff0000,0,0.59,0.61') end it "should be able to generate given an array of range-marker hash options" do Gchart.line(:range_markers => [ {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}, {:start_position => 0, :stop_position => 0.6, :color => '666666'}, {:color => 'cccccc', :start_position => 0.6, :stop_position => 1} ]).should include(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1')) end it "should allow a :overlaid? to be set" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true}).should include('chm=r,ffffff,0,0.59,0.61,1') Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false}).should include('chm=r,ffffff,0,0.59,0.61') end describe "when setting the orientation option" do before(:each) do @options = {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'} end it "to vertical (R) if given a valid option" do Gchart.line(:range_markers => @options.merge(:orientation => 'v')).should include('chm=R') Gchart.line(:range_markers => @options.merge(:orientation => 'V')).should include('chm=R') Gchart.line(:range_markers => @options.merge(:orientation => 'R')).should include('chm=R') Gchart.line(:range_markers => @options.merge(:orientation => 'vertical')).should include('chm=R') Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical')).should include('chm=R') end it "to horizontal (r) if given a valid option (actually anything other than the vertical options)" do Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal')).should include('chm=r') Gchart.line(:range_markers => @options.merge(:orientation => 'h')).should include('chm=r') Gchart.line(:range_markers => @options.merge(:orientation => 'etc')).should include('chm=r') end it "if left blank defaults to horizontal (r)" do Gchart.line(:range_markers => @options).should include('chm=r') end end end describe "a bar graph" do it "should have a default vertical orientation" do Gchart.bar.should include('cht=bvs') end it "should be able to have a different orientation" do Gchart.bar(:orientation => 'vertical').should include('cht=bvs') Gchart.bar(:orientation => 'v').should include('cht=bvs') Gchart.bar(:orientation => 'h').should include('cht=bhs') Gchart.bar(:orientation => 'horizontal').should include('cht=bhs') Gchart.bar(:horizontal => false).should include('cht=bvs') end it "should be set to be stacked by default" do Gchart.bar.should include('cht=bvs') end it "should be able to stacked or grouped" do Gchart.bar(:stacked => true).should include('cht=bvs') Gchart.bar(:stacked => false).should include('cht=bvg') Gchart.bar(:grouped => true).should include('cht=bvg') Gchart.bar(:grouped => false).should include('cht=bvs') end it "should be able to have different bar colors" do Gchart.bar(:bar_colors => 'efefef,00ffff').should include('chco=') Gchart.bar(:bar_colors => 'efefef,00ffff').should include('chco=efefef,00ffff') # alias Gchart.bar(:bar_color => 'efefef').should include('chco=efefef') end it "should be able to have different bar colors when using an array of colors" do Gchart.bar(:bar_colors => ['efefef','00ffff']).should include('chco=efefef,00ffff') end it 'should be able to accept a string of width and spacing options' do Gchart.bar(:bar_width_and_spacing => '25,6').should include('chbh=25,6') end it 'should be able to accept a single fixnum width and spacing option to set the bar width' do Gchart.bar(:bar_width_and_spacing => 25).should include('chbh=25') end it 'should be able to accept an array of width and spacing options' do Gchart.bar(:bar_width_and_spacing => [25,6,12]).should include('chbh=25,6,12') Gchart.bar(:bar_width_and_spacing => [25,6]).should include('chbh=25,6') Gchart.bar(:bar_width_and_spacing => [25]).should include('chbh=25') end describe "with a hash of width and spacing options" do before(:each) do @default_width = 23 @default_spacing = 4 @default_group_spacing = 8 end it 'should be able to have a custom bar width' do Gchart.bar(:bar_width_and_spacing => {:width => 19}).should include("chbh=19,#{@default_spacing},#{@default_group_spacing}") end it 'should be able to have custom spacing' do Gchart.bar(:bar_width_and_spacing => {:spacing => 19}).should include("chbh=#{@default_width},19,#{@default_group_spacing}") end it 'should be able to have custom group spacing' do Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19}).should include("chbh=#{@default_width},#{@default_spacing},19") end end end describe "a line chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @chart = Gchart.line(:title => @title, :legend => @legend) end it 'should be able have a chart title' do @chart.should include("chtt=Chart+Title") end it "should be able to a custom color, size and alignment for title" do Gchart.line(:title => @title, :title_color => 'FF0000').should include('chts=FF0000') Gchart.line(:title => @title, :title_size => '20').should include('chts=454545,20') Gchart.line(:title => @title, :title_size => '20', :title_alignment => :left).should include('chts=454545,20,l') end it "should be able to have multiple legends" do @chart.should include(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")) end it "should escape text values in url" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend) chart.should include(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")) end it "should be able to have one legend" do chart = Gchart.line(:legend => 'legend label') chart.should include("chdl=legend+label") end it "should be able to set the position of the legend" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend, :legend_position => :bottom_vertical) chart.should include("chdlp=bv") chart = Gchart.line(:title => title, :legend => legend, :legend_position => 'r') chart.should include("chdlp=r") end it "should be able to set the background fill" do Gchart.line(:bg => 'efefef').should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=bg,lg,90,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'}).should include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do Gchart.line(:graph_bg => 'efefef').should include("chf=c,s,efefef") Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'}).should include("chf=c,s,efefef") Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=c,lg,0,efefef,0,ffffff,1") Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=c,lg,0,efefef,0,ffffff,1") Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=c,lg,90,efefef,0,ffffff,1") end it "should be able to set both a graph and a background fill" do Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').should match /chf=(bg,s,efefef\|c,s,76A4FB|c,s,76A4FB\|bg,s,efefef)/ end it "should be able to have different line colors" do Gchart.line(:line_colors => 'efefef|00ffff').should include(Gchart.jstize('chco=efefef|00ffff')) Gchart.line(:line_color => 'efefef|00ffff').should include(Gchart.jstize('chco=efefef|00ffff')) end it "should be able to render a graph where all the data values are 0" do Gchart.line(:data => [0, 0, 0]).should include("chd=s:AAA") end end describe "a sparkline chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [27,25,25,25,25,27,100,31,25,36,25,25,39,25,31,25,25,25,26,26,25,25,28,25,25,100,28,27,31,25,27,27,29,25,27,26,26,25,26,26,35,33,34,25,26,25,36,25,26,37,33,33,37,37,39,25,25,25,25] @chart = Gchart.sparkline(:title => @title, :data => @data, :legend => @legend) end it "should create a sparkline" do @chart.should include('cht=ls') end it 'should be able have a chart title' do @chart.should include("chtt=Chart+Title") end it "should be able to a custom color and size title" do Gchart.sparkline(:title => @title, :title_color => 'FF0000').should include('chts=FF0000') Gchart.sparkline(:title => @title, :title_size => '20').should include('chts=454545,20') end it "should be able to have multiple legends" do @chart.should include(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")) end it "should be able to have one legend" do chart = Gchart.sparkline(:legend => 'legend label') chart.should include("chdl=legend+label") end it "should be able to set the background fill" do Gchart.sparkline(:bg => 'efefef').should include("chf=bg,s,efefef") Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=bg,lg,90,efefef,0,ffffff,1") Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'}).should include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do Gchart.sparkline(:graph_bg => 'efefef').should include("chf=c,s,efefef") Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'}).should include("chf=c,s,efefef") Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=c,lg,0,efefef,0,ffffff,1") Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=c,lg,0,efefef,0,ffffff,1") Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=c,lg,90,efefef,0,ffffff,1") end it "should be able to set both a graph and a background fill" do Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').should match(/chf=(bg,s,efefef\|c,s,76A4FB|c,s,76A4FB\|bg,s,efefef)/) end it "should be able to have different line colors" do Gchart.sparkline(:line_colors => 'efefef|00ffff').should include(Gchart.jstize('chco=efefef|00ffff')) Gchart.sparkline(:line_color => 'efefef|00ffff').should include(Gchart.jstize('chco=efefef|00ffff')) end end describe "a 3d pie chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [12,8,40,15,5] @chart = Gchart.pie(:title => @title, :legend => @legend, :data => @data) end it "should create a pie" do @chart.should include('cht=p') end it "should be able to be in 3d" do Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data).should include('cht=p3') end end describe "a google-o-meter" do before(:each) do @data = [70] @legend = ['arrow points here'] @jstized_legend = Gchart.jstize(@legend.join('|')) @chart = Gchart.meter(:data => @data) end it "should create a meter" do @chart.should include('cht=gom') end it "should be able to set a solid background fill" do Gchart.meter(:bg => 'efefef').should include("chf=bg,s,efefef") Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") end it "should be able to set labels by using the legend or labesl accessor" do Gchart.meter(:title => @title, :labels => @legend, :data => @data).should include("chl=#{@jstized_legend}") Gchart.meter(:title => @title, :labels => @legend, :data => @data).should == Gchart.meter(:title => @title, :legend => @legend, :data => @data) end end describe "a map chart" do before(:each) do @data = [0,100,50,32] @geographical_area = 'usa' @map_colors = ['FFFFFF', 'FF0000', 'FFFF00', '00FF00'] @country_codes = ['MT', 'WY', "ID", 'SD'] @chart = Gchart.map(:data => @data, :encoding => 'text', :size => '400x300', :geographical_area => @geographical_area, :map_colors => @map_colors, :country_codes => @country_codes) end it "should create a map" do @chart.should include('cht=t') end it "should set the geographical area" do @chart.should include('chtm=usa') end it "should set the map colors" do @chart.should include('chco=FFFFFF,FF0000,FFFF00,00FF00') end it "should set the country/state codes" do @chart.should include('chld=MTWYIDSD') end it "should set the chart data" do @chart.should include('chd=t:0,100,50,32') end end describe 'exporting a chart' do it "should be available in the url format by default" do Gchart.line(:data => [0, 26], :format => 'url').should == Gchart.line(:data => [0, 26]) end it "should be available as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using img_tag alias" do Gchart.line(:data => [0, 26], :format => 'img_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom dimensions" do Gchart.line(:data => [0, 26], :format => 'image_tag', :size => '400x400').should match(/<img src=(.*) width="400" height="400" alt="Google Chart" \/>/) end it "should be available as an image tag using custom alt text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :alt => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Sexy chart" \/>/) end it "should be available as an image tag using custom title text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :title => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" title="Sexy chart" \/>/) end it "should be available as an image tag using custom css id selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :id => 'chart').should match(/<img id="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom css class selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should match(/<img class="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should use ampersands to separate key/value pairs in URLs by default" do Gchart.line(:data => [0, 26]).should include "&" Gchart.line(:data => [0, 26]).should_not include "&amp;" end it "should escape ampersands in URLs when used as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should satisfy {|chart| chart.should include "&amp;" } end it "should be available as a file" do File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file') File.exist?('chart.png').should be_true File.delete('chart.png') if File.exist?('chart.png') end it "should be available as a file using a custom file name" do File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') Gchart.line(:data => [0, 26], :format => 'file', :filename => 'custom_file_name.png') File.exist?('custom_file_name.png').should be_true File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') end it "should work even with multiple attrs" do File.delete('foo.png') if File.exist?('foo.png') Gchart.line(:size => '400x200', :data => [1,2,3,4,5], # :axis_labels => [[1,2,3,4, 5], %w[foo bar]], :axis_with_labels => 'x,r', :format => "file", :filename => "foo.png" ) File.exist?('foo.png').should be_true File.delete('foo.png') if File.exist?('foo.png') end end describe 'SSL support' do it 'should change url if is presented' do Gchart.line(:use_ssl => true).should include('https://chart.googleapis.com/chart?') end it "should be available as a file" do + pending "unexpected error under Travis CI (should be fixed using http://martinottenwaelter.fr/2010/12/ruby19-and-the-ssl-error/)" File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file', :use_ssl => true) File.exist?('chart.png').should be_true File.delete('chart.png') if File.exist?('chart.png') end end
mattetti/googlecharts
4b54008a0f6fb5ce62a58a6ecd6ab58f3e943564
fix spec
diff --git a/spec/gchart_spec.rb b/spec/gchart_spec.rb index ca7b1be..c39fcfc 100644 --- a/spec/gchart_spec.rb +++ b/spec/gchart_spec.rb @@ -1,689 +1,662 @@ require File.dirname(__FILE__) + '/spec_helper.rb' require File.dirname(__FILE__) + '/../lib/gchart' Chart::Theme.add_theme_file("#{File.dirname(__FILE__)}/fixtures/test_theme.yml") # Time to add your specs! # http://rspec.rubyforge.org/ describe "The Gchart class" do it "should show supported_types on error" do Gchart.supported_types.should match(/line/) end it "should return supported types" do - Gchart.types.include?('line').should be_true + Gchart.types.should include('line') end - + it "should support theme option" do chart = Gchart.new(:type => 'line',:theme => :test) chart.send('url').should include('chco=6886B4,FDD84E') end end describe "generating a default Gchart" do before(:each) do @chart = Gchart.line end it "should create a line break when a pipe character is encountered" do @chart = Gchart.line(:title => "title|subtitle") - @chart.include?("chtt=title\nsubtitle").should be_true + @chart.should include("chtt=title\nsubtitle") end - + it "should include the Google URL" do - @chart.include?("http://chart.apis.google.com/chart?").should be_true + @chart.should include("http://chart.apis.google.com/chart?") end it "should have a default size" do @chart.should include('chs=300x200') end it "should be able to have a custom size" do - Gchart.line(:size => '400x600').include?('chs=400x600').should be_true - Gchart.line(:width => 400, :height => 600).include?('chs=400x600').should be_true + Gchart.line(:size => '400x600').should include('chs=400x600') + Gchart.line(:width => 400, :height => 600).should include('chs=400x600') end it "should have query parameters in predictable order" do Gchart.line(:axis_with_labels => 'x,y,r', :size => '400x600').should match(/chxt=.+cht=.+chs=/) end it "should have a type" do - @chart.include?('cht=lc').should be_true + @chart.should include('cht=lc') end it 'should use theme defaults if theme is set' do Gchart.line(:theme=>:test).should include('chco=6886B4,FDD84E') - if RUBY_VERSION.to_f < 1.9 - Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=c,s,FFFFFF|bg,s,FFFFFF')) - else - Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=bg,s,FFFFFF|c,s,FFFFFF')) - end + Gchart.line(:theme=>:test).should match(/chf=(c,s,FFFFFF\|bg,s,FFFFFF|bg,s,FFFFFF\|c,s,FFFFFF)/) end it "should use the simple encoding by default with auto max value" do # 9 is the max value in simple encoding, 26 being our max value the 2nd encoded value should be 9 Gchart.line(:data => [0, 26]).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => 26, :axis_with_labels => 'y').should include('chxr=0,0,26') end it "should support simple encoding with and without max_value" do Gchart.line(:data => [0, 26], :max_value => 26).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => false).should include('chd=s:Aa') end it "should support the extended encoding and encode properly" do - Gchart.line(:data => [0, 10], :encoding => 'extended', :max_value => false).include?('chd=e:AA').should be_true + Gchart.line(:data => [0, 10], :encoding => 'extended', :max_value => false).should include('chd=e:AA') Gchart.line(:encoding => 'extended', :max_value => false, :data => [[0,25,26,51,52,61,62,63], [64,89,90,115,4084]] - ).include?('chd=e:AAAZAaAzA0A9A-A.,BABZBaBz.0').should be_true + ).should include('chd=e:AAAZAaAzA0A9A-A.,BABZBaBz.0') end it "should auto set the max value for extended encoding" do Gchart.line(:data => [0, 25], :encoding => 'extended', :max_value => false).should include('chd=e:AAAZ') # Extended encoding max value is '..' - Gchart.line(:data => [0, 25], :encoding => 'extended').include?('chd=e:AA..').should be_true + Gchart.line(:data => [0, 25], :encoding => 'extended').should include('chd=e:AA..') end it "should be able to have data with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,4,45,78') end it "should be able to have missing data points with text encoding" do Gchart.line(:data => [10, 5.2, nil, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,_,45,78') end it "should handle max and min values with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=0,78') end it "should automatically handle negative values with proper max/min limits when using text encoding" do Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=-10,78') end it "should handle negative values with manual max/min limits when using text encoding" do - Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text', :min_value => -20, :max_value => 100).include?('chds=-20,100').should be_true + Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text', :min_value => -20, :max_value => 100).should include('chds=-20,100') end it "should set the proper axis values when using text encoding and negative values" do Gchart.bar( :data => [[-10], [100]], :encoding => 'text', :horizontal => true, :min_value => -20, :max_value => 100, :axis_with_labels => 'x', :bar_colors => ['FD9A3B', '4BC7DC']).should include("chxr=0,-20,100") end it "should be able to have multiple set of data with text encoding" do - Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text').include?(Gchart.jstize('chd=t:10,5.2,4,45,78|20,40,70,15,99')).should be_true + Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text').should include(Gchart.jstize('chd=t:10,5.2,4,45,78|20,40,70,15,99')) end it "should be able to receive a custom param" do - Gchart.line(:custom => 'ceci_est_une_pipe').include?('ceci_est_une_pipe').should be_true + Gchart.line(:custom => 'ceci_est_une_pipe').should include('ceci_est_une_pipe') end it "should be able to set label axis" do - Gchart.line(:axis_with_labels => 'x,y,r').include?('chxt=x,y,r').should be_true - Gchart.line(:axis_with_labels => ['x','y','r']).include?('chxt=x,y,r').should be_true + Gchart.line(:axis_with_labels => 'x,y,r').should include('chxt=x,y,r') + Gchart.line(:axis_with_labels => ['x','y','r']).should include('chxt=x,y,r') end it "should be able to have axis labels" do - Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true - Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true - Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true - Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true + Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']).should include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')) + Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan']).should include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')) + Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']]).should include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')) + Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']]).should include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')) end - + def labeled_line(options = {}) Gchart.line({:data => @data, :axis_with_labels => 'x,y'}.merge(options)) end it "should display ranges properly" do @data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] labeled_line(:axis_labels => [((1..24).to_a << 1)]). should include('chxr=0,85,672') end - + def labeled_bar(options = {}) Gchart.bar({:data => @data, :axis_with_labels => 'x,y', :axis_labels => [(1..12).to_a], :encoding => "text" }.merge(options)) end it "should force the y range properly" do @data = [1,1,1,1,1,1,1,1,6,2,1,1] labeled_bar( :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,0|1,0,16') labeled_bar( :max_value => 16, :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,16|1,0,16') # nil means ignore axis labeled_bar( :axis_range => [nil,[0,16]] ).should include('chxr=1,0,16') # empty array means take defaults labeled_bar( :max_value => 16, :axis_range => [[],[0,16]] ).should include('chxr=0,0,16|1,0,16') labeled_bar( :axis_range => [[],[0,16]] ).should include('chxr=0,0|1,0,16') Gchart.line( :data => [0,20, 40, 60, 140, 230, 60], :axis_with_labels => 'y').should include("chxr=0,0,230") end - + it "should take in consideration the max value when creating a range" do data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] url = Gchart.line(:data => data, :axis_with_labels => 'x,y', :axis_labels => [((1..24).to_a << 1)], :max_value => 700) url.should include('chxr=0,85,700') end - + it 'should generate different labels and legend' do Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three)).should(include('chdl=1|2|3') && include('chl=one|two|three')) end - end describe "generating different type of charts" do it "should be able to generate a line chart" do Gchart.line.should be_an_instance_of(String) - Gchart.line.include?('cht=lc').should be_true + Gchart.line.should include('cht=lc') end it "should be able to generate a sparkline chart" do Gchart.sparkline.should be_an_instance_of(String) - Gchart.sparkline.include?('cht=ls').should be_true + Gchart.sparkline.should include('cht=ls') end it "should be able to generate a line xy chart" do Gchart.line_xy.should be_an_instance_of(String) - Gchart.line_xy.include?('cht=lxy').should be_true + Gchart.line_xy.should include('cht=lxy') end it "should be able to generate a scatter chart" do Gchart.scatter.should be_an_instance_of(String) - Gchart.scatter.include?('cht=s').should be_true + Gchart.scatter.should include('cht=s') end it "should be able to generate a bar chart" do Gchart.bar.should be_an_instance_of(String) - Gchart.bar.include?('cht=bvs').should be_true + Gchart.bar.should include('cht=bvs') end it "should be able to generate a Venn diagram" do Gchart.venn.should be_an_instance_of(String) - Gchart.venn.include?('cht=v').should be_true + Gchart.venn.should include('cht=v') end it "should be able to generate a Pie Chart" do Gchart.pie.should be_an_instance_of(String) - Gchart.pie.include?('cht=p').should be_true + Gchart.pie.should include('cht=p') end it "should be able to generate a Google-O-Meter" do Gchart.meter.should be_an_instance_of(String) - Gchart.meter.include?('cht=gom').should be_true + Gchart.meter.should include('cht=gom') end it "should be able to generate a map chart" do Gchart.map.should be_an_instance_of(String) - Gchart.map.include?('cht=t').should be_true + Gchart.map.should include('cht=t') end it "should not support other types" do msg = "sexy is not a supported chart format. Please use one of the following: #{Gchart.supported_types}." lambda{Gchart.sexy}.should raise_error(NoMethodError) end - end describe "range markers" do it "should be able to generate given a hash of range-marker options" do - Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}).include?('chm=r,ff0000,0,0.59,0.61').should be_true + Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}).should include('chm=r,ff0000,0,0.59,0.61') end it "should be able to generate given an array of range-marker hash options" do Gchart.line(:range_markers => [ {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}, {:start_position => 0, :stop_position => 0.6, :color => '666666'}, {:color => 'cccccc', :start_position => 0.6, :stop_position => 1} - ]).include?(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1')).should be_true + ]).should include(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1')) end it "should allow a :overlaid? to be set" do - Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true}).include?('chm=r,ffffff,0,0.59,0.61,1').should be_true - Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false}).include?('chm=r,ffffff,0,0.59,0.61').should be_true + Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true}).should include('chm=r,ffffff,0,0.59,0.61,1') + Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false}).should include('chm=r,ffffff,0,0.59,0.61') end describe "when setting the orientation option" do before(:each) do @options = {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'} end it "to vertical (R) if given a valid option" do - Gchart.line(:range_markers => @options.merge(:orientation => 'v')).include?('chm=R').should be_true - Gchart.line(:range_markers => @options.merge(:orientation => 'V')).include?('chm=R').should be_true - Gchart.line(:range_markers => @options.merge(:orientation => 'R')).include?('chm=R').should be_true - Gchart.line(:range_markers => @options.merge(:orientation => 'vertical')).include?('chm=R').should be_true - Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical')).include?('chm=R').should be_true + Gchart.line(:range_markers => @options.merge(:orientation => 'v')).should include('chm=R') + Gchart.line(:range_markers => @options.merge(:orientation => 'V')).should include('chm=R') + Gchart.line(:range_markers => @options.merge(:orientation => 'R')).should include('chm=R') + Gchart.line(:range_markers => @options.merge(:orientation => 'vertical')).should include('chm=R') + Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical')).should include('chm=R') end it "to horizontal (r) if given a valid option (actually anything other than the vertical options)" do - Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal')).include?('chm=r').should be_true - Gchart.line(:range_markers => @options.merge(:orientation => 'h')).include?('chm=r').should be_true - Gchart.line(:range_markers => @options.merge(:orientation => 'etc')).include?('chm=r').should be_true + Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal')).should include('chm=r') + Gchart.line(:range_markers => @options.merge(:orientation => 'h')).should include('chm=r') + Gchart.line(:range_markers => @options.merge(:orientation => 'etc')).should include('chm=r') end it "if left blank defaults to horizontal (r)" do - Gchart.line(:range_markers => @options).include?('chm=r').should be_true + Gchart.line(:range_markers => @options).should include('chm=r') end end - end describe "a bar graph" do it "should have a default vertical orientation" do - Gchart.bar.include?('cht=bvs').should be_true + Gchart.bar.should include('cht=bvs') end it "should be able to have a different orientation" do - Gchart.bar(:orientation => 'vertical').include?('cht=bvs').should be_true - Gchart.bar(:orientation => 'v').include?('cht=bvs').should be_true - Gchart.bar(:orientation => 'h').include?('cht=bhs').should be_true - Gchart.bar(:orientation => 'horizontal').include?('cht=bhs').should be_true - Gchart.bar(:horizontal => false).include?('cht=bvs').should be_true + Gchart.bar(:orientation => 'vertical').should include('cht=bvs') + Gchart.bar(:orientation => 'v').should include('cht=bvs') + Gchart.bar(:orientation => 'h').should include('cht=bhs') + Gchart.bar(:orientation => 'horizontal').should include('cht=bhs') + Gchart.bar(:horizontal => false).should include('cht=bvs') end it "should be set to be stacked by default" do - Gchart.bar.include?('cht=bvs').should be_true + Gchart.bar.should include('cht=bvs') end it "should be able to stacked or grouped" do - Gchart.bar(:stacked => true).include?('cht=bvs').should be_true - Gchart.bar(:stacked => false).include?('cht=bvg').should be_true - Gchart.bar(:grouped => true).include?('cht=bvg').should be_true - Gchart.bar(:grouped => false).include?('cht=bvs').should be_true + Gchart.bar(:stacked => true).should include('cht=bvs') + Gchart.bar(:stacked => false).should include('cht=bvg') + Gchart.bar(:grouped => true).should include('cht=bvg') + Gchart.bar(:grouped => false).should include('cht=bvs') end it "should be able to have different bar colors" do - Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=').should be_true - Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=efefef,00ffff').should be_true + Gchart.bar(:bar_colors => 'efefef,00ffff').should include('chco=') + Gchart.bar(:bar_colors => 'efefef,00ffff').should include('chco=efefef,00ffff') # alias - Gchart.bar(:bar_color => 'efefef').include?('chco=efefef').should be_true + Gchart.bar(:bar_color => 'efefef').should include('chco=efefef') end it "should be able to have different bar colors when using an array of colors" do - Gchart.bar(:bar_colors => ['efefef','00ffff']).include?('chco=efefef,00ffff').should be_true + Gchart.bar(:bar_colors => ['efefef','00ffff']).should include('chco=efefef,00ffff') end it 'should be able to accept a string of width and spacing options' do - Gchart.bar(:bar_width_and_spacing => '25,6').include?('chbh=25,6').should be_true + Gchart.bar(:bar_width_and_spacing => '25,6').should include('chbh=25,6') end it 'should be able to accept a single fixnum width and spacing option to set the bar width' do - Gchart.bar(:bar_width_and_spacing => 25).include?('chbh=25').should be_true + Gchart.bar(:bar_width_and_spacing => 25).should include('chbh=25') end it 'should be able to accept an array of width and spacing options' do - Gchart.bar(:bar_width_and_spacing => [25,6,12]).include?('chbh=25,6,12').should be_true - Gchart.bar(:bar_width_and_spacing => [25,6]).include?('chbh=25,6').should be_true - Gchart.bar(:bar_width_and_spacing => [25]).include?('chbh=25').should be_true + Gchart.bar(:bar_width_and_spacing => [25,6,12]).should include('chbh=25,6,12') + Gchart.bar(:bar_width_and_spacing => [25,6]).should include('chbh=25,6') + Gchart.bar(:bar_width_and_spacing => [25]).should include('chbh=25') end describe "with a hash of width and spacing options" do before(:each) do @default_width = 23 @default_spacing = 4 @default_group_spacing = 8 end it 'should be able to have a custom bar width' do - Gchart.bar(:bar_width_and_spacing => {:width => 19}).include?("chbh=19,#{@default_spacing},#{@default_group_spacing}").should be_true + Gchart.bar(:bar_width_and_spacing => {:width => 19}).should include("chbh=19,#{@default_spacing},#{@default_group_spacing}") end it 'should be able to have custom spacing' do - Gchart.bar(:bar_width_and_spacing => {:spacing => 19}).include?("chbh=#{@default_width},19,#{@default_group_spacing}").should be_true + Gchart.bar(:bar_width_and_spacing => {:spacing => 19}).should include("chbh=#{@default_width},19,#{@default_group_spacing}") end it 'should be able to have custom group spacing' do - Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19}).include?("chbh=#{@default_width},#{@default_spacing},19").should be_true + Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19}).should include("chbh=#{@default_width},#{@default_spacing},19") end - end - end describe "a line chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @chart = Gchart.line(:title => @title, :legend => @legend) end it 'should be able have a chart title' do - @chart.include?("chtt=Chart+Title").should be_true + @chart.should include("chtt=Chart+Title") end it "should be able to a custom color, size and alignment for title" do - Gchart.line(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true - Gchart.line(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true - Gchart.line(:title => @title, :title_size => '20', :title_alignment => :left).include?('chts=454545,20,l').should be_true + Gchart.line(:title => @title, :title_color => 'FF0000').should include('chts=FF0000') + Gchart.line(:title => @title, :title_size => '20').should include('chts=454545,20') + Gchart.line(:title => @title, :title_size => '20', :title_alignment => :left).should include('chts=454545,20,l') end it "should be able to have multiple legends" do - @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true + @chart.should include(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")) end it "should escape text values in url" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend) - chart.include?(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")).should be_true + chart.should include(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")) end it "should be able to have one legend" do chart = Gchart.line(:legend => 'legend label') - chart.include?("chdl=legend+label").should be_true + chart.should include("chdl=legend+label") end - + it "should be able to set the position of the legend" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] - + chart = Gchart.line(:title => title, :legend => legend, :legend_position => :bottom_vertical) - chart.include?("chdlp=bv").should be_true - + chart.should include("chdlp=bv") + chart = Gchart.line(:title => title, :legend => legend, :legend_position => 'r') - chart.include?("chdlp=r").should be_true + chart.should include("chdlp=r") end it "should be able to set the background fill" do Gchart.line(:bg => 'efefef').should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=bg,lg,90,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'}).should include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do Gchart.line(:graph_bg => 'efefef').should include("chf=c,s,efefef") - Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true - Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true - Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true - Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true + Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'}).should include("chf=c,s,efefef") + Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=c,lg,0,efefef,0,ffffff,1") + Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=c,lg,0,efefef,0,ffffff,1") + Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=c,lg,90,efefef,0,ffffff,1") end it "should be able to set both a graph and a background fill" do - Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true - Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true - if RUBY_VERSION.to_f < 1.9 - Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true - else - Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true - end + Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').should match /chf=(bg,s,efefef\|c,s,76A4FB|c,s,76A4FB\|bg,s,efefef)/ end it "should be able to have different line colors" do - Gchart.line(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true - Gchart.line(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true + Gchart.line(:line_colors => 'efefef|00ffff').should include(Gchart.jstize('chco=efefef|00ffff')) + Gchart.line(:line_color => 'efefef|00ffff').should include(Gchart.jstize('chco=efefef|00ffff')) end it "should be able to render a graph where all the data values are 0" do Gchart.line(:data => [0, 0, 0]).should include("chd=s:AAA") end - end describe "a sparkline chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [27,25,25,25,25,27,100,31,25,36,25,25,39,25,31,25,25,25,26,26,25,25,28,25,25,100,28,27,31,25,27,27,29,25,27,26,26,25,26,26,35,33,34,25,26,25,36,25,26,37,33,33,37,37,39,25,25,25,25] @chart = Gchart.sparkline(:title => @title, :data => @data, :legend => @legend) end it "should create a sparkline" do - @chart.include?('cht=ls').should be_true + @chart.should include('cht=ls') end it 'should be able have a chart title' do - @chart.include?("chtt=Chart+Title").should be_true + @chart.should include("chtt=Chart+Title") end it "should be able to a custom color and size title" do - Gchart.sparkline(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true - Gchart.sparkline(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true + Gchart.sparkline(:title => @title, :title_color => 'FF0000').should include('chts=FF0000') + Gchart.sparkline(:title => @title, :title_size => '20').should include('chts=454545,20') end it "should be able to have multiple legends" do - @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true + @chart.should include(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")) end it "should be able to have one legend" do chart = Gchart.sparkline(:legend => 'legend label') - chart.include?("chdl=legend+label").should be_true + chart.should include("chdl=legend+label") end it "should be able to set the background fill" do - Gchart.sparkline(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true - Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true + Gchart.sparkline(:bg => 'efefef').should include("chf=bg,s,efefef") + Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") - Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true - Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true - Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=bg,lg,90,efefef,0,ffffff,1").should be_true + Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") + Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") + Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=bg,lg,90,efefef,0,ffffff,1") - Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'}).include?("chf=bg,ls,90,efefef,0.2,ffffff,0.2").should be_true + Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'}).should include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do - Gchart.sparkline(:graph_bg => 'efefef').include?("chf=c,s,efefef").should be_true - Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true - Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true - Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true - Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true + Gchart.sparkline(:graph_bg => 'efefef').should include("chf=c,s,efefef") + Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'}).should include("chf=c,s,efefef") + Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=c,lg,0,efefef,0,ffffff,1") + Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=c,lg,0,efefef,0,ffffff,1") + Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=c,lg,90,efefef,0,ffffff,1") end it "should be able to set both a graph and a background fill" do - Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true - Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true - if RUBY_VERSION.to_f < 1.9 - Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true - else - Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true - end + Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').should match(/chf=(bg,s,efefef\|c,s,76A4FB|c,s,76A4FB\|bg,s,efefef)/) end it "should be able to have different line colors" do - Gchart.sparkline(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true - Gchart.sparkline(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true + Gchart.sparkline(:line_colors => 'efefef|00ffff').should include(Gchart.jstize('chco=efefef|00ffff')) + Gchart.sparkline(:line_color => 'efefef|00ffff').should include(Gchart.jstize('chco=efefef|00ffff')) end - end describe "a 3d pie chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [12,8,40,15,5] @chart = Gchart.pie(:title => @title, :legend => @legend, :data => @data) end it "should create a pie" do - @chart.include?('cht=p').should be_true + @chart.should include('cht=p') end it "should be able to be in 3d" do - Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data).include?('cht=p3').should be_true + Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data).should include('cht=p3') end - end describe "a google-o-meter" do before(:each) do @data = [70] @legend = ['arrow points here'] @jstized_legend = Gchart.jstize(@legend.join('|')) @chart = Gchart.meter(:data => @data) end it "should create a meter" do - @chart.include?('cht=gom').should be_true + @chart.should include('cht=gom') end it "should be able to set a solid background fill" do - Gchart.meter(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true - Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true + Gchart.meter(:bg => 'efefef').should include("chf=bg,s,efefef") + Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") end it "should be able to set labels by using the legend or labesl accessor" do Gchart.meter(:title => @title, :labels => @legend, :data => @data).should include("chl=#{@jstized_legend}") Gchart.meter(:title => @title, :labels => @legend, :data => @data).should == Gchart.meter(:title => @title, :legend => @legend, :data => @data) end - end describe "a map chart" do before(:each) do @data = [0,100,50,32] @geographical_area = 'usa' @map_colors = ['FFFFFF', 'FF0000', 'FFFF00', '00FF00'] @country_codes = ['MT', 'WY', "ID", 'SD'] @chart = Gchart.map(:data => @data, :encoding => 'text', :size => '400x300', :geographical_area => @geographical_area, :map_colors => @map_colors, :country_codes => @country_codes) end it "should create a map" do - @chart.include?('cht=t').should be_true + @chart.should include('cht=t') end it "should set the geographical area" do - @chart.include?('chtm=usa').should be_true + @chart.should include('chtm=usa') end it "should set the map colors" do - @chart.include?('chco=FFFFFF,FF0000,FFFF00,00FF00').should be_true + @chart.should include('chco=FFFFFF,FF0000,FFFF00,00FF00') end it "should set the country/state codes" do - @chart.include?('chld=MTWYIDSD').should be_true + @chart.should include('chld=MTWYIDSD') end it "should set the chart data" do - @chart.include?('chd=t:0,100,50,32').should be_true + @chart.should include('chd=t:0,100,50,32') end - end describe 'exporting a chart' do it "should be available in the url format by default" do Gchart.line(:data => [0, 26], :format => 'url').should == Gchart.line(:data => [0, 26]) end it "should be available as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using img_tag alias" do Gchart.line(:data => [0, 26], :format => 'img_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom dimensions" do Gchart.line(:data => [0, 26], :format => 'image_tag', :size => '400x400').should match(/<img src=(.*) width="400" height="400" alt="Google Chart" \/>/) end it "should be available as an image tag using custom alt text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :alt => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Sexy chart" \/>/) end it "should be available as an image tag using custom title text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :title => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" title="Sexy chart" \/>/) end it "should be available as an image tag using custom css id selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :id => 'chart').should match(/<img id="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom css class selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should match(/<img class="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should use ampersands to separate key/value pairs in URLs by default" do - Gchart.line(:data => [0, 26]).should satisfy {|chart| chart.include? "&" } - Gchart.line(:data => [0, 26]).should_not satisfy {|chart| chart.include? "&amp;" } + Gchart.line(:data => [0, 26]).should include "&" + Gchart.line(:data => [0, 26]).should_not include "&amp;" end it "should escape ampersands in URLs when used as an image tag" do - Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should satisfy {|chart| chart.include? "&amp;" } + Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should satisfy {|chart| chart.should include "&amp;" } end it "should be available as a file" do File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file') File.exist?('chart.png').should be_true File.delete('chart.png') if File.exist?('chart.png') end it "should be available as a file using a custom file name" do File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') Gchart.line(:data => [0, 26], :format => 'file', :filename => 'custom_file_name.png') File.exist?('custom_file_name.png').should be_true File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') end it "should work even with multiple attrs" do File.delete('foo.png') if File.exist?('foo.png') Gchart.line(:size => '400x200', :data => [1,2,3,4,5], # :axis_labels => [[1,2,3,4, 5], %w[foo bar]], :axis_with_labels => 'x,r', :format => "file", :filename => "foo.png" ) File.exist?('foo.png').should be_true File.delete('foo.png') if File.exist?('foo.png') end - end describe 'SSL support' do it 'should change url if is presented' do Gchart.line(:use_ssl => true).should include('https://chart.googleapis.com/chart?') end - + it "should be available as a file" do File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file', :use_ssl => true) File.exist?('chart.png').should be_true File.delete('chart.png') if File.exist?('chart.png') end end
mattetti/googlecharts
5fbd453e3113592e42391a9c1e8f4748c319011a
Fixed the issue #44, improved README
diff --git a/README.markdown b/README.markdown index 46f5cd8..f544d69 100644 --- a/README.markdown +++ b/README.markdown @@ -1,316 +1,317 @@ The goal of this Gem is to make the creation of Google Charts a simple and easy task. require 'googlecharts' Gchart.line( :size => '200x300', :title => "example title", :bg => 'efefef', :legend => ['first data set label', 'second data set label'], :data => [10, 30, 120, 45, 72]) Check out the [full documentation over there](http://googlecharts.rubyforge.org/) This gem is fully tested using Rspec, check the rspec folder for more examples. See at the bottom of this file who reported using this gem. Chart Type ------------- This gem supports the following types of charts: * line, * line_xy * sparkline * scatter * bar * venn * pie * pie_3d * google meter Googlecharts also supports graphical themes and you can easily load your own. To create a chart, simply require Gchart and call any of the existing type: require 'gchart' Gchart.pie Chart Title ------------- To add a title to a chart pass the title to your chart: Gchart.line(:title => 'Sexy Charts!') You can also specify the color and/or size Gchart.line(:title => 'Sexy Charts!', :title_color => 'FF0000', :title_size => '20') Colors ------------- Specify a color with at least a 6-letter string of hexadecimal values in the format RRGGBB. For example: * FF0000 = red * 00FF00 = green * 0000FF = blue * 000000 = black * FFFFFF = white You can optionally specify transparency by appending a value between 00 and FF where 00 is completely transparent and FF completely opaque. For example: * 0000FFFF = solid blue * 0000FF00 = transparent blue If you need to use multiple colors, check the doc. Usually you just need to pass :attribute => 'FF0000,00FF00' Some charts have more options than other, make sure to refer to the documentation. Background options: ------------- If you don't set the background option, your graph will be transparent. * You have 3 types of background http://code.google.com/apis/chart/#chart_or_background_fill - solid - gradient - stripes By default, if you set a background color, the fill will be solid: Gchart.bar(:bg => 'efefef') However you can specify another fill type such as: Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'}) In the above code, we decided to have a gradient background, however since we only passed one color, the chart will start by the specified color and transition to white. By the default, the gradient angle is 0. Change it as follows: Gchart.line(:title =>'bg example', :bg => {:color => 'efefef', :type => 'gradient', :angle => 90}) For a more advance use of colors, refer to http://code.google.com/apis/chart/#linear_gradient Gchart.line(:bg => {:color => '76A4FB,1,ffffff,0', :type => 'gradient'}) The same way you set the background color, you can also set the graph background: Gchart.line(:graph_bg => 'cccccc') or both Gchart.line(:bg => {:color => '76A4FB,1,ffffff,0', :type => 'gradient'}, :graph_bg => 'cccccc', :title => 'Sexy Chart') Another type of fill is stripes http://code.google.com/apis/chart/#linear_stripes Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'}) You can customize the amount of stripes, colors and width by changing the color value. Themes -------- Googlecharts comes with 4 themes: keynote, thirty7signals, pastel and greyscale. (ganked from [Gruff](http://github.com/topfunky/gruff/tree/master) Gchart.line( :theme => :keynote, :data => [[0,40,10,70,20],[41,10,80,50,40],[20,60,30,60,80],[5,23,35,10,56],[80,90,5,30,60]], :title => 'keynote' ) * keynote ![keynote](http://chart.apis.google.com/chart?chtt=keynote&chco=6886B4,FDD84E,72AE6E,D1695E,8A6EAF,EFAA43&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo&chf=c,s,FFFFFF|bg,s,000000) * thirty7signals ![37signals](http://chart.apis.google.com/chart?chtt=thirty7signals&chco=FFF804,336699,339933,ff0000,cc99cc,cf5910&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo&chf=bg,s,FFFFFF) * pastel ![pastel](http://chart.apis.google.com/chart?chtt=pastel&chco=a9dada,aedaa9,daaea9,dadaa9,a9a9da&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo) * greyscale ![greyscale](http://chart.apis.google.com/chart?chtt=greyscale&chco=282828,383838,686868,989898,c8c8c8,e8e8e8&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo) You can also use your own theme. Create a yml file using the same format as the themes located in lib/themes.yml Load your theme(s): Chart::Theme.add_theme_file("#{File.dirname(__FILE__)}/fixtures/another_test_theme.yml") And use the standard method signature to use your own theme: Gchart.line(:theme => :custom_theme, :data => [[0, 40, 10, 70, 20],[41, 10, 80, 50]], :title => 'greyscale') Legend & Labels ------------- You probably will want to use a legend or labels for your graph. Gchart.line(:legend => 'legend label') or Gchart.line(:legend => ['legend label 1', 'legend label 2']) Will do the trick. You can also use the labels alias (makes more sense when using the pie charts) chart = Gchart.pie(:labels => ['label 1', 'label 2']) Multiple axis labels ------------- Multiple axis labels are available for line charts, bar charts and scatter plots. * x = bottom x-axis * t = top x-axis * y = left y-axis * r = right y-axis Gchart.line(:axis_with_label => 'x,y,r,t') To add labels on these axis: Gchart.line(:axis_with_label => 'x,y,r,t', :axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']) Note that each array entry could also be an array but represent the labels for the corresponding axis. A question which comes back often is how do I only display the y axis label? Solution: Gchart.line( :data => [0,20, 40, 60, 140, 230, 60], :axis_with_labels => 'y') Custom axis ranges --------------- If you want to display a custom range for an axis, you need to set the range as described in the Google charts documentation: min, max, step: Gchart.line( :data => [17, 17, 11, 8, 2], :axis_with_labels => ['x', 'y'], :axis_labels => [['J', 'F', 'M', 'A', 'M']], :axis_range => [nil, [2,17,5]]) In this case, the custom axis range is only defined for y (second entry) with a minimum value of 2, max 17 and a step of 5. This is also valid if you want to set a x axis and automatically define the y labels. Data options ------------- Data are passed using an array or a nested array. Gchart.bar(:data => [1,2,4,67,100,41,234]) Gchart.bar(:data => [[1,2,4,67,100,41,234],[45,23,67,12,67,300, 250]]) By default, the graph is drawn with your max value representing 100% of the height or width of the graph. You can change that my passing the max value. Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => 300) Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => 'auto') or if you want to use the real values from your dataset: Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => false) You can also define a different encoding to add more granularity: Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'simple') Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'extended') Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'text') Pies: ------------- you have 2 type of pies: - Gchart.pie() the standard 2D pie _ Gchart.pie_3d() the fancy 3D pie To set labels, you can use one of these two options: @legend = ['Matt_fu', 'Rob_fu'] Gchart.pie_3d(:title => @title, :labels => @legend, :data => @data, :size => '400x200') Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data, :size => '400x200') Bars: ------------- A bar chart can accept options to set the width of the bars, spacing between bars and spacing between bar groups. To set these, you can either provide a string, array or hash. The Google API sets these options in the order of width, spacing, and group spacing, with both spacing values being optional. So, if you provide a string or array, provide them in that order: Gchart.bar(:data => @data, :bar_width_and_spacing => '25,6') # width of 25, spacing of 6 Gchart.bar(:data => @data, :bar_width_and_spacing => '25,6,12') # width of 25, spacing of 6, group spacing of 12 Gchart.bar(:data => @data, :bar_width_and_spacing => [25,6]) # width of 25, spacing of 6 Gchart.bar(:data => @data, :bar_width_and_spacing => 25) # width of 25 The hash lets you set these values directly, with the Google default values set for any options you don't include: Gchart.bar(:data => @data, :bar_width_and_spacing => {:width => 19}) Gchart.bar(:data => @data, :bar_width_and_spacing => {:spacing => 10, :group_spacing => 12}) Radar: ------------- In a Radar graph, the x-axis is circular. The points can be connected by straight lines or curved lines. Gchart.radar(:data => @data, :curved => true) Sparklines: ------------- A sparkline chart has exactly the same parameters as a line chart. The only difference is that the axes lines are not drawn for sparklines by default. Google-o-meter ------------- A Google-o-meter has a few restrictions. It may only use a solid filled background and it may only have one label. Record Chart PNG file in filesystem Sample : -------------------------------------------- Multi Lines Chart Sample : chart = Gchart.new( :type => 'line', :title => "example title", + :theme => :keynote, :data => [[17, 17, 11, 8, 2],[10, 20, 15, 5, 7],[2, 3, 7, 9, 12]], :line_colors => 'e0440e,e62ae5,287eec', :legend => ['courbe 1','courbe 2','courbe 3'], :axis_with_labels => ['x', 'y'], :axis_range => [[0,100,20], [0,20,5]], :filename => "tmp/chart.png") # Record file in filesystem chart.file try yourself ------------- Gchart.bar( :data => [[1,2,4,67,100,41,234],[45,23,67,12,67,300, 250]], :title => 'SD Ruby Fu level', :legend => ['matt','patrick'], :bg => {:color => '76A4FB', :type => 'gradient'}, :bar_colors => 'ff0000,00ff00') "http://chart.apis.google.com/chart?chs=300x200&chdl=matt|patrick&chd=s:AAANUIv,JENCN9y&chtt=SDRuby+Fu+level&chf=bg,lg,0,76A4FB,0,ffffff,1&cht=bvs&chco=ff0000,00ff00" Gchart.pie(:data => [20,10,15,5,50], :title => 'SDRuby Fu level', :size => '400x200', :labels => ['matt', 'rob', 'patrick', 'ryan', 'jordan']) http://chart.apis.google.com/chart?cht=p&chs=400x200&chd=s:YMSG9&chtt=SDRuby+Fu+level&chl=matt|rob|patrick|ryan|jordan \ No newline at end of file diff --git a/lib/gchart.rb b/lib/gchart.rb index 7338c6f..c597793 100644 --- a/lib/gchart.rb +++ b/lib/gchart.rb @@ -1,721 +1,721 @@ $:.unshift File.dirname(__FILE__) require 'gchart/version' require 'gchart/theme' require "net/http" require "net/https" require "uri" require "cgi" require 'enumerator' class Gchart include GchartInfo def self.url(use_ssl = false) if use_ssl 'https://chart.googleapis.com/chart?' else 'http://chart.apis.google.com/chart?' end end def self.types @types ||= ['line', 'line_xy', 'scatter', 'bar', 'venn', 'pie', 'pie_3d', 'jstize', 'sparkline', 'meter', 'map', 'radar'] end def self.simple_chars @simple_chars ||= ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a end def self.chars @chars ||= simple_chars + ['-', '.'] end def self.ext_pairs @ext_pairs ||= chars.map { |char_1| chars.map { |char_2| char_1 + char_2 } }.flatten end def self.default_filename 'chart.png' end attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :legend, :legend_position, :labels, :data, :encoding, :bar_colors, :title_color, :title_size, :title_alignment, :custom, :axis_with_labels, :axis_labels, :bar_width_and_spacing, :id, :alt, :klass, :range_markers, :geographical_area, :map_colors, :country_codes, :axis_range, :filename, :min, :max, :colors, :usemap attr_accessor :bg_type, :bg_color, :bg_angle, :chart_type, :chart_color, :chart_angle, :axis_range, :thickness, :new_markers, :grid_lines, :use_ssl attr_accessor :min_value, :max_value types.each do |type| instance_eval <<-DYNCLASSMETH def #{type}(options = {}) # Start with theme defaults if a theme is set theme = options[:theme] options = theme ? Chart::Theme.load(theme).to_options.merge(options) : options # # Extract the format and optional filename, then clean the hash format = options[:format] || 'url' options[:filename] ||= default_filename options.delete(:format) #update map_colors to become bar_colors options.update(:bar_colors => options[:map_colors]) if options.has_key?(:map_colors) chart = new(options.merge!({:type => "#{type}"})) chart.send(format) end DYNCLASSMETH end def self.version VERSION::STRING end def self.method_missing(m, options={}) raise NoMethodError, "#{m} is not a supported chart format. Please use one of the following: #{supported_types}." end def initialize(options={}) # Allow Gchart to take a theme too @theme = options[:theme] options = @theme ? Chart::Theme.load(@theme).to_options.merge(options) : options options.delete(:theme) @type = options[:type] || 'line' @data = [] @width = 300 @height = 200 @curved = false @horizontal = false @grouped = false @use_ssl = false @encoding = 'simple' # @max_value = 'auto' # @min_value defaults to nil meaning zero @filename = options[:filename] # Sets the alt tag when chart is exported as image tag @alt = 'Google Chart' # Sets the CSS id selector when chart is exported as image tag @id = false # Sets the CSS class selector when chart is exported as image tag @klass = options[:class] || false # set the options value if definable options.each do |attribute, value| send("#{attribute}=", value) if self.respond_to?("#{attribute}=") end end def self.supported_types self.types.join(' ') end # Defines the Graph size using the following format: # width X height def size=(size='300x200') @width, @height = size.split("x").map { |dimension| dimension.to_i } end def size "#{width}x#{height}" end def dimensions # TODO: maybe others? [:line_xy, :scatter].include?(type) ? 2 : 1 end # Sets the orientation of a bar graph def orientation=(orientation='h') if orientation == 'h' || orientation == 'horizontal' self.horizontal = true elsif orientation == 'v' || orientation == 'vertical' self.horizontal = false end end # Sets the bar graph presentation (stacked or grouped) def stacked=(option=true) @grouped = option ? false : true end def bg=(options) if options.is_a?(String) @bg_color = options elsif options.is_a?(Hash) @bg_color = options[:color] @bg_type = options[:type] @bg_angle = options[:angle] end end def graph_bg=(options) if options.is_a?(String) @chart_color = options elsif options.is_a?(Hash) @chart_color = options[:color] @chart_type = options[:type] @chart_angle = options[:angle] end end def max_value=(max_v) if max_v =~ /false/ @max_value = false else @max_value = max_v end end def min_value=(min_v) if min_v =~ /false/ @min_value = false else @min_value = min_v end end # returns the full data range as an array # it also sets the data range if not defined def full_data_range(ds) return if max_value == false ds.each_with_index do |mds, mds_index| mds[:min_value] ||= min_value mds[:max_value] ||= max_value if mds_index == 0 && type.to_s == 'bar' # TODO: unless you specify a zero line (using chp or chds), # the min_value of a bar chart is always 0. #mds[:min_value] ||= mds[:data].first.to_a.compact.min mds[:min_value] ||= 0 end if (mds_index == 0 && type.to_s == 'bar' && !grouped && mds[:data].first.is_a?(Array)) totals = [] mds[:data].each do |l| l.each_with_index do |v, index| next if v.nil? totals[index] ||= 0 totals[index] += v end end mds[:max_value] ||= totals.compact.max else all = mds[:data].flatten.compact # default min value should be 0 unless set to auto if mds[:min_value] == 'auto' mds[:min_value] = all.min else min = all.min mds[:min_value] ||= (min && min < 0 ? min : 0) end mds[:max_value] ||= all.max end end unless axis_range @calculated_axis_range = true @axis_range = ds.map{|mds| [mds[:min_value], mds[:max_value]]} if dimensions == 1 && (type.to_s != 'bar' || horizontal) tmp = axis_range.fetch(0, []) @axis_range[0] = axis_range.fetch(1, []) @axis_range[1] = tmp end end # return [min, max] unless (min.nil? || max.nil?) # @max = (max_value.nil? || max_value == 'auto') ? ds.compact.map{|mds| mds.compact.max}.max : max_value # # if min_value.nil? # min_ds_value = ds.compact.map{|mds| mds.compact.min}.min || 0 # @min = (min_ds_value < 0) ? min_ds_value : 0 # else # @min = min_value == 'auto' ? ds.compact.map{|mds| mds.compact.min}.min || 0 : min_value # end # @axis_range = [[min,max]] end def dataset if @dataset @dataset else @dataset = convert_dataset(data || []) full_data_range(@dataset) # unless axis_range @dataset end end # Sets of data to handle multiple sets def datasets datasets = [] dataset.each do |d| if d[:data].first.is_a?(Array) datasets += d[:data] else datasets << d[:data] end end datasets end def self.jstize(string) # See http://github.com/mattetti/googlecharts/issues#issue/27 #URI.escape( string ).gsub("%7C", "|") # See discussion: http://github.com/mattetti/googlecharts/commit/9b5cfb93aa51aae06611057668e631cd515ec4f3#comment_51347 string.gsub(' ', '+').gsub(/\[|\{|\}|\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} #string.gsub(' ', '+').gsub(/\[|\{|\}|\||\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} end # load all the custom aliases require 'gchart/aliases' # Returns the chart's generated PNG as a blob. (borrowed from John's gchart.rubyforge.org) def fetch url = URI.parse(self.class.url(use_ssl)) req = Net::HTTP::Post.new(url.path) req.body = query_builder req.content_type = 'application/x-www-form-urlencoded' http = Net::HTTP.new(url.host, url.port) http.verify_mode = OpenSSL::SSL::VERIFY_PEER if use_ssl http.use_ssl = use_ssl http.start {|resp| resp.request(req) }.body end # Writes the chart's generated PNG to a file. (borrowed from John's gchart.rubyforge.org) def write io_or_file = filename || self.class.default_filename return io_or_file.write(fetch) if io_or_file.respond_to?(:write) open(io_or_file, "wb+") { |io| io.write(fetch) } end # Format def image_tag image = "<img" image += " id=\"#{id}\"" if id image += " class=\"#{klass}\"" if klass image += " src=\"#{url_builder(:html)}\"" image += " width=\"#{width}\"" image += " height=\"#{height}\"" image += " alt=\"#{alt}\"" image += " title=\"#{title}\"" if title image += " usemap=\"#{usemap}\"" if usemap image += " />" end alias_method :img_tag, :image_tag def url url_builder end def file write end # def jstize(string) self.class.jstize(string) end private # The title size cannot be set without specifying a color. # A dark key will be used for the title color if no color is specified def set_title - title_params = "chtt=#{title}" + title_params = "chtt=#{title}".gsub(/\|/,"\n") unless (title_color.nil? && title_size.nil? && title_alignment.nil?) title_params << "&chts=" + (color, size, alignment = (title_color || '454545'), title_size, (title_alignment.to_s[0,1] || 'c')).compact.join(',') end title_params end def set_size "chs=#{size}" end def set_data data = send("#{@encoding}_encoding") "chd=#{data}" end def set_colors @bg_type = fill_type(bg_type) || 's' if bg_color @chart_type = fill_type(chart_type) || 's' if chart_color "chf=" + {'bg' => fill_for(bg_type, bg_color, bg_angle), 'c' => fill_for(chart_type, chart_color, chart_angle)}.map{|k,v| "#{k},#{v}" unless v.nil?}.compact.join('|') end # set bar, line colors def set_bar_colors @bar_colors = bar_colors.join(',') if bar_colors.is_a?(Array) "chco=#{bar_colors}" end def set_country_codes @country_codes = country_codes.join() if country_codes.is_a?(Array) "chld=#{country_codes}" end # set bar spacing # chbh= # <bar width in pixels>, # <optional space between bars in a group>, # <optional space between groups> def set_bar_width_and_spacing width_and_spacing_values = case bar_width_and_spacing when String bar_width_and_spacing when Array bar_width_and_spacing.join(',') when Hash width = bar_width_and_spacing[:width] || 23 spacing = bar_width_and_spacing[:spacing] || 4 group_spacing = bar_width_and_spacing[:group_spacing] || 8 [width,spacing,group_spacing].join(',') else bar_width_and_spacing.to_s end "chbh=#{width_and_spacing_values}" end def set_range_markers markers = case range_markers when Hash set_range_marker(range_markers) when Array range_markers.collect{|marker| set_range_marker(marker)}.join('|') end "chm=#{markers}" end def set_range_marker(options) orientation = ['vertical', 'Vertical', 'V', 'v', 'R'].include?(options[:orientation]) ? 'R' : 'r' "#{orientation},#{options[:color]},0,#{options[:start_position]},#{options[:stop_position]}#{',1' if options[:overlaid?]}" end def fill_for(type=nil, color='', angle=nil) unless type.nil? case type when 'lg' angle ||= 0 color = "#{color},0,ffffff,1" if color.split(',').size == 1 "#{type},#{angle},#{color}" when 'ls' angle ||= 90 color = "#{color},0.2,ffffff,0.2" if color.split(',').size == 1 "#{type},#{angle},#{color}" else "#{type},#{color}" end end end # A chart can have one or many legends. # Gchart.line(:legend => 'label') # or # Gchart.line(:legend => ['first label', 'last label']) def set_legend if type.to_s =~ /meter/ @labels = legend return set_labels end if legend.is_a?(Array) "chdl=#{@legend.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chdl=#{legend}" end end def set_legend_position case @legend_position.to_s when /(bottom|b)$/ "chdlp=b" when /(bottom_vertical|bv)$/ "chdlp=bv" when /(top|t)$/ "chdlp=t" when /(top_vertical|tv)$/ "chdlp=tv" when /(right|r)$/ "chdlp=r" when /(left|l)$/ "chdlp=l" end end def set_line_thickness "chls=#{thickness}" end def set_line_markers "chm=#{new_markers}" end def set_grid_lines "chg=#{grid_lines}" end def set_labels if labels.is_a?(Array) "chl=#{@labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chl=#{@labels}" end end def set_axis_with_labels @axis_with_labels = axis_with_labels.join(',') if @axis_with_labels.is_a?(Array) "chxt=#{axis_with_labels}" end def set_axis_labels if axis_labels.is_a?(Array) if RUBY_VERSION.to_f < 1.9 labels_arr = axis_labels.enum_with_index.map{|labels,index| [index,labels]} else labels_arr = axis_labels.map.with_index.map{|labels,index| [index,labels]} end elsif axis_labels.is_a?(Hash) labels_arr = axis_labels.to_a end labels_arr.map! do |index,labels| if labels.is_a?(Array) "#{index}:|#{labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "#{index}:|#{labels}" end end "chxl=#{labels_arr.join('|')}" end # http://code.google.com/apis/chart/labels.html#axis_range # Specify a range for axis labels def set_axis_range # a passed axis_range should look like: # [[10,100]] or [[10,100,4]] or [[10,100], [20,300]] # in the second example, 4 is the interval set = @calculated_axis_range ? datasets : axis_range || datasets return unless set && set.respond_to?(:each) && set.find {|o| o}.respond_to?(:each) 'chxr=' + set.enum_for(:each_with_index).map do |axis_range, index| next nil if axis_range.nil? # ignore this axis min, max, step = axis_range if axis_range.size > 3 || step && max && step > max # this is a full series max = axis_range.compact.max step = nil end [index, (min_value || min || 0), (max_value || max), step].compact.join(',') end.compact.join("|") end def set_geographical_area "chtm=#{geographical_area}" end def set_type 'cht=' + case type.to_s when 'line' then "lc" when 'line_xy' then "lxy" when 'pie_3d' then "p3" when 'pie' then "p" when 'venn' then "v" when 'scatter' then "s" when 'sparkline' then "ls" when 'meter' then "gom" when 'map' then "t" when 'radar' "r" + (curved? ? 's' : '') when 'bar' "b" + (horizontal? ? "h" : "v") + (grouped? ? "g" : "s") end end def fill_type(type) case type when 'solid' then 's' when 'gradient' then 'lg' when 'stripes' then 'ls' end end def number_visible n = 0 dataset.each do |mds| return n.to_s if mds[:invisible] == true if mds[:data].first.is_a?(Array) n += mds[:data].length else n += 1 end end "" end # Turns input into an array of axis hashes, dependent on the chart type def convert_dataset(ds) if dimensions == 2 # valid inputs include: # an array of >=2 arrays, or an array of >=2 hashes ds = ds.map do |d| d.is_a?(Hash) ? d : {:data => d} end elsif dimensions == 1 # valid inputs include: # a hash, an array of data, an array of >=1 array, or an array of >=1 hash if ds.is_a?(Hash) ds = [ds] elsif not ds.first.is_a?(Hash) ds = [{:data => ds}] end end ds end # just an alias def axis_set dataset end def convert_to_simple_value(number) if number.nil? "_" else value = self.class.simple_chars[number.to_i] value.nil? ? "_" : value end end def convert_to_extended_value(number) if number.nil? '__' else value = self.class.ext_pairs[number.to_i] value.nil? ? "__" : value end end def encode_scaled_dataset(chars, nil_char) dsets = [] dataset.each do |ds| if max_value != false range = ds[:max_value] - ds[:min_value] range = 1 if range == 0 end unless ds[:data].first.is_a?(Array) ldatasets = [ds[:data]] else ldatasets = ds[:data] end ldatasets.each do |l| dsets << l.map do |number| if number.nil? nil_char else unless range.nil? || range.zero? number = chars.size * (number - ds[:min_value]) / range.to_f number = [number, chars.size - 1].min end chars[number.to_i] end end.join end end dsets.join(',') end # http://code.google.com/apis/chart/#simple # Simple encoding has a resolution of 62 different values. # Allowing five pixels per data point, this is sufficient for line and bar charts up # to about 300 pixels. Simple encoding is suitable for all other types of chart regardless of size. def simple_encoding "s" + number_visible + ":" + encode_scaled_dataset(self.class.simple_chars, '_') end # http://code.google.com/apis/chart/#text # Text encoding with data scaling lets you specify arbitrary positive or # negative floating point numbers, in combination with a scaling parameter # that lets you specify a custom range for your chart. This chart is useful # when you don't want to worry about limiting your data to a specific range, # or do the calculations to scale your data down or up to fit nicely inside # a chart. # # Valid values range from (+/-)9.999e(+/-)100, and only four non-zero digits are supported (that is, 123400, 1234, 12.34, and 0.1234 are valid, but 12345, 123.45 and 123400.5 are not). # # This encoding is not available for maps. # def text_encoding chds = dataset.map{|ds| "#{ds[:min_value]},#{ds[:max_value]}" }.join(",") "t" + number_visible + ":" + datasets.map{ |ds| ds.map{|e|e||'_'}.join(',') }.join('|') + "&chds=" + chds end # http://code.google.com/apis/chart/#extended # Extended encoding has a resolution of 4,096 different values # and is best used for large charts where a large data range is required. def extended_encoding "e" + number_visible + ":" + encode_scaled_dataset(self.class.ext_pairs, '__') end def url_builder(options="") self.class.url(use_ssl) + query_builder(options) end def query_builder(options="") query_params = instance_variables.sort.map do |var| case var.to_s when '@data' set_data unless data == [] # Set the graph size when '@width' set_size unless width.nil? || height.nil? when '@type' set_type when '@title' set_title unless title.nil? when '@legend' set_legend unless legend.nil? when '@labels' set_labels unless labels.nil? when '@legend_position' set_legend_position unless legend_position.nil? when '@thickness' set_line_thickness when '@new_markers' set_line_markers when '@bg_color' set_colors when '@chart_color' set_colors if bg_color.nil? when '@bar_colors' set_bar_colors when '@bar_width_and_spacing' set_bar_width_and_spacing when '@axis_with_labels' set_axis_with_labels when '@axis_labels' set_axis_labels when '@range_markers' set_range_markers when '@grid_lines' set_grid_lines when '@geographical_area' set_geographical_area when '@country_codes' set_country_codes when '@custom' custom end end.compact query_params << set_axis_range # Use ampersand as default delimiter unless options == :html delimiter = '&' # Escape ampersand for html image tags else delimiter = '&amp;' end jstize(query_params.join(delimiter)) end end diff --git a/spec/gchart_spec.rb b/spec/gchart_spec.rb index 18b8a23..ca7b1be 100644 --- a/spec/gchart_spec.rb +++ b/spec/gchart_spec.rb @@ -1,540 +1,545 @@ require File.dirname(__FILE__) + '/spec_helper.rb' require File.dirname(__FILE__) + '/../lib/gchart' Chart::Theme.add_theme_file("#{File.dirname(__FILE__)}/fixtures/test_theme.yml") # Time to add your specs! # http://rspec.rubyforge.org/ describe "The Gchart class" do it "should show supported_types on error" do Gchart.supported_types.should match(/line/) end it "should return supported types" do Gchart.types.include?('line').should be_true end it "should support theme option" do chart = Gchart.new(:type => 'line',:theme => :test) chart.send('url').should include('chco=6886B4,FDD84E') end end describe "generating a default Gchart" do before(:each) do @chart = Gchart.line end + it "should create a line break when a pipe character is encountered" do + @chart = Gchart.line(:title => "title|subtitle") + @chart.include?("chtt=title\nsubtitle").should be_true + end + it "should include the Google URL" do @chart.include?("http://chart.apis.google.com/chart?").should be_true end it "should have a default size" do @chart.should include('chs=300x200') end it "should be able to have a custom size" do Gchart.line(:size => '400x600').include?('chs=400x600').should be_true Gchart.line(:width => 400, :height => 600).include?('chs=400x600').should be_true end it "should have query parameters in predictable order" do Gchart.line(:axis_with_labels => 'x,y,r', :size => '400x600').should match(/chxt=.+cht=.+chs=/) end it "should have a type" do @chart.include?('cht=lc').should be_true end it 'should use theme defaults if theme is set' do Gchart.line(:theme=>:test).should include('chco=6886B4,FDD84E') if RUBY_VERSION.to_f < 1.9 Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=c,s,FFFFFF|bg,s,FFFFFF')) else Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=bg,s,FFFFFF|c,s,FFFFFF')) end end it "should use the simple encoding by default with auto max value" do # 9 is the max value in simple encoding, 26 being our max value the 2nd encoded value should be 9 Gchart.line(:data => [0, 26]).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => 26, :axis_with_labels => 'y').should include('chxr=0,0,26') end it "should support simple encoding with and without max_value" do Gchart.line(:data => [0, 26], :max_value => 26).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => false).should include('chd=s:Aa') end it "should support the extended encoding and encode properly" do Gchart.line(:data => [0, 10], :encoding => 'extended', :max_value => false).include?('chd=e:AA').should be_true Gchart.line(:encoding => 'extended', :max_value => false, :data => [[0,25,26,51,52,61,62,63], [64,89,90,115,4084]] ).include?('chd=e:AAAZAaAzA0A9A-A.,BABZBaBz.0').should be_true end it "should auto set the max value for extended encoding" do Gchart.line(:data => [0, 25], :encoding => 'extended', :max_value => false).should include('chd=e:AAAZ') # Extended encoding max value is '..' Gchart.line(:data => [0, 25], :encoding => 'extended').include?('chd=e:AA..').should be_true end it "should be able to have data with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,4,45,78') end it "should be able to have missing data points with text encoding" do Gchart.line(:data => [10, 5.2, nil, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,_,45,78') end it "should handle max and min values with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=0,78') end it "should automatically handle negative values with proper max/min limits when using text encoding" do Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=-10,78') end it "should handle negative values with manual max/min limits when using text encoding" do Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text', :min_value => -20, :max_value => 100).include?('chds=-20,100').should be_true end it "should set the proper axis values when using text encoding and negative values" do Gchart.bar( :data => [[-10], [100]], :encoding => 'text', :horizontal => true, :min_value => -20, :max_value => 100, :axis_with_labels => 'x', :bar_colors => ['FD9A3B', '4BC7DC']).should include("chxr=0,-20,100") end it "should be able to have multiple set of data with text encoding" do Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text').include?(Gchart.jstize('chd=t:10,5.2,4,45,78|20,40,70,15,99')).should be_true end it "should be able to receive a custom param" do Gchart.line(:custom => 'ceci_est_une_pipe').include?('ceci_est_une_pipe').should be_true end it "should be able to set label axis" do Gchart.line(:axis_with_labels => 'x,y,r').include?('chxt=x,y,r').should be_true Gchart.line(:axis_with_labels => ['x','y','r']).include?('chxt=x,y,r').should be_true end it "should be able to have axis labels" do Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true end def labeled_line(options = {}) Gchart.line({:data => @data, :axis_with_labels => 'x,y'}.merge(options)) end it "should display ranges properly" do @data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] labeled_line(:axis_labels => [((1..24).to_a << 1)]). should include('chxr=0,85,672') end def labeled_bar(options = {}) Gchart.bar({:data => @data, :axis_with_labels => 'x,y', :axis_labels => [(1..12).to_a], :encoding => "text" }.merge(options)) end it "should force the y range properly" do @data = [1,1,1,1,1,1,1,1,6,2,1,1] labeled_bar( :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,0|1,0,16') labeled_bar( :max_value => 16, :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,16|1,0,16') # nil means ignore axis labeled_bar( :axis_range => [nil,[0,16]] ).should include('chxr=1,0,16') # empty array means take defaults labeled_bar( :max_value => 16, :axis_range => [[],[0,16]] ).should include('chxr=0,0,16|1,0,16') labeled_bar( :axis_range => [[],[0,16]] ).should include('chxr=0,0|1,0,16') Gchart.line( :data => [0,20, 40, 60, 140, 230, 60], :axis_with_labels => 'y').should include("chxr=0,0,230") end it "should take in consideration the max value when creating a range" do data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] url = Gchart.line(:data => data, :axis_with_labels => 'x,y', :axis_labels => [((1..24).to_a << 1)], :max_value => 700) url.should include('chxr=0,85,700') end it 'should generate different labels and legend' do Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three)).should(include('chdl=1|2|3') && include('chl=one|two|three')) end end describe "generating different type of charts" do it "should be able to generate a line chart" do Gchart.line.should be_an_instance_of(String) Gchart.line.include?('cht=lc').should be_true end it "should be able to generate a sparkline chart" do Gchart.sparkline.should be_an_instance_of(String) Gchart.sparkline.include?('cht=ls').should be_true end it "should be able to generate a line xy chart" do Gchart.line_xy.should be_an_instance_of(String) Gchart.line_xy.include?('cht=lxy').should be_true end it "should be able to generate a scatter chart" do Gchart.scatter.should be_an_instance_of(String) Gchart.scatter.include?('cht=s').should be_true end it "should be able to generate a bar chart" do Gchart.bar.should be_an_instance_of(String) Gchart.bar.include?('cht=bvs').should be_true end it "should be able to generate a Venn diagram" do Gchart.venn.should be_an_instance_of(String) Gchart.venn.include?('cht=v').should be_true end it "should be able to generate a Pie Chart" do Gchart.pie.should be_an_instance_of(String) Gchart.pie.include?('cht=p').should be_true end it "should be able to generate a Google-O-Meter" do Gchart.meter.should be_an_instance_of(String) Gchart.meter.include?('cht=gom').should be_true end it "should be able to generate a map chart" do Gchart.map.should be_an_instance_of(String) Gchart.map.include?('cht=t').should be_true end it "should not support other types" do msg = "sexy is not a supported chart format. Please use one of the following: #{Gchart.supported_types}." lambda{Gchart.sexy}.should raise_error(NoMethodError) end end describe "range markers" do it "should be able to generate given a hash of range-marker options" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}).include?('chm=r,ff0000,0,0.59,0.61').should be_true end it "should be able to generate given an array of range-marker hash options" do Gchart.line(:range_markers => [ {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}, {:start_position => 0, :stop_position => 0.6, :color => '666666'}, {:color => 'cccccc', :start_position => 0.6, :stop_position => 1} ]).include?(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1')).should be_true end it "should allow a :overlaid? to be set" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true}).include?('chm=r,ffffff,0,0.59,0.61,1').should be_true Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false}).include?('chm=r,ffffff,0,0.59,0.61').should be_true end describe "when setting the orientation option" do before(:each) do @options = {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'} end it "to vertical (R) if given a valid option" do Gchart.line(:range_markers => @options.merge(:orientation => 'v')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'V')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'R')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'vertical')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical')).include?('chm=R').should be_true end it "to horizontal (r) if given a valid option (actually anything other than the vertical options)" do Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal')).include?('chm=r').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'h')).include?('chm=r').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'etc')).include?('chm=r').should be_true end it "if left blank defaults to horizontal (r)" do Gchart.line(:range_markers => @options).include?('chm=r').should be_true end end end describe "a bar graph" do it "should have a default vertical orientation" do Gchart.bar.include?('cht=bvs').should be_true end it "should be able to have a different orientation" do Gchart.bar(:orientation => 'vertical').include?('cht=bvs').should be_true Gchart.bar(:orientation => 'v').include?('cht=bvs').should be_true Gchart.bar(:orientation => 'h').include?('cht=bhs').should be_true Gchart.bar(:orientation => 'horizontal').include?('cht=bhs').should be_true Gchart.bar(:horizontal => false).include?('cht=bvs').should be_true end it "should be set to be stacked by default" do Gchart.bar.include?('cht=bvs').should be_true end it "should be able to stacked or grouped" do Gchart.bar(:stacked => true).include?('cht=bvs').should be_true Gchart.bar(:stacked => false).include?('cht=bvg').should be_true Gchart.bar(:grouped => true).include?('cht=bvg').should be_true Gchart.bar(:grouped => false).include?('cht=bvs').should be_true end it "should be able to have different bar colors" do Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=').should be_true Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=efefef,00ffff').should be_true # alias Gchart.bar(:bar_color => 'efefef').include?('chco=efefef').should be_true end it "should be able to have different bar colors when using an array of colors" do Gchart.bar(:bar_colors => ['efefef','00ffff']).include?('chco=efefef,00ffff').should be_true end it 'should be able to accept a string of width and spacing options' do Gchart.bar(:bar_width_and_spacing => '25,6').include?('chbh=25,6').should be_true end it 'should be able to accept a single fixnum width and spacing option to set the bar width' do Gchart.bar(:bar_width_and_spacing => 25).include?('chbh=25').should be_true end it 'should be able to accept an array of width and spacing options' do Gchart.bar(:bar_width_and_spacing => [25,6,12]).include?('chbh=25,6,12').should be_true Gchart.bar(:bar_width_and_spacing => [25,6]).include?('chbh=25,6').should be_true Gchart.bar(:bar_width_and_spacing => [25]).include?('chbh=25').should be_true end describe "with a hash of width and spacing options" do before(:each) do @default_width = 23 @default_spacing = 4 @default_group_spacing = 8 end it 'should be able to have a custom bar width' do Gchart.bar(:bar_width_and_spacing => {:width => 19}).include?("chbh=19,#{@default_spacing},#{@default_group_spacing}").should be_true end it 'should be able to have custom spacing' do Gchart.bar(:bar_width_and_spacing => {:spacing => 19}).include?("chbh=#{@default_width},19,#{@default_group_spacing}").should be_true end it 'should be able to have custom group spacing' do Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19}).include?("chbh=#{@default_width},#{@default_spacing},19").should be_true end end end describe "a line chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @chart = Gchart.line(:title => @title, :legend => @legend) end it 'should be able have a chart title' do @chart.include?("chtt=Chart+Title").should be_true end it "should be able to a custom color, size and alignment for title" do Gchart.line(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true Gchart.line(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true Gchart.line(:title => @title, :title_size => '20', :title_alignment => :left).include?('chts=454545,20,l').should be_true end it "should be able to have multiple legends" do @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true end it "should escape text values in url" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend) chart.include?(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")).should be_true end it "should be able to have one legend" do chart = Gchart.line(:legend => 'legend label') chart.include?("chdl=legend+label").should be_true end it "should be able to set the position of the legend" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend, :legend_position => :bottom_vertical) chart.include?("chdlp=bv").should be_true chart = Gchart.line(:title => title, :legend => legend, :legend_position => 'r') chart.include?("chdlp=r").should be_true end it "should be able to set the background fill" do Gchart.line(:bg => 'efefef').should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=bg,lg,90,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'}).should include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do Gchart.line(:graph_bg => 'efefef').should include("chf=c,s,efefef") Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true end it "should be able to set both a graph and a background fill" do Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true if RUBY_VERSION.to_f < 1.9 Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true else Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true end end it "should be able to have different line colors" do Gchart.line(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true Gchart.line(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true end it "should be able to render a graph where all the data values are 0" do Gchart.line(:data => [0, 0, 0]).should include("chd=s:AAA") end end describe "a sparkline chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [27,25,25,25,25,27,100,31,25,36,25,25,39,25,31,25,25,25,26,26,25,25,28,25,25,100,28,27,31,25,27,27,29,25,27,26,26,25,26,26,35,33,34,25,26,25,36,25,26,37,33,33,37,37,39,25,25,25,25] @chart = Gchart.sparkline(:title => @title, :data => @data, :legend => @legend) end it "should create a sparkline" do @chart.include?('cht=ls').should be_true end it 'should be able have a chart title' do @chart.include?("chtt=Chart+Title").should be_true end it "should be able to a custom color and size title" do Gchart.sparkline(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true Gchart.sparkline(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true end it "should be able to have multiple legends" do @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true end it "should be able to have one legend" do chart = Gchart.sparkline(:legend => 'legend label') chart.include?("chdl=legend+label").should be_true end it "should be able to set the background fill" do Gchart.sparkline(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=bg,lg,90,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'}).include?("chf=bg,ls,90,efefef,0.2,ffffff,0.2").should be_true end it "should be able to set a graph fill" do Gchart.sparkline(:graph_bg => 'efefef').include?("chf=c,s,efefef").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true end it "should be able to set both a graph and a background fill" do Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true if RUBY_VERSION.to_f < 1.9 Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true else Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true end end it "should be able to have different line colors" do Gchart.sparkline(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true Gchart.sparkline(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true end end describe "a 3d pie chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [12,8,40,15,5] @chart = Gchart.pie(:title => @title, :legend => @legend, :data => @data) end it "should create a pie" do @chart.include?('cht=p').should be_true end it "should be able to be in 3d" do Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data).include?('cht=p3').should be_true end end
mattetti/googlecharts
e62a60f3a93b79fbeb8a9e126f93b50b72c8aec7
Added rspec to the new feature of allowing GChart.new take theme by djtal
diff --git a/lib/gchart.rb b/lib/gchart.rb index e4d5a71..7338c6f 100644 --- a/lib/gchart.rb +++ b/lib/gchart.rb @@ -1,715 +1,721 @@ $:.unshift File.dirname(__FILE__) require 'gchart/version' require 'gchart/theme' require "net/http" require "net/https" require "uri" require "cgi" require 'enumerator' class Gchart include GchartInfo def self.url(use_ssl = false) if use_ssl 'https://chart.googleapis.com/chart?' else 'http://chart.apis.google.com/chart?' end end def self.types @types ||= ['line', 'line_xy', 'scatter', 'bar', 'venn', 'pie', 'pie_3d', 'jstize', 'sparkline', 'meter', 'map', 'radar'] end def self.simple_chars @simple_chars ||= ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a end def self.chars @chars ||= simple_chars + ['-', '.'] end def self.ext_pairs @ext_pairs ||= chars.map { |char_1| chars.map { |char_2| char_1 + char_2 } }.flatten end def self.default_filename 'chart.png' end attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :legend, :legend_position, :labels, :data, :encoding, :bar_colors, :title_color, :title_size, :title_alignment, :custom, :axis_with_labels, :axis_labels, :bar_width_and_spacing, :id, :alt, :klass, :range_markers, :geographical_area, :map_colors, :country_codes, :axis_range, :filename, :min, :max, :colors, :usemap attr_accessor :bg_type, :bg_color, :bg_angle, :chart_type, :chart_color, :chart_angle, :axis_range, :thickness, :new_markers, :grid_lines, :use_ssl attr_accessor :min_value, :max_value types.each do |type| instance_eval <<-DYNCLASSMETH def #{type}(options = {}) # Start with theme defaults if a theme is set theme = options[:theme] options = theme ? Chart::Theme.load(theme).to_options.merge(options) : options # # Extract the format and optional filename, then clean the hash format = options[:format] || 'url' options[:filename] ||= default_filename options.delete(:format) #update map_colors to become bar_colors options.update(:bar_colors => options[:map_colors]) if options.has_key?(:map_colors) chart = new(options.merge!({:type => "#{type}"})) chart.send(format) end DYNCLASSMETH end def self.version VERSION::STRING end def self.method_missing(m, options={}) raise NoMethodError, "#{m} is not a supported chart format. Please use one of the following: #{supported_types}." end def initialize(options={}) + # Allow Gchart to take a theme too + @theme = options[:theme] + options = @theme ? Chart::Theme.load(@theme).to_options.merge(options) : options + options.delete(:theme) + @type = options[:type] || 'line' @data = [] @width = 300 @height = 200 @curved = false @horizontal = false @grouped = false @use_ssl = false @encoding = 'simple' # @max_value = 'auto' # @min_value defaults to nil meaning zero @filename = options[:filename] # Sets the alt tag when chart is exported as image tag @alt = 'Google Chart' # Sets the CSS id selector when chart is exported as image tag @id = false # Sets the CSS class selector when chart is exported as image tag @klass = options[:class] || false # set the options value if definable options.each do |attribute, value| send("#{attribute}=", value) if self.respond_to?("#{attribute}=") end end def self.supported_types self.types.join(' ') end # Defines the Graph size using the following format: # width X height def size=(size='300x200') @width, @height = size.split("x").map { |dimension| dimension.to_i } end def size "#{width}x#{height}" end def dimensions # TODO: maybe others? [:line_xy, :scatter].include?(type) ? 2 : 1 end # Sets the orientation of a bar graph def orientation=(orientation='h') if orientation == 'h' || orientation == 'horizontal' self.horizontal = true elsif orientation == 'v' || orientation == 'vertical' self.horizontal = false end end # Sets the bar graph presentation (stacked or grouped) def stacked=(option=true) @grouped = option ? false : true end def bg=(options) if options.is_a?(String) @bg_color = options elsif options.is_a?(Hash) @bg_color = options[:color] @bg_type = options[:type] @bg_angle = options[:angle] end end def graph_bg=(options) if options.is_a?(String) @chart_color = options elsif options.is_a?(Hash) @chart_color = options[:color] @chart_type = options[:type] @chart_angle = options[:angle] end end def max_value=(max_v) if max_v =~ /false/ @max_value = false else @max_value = max_v end end def min_value=(min_v) if min_v =~ /false/ @min_value = false else @min_value = min_v end end # returns the full data range as an array # it also sets the data range if not defined def full_data_range(ds) return if max_value == false ds.each_with_index do |mds, mds_index| mds[:min_value] ||= min_value mds[:max_value] ||= max_value if mds_index == 0 && type.to_s == 'bar' # TODO: unless you specify a zero line (using chp or chds), # the min_value of a bar chart is always 0. #mds[:min_value] ||= mds[:data].first.to_a.compact.min mds[:min_value] ||= 0 end if (mds_index == 0 && type.to_s == 'bar' && !grouped && mds[:data].first.is_a?(Array)) totals = [] mds[:data].each do |l| l.each_with_index do |v, index| next if v.nil? totals[index] ||= 0 totals[index] += v end end mds[:max_value] ||= totals.compact.max else all = mds[:data].flatten.compact # default min value should be 0 unless set to auto if mds[:min_value] == 'auto' mds[:min_value] = all.min else min = all.min mds[:min_value] ||= (min && min < 0 ? min : 0) end mds[:max_value] ||= all.max end end unless axis_range @calculated_axis_range = true @axis_range = ds.map{|mds| [mds[:min_value], mds[:max_value]]} if dimensions == 1 && (type.to_s != 'bar' || horizontal) tmp = axis_range.fetch(0, []) @axis_range[0] = axis_range.fetch(1, []) @axis_range[1] = tmp end end # return [min, max] unless (min.nil? || max.nil?) # @max = (max_value.nil? || max_value == 'auto') ? ds.compact.map{|mds| mds.compact.max}.max : max_value # # if min_value.nil? # min_ds_value = ds.compact.map{|mds| mds.compact.min}.min || 0 # @min = (min_ds_value < 0) ? min_ds_value : 0 # else # @min = min_value == 'auto' ? ds.compact.map{|mds| mds.compact.min}.min || 0 : min_value # end # @axis_range = [[min,max]] end def dataset if @dataset @dataset else @dataset = convert_dataset(data || []) full_data_range(@dataset) # unless axis_range @dataset end end # Sets of data to handle multiple sets def datasets datasets = [] dataset.each do |d| if d[:data].first.is_a?(Array) datasets += d[:data] else datasets << d[:data] end end datasets end def self.jstize(string) # See http://github.com/mattetti/googlecharts/issues#issue/27 #URI.escape( string ).gsub("%7C", "|") # See discussion: http://github.com/mattetti/googlecharts/commit/9b5cfb93aa51aae06611057668e631cd515ec4f3#comment_51347 string.gsub(' ', '+').gsub(/\[|\{|\}|\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} #string.gsub(' ', '+').gsub(/\[|\{|\}|\||\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} end # load all the custom aliases require 'gchart/aliases' # Returns the chart's generated PNG as a blob. (borrowed from John's gchart.rubyforge.org) def fetch url = URI.parse(self.class.url(use_ssl)) req = Net::HTTP::Post.new(url.path) req.body = query_builder req.content_type = 'application/x-www-form-urlencoded' http = Net::HTTP.new(url.host, url.port) http.verify_mode = OpenSSL::SSL::VERIFY_PEER if use_ssl http.use_ssl = use_ssl http.start {|resp| resp.request(req) }.body end # Writes the chart's generated PNG to a file. (borrowed from John's gchart.rubyforge.org) def write io_or_file = filename || self.class.default_filename return io_or_file.write(fetch) if io_or_file.respond_to?(:write) open(io_or_file, "wb+") { |io| io.write(fetch) } end # Format def image_tag image = "<img" image += " id=\"#{id}\"" if id image += " class=\"#{klass}\"" if klass image += " src=\"#{url_builder(:html)}\"" image += " width=\"#{width}\"" image += " height=\"#{height}\"" image += " alt=\"#{alt}\"" image += " title=\"#{title}\"" if title image += " usemap=\"#{usemap}\"" if usemap image += " />" end alias_method :img_tag, :image_tag def url url_builder end def file write end # def jstize(string) self.class.jstize(string) end private # The title size cannot be set without specifying a color. # A dark key will be used for the title color if no color is specified def set_title title_params = "chtt=#{title}" unless (title_color.nil? && title_size.nil? && title_alignment.nil?) title_params << "&chts=" + (color, size, alignment = (title_color || '454545'), title_size, (title_alignment.to_s[0,1] || 'c')).compact.join(',') end title_params end def set_size "chs=#{size}" end def set_data data = send("#{@encoding}_encoding") "chd=#{data}" end def set_colors @bg_type = fill_type(bg_type) || 's' if bg_color @chart_type = fill_type(chart_type) || 's' if chart_color "chf=" + {'bg' => fill_for(bg_type, bg_color, bg_angle), 'c' => fill_for(chart_type, chart_color, chart_angle)}.map{|k,v| "#{k},#{v}" unless v.nil?}.compact.join('|') end # set bar, line colors def set_bar_colors @bar_colors = bar_colors.join(',') if bar_colors.is_a?(Array) "chco=#{bar_colors}" end def set_country_codes @country_codes = country_codes.join() if country_codes.is_a?(Array) "chld=#{country_codes}" end # set bar spacing # chbh= # <bar width in pixels>, # <optional space between bars in a group>, # <optional space between groups> def set_bar_width_and_spacing width_and_spacing_values = case bar_width_and_spacing when String bar_width_and_spacing when Array bar_width_and_spacing.join(',') when Hash width = bar_width_and_spacing[:width] || 23 spacing = bar_width_and_spacing[:spacing] || 4 group_spacing = bar_width_and_spacing[:group_spacing] || 8 [width,spacing,group_spacing].join(',') else bar_width_and_spacing.to_s end "chbh=#{width_and_spacing_values}" end def set_range_markers markers = case range_markers when Hash set_range_marker(range_markers) when Array range_markers.collect{|marker| set_range_marker(marker)}.join('|') end "chm=#{markers}" end def set_range_marker(options) orientation = ['vertical', 'Vertical', 'V', 'v', 'R'].include?(options[:orientation]) ? 'R' : 'r' "#{orientation},#{options[:color]},0,#{options[:start_position]},#{options[:stop_position]}#{',1' if options[:overlaid?]}" end def fill_for(type=nil, color='', angle=nil) unless type.nil? case type when 'lg' angle ||= 0 color = "#{color},0,ffffff,1" if color.split(',').size == 1 "#{type},#{angle},#{color}" when 'ls' angle ||= 90 color = "#{color},0.2,ffffff,0.2" if color.split(',').size == 1 "#{type},#{angle},#{color}" else "#{type},#{color}" end end end # A chart can have one or many legends. # Gchart.line(:legend => 'label') # or # Gchart.line(:legend => ['first label', 'last label']) def set_legend if type.to_s =~ /meter/ @labels = legend return set_labels end if legend.is_a?(Array) "chdl=#{@legend.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chdl=#{legend}" end end def set_legend_position case @legend_position.to_s when /(bottom|b)$/ "chdlp=b" when /(bottom_vertical|bv)$/ "chdlp=bv" when /(top|t)$/ "chdlp=t" when /(top_vertical|tv)$/ "chdlp=tv" when /(right|r)$/ "chdlp=r" when /(left|l)$/ "chdlp=l" end end def set_line_thickness "chls=#{thickness}" end def set_line_markers "chm=#{new_markers}" end def set_grid_lines "chg=#{grid_lines}" end def set_labels if labels.is_a?(Array) "chl=#{@labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chl=#{@labels}" end end def set_axis_with_labels @axis_with_labels = axis_with_labels.join(',') if @axis_with_labels.is_a?(Array) "chxt=#{axis_with_labels}" end def set_axis_labels if axis_labels.is_a?(Array) if RUBY_VERSION.to_f < 1.9 labels_arr = axis_labels.enum_with_index.map{|labels,index| [index,labels]} else labels_arr = axis_labels.map.with_index.map{|labels,index| [index,labels]} end elsif axis_labels.is_a?(Hash) labels_arr = axis_labels.to_a end labels_arr.map! do |index,labels| if labels.is_a?(Array) "#{index}:|#{labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "#{index}:|#{labels}" end end "chxl=#{labels_arr.join('|')}" end # http://code.google.com/apis/chart/labels.html#axis_range # Specify a range for axis labels def set_axis_range # a passed axis_range should look like: # [[10,100]] or [[10,100,4]] or [[10,100], [20,300]] # in the second example, 4 is the interval set = @calculated_axis_range ? datasets : axis_range || datasets return unless set && set.respond_to?(:each) && set.find {|o| o}.respond_to?(:each) 'chxr=' + set.enum_for(:each_with_index).map do |axis_range, index| next nil if axis_range.nil? # ignore this axis min, max, step = axis_range if axis_range.size > 3 || step && max && step > max # this is a full series max = axis_range.compact.max step = nil end [index, (min_value || min || 0), (max_value || max), step].compact.join(',') end.compact.join("|") end def set_geographical_area "chtm=#{geographical_area}" end def set_type 'cht=' + case type.to_s when 'line' then "lc" when 'line_xy' then "lxy" when 'pie_3d' then "p3" when 'pie' then "p" when 'venn' then "v" when 'scatter' then "s" when 'sparkline' then "ls" when 'meter' then "gom" when 'map' then "t" when 'radar' "r" + (curved? ? 's' : '') when 'bar' "b" + (horizontal? ? "h" : "v") + (grouped? ? "g" : "s") end end def fill_type(type) case type when 'solid' then 's' when 'gradient' then 'lg' when 'stripes' then 'ls' end end def number_visible n = 0 dataset.each do |mds| return n.to_s if mds[:invisible] == true if mds[:data].first.is_a?(Array) n += mds[:data].length else n += 1 end end "" end # Turns input into an array of axis hashes, dependent on the chart type def convert_dataset(ds) if dimensions == 2 # valid inputs include: # an array of >=2 arrays, or an array of >=2 hashes ds = ds.map do |d| d.is_a?(Hash) ? d : {:data => d} end elsif dimensions == 1 # valid inputs include: # a hash, an array of data, an array of >=1 array, or an array of >=1 hash if ds.is_a?(Hash) ds = [ds] elsif not ds.first.is_a?(Hash) ds = [{:data => ds}] end end ds end # just an alias def axis_set dataset end def convert_to_simple_value(number) if number.nil? "_" else value = self.class.simple_chars[number.to_i] value.nil? ? "_" : value end end def convert_to_extended_value(number) if number.nil? '__' else value = self.class.ext_pairs[number.to_i] value.nil? ? "__" : value end end def encode_scaled_dataset(chars, nil_char) dsets = [] dataset.each do |ds| if max_value != false range = ds[:max_value] - ds[:min_value] range = 1 if range == 0 end unless ds[:data].first.is_a?(Array) ldatasets = [ds[:data]] else ldatasets = ds[:data] end ldatasets.each do |l| dsets << l.map do |number| if number.nil? nil_char else unless range.nil? || range.zero? number = chars.size * (number - ds[:min_value]) / range.to_f number = [number, chars.size - 1].min end chars[number.to_i] end end.join end end dsets.join(',') end # http://code.google.com/apis/chart/#simple # Simple encoding has a resolution of 62 different values. # Allowing five pixels per data point, this is sufficient for line and bar charts up # to about 300 pixels. Simple encoding is suitable for all other types of chart regardless of size. def simple_encoding "s" + number_visible + ":" + encode_scaled_dataset(self.class.simple_chars, '_') end # http://code.google.com/apis/chart/#text # Text encoding with data scaling lets you specify arbitrary positive or # negative floating point numbers, in combination with a scaling parameter # that lets you specify a custom range for your chart. This chart is useful # when you don't want to worry about limiting your data to a specific range, # or do the calculations to scale your data down or up to fit nicely inside # a chart. # # Valid values range from (+/-)9.999e(+/-)100, and only four non-zero digits are supported (that is, 123400, 1234, 12.34, and 0.1234 are valid, but 12345, 123.45 and 123400.5 are not). # # This encoding is not available for maps. # def text_encoding chds = dataset.map{|ds| "#{ds[:min_value]},#{ds[:max_value]}" }.join(",") "t" + number_visible + ":" + datasets.map{ |ds| ds.map{|e|e||'_'}.join(',') }.join('|') + "&chds=" + chds end # http://code.google.com/apis/chart/#extended # Extended encoding has a resolution of 4,096 different values # and is best used for large charts where a large data range is required. def extended_encoding "e" + number_visible + ":" + encode_scaled_dataset(self.class.ext_pairs, '__') end def url_builder(options="") self.class.url(use_ssl) + query_builder(options) end def query_builder(options="") query_params = instance_variables.sort.map do |var| case var.to_s + when '@data' set_data unless data == [] # Set the graph size when '@width' set_size unless width.nil? || height.nil? when '@type' set_type when '@title' set_title unless title.nil? when '@legend' set_legend unless legend.nil? when '@labels' set_labels unless labels.nil? when '@legend_position' set_legend_position unless legend_position.nil? when '@thickness' set_line_thickness when '@new_markers' set_line_markers when '@bg_color' set_colors when '@chart_color' set_colors if bg_color.nil? when '@bar_colors' set_bar_colors when '@bar_width_and_spacing' set_bar_width_and_spacing when '@axis_with_labels' set_axis_with_labels when '@axis_labels' set_axis_labels when '@range_markers' set_range_markers when '@grid_lines' set_grid_lines when '@geographical_area' set_geographical_area when '@country_codes' set_country_codes when '@custom' custom end end.compact query_params << set_axis_range # Use ampersand as default delimiter unless options == :html delimiter = '&' # Escape ampersand for html image tags else delimiter = '&amp;' end jstize(query_params.join(delimiter)) end end diff --git a/spec/gchart_spec.rb b/spec/gchart_spec.rb index 3885f73..18b8a23 100644 --- a/spec/gchart_spec.rb +++ b/spec/gchart_spec.rb @@ -1,678 +1,684 @@ require File.dirname(__FILE__) + '/spec_helper.rb' require File.dirname(__FILE__) + '/../lib/gchart' Chart::Theme.add_theme_file("#{File.dirname(__FILE__)}/fixtures/test_theme.yml") # Time to add your specs! # http://rspec.rubyforge.org/ describe "The Gchart class" do it "should show supported_types on error" do Gchart.supported_types.should match(/line/) end it "should return supported types" do Gchart.types.include?('line').should be_true end + + it "should support theme option" do + chart = Gchart.new(:type => 'line',:theme => :test) + chart.send('url').should include('chco=6886B4,FDD84E') + end end describe "generating a default Gchart" do before(:each) do @chart = Gchart.line end it "should include the Google URL" do @chart.include?("http://chart.apis.google.com/chart?").should be_true end it "should have a default size" do @chart.should include('chs=300x200') end it "should be able to have a custom size" do Gchart.line(:size => '400x600').include?('chs=400x600').should be_true Gchart.line(:width => 400, :height => 600).include?('chs=400x600').should be_true end it "should have query parameters in predictable order" do Gchart.line(:axis_with_labels => 'x,y,r', :size => '400x600').should match(/chxt=.+cht=.+chs=/) end it "should have a type" do @chart.include?('cht=lc').should be_true end it 'should use theme defaults if theme is set' do Gchart.line(:theme=>:test).should include('chco=6886B4,FDD84E') if RUBY_VERSION.to_f < 1.9 Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=c,s,FFFFFF|bg,s,FFFFFF')) else Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=bg,s,FFFFFF|c,s,FFFFFF')) end end it "should use the simple encoding by default with auto max value" do # 9 is the max value in simple encoding, 26 being our max value the 2nd encoded value should be 9 Gchart.line(:data => [0, 26]).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => 26, :axis_with_labels => 'y').should include('chxr=0,0,26') end it "should support simple encoding with and without max_value" do Gchart.line(:data => [0, 26], :max_value => 26).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => false).should include('chd=s:Aa') end it "should support the extended encoding and encode properly" do Gchart.line(:data => [0, 10], :encoding => 'extended', :max_value => false).include?('chd=e:AA').should be_true Gchart.line(:encoding => 'extended', :max_value => false, :data => [[0,25,26,51,52,61,62,63], [64,89,90,115,4084]] ).include?('chd=e:AAAZAaAzA0A9A-A.,BABZBaBz.0').should be_true end it "should auto set the max value for extended encoding" do Gchart.line(:data => [0, 25], :encoding => 'extended', :max_value => false).should include('chd=e:AAAZ') # Extended encoding max value is '..' Gchart.line(:data => [0, 25], :encoding => 'extended').include?('chd=e:AA..').should be_true end it "should be able to have data with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,4,45,78') end it "should be able to have missing data points with text encoding" do Gchart.line(:data => [10, 5.2, nil, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,_,45,78') end it "should handle max and min values with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=0,78') end it "should automatically handle negative values with proper max/min limits when using text encoding" do Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=-10,78') end it "should handle negative values with manual max/min limits when using text encoding" do Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text', :min_value => -20, :max_value => 100).include?('chds=-20,100').should be_true end it "should set the proper axis values when using text encoding and negative values" do Gchart.bar( :data => [[-10], [100]], :encoding => 'text', :horizontal => true, :min_value => -20, :max_value => 100, :axis_with_labels => 'x', :bar_colors => ['FD9A3B', '4BC7DC']).should include("chxr=0,-20,100") end it "should be able to have multiple set of data with text encoding" do Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text').include?(Gchart.jstize('chd=t:10,5.2,4,45,78|20,40,70,15,99')).should be_true end it "should be able to receive a custom param" do Gchart.line(:custom => 'ceci_est_une_pipe').include?('ceci_est_une_pipe').should be_true end it "should be able to set label axis" do Gchart.line(:axis_with_labels => 'x,y,r').include?('chxt=x,y,r').should be_true Gchart.line(:axis_with_labels => ['x','y','r']).include?('chxt=x,y,r').should be_true end it "should be able to have axis labels" do Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true end def labeled_line(options = {}) Gchart.line({:data => @data, :axis_with_labels => 'x,y'}.merge(options)) end it "should display ranges properly" do @data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] labeled_line(:axis_labels => [((1..24).to_a << 1)]). should include('chxr=0,85,672') end def labeled_bar(options = {}) Gchart.bar({:data => @data, :axis_with_labels => 'x,y', :axis_labels => [(1..12).to_a], :encoding => "text" }.merge(options)) end it "should force the y range properly" do @data = [1,1,1,1,1,1,1,1,6,2,1,1] labeled_bar( :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,0|1,0,16') labeled_bar( :max_value => 16, :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,16|1,0,16') # nil means ignore axis labeled_bar( :axis_range => [nil,[0,16]] ).should include('chxr=1,0,16') # empty array means take defaults labeled_bar( :max_value => 16, :axis_range => [[],[0,16]] ).should include('chxr=0,0,16|1,0,16') labeled_bar( :axis_range => [[],[0,16]] ).should include('chxr=0,0|1,0,16') Gchart.line( :data => [0,20, 40, 60, 140, 230, 60], :axis_with_labels => 'y').should include("chxr=0,0,230") end it "should take in consideration the max value when creating a range" do data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] url = Gchart.line(:data => data, :axis_with_labels => 'x,y', :axis_labels => [((1..24).to_a << 1)], :max_value => 700) url.should include('chxr=0,85,700') end it 'should generate different labels and legend' do Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three)).should(include('chdl=1|2|3') && include('chl=one|two|three')) end end describe "generating different type of charts" do it "should be able to generate a line chart" do Gchart.line.should be_an_instance_of(String) Gchart.line.include?('cht=lc').should be_true end it "should be able to generate a sparkline chart" do Gchart.sparkline.should be_an_instance_of(String) Gchart.sparkline.include?('cht=ls').should be_true end it "should be able to generate a line xy chart" do Gchart.line_xy.should be_an_instance_of(String) Gchart.line_xy.include?('cht=lxy').should be_true end it "should be able to generate a scatter chart" do Gchart.scatter.should be_an_instance_of(String) Gchart.scatter.include?('cht=s').should be_true end it "should be able to generate a bar chart" do Gchart.bar.should be_an_instance_of(String) Gchart.bar.include?('cht=bvs').should be_true end it "should be able to generate a Venn diagram" do Gchart.venn.should be_an_instance_of(String) Gchart.venn.include?('cht=v').should be_true end it "should be able to generate a Pie Chart" do Gchart.pie.should be_an_instance_of(String) Gchart.pie.include?('cht=p').should be_true end it "should be able to generate a Google-O-Meter" do Gchart.meter.should be_an_instance_of(String) Gchart.meter.include?('cht=gom').should be_true end it "should be able to generate a map chart" do Gchart.map.should be_an_instance_of(String) Gchart.map.include?('cht=t').should be_true end it "should not support other types" do msg = "sexy is not a supported chart format. Please use one of the following: #{Gchart.supported_types}." lambda{Gchart.sexy}.should raise_error(NoMethodError) end end describe "range markers" do it "should be able to generate given a hash of range-marker options" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}).include?('chm=r,ff0000,0,0.59,0.61').should be_true end it "should be able to generate given an array of range-marker hash options" do Gchart.line(:range_markers => [ {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}, {:start_position => 0, :stop_position => 0.6, :color => '666666'}, {:color => 'cccccc', :start_position => 0.6, :stop_position => 1} ]).include?(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1')).should be_true end it "should allow a :overlaid? to be set" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true}).include?('chm=r,ffffff,0,0.59,0.61,1').should be_true Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false}).include?('chm=r,ffffff,0,0.59,0.61').should be_true end describe "when setting the orientation option" do before(:each) do @options = {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'} end it "to vertical (R) if given a valid option" do Gchart.line(:range_markers => @options.merge(:orientation => 'v')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'V')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'R')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'vertical')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical')).include?('chm=R').should be_true end it "to horizontal (r) if given a valid option (actually anything other than the vertical options)" do Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal')).include?('chm=r').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'h')).include?('chm=r').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'etc')).include?('chm=r').should be_true end it "if left blank defaults to horizontal (r)" do Gchart.line(:range_markers => @options).include?('chm=r').should be_true end end end describe "a bar graph" do it "should have a default vertical orientation" do Gchart.bar.include?('cht=bvs').should be_true end it "should be able to have a different orientation" do Gchart.bar(:orientation => 'vertical').include?('cht=bvs').should be_true Gchart.bar(:orientation => 'v').include?('cht=bvs').should be_true Gchart.bar(:orientation => 'h').include?('cht=bhs').should be_true Gchart.bar(:orientation => 'horizontal').include?('cht=bhs').should be_true Gchart.bar(:horizontal => false).include?('cht=bvs').should be_true end it "should be set to be stacked by default" do Gchart.bar.include?('cht=bvs').should be_true end it "should be able to stacked or grouped" do Gchart.bar(:stacked => true).include?('cht=bvs').should be_true Gchart.bar(:stacked => false).include?('cht=bvg').should be_true Gchart.bar(:grouped => true).include?('cht=bvg').should be_true Gchart.bar(:grouped => false).include?('cht=bvs').should be_true end it "should be able to have different bar colors" do Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=').should be_true Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=efefef,00ffff').should be_true # alias Gchart.bar(:bar_color => 'efefef').include?('chco=efefef').should be_true end it "should be able to have different bar colors when using an array of colors" do Gchart.bar(:bar_colors => ['efefef','00ffff']).include?('chco=efefef,00ffff').should be_true end it 'should be able to accept a string of width and spacing options' do Gchart.bar(:bar_width_and_spacing => '25,6').include?('chbh=25,6').should be_true end it 'should be able to accept a single fixnum width and spacing option to set the bar width' do Gchart.bar(:bar_width_and_spacing => 25).include?('chbh=25').should be_true end it 'should be able to accept an array of width and spacing options' do Gchart.bar(:bar_width_and_spacing => [25,6,12]).include?('chbh=25,6,12').should be_true Gchart.bar(:bar_width_and_spacing => [25,6]).include?('chbh=25,6').should be_true Gchart.bar(:bar_width_and_spacing => [25]).include?('chbh=25').should be_true end describe "with a hash of width and spacing options" do before(:each) do @default_width = 23 @default_spacing = 4 @default_group_spacing = 8 end it 'should be able to have a custom bar width' do Gchart.bar(:bar_width_and_spacing => {:width => 19}).include?("chbh=19,#{@default_spacing},#{@default_group_spacing}").should be_true end it 'should be able to have custom spacing' do Gchart.bar(:bar_width_and_spacing => {:spacing => 19}).include?("chbh=#{@default_width},19,#{@default_group_spacing}").should be_true end it 'should be able to have custom group spacing' do Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19}).include?("chbh=#{@default_width},#{@default_spacing},19").should be_true end end end describe "a line chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @chart = Gchart.line(:title => @title, :legend => @legend) end it 'should be able have a chart title' do @chart.include?("chtt=Chart+Title").should be_true end it "should be able to a custom color, size and alignment for title" do Gchart.line(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true Gchart.line(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true Gchart.line(:title => @title, :title_size => '20', :title_alignment => :left).include?('chts=454545,20,l').should be_true end it "should be able to have multiple legends" do @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true end it "should escape text values in url" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend) chart.include?(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")).should be_true end it "should be able to have one legend" do chart = Gchart.line(:legend => 'legend label') chart.include?("chdl=legend+label").should be_true end it "should be able to set the position of the legend" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend, :legend_position => :bottom_vertical) chart.include?("chdlp=bv").should be_true chart = Gchart.line(:title => title, :legend => legend, :legend_position => 'r') chart.include?("chdlp=r").should be_true end it "should be able to set the background fill" do Gchart.line(:bg => 'efefef').should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=bg,lg,90,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'}).should include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do Gchart.line(:graph_bg => 'efefef').should include("chf=c,s,efefef") Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true end it "should be able to set both a graph and a background fill" do Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true if RUBY_VERSION.to_f < 1.9 Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true else Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true end end it "should be able to have different line colors" do Gchart.line(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true Gchart.line(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true end it "should be able to render a graph where all the data values are 0" do Gchart.line(:data => [0, 0, 0]).should include("chd=s:AAA") end end describe "a sparkline chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [27,25,25,25,25,27,100,31,25,36,25,25,39,25,31,25,25,25,26,26,25,25,28,25,25,100,28,27,31,25,27,27,29,25,27,26,26,25,26,26,35,33,34,25,26,25,36,25,26,37,33,33,37,37,39,25,25,25,25] @chart = Gchart.sparkline(:title => @title, :data => @data, :legend => @legend) end it "should create a sparkline" do @chart.include?('cht=ls').should be_true end it 'should be able have a chart title' do @chart.include?("chtt=Chart+Title").should be_true end it "should be able to a custom color and size title" do Gchart.sparkline(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true Gchart.sparkline(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true end it "should be able to have multiple legends" do @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true end it "should be able to have one legend" do chart = Gchart.sparkline(:legend => 'legend label') chart.include?("chdl=legend+label").should be_true end it "should be able to set the background fill" do Gchart.sparkline(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=bg,lg,90,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'}).include?("chf=bg,ls,90,efefef,0.2,ffffff,0.2").should be_true end it "should be able to set a graph fill" do Gchart.sparkline(:graph_bg => 'efefef').include?("chf=c,s,efefef").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true end it "should be able to set both a graph and a background fill" do Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true if RUBY_VERSION.to_f < 1.9 Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true else Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true end end it "should be able to have different line colors" do Gchart.sparkline(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true Gchart.sparkline(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true end end describe "a 3d pie chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [12,8,40,15,5] @chart = Gchart.pie(:title => @title, :legend => @legend, :data => @data) end it "should create a pie" do @chart.include?('cht=p').should be_true end it "should be able to be in 3d" do Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data).include?('cht=p3').should be_true end end describe "a google-o-meter" do before(:each) do @data = [70] @legend = ['arrow points here'] @jstized_legend = Gchart.jstize(@legend.join('|')) @chart = Gchart.meter(:data => @data) end it "should create a meter" do @chart.include?('cht=gom').should be_true end it "should be able to set a solid background fill" do Gchart.meter(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true end it "should be able to set labels by using the legend or labesl accessor" do Gchart.meter(:title => @title, :labels => @legend, :data => @data).should include("chl=#{@jstized_legend}") Gchart.meter(:title => @title, :labels => @legend, :data => @data).should == Gchart.meter(:title => @title, :legend => @legend, :data => @data) end end describe "a map chart" do before(:each) do @data = [0,100,50,32] @geographical_area = 'usa' @map_colors = ['FFFFFF', 'FF0000', 'FFFF00', '00FF00'] @country_codes = ['MT', 'WY', "ID", 'SD'] @chart = Gchart.map(:data => @data, :encoding => 'text', :size => '400x300', :geographical_area => @geographical_area, :map_colors => @map_colors, :country_codes => @country_codes) end it "should create a map" do @chart.include?('cht=t').should be_true end it "should set the geographical area" do @chart.include?('chtm=usa').should be_true end it "should set the map colors" do @chart.include?('chco=FFFFFF,FF0000,FFFF00,00FF00').should be_true end it "should set the country/state codes" do @chart.include?('chld=MTWYIDSD').should be_true end it "should set the chart data" do @chart.include?('chd=t:0,100,50,32').should be_true end end describe 'exporting a chart' do it "should be available in the url format by default" do Gchart.line(:data => [0, 26], :format => 'url').should == Gchart.line(:data => [0, 26]) end it "should be available as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using img_tag alias" do Gchart.line(:data => [0, 26], :format => 'img_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom dimensions" do Gchart.line(:data => [0, 26], :format => 'image_tag', :size => '400x400').should match(/<img src=(.*) width="400" height="400" alt="Google Chart" \/>/) end it "should be available as an image tag using custom alt text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :alt => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Sexy chart" \/>/) end it "should be available as an image tag using custom title text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :title => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" title="Sexy chart" \/>/) end it "should be available as an image tag using custom css id selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :id => 'chart').should match(/<img id="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom css class selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should match(/<img class="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should use ampersands to separate key/value pairs in URLs by default" do Gchart.line(:data => [0, 26]).should satisfy {|chart| chart.include? "&" } Gchart.line(:data => [0, 26]).should_not satisfy {|chart| chart.include? "&amp;" } end it "should escape ampersands in URLs when used as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should satisfy {|chart| chart.include? "&amp;" } end it "should be available as a file" do File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file') File.exist?('chart.png').should be_true File.delete('chart.png') if File.exist?('chart.png') end it "should be available as a file using a custom file name" do File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') Gchart.line(:data => [0, 26], :format => 'file', :filename => 'custom_file_name.png') File.exist?('custom_file_name.png').should be_true File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') end it "should work even with multiple attrs" do File.delete('foo.png') if File.exist?('foo.png') Gchart.line(:size => '400x200', :data => [1,2,3,4,5], # :axis_labels => [[1,2,3,4, 5], %w[foo bar]], :axis_with_labels => 'x,r', :format => "file", :filename => "foo.png" ) File.exist?('foo.png').should be_true File.delete('foo.png') if File.exist?('foo.png') end end describe 'SSL support' do it 'should change url if is presented' do Gchart.line(:use_ssl => true).should include('https://chart.googleapis.com/chart?') end it "should be available as a file" do File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file', :use_ssl => true) File.exist?('chart.png').should be_true File.delete('chart.png') if File.exist?('chart.png') end end +
mattetti/googlecharts
2952122ccd80a879a76c9e3b95f72c8b00d95d83
add gitignore
diff --git a/.gitignore b/.gitignore index b7a1d91..76eb170 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,8 @@ .DS_Store log/* .manifest -pkg \ No newline at end of file +pkg +.rspec +.rvmrc +Gemfile +Gemfile.lock \ No newline at end of file
mattetti/googlecharts
5c6ea46152bdf8f969e168b3ed7185787bfac09d
Version bump to 1.6.8
diff --git a/History.txt b/History.txt index 60c7c29..d1da183 100644 --- a/History.txt +++ b/History.txt @@ -1,58 +1,61 @@ +== 1.6.8 +* added title alignment support + == 1.6.7 * changed url for ssl connection == 1.6.6 * added ssl support * refactored code * аdded ability to set the legend position * fixed legend position value * separated labels and legends for pies == 1.3.6 * support nil values. The Google Charts API specifies that a single underscore (_) can be used to omit a value from a line chart with 'simple' data encoding, and a double underscore (__) can do the same for a chart with 'extended' data encoding. (Matt Moyer) * allow a label to appear on a google-o-meter via the :legend option. (hallettj) == 1.3.5 * added code to properly escape image tag URLs (mokolabs) * added themes support + 4 default themes (keynote, thirty7signals, pastel, greyscale) chart.line(:theme=>:keynote) (jakehow) == 1.3.4 * updated documentation and cleaned it up (mokolabs) * added support for custom class, id and alt tags when using the image_tag format (i.e Gchart.line(:data => [0, 26], :format => 'image_tag')) (mokolabs) == 1.3.2 - 1.3.3 * changes required by github == 1.3.1 * added width and spacing options == 1.3.0 * added support for google-o-meter * fixed a bug when the max value of a data set was 0 == 1.2.0 * added support for sparklines == 1.1.0 * fixed another bug fix related to the uri escaping required to download the file properly. == 1.0.0 * fixed the (URI::InvalidURIError) issue == 0.2.0 * added export options (file and image tag) * added support for all arguments to be passed as a string or an array == 0.1.0 2007-12-11 * fixed the axis labels == 0.0.3 2007-12-11 * added :chart_background alias and fixed a bug related to the background colors. == 0.0.2 2007-12-11 * added support for more features and aliases == 0.0.1 2007-12-08 * 1 major enhancement: * Initial release diff --git a/lib/gchart/version.rb b/lib/gchart/version.rb index da83559..a71d158 100644 --- a/lib/gchart/version.rb +++ b/lib/gchart/version.rb @@ -1,3 +1,3 @@ module GchartInfo #:nodoc: - VERSION = "1.6.7" + VERSION = "1.6.8" end
mattetti/googlecharts
ae6984ed236983fad71124a9527da9d7b7799d41
spec for title alignment
diff --git a/spec/gchart_spec.rb b/spec/gchart_spec.rb index d549c50..3885f73 100644 --- a/spec/gchart_spec.rb +++ b/spec/gchart_spec.rb @@ -1,677 +1,678 @@ require File.dirname(__FILE__) + '/spec_helper.rb' require File.dirname(__FILE__) + '/../lib/gchart' Chart::Theme.add_theme_file("#{File.dirname(__FILE__)}/fixtures/test_theme.yml") # Time to add your specs! # http://rspec.rubyforge.org/ describe "The Gchart class" do it "should show supported_types on error" do Gchart.supported_types.should match(/line/) end it "should return supported types" do Gchart.types.include?('line').should be_true end end describe "generating a default Gchart" do before(:each) do @chart = Gchart.line end it "should include the Google URL" do @chart.include?("http://chart.apis.google.com/chart?").should be_true end it "should have a default size" do @chart.should include('chs=300x200') end it "should be able to have a custom size" do Gchart.line(:size => '400x600').include?('chs=400x600').should be_true Gchart.line(:width => 400, :height => 600).include?('chs=400x600').should be_true end it "should have query parameters in predictable order" do Gchart.line(:axis_with_labels => 'x,y,r', :size => '400x600').should match(/chxt=.+cht=.+chs=/) end it "should have a type" do @chart.include?('cht=lc').should be_true end it 'should use theme defaults if theme is set' do Gchart.line(:theme=>:test).should include('chco=6886B4,FDD84E') if RUBY_VERSION.to_f < 1.9 Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=c,s,FFFFFF|bg,s,FFFFFF')) else Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=bg,s,FFFFFF|c,s,FFFFFF')) end end it "should use the simple encoding by default with auto max value" do # 9 is the max value in simple encoding, 26 being our max value the 2nd encoded value should be 9 Gchart.line(:data => [0, 26]).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => 26, :axis_with_labels => 'y').should include('chxr=0,0,26') end it "should support simple encoding with and without max_value" do Gchart.line(:data => [0, 26], :max_value => 26).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => false).should include('chd=s:Aa') end it "should support the extended encoding and encode properly" do Gchart.line(:data => [0, 10], :encoding => 'extended', :max_value => false).include?('chd=e:AA').should be_true Gchart.line(:encoding => 'extended', :max_value => false, :data => [[0,25,26,51,52,61,62,63], [64,89,90,115,4084]] ).include?('chd=e:AAAZAaAzA0A9A-A.,BABZBaBz.0').should be_true end it "should auto set the max value for extended encoding" do Gchart.line(:data => [0, 25], :encoding => 'extended', :max_value => false).should include('chd=e:AAAZ') # Extended encoding max value is '..' Gchart.line(:data => [0, 25], :encoding => 'extended').include?('chd=e:AA..').should be_true end it "should be able to have data with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,4,45,78') end it "should be able to have missing data points with text encoding" do Gchart.line(:data => [10, 5.2, nil, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,_,45,78') end it "should handle max and min values with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=0,78') end it "should automatically handle negative values with proper max/min limits when using text encoding" do Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=-10,78') end it "should handle negative values with manual max/min limits when using text encoding" do Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text', :min_value => -20, :max_value => 100).include?('chds=-20,100').should be_true end it "should set the proper axis values when using text encoding and negative values" do Gchart.bar( :data => [[-10], [100]], :encoding => 'text', :horizontal => true, :min_value => -20, :max_value => 100, :axis_with_labels => 'x', :bar_colors => ['FD9A3B', '4BC7DC']).should include("chxr=0,-20,100") end it "should be able to have multiple set of data with text encoding" do Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text').include?(Gchart.jstize('chd=t:10,5.2,4,45,78|20,40,70,15,99')).should be_true end it "should be able to receive a custom param" do Gchart.line(:custom => 'ceci_est_une_pipe').include?('ceci_est_une_pipe').should be_true end it "should be able to set label axis" do Gchart.line(:axis_with_labels => 'x,y,r').include?('chxt=x,y,r').should be_true Gchart.line(:axis_with_labels => ['x','y','r']).include?('chxt=x,y,r').should be_true end it "should be able to have axis labels" do Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true end def labeled_line(options = {}) Gchart.line({:data => @data, :axis_with_labels => 'x,y'}.merge(options)) end it "should display ranges properly" do @data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] labeled_line(:axis_labels => [((1..24).to_a << 1)]). should include('chxr=0,85,672') end def labeled_bar(options = {}) Gchart.bar({:data => @data, :axis_with_labels => 'x,y', :axis_labels => [(1..12).to_a], :encoding => "text" }.merge(options)) end it "should force the y range properly" do @data = [1,1,1,1,1,1,1,1,6,2,1,1] labeled_bar( :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,0|1,0,16') labeled_bar( :max_value => 16, :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,16|1,0,16') # nil means ignore axis labeled_bar( :axis_range => [nil,[0,16]] ).should include('chxr=1,0,16') # empty array means take defaults labeled_bar( :max_value => 16, :axis_range => [[],[0,16]] ).should include('chxr=0,0,16|1,0,16') labeled_bar( :axis_range => [[],[0,16]] ).should include('chxr=0,0|1,0,16') Gchart.line( :data => [0,20, 40, 60, 140, 230, 60], :axis_with_labels => 'y').should include("chxr=0,0,230") end it "should take in consideration the max value when creating a range" do data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] url = Gchart.line(:data => data, :axis_with_labels => 'x,y', :axis_labels => [((1..24).to_a << 1)], :max_value => 700) url.should include('chxr=0,85,700') end it 'should generate different labels and legend' do Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three)).should(include('chdl=1|2|3') && include('chl=one|two|three')) end end describe "generating different type of charts" do it "should be able to generate a line chart" do Gchart.line.should be_an_instance_of(String) Gchart.line.include?('cht=lc').should be_true end it "should be able to generate a sparkline chart" do Gchart.sparkline.should be_an_instance_of(String) Gchart.sparkline.include?('cht=ls').should be_true end it "should be able to generate a line xy chart" do Gchart.line_xy.should be_an_instance_of(String) Gchart.line_xy.include?('cht=lxy').should be_true end it "should be able to generate a scatter chart" do Gchart.scatter.should be_an_instance_of(String) Gchart.scatter.include?('cht=s').should be_true end it "should be able to generate a bar chart" do Gchart.bar.should be_an_instance_of(String) Gchart.bar.include?('cht=bvs').should be_true end it "should be able to generate a Venn diagram" do Gchart.venn.should be_an_instance_of(String) Gchart.venn.include?('cht=v').should be_true end it "should be able to generate a Pie Chart" do Gchart.pie.should be_an_instance_of(String) Gchart.pie.include?('cht=p').should be_true end it "should be able to generate a Google-O-Meter" do Gchart.meter.should be_an_instance_of(String) Gchart.meter.include?('cht=gom').should be_true end it "should be able to generate a map chart" do Gchart.map.should be_an_instance_of(String) Gchart.map.include?('cht=t').should be_true end it "should not support other types" do msg = "sexy is not a supported chart format. Please use one of the following: #{Gchart.supported_types}." lambda{Gchart.sexy}.should raise_error(NoMethodError) end end describe "range markers" do it "should be able to generate given a hash of range-marker options" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}).include?('chm=r,ff0000,0,0.59,0.61').should be_true end it "should be able to generate given an array of range-marker hash options" do Gchart.line(:range_markers => [ {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}, {:start_position => 0, :stop_position => 0.6, :color => '666666'}, {:color => 'cccccc', :start_position => 0.6, :stop_position => 1} ]).include?(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1')).should be_true end it "should allow a :overlaid? to be set" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true}).include?('chm=r,ffffff,0,0.59,0.61,1').should be_true Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false}).include?('chm=r,ffffff,0,0.59,0.61').should be_true end describe "when setting the orientation option" do before(:each) do @options = {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'} end it "to vertical (R) if given a valid option" do Gchart.line(:range_markers => @options.merge(:orientation => 'v')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'V')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'R')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'vertical')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical')).include?('chm=R').should be_true end it "to horizontal (r) if given a valid option (actually anything other than the vertical options)" do Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal')).include?('chm=r').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'h')).include?('chm=r').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'etc')).include?('chm=r').should be_true end it "if left blank defaults to horizontal (r)" do Gchart.line(:range_markers => @options).include?('chm=r').should be_true end end end describe "a bar graph" do it "should have a default vertical orientation" do Gchart.bar.include?('cht=bvs').should be_true end it "should be able to have a different orientation" do Gchart.bar(:orientation => 'vertical').include?('cht=bvs').should be_true Gchart.bar(:orientation => 'v').include?('cht=bvs').should be_true Gchart.bar(:orientation => 'h').include?('cht=bhs').should be_true Gchart.bar(:orientation => 'horizontal').include?('cht=bhs').should be_true Gchart.bar(:horizontal => false).include?('cht=bvs').should be_true end it "should be set to be stacked by default" do Gchart.bar.include?('cht=bvs').should be_true end it "should be able to stacked or grouped" do Gchart.bar(:stacked => true).include?('cht=bvs').should be_true Gchart.bar(:stacked => false).include?('cht=bvg').should be_true Gchart.bar(:grouped => true).include?('cht=bvg').should be_true Gchart.bar(:grouped => false).include?('cht=bvs').should be_true end it "should be able to have different bar colors" do Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=').should be_true Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=efefef,00ffff').should be_true # alias Gchart.bar(:bar_color => 'efefef').include?('chco=efefef').should be_true end it "should be able to have different bar colors when using an array of colors" do Gchart.bar(:bar_colors => ['efefef','00ffff']).include?('chco=efefef,00ffff').should be_true end it 'should be able to accept a string of width and spacing options' do Gchart.bar(:bar_width_and_spacing => '25,6').include?('chbh=25,6').should be_true end it 'should be able to accept a single fixnum width and spacing option to set the bar width' do Gchart.bar(:bar_width_and_spacing => 25).include?('chbh=25').should be_true end it 'should be able to accept an array of width and spacing options' do Gchart.bar(:bar_width_and_spacing => [25,6,12]).include?('chbh=25,6,12').should be_true Gchart.bar(:bar_width_and_spacing => [25,6]).include?('chbh=25,6').should be_true Gchart.bar(:bar_width_and_spacing => [25]).include?('chbh=25').should be_true end describe "with a hash of width and spacing options" do before(:each) do @default_width = 23 @default_spacing = 4 @default_group_spacing = 8 end it 'should be able to have a custom bar width' do Gchart.bar(:bar_width_and_spacing => {:width => 19}).include?("chbh=19,#{@default_spacing},#{@default_group_spacing}").should be_true end it 'should be able to have custom spacing' do Gchart.bar(:bar_width_and_spacing => {:spacing => 19}).include?("chbh=#{@default_width},19,#{@default_group_spacing}").should be_true end it 'should be able to have custom group spacing' do Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19}).include?("chbh=#{@default_width},#{@default_spacing},19").should be_true end end end describe "a line chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @chart = Gchart.line(:title => @title, :legend => @legend) end it 'should be able have a chart title' do @chart.include?("chtt=Chart+Title").should be_true end - it "should be able to a custom color and size title" do + it "should be able to a custom color, size and alignment for title" do Gchart.line(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true Gchart.line(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true + Gchart.line(:title => @title, :title_size => '20', :title_alignment => :left).include?('chts=454545,20,l').should be_true end it "should be able to have multiple legends" do @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true end it "should escape text values in url" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend) chart.include?(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")).should be_true end it "should be able to have one legend" do chart = Gchart.line(:legend => 'legend label') chart.include?("chdl=legend+label").should be_true end it "should be able to set the position of the legend" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend, :legend_position => :bottom_vertical) chart.include?("chdlp=bv").should be_true chart = Gchart.line(:title => title, :legend => legend, :legend_position => 'r') chart.include?("chdlp=r").should be_true end it "should be able to set the background fill" do Gchart.line(:bg => 'efefef').should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=bg,lg,90,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'}).should include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do Gchart.line(:graph_bg => 'efefef').should include("chf=c,s,efefef") Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true end it "should be able to set both a graph and a background fill" do Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true if RUBY_VERSION.to_f < 1.9 Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true else Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true end end it "should be able to have different line colors" do Gchart.line(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true Gchart.line(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true end it "should be able to render a graph where all the data values are 0" do Gchart.line(:data => [0, 0, 0]).should include("chd=s:AAA") end end describe "a sparkline chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [27,25,25,25,25,27,100,31,25,36,25,25,39,25,31,25,25,25,26,26,25,25,28,25,25,100,28,27,31,25,27,27,29,25,27,26,26,25,26,26,35,33,34,25,26,25,36,25,26,37,33,33,37,37,39,25,25,25,25] @chart = Gchart.sparkline(:title => @title, :data => @data, :legend => @legend) end it "should create a sparkline" do @chart.include?('cht=ls').should be_true end it 'should be able have a chart title' do @chart.include?("chtt=Chart+Title").should be_true end it "should be able to a custom color and size title" do Gchart.sparkline(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true Gchart.sparkline(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true end it "should be able to have multiple legends" do @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true end it "should be able to have one legend" do chart = Gchart.sparkline(:legend => 'legend label') chart.include?("chdl=legend+label").should be_true end it "should be able to set the background fill" do Gchart.sparkline(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=bg,lg,90,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'}).include?("chf=bg,ls,90,efefef,0.2,ffffff,0.2").should be_true end it "should be able to set a graph fill" do Gchart.sparkline(:graph_bg => 'efefef').include?("chf=c,s,efefef").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true end it "should be able to set both a graph and a background fill" do Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true if RUBY_VERSION.to_f < 1.9 Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true else Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true end end it "should be able to have different line colors" do Gchart.sparkline(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true Gchart.sparkline(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true end end describe "a 3d pie chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [12,8,40,15,5] @chart = Gchart.pie(:title => @title, :legend => @legend, :data => @data) end it "should create a pie" do @chart.include?('cht=p').should be_true end it "should be able to be in 3d" do Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data).include?('cht=p3').should be_true end end describe "a google-o-meter" do before(:each) do @data = [70] @legend = ['arrow points here'] @jstized_legend = Gchart.jstize(@legend.join('|')) @chart = Gchart.meter(:data => @data) end it "should create a meter" do @chart.include?('cht=gom').should be_true end it "should be able to set a solid background fill" do Gchart.meter(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true end it "should be able to set labels by using the legend or labesl accessor" do Gchart.meter(:title => @title, :labels => @legend, :data => @data).should include("chl=#{@jstized_legend}") Gchart.meter(:title => @title, :labels => @legend, :data => @data).should == Gchart.meter(:title => @title, :legend => @legend, :data => @data) end end describe "a map chart" do before(:each) do @data = [0,100,50,32] @geographical_area = 'usa' @map_colors = ['FFFFFF', 'FF0000', 'FFFF00', '00FF00'] @country_codes = ['MT', 'WY', "ID", 'SD'] @chart = Gchart.map(:data => @data, :encoding => 'text', :size => '400x300', :geographical_area => @geographical_area, :map_colors => @map_colors, :country_codes => @country_codes) end it "should create a map" do @chart.include?('cht=t').should be_true end it "should set the geographical area" do @chart.include?('chtm=usa').should be_true end it "should set the map colors" do @chart.include?('chco=FFFFFF,FF0000,FFFF00,00FF00').should be_true end it "should set the country/state codes" do @chart.include?('chld=MTWYIDSD').should be_true end it "should set the chart data" do @chart.include?('chd=t:0,100,50,32').should be_true end end describe 'exporting a chart' do it "should be available in the url format by default" do Gchart.line(:data => [0, 26], :format => 'url').should == Gchart.line(:data => [0, 26]) end it "should be available as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using img_tag alias" do Gchart.line(:data => [0, 26], :format => 'img_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom dimensions" do Gchart.line(:data => [0, 26], :format => 'image_tag', :size => '400x400').should match(/<img src=(.*) width="400" height="400" alt="Google Chart" \/>/) end it "should be available as an image tag using custom alt text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :alt => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Sexy chart" \/>/) end it "should be available as an image tag using custom title text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :title => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" title="Sexy chart" \/>/) end it "should be available as an image tag using custom css id selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :id => 'chart').should match(/<img id="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom css class selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should match(/<img class="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should use ampersands to separate key/value pairs in URLs by default" do Gchart.line(:data => [0, 26]).should satisfy {|chart| chart.include? "&" } Gchart.line(:data => [0, 26]).should_not satisfy {|chart| chart.include? "&amp;" } end it "should escape ampersands in URLs when used as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should satisfy {|chart| chart.include? "&amp;" } end it "should be available as a file" do File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file') File.exist?('chart.png').should be_true File.delete('chart.png') if File.exist?('chart.png') end it "should be available as a file using a custom file name" do File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') Gchart.line(:data => [0, 26], :format => 'file', :filename => 'custom_file_name.png') File.exist?('custom_file_name.png').should be_true File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') end it "should work even with multiple attrs" do File.delete('foo.png') if File.exist?('foo.png') Gchart.line(:size => '400x200', :data => [1,2,3,4,5], # :axis_labels => [[1,2,3,4, 5], %w[foo bar]], :axis_with_labels => 'x,r', :format => "file", :filename => "foo.png" ) File.exist?('foo.png').should be_true File.delete('foo.png') if File.exist?('foo.png') end end describe 'SSL support' do it 'should change url if is presented' do Gchart.line(:use_ssl => true).should include('https://chart.googleapis.com/chart?') end it "should be available as a file" do File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file', :use_ssl => true) File.exist?('chart.png').should be_true File.delete('chart.png') if File.exist?('chart.png') end end
mattetti/googlecharts
6af92dc28983f1032ae6b8e437f50ea578a6f99c
ability to define title alignment as :center or :left or :right
diff --git a/lib/gchart.rb b/lib/gchart.rb index 5a66439..e4d5a71 100644 --- a/lib/gchart.rb +++ b/lib/gchart.rb @@ -1,715 +1,715 @@ $:.unshift File.dirname(__FILE__) require 'gchart/version' require 'gchart/theme' require "net/http" require "net/https" require "uri" require "cgi" require 'enumerator' class Gchart include GchartInfo def self.url(use_ssl = false) if use_ssl 'https://chart.googleapis.com/chart?' else 'http://chart.apis.google.com/chart?' end end def self.types @types ||= ['line', 'line_xy', 'scatter', 'bar', 'venn', 'pie', 'pie_3d', 'jstize', 'sparkline', 'meter', 'map', 'radar'] end def self.simple_chars @simple_chars ||= ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a end def self.chars @chars ||= simple_chars + ['-', '.'] end def self.ext_pairs @ext_pairs ||= chars.map { |char_1| chars.map { |char_2| char_1 + char_2 } }.flatten end def self.default_filename 'chart.png' end attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :legend, :legend_position, :labels, :data, :encoding, :bar_colors, :title_color, :title_size, :title_alignment, :custom, :axis_with_labels, :axis_labels, :bar_width_and_spacing, :id, :alt, :klass, :range_markers, :geographical_area, :map_colors, :country_codes, :axis_range, :filename, :min, :max, :colors, :usemap attr_accessor :bg_type, :bg_color, :bg_angle, :chart_type, :chart_color, :chart_angle, :axis_range, :thickness, :new_markers, :grid_lines, :use_ssl attr_accessor :min_value, :max_value types.each do |type| instance_eval <<-DYNCLASSMETH def #{type}(options = {}) # Start with theme defaults if a theme is set theme = options[:theme] options = theme ? Chart::Theme.load(theme).to_options.merge(options) : options # # Extract the format and optional filename, then clean the hash format = options[:format] || 'url' options[:filename] ||= default_filename options.delete(:format) #update map_colors to become bar_colors options.update(:bar_colors => options[:map_colors]) if options.has_key?(:map_colors) chart = new(options.merge!({:type => "#{type}"})) chart.send(format) end DYNCLASSMETH end def self.version VERSION::STRING end def self.method_missing(m, options={}) raise NoMethodError, "#{m} is not a supported chart format. Please use one of the following: #{supported_types}." end def initialize(options={}) @type = options[:type] || 'line' @data = [] @width = 300 @height = 200 @curved = false @horizontal = false @grouped = false @use_ssl = false @encoding = 'simple' # @max_value = 'auto' # @min_value defaults to nil meaning zero @filename = options[:filename] # Sets the alt tag when chart is exported as image tag @alt = 'Google Chart' # Sets the CSS id selector when chart is exported as image tag @id = false # Sets the CSS class selector when chart is exported as image tag @klass = options[:class] || false # set the options value if definable options.each do |attribute, value| send("#{attribute}=", value) if self.respond_to?("#{attribute}=") end end def self.supported_types self.types.join(' ') end # Defines the Graph size using the following format: # width X height def size=(size='300x200') @width, @height = size.split("x").map { |dimension| dimension.to_i } end def size "#{width}x#{height}" end def dimensions # TODO: maybe others? [:line_xy, :scatter].include?(type) ? 2 : 1 end # Sets the orientation of a bar graph def orientation=(orientation='h') if orientation == 'h' || orientation == 'horizontal' self.horizontal = true elsif orientation == 'v' || orientation == 'vertical' self.horizontal = false end end # Sets the bar graph presentation (stacked or grouped) def stacked=(option=true) @grouped = option ? false : true end def bg=(options) if options.is_a?(String) @bg_color = options elsif options.is_a?(Hash) @bg_color = options[:color] @bg_type = options[:type] @bg_angle = options[:angle] end end def graph_bg=(options) if options.is_a?(String) @chart_color = options elsif options.is_a?(Hash) @chart_color = options[:color] @chart_type = options[:type] @chart_angle = options[:angle] end end def max_value=(max_v) if max_v =~ /false/ @max_value = false else @max_value = max_v end end def min_value=(min_v) if min_v =~ /false/ @min_value = false else @min_value = min_v end end # returns the full data range as an array # it also sets the data range if not defined def full_data_range(ds) return if max_value == false ds.each_with_index do |mds, mds_index| mds[:min_value] ||= min_value mds[:max_value] ||= max_value if mds_index == 0 && type.to_s == 'bar' # TODO: unless you specify a zero line (using chp or chds), # the min_value of a bar chart is always 0. #mds[:min_value] ||= mds[:data].first.to_a.compact.min mds[:min_value] ||= 0 end if (mds_index == 0 && type.to_s == 'bar' && !grouped && mds[:data].first.is_a?(Array)) totals = [] mds[:data].each do |l| l.each_with_index do |v, index| next if v.nil? totals[index] ||= 0 totals[index] += v end end mds[:max_value] ||= totals.compact.max else all = mds[:data].flatten.compact # default min value should be 0 unless set to auto if mds[:min_value] == 'auto' mds[:min_value] = all.min else min = all.min mds[:min_value] ||= (min && min < 0 ? min : 0) end mds[:max_value] ||= all.max end end unless axis_range @calculated_axis_range = true @axis_range = ds.map{|mds| [mds[:min_value], mds[:max_value]]} if dimensions == 1 && (type.to_s != 'bar' || horizontal) tmp = axis_range.fetch(0, []) @axis_range[0] = axis_range.fetch(1, []) @axis_range[1] = tmp end end # return [min, max] unless (min.nil? || max.nil?) # @max = (max_value.nil? || max_value == 'auto') ? ds.compact.map{|mds| mds.compact.max}.max : max_value # # if min_value.nil? # min_ds_value = ds.compact.map{|mds| mds.compact.min}.min || 0 # @min = (min_ds_value < 0) ? min_ds_value : 0 # else # @min = min_value == 'auto' ? ds.compact.map{|mds| mds.compact.min}.min || 0 : min_value # end # @axis_range = [[min,max]] end def dataset if @dataset @dataset else @dataset = convert_dataset(data || []) full_data_range(@dataset) # unless axis_range @dataset end end # Sets of data to handle multiple sets def datasets datasets = [] dataset.each do |d| if d[:data].first.is_a?(Array) datasets += d[:data] else datasets << d[:data] end end datasets end def self.jstize(string) # See http://github.com/mattetti/googlecharts/issues#issue/27 #URI.escape( string ).gsub("%7C", "|") # See discussion: http://github.com/mattetti/googlecharts/commit/9b5cfb93aa51aae06611057668e631cd515ec4f3#comment_51347 string.gsub(' ', '+').gsub(/\[|\{|\}|\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} #string.gsub(' ', '+').gsub(/\[|\{|\}|\||\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} end # load all the custom aliases require 'gchart/aliases' # Returns the chart's generated PNG as a blob. (borrowed from John's gchart.rubyforge.org) def fetch url = URI.parse(self.class.url(use_ssl)) req = Net::HTTP::Post.new(url.path) req.body = query_builder req.content_type = 'application/x-www-form-urlencoded' http = Net::HTTP.new(url.host, url.port) http.verify_mode = OpenSSL::SSL::VERIFY_PEER if use_ssl http.use_ssl = use_ssl http.start {|resp| resp.request(req) }.body end # Writes the chart's generated PNG to a file. (borrowed from John's gchart.rubyforge.org) def write io_or_file = filename || self.class.default_filename return io_or_file.write(fetch) if io_or_file.respond_to?(:write) open(io_or_file, "wb+") { |io| io.write(fetch) } end # Format def image_tag image = "<img" image += " id=\"#{id}\"" if id image += " class=\"#{klass}\"" if klass image += " src=\"#{url_builder(:html)}\"" image += " width=\"#{width}\"" image += " height=\"#{height}\"" image += " alt=\"#{alt}\"" image += " title=\"#{title}\"" if title image += " usemap=\"#{usemap}\"" if usemap image += " />" end alias_method :img_tag, :image_tag def url url_builder end def file write end # def jstize(string) self.class.jstize(string) end private # The title size cannot be set without specifying a color. # A dark key will be used for the title color if no color is specified def set_title title_params = "chtt=#{title}" unless (title_color.nil? && title_size.nil? && title_alignment.nil?) - title_params << "&chts=" + (color, size, alignment = (title_color || '454545'), title_size, (title_alignment || 'c')).compact.join(',') + title_params << "&chts=" + (color, size, alignment = (title_color || '454545'), title_size, (title_alignment.to_s[0,1] || 'c')).compact.join(',') end title_params end def set_size "chs=#{size}" end def set_data data = send("#{@encoding}_encoding") "chd=#{data}" end def set_colors @bg_type = fill_type(bg_type) || 's' if bg_color @chart_type = fill_type(chart_type) || 's' if chart_color "chf=" + {'bg' => fill_for(bg_type, bg_color, bg_angle), 'c' => fill_for(chart_type, chart_color, chart_angle)}.map{|k,v| "#{k},#{v}" unless v.nil?}.compact.join('|') end # set bar, line colors def set_bar_colors @bar_colors = bar_colors.join(',') if bar_colors.is_a?(Array) "chco=#{bar_colors}" end def set_country_codes @country_codes = country_codes.join() if country_codes.is_a?(Array) "chld=#{country_codes}" end # set bar spacing # chbh= # <bar width in pixels>, # <optional space between bars in a group>, # <optional space between groups> def set_bar_width_and_spacing width_and_spacing_values = case bar_width_and_spacing when String bar_width_and_spacing when Array bar_width_and_spacing.join(',') when Hash width = bar_width_and_spacing[:width] || 23 spacing = bar_width_and_spacing[:spacing] || 4 group_spacing = bar_width_and_spacing[:group_spacing] || 8 [width,spacing,group_spacing].join(',') else bar_width_and_spacing.to_s end "chbh=#{width_and_spacing_values}" end def set_range_markers markers = case range_markers when Hash set_range_marker(range_markers) when Array range_markers.collect{|marker| set_range_marker(marker)}.join('|') end "chm=#{markers}" end def set_range_marker(options) orientation = ['vertical', 'Vertical', 'V', 'v', 'R'].include?(options[:orientation]) ? 'R' : 'r' "#{orientation},#{options[:color]},0,#{options[:start_position]},#{options[:stop_position]}#{',1' if options[:overlaid?]}" end def fill_for(type=nil, color='', angle=nil) unless type.nil? case type when 'lg' angle ||= 0 color = "#{color},0,ffffff,1" if color.split(',').size == 1 "#{type},#{angle},#{color}" when 'ls' angle ||= 90 color = "#{color},0.2,ffffff,0.2" if color.split(',').size == 1 "#{type},#{angle},#{color}" else "#{type},#{color}" end end end # A chart can have one or many legends. # Gchart.line(:legend => 'label') # or # Gchart.line(:legend => ['first label', 'last label']) def set_legend if type.to_s =~ /meter/ @labels = legend return set_labels end if legend.is_a?(Array) "chdl=#{@legend.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chdl=#{legend}" end end def set_legend_position case @legend_position.to_s when /(bottom|b)$/ "chdlp=b" when /(bottom_vertical|bv)$/ "chdlp=bv" when /(top|t)$/ "chdlp=t" when /(top_vertical|tv)$/ "chdlp=tv" when /(right|r)$/ "chdlp=r" when /(left|l)$/ "chdlp=l" end end def set_line_thickness "chls=#{thickness}" end def set_line_markers "chm=#{new_markers}" end def set_grid_lines "chg=#{grid_lines}" end def set_labels if labels.is_a?(Array) "chl=#{@labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chl=#{@labels}" end end def set_axis_with_labels @axis_with_labels = axis_with_labels.join(',') if @axis_with_labels.is_a?(Array) "chxt=#{axis_with_labels}" end def set_axis_labels if axis_labels.is_a?(Array) if RUBY_VERSION.to_f < 1.9 labels_arr = axis_labels.enum_with_index.map{|labels,index| [index,labels]} else labels_arr = axis_labels.map.with_index.map{|labels,index| [index,labels]} end elsif axis_labels.is_a?(Hash) labels_arr = axis_labels.to_a end labels_arr.map! do |index,labels| if labels.is_a?(Array) "#{index}:|#{labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "#{index}:|#{labels}" end end "chxl=#{labels_arr.join('|')}" end # http://code.google.com/apis/chart/labels.html#axis_range # Specify a range for axis labels def set_axis_range # a passed axis_range should look like: # [[10,100]] or [[10,100,4]] or [[10,100], [20,300]] # in the second example, 4 is the interval set = @calculated_axis_range ? datasets : axis_range || datasets return unless set && set.respond_to?(:each) && set.find {|o| o}.respond_to?(:each) 'chxr=' + set.enum_for(:each_with_index).map do |axis_range, index| next nil if axis_range.nil? # ignore this axis min, max, step = axis_range if axis_range.size > 3 || step && max && step > max # this is a full series max = axis_range.compact.max step = nil end [index, (min_value || min || 0), (max_value || max), step].compact.join(',') end.compact.join("|") end def set_geographical_area "chtm=#{geographical_area}" end def set_type 'cht=' + case type.to_s when 'line' then "lc" when 'line_xy' then "lxy" when 'pie_3d' then "p3" when 'pie' then "p" when 'venn' then "v" when 'scatter' then "s" when 'sparkline' then "ls" when 'meter' then "gom" when 'map' then "t" when 'radar' "r" + (curved? ? 's' : '') when 'bar' "b" + (horizontal? ? "h" : "v") + (grouped? ? "g" : "s") end end def fill_type(type) case type when 'solid' then 's' when 'gradient' then 'lg' when 'stripes' then 'ls' end end def number_visible n = 0 dataset.each do |mds| return n.to_s if mds[:invisible] == true if mds[:data].first.is_a?(Array) n += mds[:data].length else n += 1 end end "" end # Turns input into an array of axis hashes, dependent on the chart type def convert_dataset(ds) if dimensions == 2 # valid inputs include: # an array of >=2 arrays, or an array of >=2 hashes ds = ds.map do |d| d.is_a?(Hash) ? d : {:data => d} end elsif dimensions == 1 # valid inputs include: # a hash, an array of data, an array of >=1 array, or an array of >=1 hash if ds.is_a?(Hash) ds = [ds] elsif not ds.first.is_a?(Hash) ds = [{:data => ds}] end end ds end # just an alias def axis_set dataset end def convert_to_simple_value(number) if number.nil? "_" else value = self.class.simple_chars[number.to_i] value.nil? ? "_" : value end end def convert_to_extended_value(number) if number.nil? '__' else value = self.class.ext_pairs[number.to_i] value.nil? ? "__" : value end end def encode_scaled_dataset(chars, nil_char) dsets = [] dataset.each do |ds| if max_value != false range = ds[:max_value] - ds[:min_value] range = 1 if range == 0 end unless ds[:data].first.is_a?(Array) ldatasets = [ds[:data]] else ldatasets = ds[:data] end ldatasets.each do |l| dsets << l.map do |number| if number.nil? nil_char else unless range.nil? || range.zero? number = chars.size * (number - ds[:min_value]) / range.to_f number = [number, chars.size - 1].min end chars[number.to_i] end end.join end end dsets.join(',') end # http://code.google.com/apis/chart/#simple # Simple encoding has a resolution of 62 different values. # Allowing five pixels per data point, this is sufficient for line and bar charts up # to about 300 pixels. Simple encoding is suitable for all other types of chart regardless of size. def simple_encoding "s" + number_visible + ":" + encode_scaled_dataset(self.class.simple_chars, '_') end # http://code.google.com/apis/chart/#text # Text encoding with data scaling lets you specify arbitrary positive or # negative floating point numbers, in combination with a scaling parameter # that lets you specify a custom range for your chart. This chart is useful # when you don't want to worry about limiting your data to a specific range, # or do the calculations to scale your data down or up to fit nicely inside # a chart. # # Valid values range from (+/-)9.999e(+/-)100, and only four non-zero digits are supported (that is, 123400, 1234, 12.34, and 0.1234 are valid, but 12345, 123.45 and 123400.5 are not). # # This encoding is not available for maps. # def text_encoding chds = dataset.map{|ds| "#{ds[:min_value]},#{ds[:max_value]}" }.join(",") "t" + number_visible + ":" + datasets.map{ |ds| ds.map{|e|e||'_'}.join(',') }.join('|') + "&chds=" + chds end # http://code.google.com/apis/chart/#extended # Extended encoding has a resolution of 4,096 different values # and is best used for large charts where a large data range is required. def extended_encoding "e" + number_visible + ":" + encode_scaled_dataset(self.class.ext_pairs, '__') end def url_builder(options="") self.class.url(use_ssl) + query_builder(options) end def query_builder(options="") query_params = instance_variables.sort.map do |var| case var.to_s when '@data' set_data unless data == [] # Set the graph size when '@width' set_size unless width.nil? || height.nil? when '@type' set_type when '@title' set_title unless title.nil? when '@legend' set_legend unless legend.nil? when '@labels' set_labels unless labels.nil? when '@legend_position' set_legend_position unless legend_position.nil? when '@thickness' set_line_thickness when '@new_markers' set_line_markers when '@bg_color' set_colors when '@chart_color' set_colors if bg_color.nil? when '@bar_colors' set_bar_colors when '@bar_width_and_spacing' set_bar_width_and_spacing when '@axis_with_labels' set_axis_with_labels when '@axis_labels' set_axis_labels when '@range_markers' set_range_markers when '@grid_lines' set_grid_lines when '@geographical_area' set_geographical_area when '@country_codes' set_country_codes when '@custom' custom end end.compact query_params << set_axis_range # Use ampersand as default delimiter unless options == :html delimiter = '&' # Escape ampersand for html image tags else delimiter = '&amp;' end jstize(query_params.join(delimiter)) end end
mattetti/googlecharts
6840ca485ddc19b88d37f1b5997fe008202df729
add opt_alignment on chts
diff --git a/lib/gchart.rb b/lib/gchart.rb index deef5e4..5a66439 100644 --- a/lib/gchart.rb +++ b/lib/gchart.rb @@ -1,715 +1,715 @@ $:.unshift File.dirname(__FILE__) require 'gchart/version' require 'gchart/theme' require "net/http" require "net/https" require "uri" require "cgi" require 'enumerator' class Gchart include GchartInfo def self.url(use_ssl = false) if use_ssl 'https://chart.googleapis.com/chart?' else 'http://chart.apis.google.com/chart?' end end def self.types @types ||= ['line', 'line_xy', 'scatter', 'bar', 'venn', 'pie', 'pie_3d', 'jstize', 'sparkline', 'meter', 'map', 'radar'] end def self.simple_chars @simple_chars ||= ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a end def self.chars @chars ||= simple_chars + ['-', '.'] end def self.ext_pairs @ext_pairs ||= chars.map { |char_1| chars.map { |char_2| char_1 + char_2 } }.flatten end def self.default_filename 'chart.png' end attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :legend, :legend_position, :labels, :data, :encoding, :bar_colors, - :title_color, :title_size, :custom, :axis_with_labels, :axis_labels, :bar_width_and_spacing, :id, :alt, :klass, + :title_color, :title_size, :title_alignment, :custom, :axis_with_labels, :axis_labels, :bar_width_and_spacing, :id, :alt, :klass, :range_markers, :geographical_area, :map_colors, :country_codes, :axis_range, :filename, :min, :max, :colors, :usemap attr_accessor :bg_type, :bg_color, :bg_angle, :chart_type, :chart_color, :chart_angle, :axis_range, :thickness, :new_markers, :grid_lines, :use_ssl attr_accessor :min_value, :max_value types.each do |type| instance_eval <<-DYNCLASSMETH def #{type}(options = {}) # Start with theme defaults if a theme is set theme = options[:theme] options = theme ? Chart::Theme.load(theme).to_options.merge(options) : options # # Extract the format and optional filename, then clean the hash format = options[:format] || 'url' options[:filename] ||= default_filename options.delete(:format) #update map_colors to become bar_colors options.update(:bar_colors => options[:map_colors]) if options.has_key?(:map_colors) chart = new(options.merge!({:type => "#{type}"})) chart.send(format) end DYNCLASSMETH end def self.version VERSION::STRING end def self.method_missing(m, options={}) raise NoMethodError, "#{m} is not a supported chart format. Please use one of the following: #{supported_types}." end def initialize(options={}) @type = options[:type] || 'line' @data = [] @width = 300 @height = 200 @curved = false @horizontal = false @grouped = false @use_ssl = false @encoding = 'simple' # @max_value = 'auto' # @min_value defaults to nil meaning zero @filename = options[:filename] # Sets the alt tag when chart is exported as image tag @alt = 'Google Chart' # Sets the CSS id selector when chart is exported as image tag @id = false # Sets the CSS class selector when chart is exported as image tag @klass = options[:class] || false # set the options value if definable options.each do |attribute, value| send("#{attribute}=", value) if self.respond_to?("#{attribute}=") end end def self.supported_types self.types.join(' ') end # Defines the Graph size using the following format: # width X height def size=(size='300x200') @width, @height = size.split("x").map { |dimension| dimension.to_i } end def size "#{width}x#{height}" end def dimensions # TODO: maybe others? [:line_xy, :scatter].include?(type) ? 2 : 1 end # Sets the orientation of a bar graph def orientation=(orientation='h') if orientation == 'h' || orientation == 'horizontal' self.horizontal = true elsif orientation == 'v' || orientation == 'vertical' self.horizontal = false end end # Sets the bar graph presentation (stacked or grouped) def stacked=(option=true) @grouped = option ? false : true end def bg=(options) if options.is_a?(String) @bg_color = options elsif options.is_a?(Hash) @bg_color = options[:color] @bg_type = options[:type] @bg_angle = options[:angle] end end def graph_bg=(options) if options.is_a?(String) @chart_color = options elsif options.is_a?(Hash) @chart_color = options[:color] @chart_type = options[:type] @chart_angle = options[:angle] end end def max_value=(max_v) if max_v =~ /false/ @max_value = false else @max_value = max_v end end def min_value=(min_v) if min_v =~ /false/ @min_value = false else @min_value = min_v end end # returns the full data range as an array # it also sets the data range if not defined def full_data_range(ds) return if max_value == false ds.each_with_index do |mds, mds_index| mds[:min_value] ||= min_value mds[:max_value] ||= max_value if mds_index == 0 && type.to_s == 'bar' # TODO: unless you specify a zero line (using chp or chds), # the min_value of a bar chart is always 0. #mds[:min_value] ||= mds[:data].first.to_a.compact.min mds[:min_value] ||= 0 end if (mds_index == 0 && type.to_s == 'bar' && !grouped && mds[:data].first.is_a?(Array)) totals = [] mds[:data].each do |l| l.each_with_index do |v, index| next if v.nil? totals[index] ||= 0 totals[index] += v end end mds[:max_value] ||= totals.compact.max else all = mds[:data].flatten.compact # default min value should be 0 unless set to auto if mds[:min_value] == 'auto' mds[:min_value] = all.min else min = all.min mds[:min_value] ||= (min && min < 0 ? min : 0) end mds[:max_value] ||= all.max end end unless axis_range @calculated_axis_range = true @axis_range = ds.map{|mds| [mds[:min_value], mds[:max_value]]} if dimensions == 1 && (type.to_s != 'bar' || horizontal) tmp = axis_range.fetch(0, []) @axis_range[0] = axis_range.fetch(1, []) @axis_range[1] = tmp end end # return [min, max] unless (min.nil? || max.nil?) # @max = (max_value.nil? || max_value == 'auto') ? ds.compact.map{|mds| mds.compact.max}.max : max_value # # if min_value.nil? # min_ds_value = ds.compact.map{|mds| mds.compact.min}.min || 0 # @min = (min_ds_value < 0) ? min_ds_value : 0 # else # @min = min_value == 'auto' ? ds.compact.map{|mds| mds.compact.min}.min || 0 : min_value # end # @axis_range = [[min,max]] end def dataset if @dataset @dataset else @dataset = convert_dataset(data || []) full_data_range(@dataset) # unless axis_range @dataset end end # Sets of data to handle multiple sets def datasets datasets = [] dataset.each do |d| if d[:data].first.is_a?(Array) datasets += d[:data] else datasets << d[:data] end end datasets end def self.jstize(string) # See http://github.com/mattetti/googlecharts/issues#issue/27 #URI.escape( string ).gsub("%7C", "|") # See discussion: http://github.com/mattetti/googlecharts/commit/9b5cfb93aa51aae06611057668e631cd515ec4f3#comment_51347 string.gsub(' ', '+').gsub(/\[|\{|\}|\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} #string.gsub(' ', '+').gsub(/\[|\{|\}|\||\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} end # load all the custom aliases require 'gchart/aliases' # Returns the chart's generated PNG as a blob. (borrowed from John's gchart.rubyforge.org) def fetch url = URI.parse(self.class.url(use_ssl)) req = Net::HTTP::Post.new(url.path) req.body = query_builder req.content_type = 'application/x-www-form-urlencoded' http = Net::HTTP.new(url.host, url.port) http.verify_mode = OpenSSL::SSL::VERIFY_PEER if use_ssl http.use_ssl = use_ssl http.start {|resp| resp.request(req) }.body end # Writes the chart's generated PNG to a file. (borrowed from John's gchart.rubyforge.org) def write io_or_file = filename || self.class.default_filename return io_or_file.write(fetch) if io_or_file.respond_to?(:write) open(io_or_file, "wb+") { |io| io.write(fetch) } end # Format def image_tag image = "<img" image += " id=\"#{id}\"" if id image += " class=\"#{klass}\"" if klass image += " src=\"#{url_builder(:html)}\"" image += " width=\"#{width}\"" image += " height=\"#{height}\"" image += " alt=\"#{alt}\"" image += " title=\"#{title}\"" if title image += " usemap=\"#{usemap}\"" if usemap image += " />" end alias_method :img_tag, :image_tag def url url_builder end def file write end # def jstize(string) self.class.jstize(string) end private # The title size cannot be set without specifying a color. # A dark key will be used for the title color if no color is specified def set_title title_params = "chtt=#{title}" - unless (title_color.nil? && title_size.nil? ) - title_params << "&chts=" + (color, size = (title_color || '454545'), title_size).compact.join(',') + unless (title_color.nil? && title_size.nil? && title_alignment.nil?) + title_params << "&chts=" + (color, size, alignment = (title_color || '454545'), title_size, (title_alignment || 'c')).compact.join(',') end title_params end def set_size "chs=#{size}" end def set_data data = send("#{@encoding}_encoding") "chd=#{data}" end def set_colors @bg_type = fill_type(bg_type) || 's' if bg_color @chart_type = fill_type(chart_type) || 's' if chart_color "chf=" + {'bg' => fill_for(bg_type, bg_color, bg_angle), 'c' => fill_for(chart_type, chart_color, chart_angle)}.map{|k,v| "#{k},#{v}" unless v.nil?}.compact.join('|') end # set bar, line colors def set_bar_colors @bar_colors = bar_colors.join(',') if bar_colors.is_a?(Array) "chco=#{bar_colors}" end def set_country_codes @country_codes = country_codes.join() if country_codes.is_a?(Array) "chld=#{country_codes}" end # set bar spacing # chbh= # <bar width in pixels>, # <optional space between bars in a group>, # <optional space between groups> def set_bar_width_and_spacing width_and_spacing_values = case bar_width_and_spacing when String bar_width_and_spacing when Array bar_width_and_spacing.join(',') when Hash width = bar_width_and_spacing[:width] || 23 spacing = bar_width_and_spacing[:spacing] || 4 group_spacing = bar_width_and_spacing[:group_spacing] || 8 [width,spacing,group_spacing].join(',') else bar_width_and_spacing.to_s end "chbh=#{width_and_spacing_values}" end def set_range_markers markers = case range_markers when Hash set_range_marker(range_markers) when Array range_markers.collect{|marker| set_range_marker(marker)}.join('|') end "chm=#{markers}" end def set_range_marker(options) orientation = ['vertical', 'Vertical', 'V', 'v', 'R'].include?(options[:orientation]) ? 'R' : 'r' "#{orientation},#{options[:color]},0,#{options[:start_position]},#{options[:stop_position]}#{',1' if options[:overlaid?]}" end def fill_for(type=nil, color='', angle=nil) unless type.nil? case type when 'lg' angle ||= 0 color = "#{color},0,ffffff,1" if color.split(',').size == 1 "#{type},#{angle},#{color}" when 'ls' angle ||= 90 color = "#{color},0.2,ffffff,0.2" if color.split(',').size == 1 "#{type},#{angle},#{color}" else "#{type},#{color}" end end end # A chart can have one or many legends. # Gchart.line(:legend => 'label') # or # Gchart.line(:legend => ['first label', 'last label']) def set_legend if type.to_s =~ /meter/ @labels = legend return set_labels end if legend.is_a?(Array) "chdl=#{@legend.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chdl=#{legend}" end end def set_legend_position case @legend_position.to_s when /(bottom|b)$/ "chdlp=b" when /(bottom_vertical|bv)$/ "chdlp=bv" when /(top|t)$/ "chdlp=t" when /(top_vertical|tv)$/ "chdlp=tv" when /(right|r)$/ "chdlp=r" when /(left|l)$/ "chdlp=l" end end def set_line_thickness "chls=#{thickness}" end def set_line_markers "chm=#{new_markers}" end def set_grid_lines "chg=#{grid_lines}" end def set_labels if labels.is_a?(Array) "chl=#{@labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chl=#{@labels}" end end def set_axis_with_labels @axis_with_labels = axis_with_labels.join(',') if @axis_with_labels.is_a?(Array) "chxt=#{axis_with_labels}" end def set_axis_labels if axis_labels.is_a?(Array) if RUBY_VERSION.to_f < 1.9 labels_arr = axis_labels.enum_with_index.map{|labels,index| [index,labels]} else labels_arr = axis_labels.map.with_index.map{|labels,index| [index,labels]} end elsif axis_labels.is_a?(Hash) labels_arr = axis_labels.to_a end labels_arr.map! do |index,labels| if labels.is_a?(Array) "#{index}:|#{labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "#{index}:|#{labels}" end end "chxl=#{labels_arr.join('|')}" end # http://code.google.com/apis/chart/labels.html#axis_range # Specify a range for axis labels def set_axis_range # a passed axis_range should look like: # [[10,100]] or [[10,100,4]] or [[10,100], [20,300]] # in the second example, 4 is the interval set = @calculated_axis_range ? datasets : axis_range || datasets return unless set && set.respond_to?(:each) && set.find {|o| o}.respond_to?(:each) 'chxr=' + set.enum_for(:each_with_index).map do |axis_range, index| next nil if axis_range.nil? # ignore this axis min, max, step = axis_range if axis_range.size > 3 || step && max && step > max # this is a full series max = axis_range.compact.max step = nil end [index, (min_value || min || 0), (max_value || max), step].compact.join(',') end.compact.join("|") end def set_geographical_area "chtm=#{geographical_area}" end def set_type 'cht=' + case type.to_s when 'line' then "lc" when 'line_xy' then "lxy" when 'pie_3d' then "p3" when 'pie' then "p" when 'venn' then "v" when 'scatter' then "s" when 'sparkline' then "ls" when 'meter' then "gom" when 'map' then "t" when 'radar' "r" + (curved? ? 's' : '') when 'bar' "b" + (horizontal? ? "h" : "v") + (grouped? ? "g" : "s") end end def fill_type(type) case type when 'solid' then 's' when 'gradient' then 'lg' when 'stripes' then 'ls' end end def number_visible n = 0 dataset.each do |mds| return n.to_s if mds[:invisible] == true if mds[:data].first.is_a?(Array) n += mds[:data].length else n += 1 end end "" end # Turns input into an array of axis hashes, dependent on the chart type def convert_dataset(ds) if dimensions == 2 # valid inputs include: # an array of >=2 arrays, or an array of >=2 hashes ds = ds.map do |d| d.is_a?(Hash) ? d : {:data => d} end elsif dimensions == 1 # valid inputs include: # a hash, an array of data, an array of >=1 array, or an array of >=1 hash if ds.is_a?(Hash) ds = [ds] elsif not ds.first.is_a?(Hash) ds = [{:data => ds}] end end ds end # just an alias def axis_set dataset end def convert_to_simple_value(number) if number.nil? "_" else value = self.class.simple_chars[number.to_i] value.nil? ? "_" : value end end def convert_to_extended_value(number) if number.nil? '__' else value = self.class.ext_pairs[number.to_i] value.nil? ? "__" : value end end def encode_scaled_dataset(chars, nil_char) dsets = [] dataset.each do |ds| if max_value != false range = ds[:max_value] - ds[:min_value] range = 1 if range == 0 end unless ds[:data].first.is_a?(Array) ldatasets = [ds[:data]] else ldatasets = ds[:data] end ldatasets.each do |l| dsets << l.map do |number| if number.nil? nil_char else unless range.nil? || range.zero? number = chars.size * (number - ds[:min_value]) / range.to_f number = [number, chars.size - 1].min end chars[number.to_i] end end.join end end dsets.join(',') end # http://code.google.com/apis/chart/#simple # Simple encoding has a resolution of 62 different values. # Allowing five pixels per data point, this is sufficient for line and bar charts up # to about 300 pixels. Simple encoding is suitable for all other types of chart regardless of size. def simple_encoding "s" + number_visible + ":" + encode_scaled_dataset(self.class.simple_chars, '_') end # http://code.google.com/apis/chart/#text # Text encoding with data scaling lets you specify arbitrary positive or # negative floating point numbers, in combination with a scaling parameter # that lets you specify a custom range for your chart. This chart is useful # when you don't want to worry about limiting your data to a specific range, # or do the calculations to scale your data down or up to fit nicely inside # a chart. # # Valid values range from (+/-)9.999e(+/-)100, and only four non-zero digits are supported (that is, 123400, 1234, 12.34, and 0.1234 are valid, but 12345, 123.45 and 123400.5 are not). # # This encoding is not available for maps. # def text_encoding chds = dataset.map{|ds| "#{ds[:min_value]},#{ds[:max_value]}" }.join(",") "t" + number_visible + ":" + datasets.map{ |ds| ds.map{|e|e||'_'}.join(',') }.join('|') + "&chds=" + chds end # http://code.google.com/apis/chart/#extended # Extended encoding has a resolution of 4,096 different values # and is best used for large charts where a large data range is required. def extended_encoding "e" + number_visible + ":" + encode_scaled_dataset(self.class.ext_pairs, '__') end def url_builder(options="") self.class.url(use_ssl) + query_builder(options) end def query_builder(options="") query_params = instance_variables.sort.map do |var| case var.to_s when '@data' set_data unless data == [] # Set the graph size when '@width' set_size unless width.nil? || height.nil? when '@type' set_type when '@title' set_title unless title.nil? when '@legend' set_legend unless legend.nil? when '@labels' set_labels unless labels.nil? when '@legend_position' set_legend_position unless legend_position.nil? when '@thickness' set_line_thickness when '@new_markers' set_line_markers when '@bg_color' set_colors when '@chart_color' set_colors if bg_color.nil? when '@bar_colors' set_bar_colors when '@bar_width_and_spacing' set_bar_width_and_spacing when '@axis_with_labels' set_axis_with_labels when '@axis_labels' set_axis_labels when '@range_markers' set_range_markers when '@grid_lines' set_grid_lines when '@geographical_area' set_geographical_area when '@country_codes' set_country_codes when '@custom' custom end end.compact query_params << set_axis_range # Use ampersand as default delimiter unless options == :html delimiter = '&' # Escape ampersand for html image tags else delimiter = '&amp;' end jstize(query_params.join(delimiter)) end end
mattetti/googlecharts
0a9f9912780ae4848e6b557a9e73672d0213d422
Add Example to record file PNG in filesystem to README
diff --git a/README.markdown b/README.markdown index d8a0507..46f5cd8 100644 --- a/README.markdown +++ b/README.markdown @@ -1,299 +1,316 @@ The goal of this Gem is to make the creation of Google Charts a simple and easy task. require 'googlecharts' Gchart.line( :size => '200x300', :title => "example title", :bg => 'efefef', :legend => ['first data set label', 'second data set label'], :data => [10, 30, 120, 45, 72]) Check out the [full documentation over there](http://googlecharts.rubyforge.org/) This gem is fully tested using Rspec, check the rspec folder for more examples. See at the bottom of this file who reported using this gem. Chart Type ------------- This gem supports the following types of charts: * line, * line_xy * sparkline * scatter * bar * venn * pie * pie_3d * google meter Googlecharts also supports graphical themes and you can easily load your own. To create a chart, simply require Gchart and call any of the existing type: require 'gchart' Gchart.pie Chart Title ------------- To add a title to a chart pass the title to your chart: Gchart.line(:title => 'Sexy Charts!') You can also specify the color and/or size Gchart.line(:title => 'Sexy Charts!', :title_color => 'FF0000', :title_size => '20') Colors ------------- Specify a color with at least a 6-letter string of hexadecimal values in the format RRGGBB. For example: * FF0000 = red * 00FF00 = green * 0000FF = blue * 000000 = black * FFFFFF = white You can optionally specify transparency by appending a value between 00 and FF where 00 is completely transparent and FF completely opaque. For example: * 0000FFFF = solid blue * 0000FF00 = transparent blue If you need to use multiple colors, check the doc. Usually you just need to pass :attribute => 'FF0000,00FF00' Some charts have more options than other, make sure to refer to the documentation. Background options: ------------- If you don't set the background option, your graph will be transparent. * You have 3 types of background http://code.google.com/apis/chart/#chart_or_background_fill - solid - gradient - stripes By default, if you set a background color, the fill will be solid: Gchart.bar(:bg => 'efefef') However you can specify another fill type such as: Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'}) In the above code, we decided to have a gradient background, however since we only passed one color, the chart will start by the specified color and transition to white. By the default, the gradient angle is 0. Change it as follows: Gchart.line(:title =>'bg example', :bg => {:color => 'efefef', :type => 'gradient', :angle => 90}) For a more advance use of colors, refer to http://code.google.com/apis/chart/#linear_gradient Gchart.line(:bg => {:color => '76A4FB,1,ffffff,0', :type => 'gradient'}) The same way you set the background color, you can also set the graph background: Gchart.line(:graph_bg => 'cccccc') or both Gchart.line(:bg => {:color => '76A4FB,1,ffffff,0', :type => 'gradient'}, :graph_bg => 'cccccc', :title => 'Sexy Chart') Another type of fill is stripes http://code.google.com/apis/chart/#linear_stripes Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'}) You can customize the amount of stripes, colors and width by changing the color value. Themes -------- Googlecharts comes with 4 themes: keynote, thirty7signals, pastel and greyscale. (ganked from [Gruff](http://github.com/topfunky/gruff/tree/master) Gchart.line( :theme => :keynote, :data => [[0,40,10,70,20],[41,10,80,50,40],[20,60,30,60,80],[5,23,35,10,56],[80,90,5,30,60]], :title => 'keynote' ) * keynote ![keynote](http://chart.apis.google.com/chart?chtt=keynote&chco=6886B4,FDD84E,72AE6E,D1695E,8A6EAF,EFAA43&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo&chf=c,s,FFFFFF|bg,s,000000) * thirty7signals ![37signals](http://chart.apis.google.com/chart?chtt=thirty7signals&chco=FFF804,336699,339933,ff0000,cc99cc,cf5910&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo&chf=bg,s,FFFFFF) * pastel ![pastel](http://chart.apis.google.com/chart?chtt=pastel&chco=a9dada,aedaa9,daaea9,dadaa9,a9a9da&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo) * greyscale ![greyscale](http://chart.apis.google.com/chart?chtt=greyscale&chco=282828,383838,686868,989898,c8c8c8,e8e8e8&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo) You can also use your own theme. Create a yml file using the same format as the themes located in lib/themes.yml Load your theme(s): Chart::Theme.add_theme_file("#{File.dirname(__FILE__)}/fixtures/another_test_theme.yml") And use the standard method signature to use your own theme: Gchart.line(:theme => :custom_theme, :data => [[0, 40, 10, 70, 20],[41, 10, 80, 50]], :title => 'greyscale') Legend & Labels ------------- You probably will want to use a legend or labels for your graph. Gchart.line(:legend => 'legend label') or Gchart.line(:legend => ['legend label 1', 'legend label 2']) Will do the trick. You can also use the labels alias (makes more sense when using the pie charts) chart = Gchart.pie(:labels => ['label 1', 'label 2']) Multiple axis labels ------------- Multiple axis labels are available for line charts, bar charts and scatter plots. * x = bottom x-axis * t = top x-axis * y = left y-axis * r = right y-axis Gchart.line(:axis_with_label => 'x,y,r,t') To add labels on these axis: Gchart.line(:axis_with_label => 'x,y,r,t', :axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']) Note that each array entry could also be an array but represent the labels for the corresponding axis. A question which comes back often is how do I only display the y axis label? Solution: Gchart.line( :data => [0,20, 40, 60, 140, 230, 60], :axis_with_labels => 'y') Custom axis ranges --------------- If you want to display a custom range for an axis, you need to set the range as described in the Google charts documentation: min, max, step: Gchart.line( :data => [17, 17, 11, 8, 2], :axis_with_labels => ['x', 'y'], :axis_labels => [['J', 'F', 'M', 'A', 'M']], :axis_range => [nil, [2,17,5]]) In this case, the custom axis range is only defined for y (second entry) with a minimum value of 2, max 17 and a step of 5. This is also valid if you want to set a x axis and automatically define the y labels. Data options ------------- Data are passed using an array or a nested array. Gchart.bar(:data => [1,2,4,67,100,41,234]) Gchart.bar(:data => [[1,2,4,67,100,41,234],[45,23,67,12,67,300, 250]]) By default, the graph is drawn with your max value representing 100% of the height or width of the graph. You can change that my passing the max value. Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => 300) Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => 'auto') or if you want to use the real values from your dataset: Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => false) You can also define a different encoding to add more granularity: Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'simple') Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'extended') Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'text') Pies: ------------- you have 2 type of pies: - Gchart.pie() the standard 2D pie _ Gchart.pie_3d() the fancy 3D pie To set labels, you can use one of these two options: @legend = ['Matt_fu', 'Rob_fu'] Gchart.pie_3d(:title => @title, :labels => @legend, :data => @data, :size => '400x200') Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data, :size => '400x200') Bars: ------------- A bar chart can accept options to set the width of the bars, spacing between bars and spacing between bar groups. To set these, you can either provide a string, array or hash. The Google API sets these options in the order of width, spacing, and group spacing, with both spacing values being optional. So, if you provide a string or array, provide them in that order: Gchart.bar(:data => @data, :bar_width_and_spacing => '25,6') # width of 25, spacing of 6 Gchart.bar(:data => @data, :bar_width_and_spacing => '25,6,12') # width of 25, spacing of 6, group spacing of 12 Gchart.bar(:data => @data, :bar_width_and_spacing => [25,6]) # width of 25, spacing of 6 Gchart.bar(:data => @data, :bar_width_and_spacing => 25) # width of 25 The hash lets you set these values directly, with the Google default values set for any options you don't include: Gchart.bar(:data => @data, :bar_width_and_spacing => {:width => 19}) Gchart.bar(:data => @data, :bar_width_and_spacing => {:spacing => 10, :group_spacing => 12}) Radar: ------------- In a Radar graph, the x-axis is circular. The points can be connected by straight lines or curved lines. Gchart.radar(:data => @data, :curved => true) Sparklines: ------------- A sparkline chart has exactly the same parameters as a line chart. The only difference is that the axes lines are not drawn for sparklines by default. Google-o-meter ------------- A Google-o-meter has a few restrictions. It may only use a solid filled background and it may only have one label. +Record Chart PNG file in filesystem Sample : +-------------------------------------------- + +Multi Lines Chart Sample : + + chart = Gchart.new( :type => 'line', + :title => "example title", + :data => [[17, 17, 11, 8, 2],[10, 20, 15, 5, 7],[2, 3, 7, 9, 12]], + :line_colors => 'e0440e,e62ae5,287eec', + :legend => ['courbe 1','courbe 2','courbe 3'], + :axis_with_labels => ['x', 'y'], + :axis_range => [[0,100,20], [0,20,5]], + :filename => "tmp/chart.png") + + # Record file in filesystem + chart.file + try yourself ------------- Gchart.bar( :data => [[1,2,4,67,100,41,234],[45,23,67,12,67,300, 250]], :title => 'SD Ruby Fu level', :legend => ['matt','patrick'], :bg => {:color => '76A4FB', :type => 'gradient'}, :bar_colors => 'ff0000,00ff00') "http://chart.apis.google.com/chart?chs=300x200&chdl=matt|patrick&chd=s:AAANUIv,JENCN9y&chtt=SDRuby+Fu+level&chf=bg,lg,0,76A4FB,0,ffffff,1&cht=bvs&chco=ff0000,00ff00" Gchart.pie(:data => [20,10,15,5,50], :title => 'SDRuby Fu level', :size => '400x200', :labels => ['matt', 'rob', 'patrick', 'ryan', 'jordan']) http://chart.apis.google.com/chart?cht=p&chs=400x200&chd=s:YMSG9&chtt=SDRuby+Fu+level&chl=matt|rob|patrick|ryan|jordan \ No newline at end of file
mattetti/googlecharts
bf256abe122bdf73bda636c1893493b39a136bc8
Version bump to 1.6.7
diff --git a/lib/gchart/version.rb b/lib/gchart/version.rb index ef1cb59..da83559 100644 --- a/lib/gchart/version.rb +++ b/lib/gchart/version.rb @@ -1,3 +1,3 @@ module GchartInfo #:nodoc: - VERSION = "1.6.6" + VERSION = "1.6.7" end
mattetti/googlecharts
515f3ce75b11fca593c03f15905f1c8428b05f38
changed url for ssl connection
diff --git a/History.txt b/History.txt index d66bc88..60c7c29 100644 --- a/History.txt +++ b/History.txt @@ -1,55 +1,58 @@ +== 1.6.7 +* changed url for ssl connection + == 1.6.6 * added ssl support * refactored code * аdded ability to set the legend position * fixed legend position value * separated labels and legends for pies == 1.3.6 * support nil values. The Google Charts API specifies that a single underscore (_) can be used to omit a value from a line chart with 'simple' data encoding, and a double underscore (__) can do the same for a chart with 'extended' data encoding. (Matt Moyer) * allow a label to appear on a google-o-meter via the :legend option. (hallettj) == 1.3.5 * added code to properly escape image tag URLs (mokolabs) * added themes support + 4 default themes (keynote, thirty7signals, pastel, greyscale) chart.line(:theme=>:keynote) (jakehow) == 1.3.4 * updated documentation and cleaned it up (mokolabs) * added support for custom class, id and alt tags when using the image_tag format (i.e Gchart.line(:data => [0, 26], :format => 'image_tag')) (mokolabs) == 1.3.2 - 1.3.3 * changes required by github == 1.3.1 * added width and spacing options == 1.3.0 * added support for google-o-meter * fixed a bug when the max value of a data set was 0 == 1.2.0 * added support for sparklines == 1.1.0 * fixed another bug fix related to the uri escaping required to download the file properly. == 1.0.0 * fixed the (URI::InvalidURIError) issue == 0.2.0 * added export options (file and image tag) * added support for all arguments to be passed as a string or an array == 0.1.0 2007-12-11 * fixed the axis labels == 0.0.3 2007-12-11 * added :chart_background alias and fixed a bug related to the background colors. == 0.0.2 2007-12-11 * added support for more features and aliases == 0.0.1 2007-12-08 * 1 major enhancement: * Initial release diff --git a/lib/gchart.rb b/lib/gchart.rb index 8ea4488..deef5e4 100644 --- a/lib/gchart.rb +++ b/lib/gchart.rb @@ -1,714 +1,715 @@ $:.unshift File.dirname(__FILE__) require 'gchart/version' require 'gchart/theme' require "net/http" require "net/https" require "uri" require "cgi" require 'enumerator' class Gchart include GchartInfo def self.url(use_ssl = false) if use_ssl - 'https://www.google.com/chart?' + 'https://chart.googleapis.com/chart?' else 'http://chart.apis.google.com/chart?' end end def self.types @types ||= ['line', 'line_xy', 'scatter', 'bar', 'venn', 'pie', 'pie_3d', 'jstize', 'sparkline', 'meter', 'map', 'radar'] end def self.simple_chars @simple_chars ||= ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a end def self.chars @chars ||= simple_chars + ['-', '.'] end def self.ext_pairs @ext_pairs ||= chars.map { |char_1| chars.map { |char_2| char_1 + char_2 } }.flatten end def self.default_filename 'chart.png' end attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :legend, :legend_position, :labels, :data, :encoding, :bar_colors, :title_color, :title_size, :custom, :axis_with_labels, :axis_labels, :bar_width_and_spacing, :id, :alt, :klass, :range_markers, :geographical_area, :map_colors, :country_codes, :axis_range, :filename, :min, :max, :colors, :usemap attr_accessor :bg_type, :bg_color, :bg_angle, :chart_type, :chart_color, :chart_angle, :axis_range, :thickness, :new_markers, :grid_lines, :use_ssl attr_accessor :min_value, :max_value types.each do |type| instance_eval <<-DYNCLASSMETH def #{type}(options = {}) # Start with theme defaults if a theme is set theme = options[:theme] options = theme ? Chart::Theme.load(theme).to_options.merge(options) : options # # Extract the format and optional filename, then clean the hash format = options[:format] || 'url' options[:filename] ||= default_filename options.delete(:format) #update map_colors to become bar_colors options.update(:bar_colors => options[:map_colors]) if options.has_key?(:map_colors) chart = new(options.merge!({:type => "#{type}"})) chart.send(format) end DYNCLASSMETH end def self.version VERSION::STRING end def self.method_missing(m, options={}) raise NoMethodError, "#{m} is not a supported chart format. Please use one of the following: #{supported_types}." end def initialize(options={}) @type = options[:type] || 'line' @data = [] @width = 300 @height = 200 @curved = false @horizontal = false @grouped = false @use_ssl = false @encoding = 'simple' # @max_value = 'auto' # @min_value defaults to nil meaning zero @filename = options[:filename] # Sets the alt tag when chart is exported as image tag @alt = 'Google Chart' # Sets the CSS id selector when chart is exported as image tag @id = false # Sets the CSS class selector when chart is exported as image tag @klass = options[:class] || false # set the options value if definable options.each do |attribute, value| send("#{attribute}=", value) if self.respond_to?("#{attribute}=") end end def self.supported_types self.types.join(' ') end # Defines the Graph size using the following format: # width X height def size=(size='300x200') @width, @height = size.split("x").map { |dimension| dimension.to_i } end def size "#{width}x#{height}" end def dimensions # TODO: maybe others? [:line_xy, :scatter].include?(type) ? 2 : 1 end # Sets the orientation of a bar graph def orientation=(orientation='h') if orientation == 'h' || orientation == 'horizontal' self.horizontal = true elsif orientation == 'v' || orientation == 'vertical' self.horizontal = false end end # Sets the bar graph presentation (stacked or grouped) def stacked=(option=true) @grouped = option ? false : true end def bg=(options) if options.is_a?(String) @bg_color = options elsif options.is_a?(Hash) @bg_color = options[:color] @bg_type = options[:type] @bg_angle = options[:angle] end end def graph_bg=(options) if options.is_a?(String) @chart_color = options elsif options.is_a?(Hash) @chart_color = options[:color] @chart_type = options[:type] @chart_angle = options[:angle] end end def max_value=(max_v) if max_v =~ /false/ @max_value = false else @max_value = max_v end end def min_value=(min_v) if min_v =~ /false/ @min_value = false else @min_value = min_v end end # returns the full data range as an array # it also sets the data range if not defined def full_data_range(ds) return if max_value == false ds.each_with_index do |mds, mds_index| mds[:min_value] ||= min_value mds[:max_value] ||= max_value if mds_index == 0 && type.to_s == 'bar' # TODO: unless you specify a zero line (using chp or chds), # the min_value of a bar chart is always 0. #mds[:min_value] ||= mds[:data].first.to_a.compact.min mds[:min_value] ||= 0 end if (mds_index == 0 && type.to_s == 'bar' && !grouped && mds[:data].first.is_a?(Array)) totals = [] mds[:data].each do |l| l.each_with_index do |v, index| next if v.nil? totals[index] ||= 0 totals[index] += v end end mds[:max_value] ||= totals.compact.max else all = mds[:data].flatten.compact # default min value should be 0 unless set to auto if mds[:min_value] == 'auto' mds[:min_value] = all.min else min = all.min mds[:min_value] ||= (min && min < 0 ? min : 0) end mds[:max_value] ||= all.max end end unless axis_range @calculated_axis_range = true @axis_range = ds.map{|mds| [mds[:min_value], mds[:max_value]]} if dimensions == 1 && (type.to_s != 'bar' || horizontal) tmp = axis_range.fetch(0, []) @axis_range[0] = axis_range.fetch(1, []) @axis_range[1] = tmp end end # return [min, max] unless (min.nil? || max.nil?) # @max = (max_value.nil? || max_value == 'auto') ? ds.compact.map{|mds| mds.compact.max}.max : max_value # # if min_value.nil? # min_ds_value = ds.compact.map{|mds| mds.compact.min}.min || 0 # @min = (min_ds_value < 0) ? min_ds_value : 0 # else # @min = min_value == 'auto' ? ds.compact.map{|mds| mds.compact.min}.min || 0 : min_value # end # @axis_range = [[min,max]] end def dataset if @dataset @dataset else @dataset = convert_dataset(data || []) full_data_range(@dataset) # unless axis_range @dataset end end # Sets of data to handle multiple sets def datasets datasets = [] dataset.each do |d| if d[:data].first.is_a?(Array) datasets += d[:data] else datasets << d[:data] end end datasets end def self.jstize(string) # See http://github.com/mattetti/googlecharts/issues#issue/27 #URI.escape( string ).gsub("%7C", "|") # See discussion: http://github.com/mattetti/googlecharts/commit/9b5cfb93aa51aae06611057668e631cd515ec4f3#comment_51347 string.gsub(' ', '+').gsub(/\[|\{|\}|\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} #string.gsub(' ', '+').gsub(/\[|\{|\}|\||\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} end # load all the custom aliases require 'gchart/aliases' # Returns the chart's generated PNG as a blob. (borrowed from John's gchart.rubyforge.org) def fetch url = URI.parse(self.class.url(use_ssl)) req = Net::HTTP::Post.new(url.path) req.body = query_builder req.content_type = 'application/x-www-form-urlencoded' http = Net::HTTP.new(url.host, url.port) + http.verify_mode = OpenSSL::SSL::VERIFY_PEER if use_ssl http.use_ssl = use_ssl http.start {|resp| resp.request(req) }.body end # Writes the chart's generated PNG to a file. (borrowed from John's gchart.rubyforge.org) def write io_or_file = filename || self.class.default_filename return io_or_file.write(fetch) if io_or_file.respond_to?(:write) open(io_or_file, "wb+") { |io| io.write(fetch) } end # Format def image_tag image = "<img" image += " id=\"#{id}\"" if id image += " class=\"#{klass}\"" if klass image += " src=\"#{url_builder(:html)}\"" image += " width=\"#{width}\"" image += " height=\"#{height}\"" image += " alt=\"#{alt}\"" image += " title=\"#{title}\"" if title image += " usemap=\"#{usemap}\"" if usemap image += " />" end alias_method :img_tag, :image_tag def url url_builder end def file write end # def jstize(string) self.class.jstize(string) end private # The title size cannot be set without specifying a color. # A dark key will be used for the title color if no color is specified def set_title title_params = "chtt=#{title}" unless (title_color.nil? && title_size.nil? ) title_params << "&chts=" + (color, size = (title_color || '454545'), title_size).compact.join(',') end title_params end def set_size "chs=#{size}" end def set_data data = send("#{@encoding}_encoding") "chd=#{data}" end def set_colors @bg_type = fill_type(bg_type) || 's' if bg_color @chart_type = fill_type(chart_type) || 's' if chart_color "chf=" + {'bg' => fill_for(bg_type, bg_color, bg_angle), 'c' => fill_for(chart_type, chart_color, chart_angle)}.map{|k,v| "#{k},#{v}" unless v.nil?}.compact.join('|') end # set bar, line colors def set_bar_colors @bar_colors = bar_colors.join(',') if bar_colors.is_a?(Array) "chco=#{bar_colors}" end def set_country_codes @country_codes = country_codes.join() if country_codes.is_a?(Array) "chld=#{country_codes}" end # set bar spacing # chbh= # <bar width in pixels>, # <optional space between bars in a group>, # <optional space between groups> def set_bar_width_and_spacing width_and_spacing_values = case bar_width_and_spacing when String bar_width_and_spacing when Array bar_width_and_spacing.join(',') when Hash width = bar_width_and_spacing[:width] || 23 spacing = bar_width_and_spacing[:spacing] || 4 group_spacing = bar_width_and_spacing[:group_spacing] || 8 [width,spacing,group_spacing].join(',') else bar_width_and_spacing.to_s end "chbh=#{width_and_spacing_values}" end def set_range_markers markers = case range_markers when Hash set_range_marker(range_markers) when Array range_markers.collect{|marker| set_range_marker(marker)}.join('|') end "chm=#{markers}" end def set_range_marker(options) orientation = ['vertical', 'Vertical', 'V', 'v', 'R'].include?(options[:orientation]) ? 'R' : 'r' "#{orientation},#{options[:color]},0,#{options[:start_position]},#{options[:stop_position]}#{',1' if options[:overlaid?]}" end def fill_for(type=nil, color='', angle=nil) unless type.nil? case type when 'lg' angle ||= 0 color = "#{color},0,ffffff,1" if color.split(',').size == 1 "#{type},#{angle},#{color}" when 'ls' angle ||= 90 color = "#{color},0.2,ffffff,0.2" if color.split(',').size == 1 "#{type},#{angle},#{color}" else "#{type},#{color}" end end end # A chart can have one or many legends. # Gchart.line(:legend => 'label') # or # Gchart.line(:legend => ['first label', 'last label']) def set_legend if type.to_s =~ /meter/ @labels = legend return set_labels end if legend.is_a?(Array) "chdl=#{@legend.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chdl=#{legend}" end end def set_legend_position case @legend_position.to_s when /(bottom|b)$/ "chdlp=b" when /(bottom_vertical|bv)$/ "chdlp=bv" when /(top|t)$/ "chdlp=t" when /(top_vertical|tv)$/ "chdlp=tv" when /(right|r)$/ "chdlp=r" when /(left|l)$/ "chdlp=l" end end def set_line_thickness "chls=#{thickness}" end def set_line_markers "chm=#{new_markers}" end def set_grid_lines "chg=#{grid_lines}" end def set_labels if labels.is_a?(Array) "chl=#{@labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chl=#{@labels}" end end def set_axis_with_labels @axis_with_labels = axis_with_labels.join(',') if @axis_with_labels.is_a?(Array) "chxt=#{axis_with_labels}" end def set_axis_labels if axis_labels.is_a?(Array) if RUBY_VERSION.to_f < 1.9 labels_arr = axis_labels.enum_with_index.map{|labels,index| [index,labels]} else labels_arr = axis_labels.map.with_index.map{|labels,index| [index,labels]} end elsif axis_labels.is_a?(Hash) labels_arr = axis_labels.to_a end labels_arr.map! do |index,labels| if labels.is_a?(Array) "#{index}:|#{labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "#{index}:|#{labels}" end end "chxl=#{labels_arr.join('|')}" end # http://code.google.com/apis/chart/labels.html#axis_range # Specify a range for axis labels def set_axis_range # a passed axis_range should look like: # [[10,100]] or [[10,100,4]] or [[10,100], [20,300]] # in the second example, 4 is the interval set = @calculated_axis_range ? datasets : axis_range || datasets return unless set && set.respond_to?(:each) && set.find {|o| o}.respond_to?(:each) 'chxr=' + set.enum_for(:each_with_index).map do |axis_range, index| next nil if axis_range.nil? # ignore this axis min, max, step = axis_range if axis_range.size > 3 || step && max && step > max # this is a full series max = axis_range.compact.max step = nil end [index, (min_value || min || 0), (max_value || max), step].compact.join(',') end.compact.join("|") end def set_geographical_area "chtm=#{geographical_area}" end def set_type 'cht=' + case type.to_s when 'line' then "lc" when 'line_xy' then "lxy" when 'pie_3d' then "p3" when 'pie' then "p" when 'venn' then "v" when 'scatter' then "s" when 'sparkline' then "ls" when 'meter' then "gom" when 'map' then "t" when 'radar' "r" + (curved? ? 's' : '') when 'bar' "b" + (horizontal? ? "h" : "v") + (grouped? ? "g" : "s") end end def fill_type(type) case type when 'solid' then 's' when 'gradient' then 'lg' when 'stripes' then 'ls' end end def number_visible n = 0 dataset.each do |mds| return n.to_s if mds[:invisible] == true if mds[:data].first.is_a?(Array) n += mds[:data].length else n += 1 end end "" end # Turns input into an array of axis hashes, dependent on the chart type def convert_dataset(ds) if dimensions == 2 # valid inputs include: # an array of >=2 arrays, or an array of >=2 hashes ds = ds.map do |d| d.is_a?(Hash) ? d : {:data => d} end elsif dimensions == 1 # valid inputs include: # a hash, an array of data, an array of >=1 array, or an array of >=1 hash if ds.is_a?(Hash) ds = [ds] elsif not ds.first.is_a?(Hash) ds = [{:data => ds}] end end ds end # just an alias def axis_set dataset end def convert_to_simple_value(number) if number.nil? "_" else value = self.class.simple_chars[number.to_i] value.nil? ? "_" : value end end def convert_to_extended_value(number) if number.nil? '__' else value = self.class.ext_pairs[number.to_i] value.nil? ? "__" : value end end def encode_scaled_dataset(chars, nil_char) dsets = [] dataset.each do |ds| if max_value != false range = ds[:max_value] - ds[:min_value] range = 1 if range == 0 end unless ds[:data].first.is_a?(Array) ldatasets = [ds[:data]] else ldatasets = ds[:data] end ldatasets.each do |l| dsets << l.map do |number| if number.nil? nil_char else unless range.nil? || range.zero? number = chars.size * (number - ds[:min_value]) / range.to_f number = [number, chars.size - 1].min end chars[number.to_i] end end.join end end dsets.join(',') end # http://code.google.com/apis/chart/#simple # Simple encoding has a resolution of 62 different values. # Allowing five pixels per data point, this is sufficient for line and bar charts up # to about 300 pixels. Simple encoding is suitable for all other types of chart regardless of size. def simple_encoding "s" + number_visible + ":" + encode_scaled_dataset(self.class.simple_chars, '_') end # http://code.google.com/apis/chart/#text # Text encoding with data scaling lets you specify arbitrary positive or # negative floating point numbers, in combination with a scaling parameter # that lets you specify a custom range for your chart. This chart is useful # when you don't want to worry about limiting your data to a specific range, # or do the calculations to scale your data down or up to fit nicely inside # a chart. # # Valid values range from (+/-)9.999e(+/-)100, and only four non-zero digits are supported (that is, 123400, 1234, 12.34, and 0.1234 are valid, but 12345, 123.45 and 123400.5 are not). # # This encoding is not available for maps. # def text_encoding chds = dataset.map{|ds| "#{ds[:min_value]},#{ds[:max_value]}" }.join(",") "t" + number_visible + ":" + datasets.map{ |ds| ds.map{|e|e||'_'}.join(',') }.join('|') + "&chds=" + chds end # http://code.google.com/apis/chart/#extended # Extended encoding has a resolution of 4,096 different values # and is best used for large charts where a large data range is required. def extended_encoding "e" + number_visible + ":" + encode_scaled_dataset(self.class.ext_pairs, '__') end def url_builder(options="") self.class.url(use_ssl) + query_builder(options) end def query_builder(options="") query_params = instance_variables.sort.map do |var| case var.to_s when '@data' set_data unless data == [] # Set the graph size when '@width' set_size unless width.nil? || height.nil? when '@type' set_type when '@title' set_title unless title.nil? when '@legend' set_legend unless legend.nil? when '@labels' set_labels unless labels.nil? when '@legend_position' set_legend_position unless legend_position.nil? when '@thickness' set_line_thickness when '@new_markers' set_line_markers when '@bg_color' set_colors when '@chart_color' set_colors if bg_color.nil? when '@bar_colors' set_bar_colors when '@bar_width_and_spacing' set_bar_width_and_spacing when '@axis_with_labels' set_axis_with_labels when '@axis_labels' set_axis_labels when '@range_markers' set_range_markers when '@grid_lines' set_grid_lines when '@geographical_area' set_geographical_area when '@country_codes' set_country_codes when '@custom' custom end end.compact query_params << set_axis_range # Use ampersand as default delimiter unless options == :html delimiter = '&' # Escape ampersand for html image tags else delimiter = '&amp;' end jstize(query_params.join(delimiter)) end end diff --git a/spec/gchart_spec.rb b/spec/gchart_spec.rb index 48624aa..d549c50 100644 --- a/spec/gchart_spec.rb +++ b/spec/gchart_spec.rb @@ -1,678 +1,677 @@ require File.dirname(__FILE__) + '/spec_helper.rb' require File.dirname(__FILE__) + '/../lib/gchart' Chart::Theme.add_theme_file("#{File.dirname(__FILE__)}/fixtures/test_theme.yml") # Time to add your specs! # http://rspec.rubyforge.org/ describe "The Gchart class" do it "should show supported_types on error" do Gchart.supported_types.should match(/line/) end it "should return supported types" do Gchart.types.include?('line').should be_true end end describe "generating a default Gchart" do before(:each) do @chart = Gchart.line end it "should include the Google URL" do @chart.include?("http://chart.apis.google.com/chart?").should be_true end it "should have a default size" do @chart.should include('chs=300x200') end it "should be able to have a custom size" do Gchart.line(:size => '400x600').include?('chs=400x600').should be_true Gchart.line(:width => 400, :height => 600).include?('chs=400x600').should be_true end it "should have query parameters in predictable order" do Gchart.line(:axis_with_labels => 'x,y,r', :size => '400x600').should match(/chxt=.+cht=.+chs=/) end it "should have a type" do @chart.include?('cht=lc').should be_true end it 'should use theme defaults if theme is set' do Gchart.line(:theme=>:test).should include('chco=6886B4,FDD84E') if RUBY_VERSION.to_f < 1.9 Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=c,s,FFFFFF|bg,s,FFFFFF')) else Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=bg,s,FFFFFF|c,s,FFFFFF')) end end it "should use the simple encoding by default with auto max value" do # 9 is the max value in simple encoding, 26 being our max value the 2nd encoded value should be 9 Gchart.line(:data => [0, 26]).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => 26, :axis_with_labels => 'y').should include('chxr=0,0,26') end it "should support simple encoding with and without max_value" do Gchart.line(:data => [0, 26], :max_value => 26).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => false).should include('chd=s:Aa') end it "should support the extended encoding and encode properly" do Gchart.line(:data => [0, 10], :encoding => 'extended', :max_value => false).include?('chd=e:AA').should be_true Gchart.line(:encoding => 'extended', :max_value => false, :data => [[0,25,26,51,52,61,62,63], [64,89,90,115,4084]] ).include?('chd=e:AAAZAaAzA0A9A-A.,BABZBaBz.0').should be_true end it "should auto set the max value for extended encoding" do Gchart.line(:data => [0, 25], :encoding => 'extended', :max_value => false).should include('chd=e:AAAZ') # Extended encoding max value is '..' Gchart.line(:data => [0, 25], :encoding => 'extended').include?('chd=e:AA..').should be_true end it "should be able to have data with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,4,45,78') end it "should be able to have missing data points with text encoding" do Gchart.line(:data => [10, 5.2, nil, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,_,45,78') end it "should handle max and min values with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=0,78') end it "should automatically handle negative values with proper max/min limits when using text encoding" do Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=-10,78') end it "should handle negative values with manual max/min limits when using text encoding" do Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text', :min_value => -20, :max_value => 100).include?('chds=-20,100').should be_true end it "should set the proper axis values when using text encoding and negative values" do Gchart.bar( :data => [[-10], [100]], :encoding => 'text', :horizontal => true, :min_value => -20, :max_value => 100, :axis_with_labels => 'x', :bar_colors => ['FD9A3B', '4BC7DC']).should include("chxr=0,-20,100") end it "should be able to have multiple set of data with text encoding" do Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text').include?(Gchart.jstize('chd=t:10,5.2,4,45,78|20,40,70,15,99')).should be_true end it "should be able to receive a custom param" do Gchart.line(:custom => 'ceci_est_une_pipe').include?('ceci_est_une_pipe').should be_true end it "should be able to set label axis" do Gchart.line(:axis_with_labels => 'x,y,r').include?('chxt=x,y,r').should be_true Gchart.line(:axis_with_labels => ['x','y','r']).include?('chxt=x,y,r').should be_true end it "should be able to have axis labels" do Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true end def labeled_line(options = {}) Gchart.line({:data => @data, :axis_with_labels => 'x,y'}.merge(options)) end it "should display ranges properly" do @data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] labeled_line(:axis_labels => [((1..24).to_a << 1)]). should include('chxr=0,85,672') end def labeled_bar(options = {}) Gchart.bar({:data => @data, :axis_with_labels => 'x,y', :axis_labels => [(1..12).to_a], :encoding => "text" }.merge(options)) end it "should force the y range properly" do @data = [1,1,1,1,1,1,1,1,6,2,1,1] labeled_bar( :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,0|1,0,16') labeled_bar( :max_value => 16, :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,16|1,0,16') # nil means ignore axis labeled_bar( :axis_range => [nil,[0,16]] ).should include('chxr=1,0,16') # empty array means take defaults labeled_bar( :max_value => 16, :axis_range => [[],[0,16]] ).should include('chxr=0,0,16|1,0,16') labeled_bar( :axis_range => [[],[0,16]] ).should include('chxr=0,0|1,0,16') Gchart.line( :data => [0,20, 40, 60, 140, 230, 60], :axis_with_labels => 'y').should include("chxr=0,0,230") end it "should take in consideration the max value when creating a range" do data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] url = Gchart.line(:data => data, :axis_with_labels => 'x,y', :axis_labels => [((1..24).to_a << 1)], :max_value => 700) url.should include('chxr=0,85,700') end it 'should generate different labels and legend' do Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three)).should(include('chdl=1|2|3') && include('chl=one|two|three')) end end describe "generating different type of charts" do it "should be able to generate a line chart" do Gchart.line.should be_an_instance_of(String) Gchart.line.include?('cht=lc').should be_true end it "should be able to generate a sparkline chart" do Gchart.sparkline.should be_an_instance_of(String) Gchart.sparkline.include?('cht=ls').should be_true end it "should be able to generate a line xy chart" do Gchart.line_xy.should be_an_instance_of(String) Gchart.line_xy.include?('cht=lxy').should be_true end it "should be able to generate a scatter chart" do Gchart.scatter.should be_an_instance_of(String) Gchart.scatter.include?('cht=s').should be_true end it "should be able to generate a bar chart" do Gchart.bar.should be_an_instance_of(String) Gchart.bar.include?('cht=bvs').should be_true end it "should be able to generate a Venn diagram" do Gchart.venn.should be_an_instance_of(String) Gchart.venn.include?('cht=v').should be_true end it "should be able to generate a Pie Chart" do Gchart.pie.should be_an_instance_of(String) Gchart.pie.include?('cht=p').should be_true end it "should be able to generate a Google-O-Meter" do Gchart.meter.should be_an_instance_of(String) Gchart.meter.include?('cht=gom').should be_true end it "should be able to generate a map chart" do Gchart.map.should be_an_instance_of(String) Gchart.map.include?('cht=t').should be_true end it "should not support other types" do msg = "sexy is not a supported chart format. Please use one of the following: #{Gchart.supported_types}." lambda{Gchart.sexy}.should raise_error(NoMethodError) end end describe "range markers" do it "should be able to generate given a hash of range-marker options" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}).include?('chm=r,ff0000,0,0.59,0.61').should be_true end it "should be able to generate given an array of range-marker hash options" do Gchart.line(:range_markers => [ {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}, {:start_position => 0, :stop_position => 0.6, :color => '666666'}, {:color => 'cccccc', :start_position => 0.6, :stop_position => 1} ]).include?(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1')).should be_true end it "should allow a :overlaid? to be set" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true}).include?('chm=r,ffffff,0,0.59,0.61,1').should be_true Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false}).include?('chm=r,ffffff,0,0.59,0.61').should be_true end describe "when setting the orientation option" do before(:each) do @options = {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'} end it "to vertical (R) if given a valid option" do Gchart.line(:range_markers => @options.merge(:orientation => 'v')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'V')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'R')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'vertical')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical')).include?('chm=R').should be_true end it "to horizontal (r) if given a valid option (actually anything other than the vertical options)" do Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal')).include?('chm=r').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'h')).include?('chm=r').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'etc')).include?('chm=r').should be_true end it "if left blank defaults to horizontal (r)" do Gchart.line(:range_markers => @options).include?('chm=r').should be_true end end end describe "a bar graph" do it "should have a default vertical orientation" do Gchart.bar.include?('cht=bvs').should be_true end it "should be able to have a different orientation" do Gchart.bar(:orientation => 'vertical').include?('cht=bvs').should be_true Gchart.bar(:orientation => 'v').include?('cht=bvs').should be_true Gchart.bar(:orientation => 'h').include?('cht=bhs').should be_true Gchart.bar(:orientation => 'horizontal').include?('cht=bhs').should be_true Gchart.bar(:horizontal => false).include?('cht=bvs').should be_true end it "should be set to be stacked by default" do Gchart.bar.include?('cht=bvs').should be_true end it "should be able to stacked or grouped" do Gchart.bar(:stacked => true).include?('cht=bvs').should be_true Gchart.bar(:stacked => false).include?('cht=bvg').should be_true Gchart.bar(:grouped => true).include?('cht=bvg').should be_true Gchart.bar(:grouped => false).include?('cht=bvs').should be_true end it "should be able to have different bar colors" do Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=').should be_true Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=efefef,00ffff').should be_true # alias Gchart.bar(:bar_color => 'efefef').include?('chco=efefef').should be_true end it "should be able to have different bar colors when using an array of colors" do Gchart.bar(:bar_colors => ['efefef','00ffff']).include?('chco=efefef,00ffff').should be_true end it 'should be able to accept a string of width and spacing options' do Gchart.bar(:bar_width_and_spacing => '25,6').include?('chbh=25,6').should be_true end it 'should be able to accept a single fixnum width and spacing option to set the bar width' do Gchart.bar(:bar_width_and_spacing => 25).include?('chbh=25').should be_true end it 'should be able to accept an array of width and spacing options' do Gchart.bar(:bar_width_and_spacing => [25,6,12]).include?('chbh=25,6,12').should be_true Gchart.bar(:bar_width_and_spacing => [25,6]).include?('chbh=25,6').should be_true Gchart.bar(:bar_width_and_spacing => [25]).include?('chbh=25').should be_true end describe "with a hash of width and spacing options" do before(:each) do @default_width = 23 @default_spacing = 4 @default_group_spacing = 8 end it 'should be able to have a custom bar width' do Gchart.bar(:bar_width_and_spacing => {:width => 19}).include?("chbh=19,#{@default_spacing},#{@default_group_spacing}").should be_true end it 'should be able to have custom spacing' do Gchart.bar(:bar_width_and_spacing => {:spacing => 19}).include?("chbh=#{@default_width},19,#{@default_group_spacing}").should be_true end it 'should be able to have custom group spacing' do Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19}).include?("chbh=#{@default_width},#{@default_spacing},19").should be_true end end end describe "a line chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @chart = Gchart.line(:title => @title, :legend => @legend) end it 'should be able have a chart title' do @chart.include?("chtt=Chart+Title").should be_true end it "should be able to a custom color and size title" do Gchart.line(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true Gchart.line(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true end it "should be able to have multiple legends" do @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true end it "should escape text values in url" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend) chart.include?(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")).should be_true end it "should be able to have one legend" do chart = Gchart.line(:legend => 'legend label') chart.include?("chdl=legend+label").should be_true end it "should be able to set the position of the legend" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend, :legend_position => :bottom_vertical) - puts chart.inspect chart.include?("chdlp=bv").should be_true chart = Gchart.line(:title => title, :legend => legend, :legend_position => 'r') chart.include?("chdlp=r").should be_true end it "should be able to set the background fill" do Gchart.line(:bg => 'efefef').should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=bg,lg,90,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'}).should include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do Gchart.line(:graph_bg => 'efefef').should include("chf=c,s,efefef") Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true end it "should be able to set both a graph and a background fill" do Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true if RUBY_VERSION.to_f < 1.9 Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true else Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true end end it "should be able to have different line colors" do Gchart.line(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true Gchart.line(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true end it "should be able to render a graph where all the data values are 0" do Gchart.line(:data => [0, 0, 0]).should include("chd=s:AAA") end end describe "a sparkline chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [27,25,25,25,25,27,100,31,25,36,25,25,39,25,31,25,25,25,26,26,25,25,28,25,25,100,28,27,31,25,27,27,29,25,27,26,26,25,26,26,35,33,34,25,26,25,36,25,26,37,33,33,37,37,39,25,25,25,25] @chart = Gchart.sparkline(:title => @title, :data => @data, :legend => @legend) end it "should create a sparkline" do @chart.include?('cht=ls').should be_true end it 'should be able have a chart title' do @chart.include?("chtt=Chart+Title").should be_true end it "should be able to a custom color and size title" do Gchart.sparkline(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true Gchart.sparkline(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true end it "should be able to have multiple legends" do @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true end it "should be able to have one legend" do chart = Gchart.sparkline(:legend => 'legend label') chart.include?("chdl=legend+label").should be_true end it "should be able to set the background fill" do Gchart.sparkline(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=bg,lg,90,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'}).include?("chf=bg,ls,90,efefef,0.2,ffffff,0.2").should be_true end it "should be able to set a graph fill" do Gchart.sparkline(:graph_bg => 'efefef').include?("chf=c,s,efefef").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true end it "should be able to set both a graph and a background fill" do Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true if RUBY_VERSION.to_f < 1.9 Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true else Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true end end it "should be able to have different line colors" do Gchart.sparkline(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true Gchart.sparkline(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true end end describe "a 3d pie chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [12,8,40,15,5] @chart = Gchart.pie(:title => @title, :legend => @legend, :data => @data) end it "should create a pie" do @chart.include?('cht=p').should be_true end it "should be able to be in 3d" do Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data).include?('cht=p3').should be_true end end describe "a google-o-meter" do before(:each) do @data = [70] @legend = ['arrow points here'] @jstized_legend = Gchart.jstize(@legend.join('|')) @chart = Gchart.meter(:data => @data) end it "should create a meter" do @chart.include?('cht=gom').should be_true end it "should be able to set a solid background fill" do Gchart.meter(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true end it "should be able to set labels by using the legend or labesl accessor" do Gchart.meter(:title => @title, :labels => @legend, :data => @data).should include("chl=#{@jstized_legend}") Gchart.meter(:title => @title, :labels => @legend, :data => @data).should == Gchart.meter(:title => @title, :legend => @legend, :data => @data) end end describe "a map chart" do before(:each) do @data = [0,100,50,32] @geographical_area = 'usa' @map_colors = ['FFFFFF', 'FF0000', 'FFFF00', '00FF00'] @country_codes = ['MT', 'WY', "ID", 'SD'] @chart = Gchart.map(:data => @data, :encoding => 'text', :size => '400x300', :geographical_area => @geographical_area, :map_colors => @map_colors, :country_codes => @country_codes) end it "should create a map" do @chart.include?('cht=t').should be_true end it "should set the geographical area" do @chart.include?('chtm=usa').should be_true end it "should set the map colors" do @chart.include?('chco=FFFFFF,FF0000,FFFF00,00FF00').should be_true end it "should set the country/state codes" do @chart.include?('chld=MTWYIDSD').should be_true end it "should set the chart data" do @chart.include?('chd=t:0,100,50,32').should be_true end end describe 'exporting a chart' do it "should be available in the url format by default" do Gchart.line(:data => [0, 26], :format => 'url').should == Gchart.line(:data => [0, 26]) end it "should be available as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using img_tag alias" do Gchart.line(:data => [0, 26], :format => 'img_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom dimensions" do Gchart.line(:data => [0, 26], :format => 'image_tag', :size => '400x400').should match(/<img src=(.*) width="400" height="400" alt="Google Chart" \/>/) end it "should be available as an image tag using custom alt text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :alt => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Sexy chart" \/>/) end it "should be available as an image tag using custom title text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :title => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" title="Sexy chart" \/>/) end it "should be available as an image tag using custom css id selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :id => 'chart').should match(/<img id="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom css class selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should match(/<img class="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should use ampersands to separate key/value pairs in URLs by default" do Gchart.line(:data => [0, 26]).should satisfy {|chart| chart.include? "&" } Gchart.line(:data => [0, 26]).should_not satisfy {|chart| chart.include? "&amp;" } end it "should escape ampersands in URLs when used as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should satisfy {|chart| chart.include? "&amp;" } end it "should be available as a file" do File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file') File.exist?('chart.png').should be_true File.delete('chart.png') if File.exist?('chart.png') end it "should be available as a file using a custom file name" do File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') Gchart.line(:data => [0, 26], :format => 'file', :filename => 'custom_file_name.png') File.exist?('custom_file_name.png').should be_true File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') end it "should work even with multiple attrs" do File.delete('foo.png') if File.exist?('foo.png') Gchart.line(:size => '400x200', :data => [1,2,3,4,5], # :axis_labels => [[1,2,3,4, 5], %w[foo bar]], :axis_with_labels => 'x,r', :format => "file", :filename => "foo.png" ) File.exist?('foo.png').should be_true File.delete('foo.png') if File.exist?('foo.png') end end describe 'SSL support' do it 'should change url if is presented' do - Gchart.line(:use_ssl => true).should include('https://www.google.com/chart?') + Gchart.line(:use_ssl => true).should include('https://chart.googleapis.com/chart?') end it "should be available as a file" do File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file', :use_ssl => true) File.exist?('chart.png').should be_true File.delete('chart.png') if File.exist?('chart.png') end end
mattetti/googlecharts
5c4ed036e92a647252c44214ed421cf115869033
fix gemspec
diff --git a/googlecharts.gemspec b/googlecharts.gemspec index 9b9e14f..e4c8e02 100644 --- a/googlecharts.gemspec +++ b/googlecharts.gemspec @@ -1,20 +1,20 @@ # -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "gchart/version" Gem::Specification.new do |s| s.name = %q{googlecharts} s.version = GchartInfo::VERSION s.platform = Gem::Platform::RUBY - s.authors = ["Matt Aimonetti"] + s.authors = ["Matt Aimonetti", "Andrey Deryabin"] s.date = %q{2011-05-21} s.summary = %q{Generate charts using Google API & Ruby} s.description = %q{Generate charts using Google API & Ruby} - s.email = %q{[email protected]} - s.homepage = %q{http://github.com/aderyabin/zendesk} + s.email = %q{[email protected] [email protected]} + s.homepage = %q{http://googlecharts.rubyforge.org/} s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] end
mattetti/googlecharts
80adc28fcb89e388a454f559b6b52ef8d276e3b3
Version bump to 1.6.6
diff --git a/lib/gchart/version.rb b/lib/gchart/version.rb index 62b747d..ef1cb59 100644 --- a/lib/gchart/version.rb +++ b/lib/gchart/version.rb @@ -1,3 +1,3 @@ module GchartInfo #:nodoc: - VERSION = "1.6.5" + VERSION = "1.6.6" end
mattetti/googlecharts
19581740b751f4197391d6d91394060ef4f4af2f
refactored gem internal files
diff --git a/History.txt b/History.txt index 7ce5afc..d66bc88 100644 --- a/History.txt +++ b/History.txt @@ -1,48 +1,55 @@ +== 1.6.6 +* added ssl support +* refactored code +* аdded ability to set the legend position +* fixed legend position value +* separated labels and legends for pies + == 1.3.6 * support nil values. The Google Charts API specifies that a single underscore (_) can be used to omit a value from a line chart with 'simple' data encoding, and a double underscore (__) can do the same for a chart with 'extended' data encoding. (Matt Moyer) * allow a label to appear on a google-o-meter via the :legend option. (hallettj) == 1.3.5 * added code to properly escape image tag URLs (mokolabs) * added themes support + 4 default themes (keynote, thirty7signals, pastel, greyscale) chart.line(:theme=>:keynote) (jakehow) == 1.3.4 * updated documentation and cleaned it up (mokolabs) * added support for custom class, id and alt tags when using the image_tag format (i.e Gchart.line(:data => [0, 26], :format => 'image_tag')) (mokolabs) == 1.3.2 - 1.3.3 * changes required by github == 1.3.1 * added width and spacing options == 1.3.0 * added support for google-o-meter * fixed a bug when the max value of a data set was 0 == 1.2.0 * added support for sparklines == 1.1.0 * fixed another bug fix related to the uri escaping required to download the file properly. == 1.0.0 * fixed the (URI::InvalidURIError) issue == 0.2.0 * added export options (file and image tag) * added support for all arguments to be passed as a string or an array == 0.1.0 2007-12-11 * fixed the axis labels == 0.0.3 2007-12-11 * added :chart_background alias and fixed a bug related to the background colors. == 0.0.2 2007-12-11 * added support for more features and aliases == 0.0.1 2007-12-08 * 1 major enhancement: * Initial release diff --git a/README.markdown b/README.markdown index 399ea4a..d8a0507 100644 --- a/README.markdown +++ b/README.markdown @@ -1,325 +1,299 @@ The goal of this Gem is to make the creation of Google Charts a simple and easy task. require 'googlecharts' Gchart.line( :size => '200x300', :title => "example title", :bg => 'efefef', :legend => ['first data set label', 'second data set label'], :data => [10, 30, 120, 45, 72]) Check out the [full documentation over there](http://googlecharts.rubyforge.org/) This gem is fully tested using Rspec, check the rspec folder for more examples. See at the bottom of this file who reported using this gem. Chart Type ------------- This gem supports the following types of charts: * line, * line_xy * sparkline * scatter * bar * venn * pie * pie_3d * google meter Googlecharts also supports graphical themes and you can easily load your own. To create a chart, simply require Gchart and call any of the existing type: require 'gchart' Gchart.pie Chart Title ------------- To add a title to a chart pass the title to your chart: Gchart.line(:title => 'Sexy Charts!') You can also specify the color and/or size Gchart.line(:title => 'Sexy Charts!', :title_color => 'FF0000', :title_size => '20') Colors ------------- Specify a color with at least a 6-letter string of hexadecimal values in the format RRGGBB. For example: * FF0000 = red * 00FF00 = green * 0000FF = blue * 000000 = black * FFFFFF = white You can optionally specify transparency by appending a value between 00 and FF where 00 is completely transparent and FF completely opaque. For example: * 0000FFFF = solid blue * 0000FF00 = transparent blue If you need to use multiple colors, check the doc. Usually you just need to pass :attribute => 'FF0000,00FF00' Some charts have more options than other, make sure to refer to the documentation. Background options: ------------- If you don't set the background option, your graph will be transparent. * You have 3 types of background http://code.google.com/apis/chart/#chart_or_background_fill - solid - gradient - stripes By default, if you set a background color, the fill will be solid: Gchart.bar(:bg => 'efefef') However you can specify another fill type such as: Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'}) In the above code, we decided to have a gradient background, however since we only passed one color, the chart will start by the specified color and transition to white. By the default, the gradient angle is 0. Change it as follows: Gchart.line(:title =>'bg example', :bg => {:color => 'efefef', :type => 'gradient', :angle => 90}) For a more advance use of colors, refer to http://code.google.com/apis/chart/#linear_gradient Gchart.line(:bg => {:color => '76A4FB,1,ffffff,0', :type => 'gradient'}) The same way you set the background color, you can also set the graph background: Gchart.line(:graph_bg => 'cccccc') or both Gchart.line(:bg => {:color => '76A4FB,1,ffffff,0', :type => 'gradient'}, :graph_bg => 'cccccc', :title => 'Sexy Chart') Another type of fill is stripes http://code.google.com/apis/chart/#linear_stripes Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'}) You can customize the amount of stripes, colors and width by changing the color value. Themes -------- Googlecharts comes with 4 themes: keynote, thirty7signals, pastel and greyscale. (ganked from [Gruff](http://github.com/topfunky/gruff/tree/master) Gchart.line( :theme => :keynote, :data => [[0,40,10,70,20],[41,10,80,50,40],[20,60,30,60,80],[5,23,35,10,56],[80,90,5,30,60]], :title => 'keynote' ) * keynote ![keynote](http://chart.apis.google.com/chart?chtt=keynote&chco=6886B4,FDD84E,72AE6E,D1695E,8A6EAF,EFAA43&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo&chf=c,s,FFFFFF|bg,s,000000) * thirty7signals ![37signals](http://chart.apis.google.com/chart?chtt=thirty7signals&chco=FFF804,336699,339933,ff0000,cc99cc,cf5910&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo&chf=bg,s,FFFFFF) * pastel ![pastel](http://chart.apis.google.com/chart?chtt=pastel&chco=a9dada,aedaa9,daaea9,dadaa9,a9a9da&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo) * greyscale ![greyscale](http://chart.apis.google.com/chart?chtt=greyscale&chco=282828,383838,686868,989898,c8c8c8,e8e8e8&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo) You can also use your own theme. Create a yml file using the same format as the themes located in lib/themes.yml Load your theme(s): Chart::Theme.add_theme_file("#{File.dirname(__FILE__)}/fixtures/another_test_theme.yml") And use the standard method signature to use your own theme: Gchart.line(:theme => :custom_theme, :data => [[0, 40, 10, 70, 20],[41, 10, 80, 50]], :title => 'greyscale') Legend & Labels ------------- You probably will want to use a legend or labels for your graph. Gchart.line(:legend => 'legend label') or Gchart.line(:legend => ['legend label 1', 'legend label 2']) Will do the trick. You can also use the labels alias (makes more sense when using the pie charts) chart = Gchart.pie(:labels => ['label 1', 'label 2']) Multiple axis labels ------------- Multiple axis labels are available for line charts, bar charts and scatter plots. * x = bottom x-axis * t = top x-axis * y = left y-axis * r = right y-axis Gchart.line(:axis_with_label => 'x,y,r,t') To add labels on these axis: Gchart.line(:axis_with_label => 'x,y,r,t', :axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']) Note that each array entry could also be an array but represent the labels for the corresponding axis. A question which comes back often is how do I only display the y axis label? Solution: Gchart.line( :data => [0,20, 40, 60, 140, 230, 60], :axis_with_labels => 'y') Custom axis ranges --------------- If you want to display a custom range for an axis, you need to set the range as described in the Google charts documentation: min, max, step: Gchart.line( :data => [17, 17, 11, 8, 2], :axis_with_labels => ['x', 'y'], :axis_labels => [['J', 'F', 'M', 'A', 'M']], :axis_range => [nil, [2,17,5]]) In this case, the custom axis range is only defined for y (second entry) with a minimum value of 2, max 17 and a step of 5. This is also valid if you want to set a x axis and automatically define the y labels. Data options ------------- Data are passed using an array or a nested array. Gchart.bar(:data => [1,2,4,67,100,41,234]) Gchart.bar(:data => [[1,2,4,67,100,41,234],[45,23,67,12,67,300, 250]]) By default, the graph is drawn with your max value representing 100% of the height or width of the graph. You can change that my passing the max value. Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => 300) Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => 'auto') or if you want to use the real values from your dataset: Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => false) You can also define a different encoding to add more granularity: Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'simple') Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'extended') Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'text') Pies: ------------- you have 2 type of pies: - Gchart.pie() the standard 2D pie _ Gchart.pie_3d() the fancy 3D pie To set labels, you can use one of these two options: @legend = ['Matt_fu', 'Rob_fu'] Gchart.pie_3d(:title => @title, :labels => @legend, :data => @data, :size => '400x200') Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data, :size => '400x200') Bars: ------------- A bar chart can accept options to set the width of the bars, spacing between bars and spacing between bar groups. To set these, you can either provide a string, array or hash. The Google API sets these options in the order of width, spacing, and group spacing, with both spacing values being optional. So, if you provide a string or array, provide them in that order: Gchart.bar(:data => @data, :bar_width_and_spacing => '25,6') # width of 25, spacing of 6 Gchart.bar(:data => @data, :bar_width_and_spacing => '25,6,12') # width of 25, spacing of 6, group spacing of 12 Gchart.bar(:data => @data, :bar_width_and_spacing => [25,6]) # width of 25, spacing of 6 Gchart.bar(:data => @data, :bar_width_and_spacing => 25) # width of 25 The hash lets you set these values directly, with the Google default values set for any options you don't include: Gchart.bar(:data => @data, :bar_width_and_spacing => {:width => 19}) Gchart.bar(:data => @data, :bar_width_and_spacing => {:spacing => 10, :group_spacing => 12}) Radar: ------------- In a Radar graph, the x-axis is circular. The points can be connected by straight lines or curved lines. Gchart.radar(:data => @data, :curved => true) Sparklines: ------------- A sparkline chart has exactly the same parameters as a line chart. The only difference is that the axes lines are not drawn for sparklines by default. Google-o-meter ------------- A Google-o-meter has a few restrictions. It may only use a solid filled background and it may only have one label. try yourself ------------- Gchart.bar( :data => [[1,2,4,67,100,41,234],[45,23,67,12,67,300, 250]], :title => 'SD Ruby Fu level', :legend => ['matt','patrick'], :bg => {:color => '76A4FB', :type => 'gradient'}, :bar_colors => 'ff0000,00ff00') "http://chart.apis.google.com/chart?chs=300x200&chdl=matt|patrick&chd=s:AAANUIv,JENCN9y&chtt=SDRuby+Fu+level&chf=bg,lg,0,76A4FB,0,ffffff,1&cht=bvs&chco=ff0000,00ff00" Gchart.pie(:data => [20,10,15,5,50], :title => 'SDRuby Fu level', :size => '400x200', :labels => ['matt', 'rob', 'patrick', 'ryan', 'jordan']) -http://chart.apis.google.com/chart?cht=p&chs=400x200&chd=s:YMSG9&chtt=SDRuby+Fu+level&chl=matt|rob|patrick|ryan|jordan - - -People reported using this gem: ---------------------- - -![github](http://img.skitch.com/20080627-r14subqdx2ye3w13qefbx974gc.png) - -* [http://github.com](http://github.com) - -![stafftool.com](http://stafftool.com/images/masthead_screen.gif) - -* [http://stafftool.com/](http://stafftool.com/) Takeo (contributor) - -![graffletopia.com](http://img.skitch.com/20080627-g2pp89h7gdbh15m1rr8hx48jep.jpg) - -* [graffleropia.com](http://graffletopia.com) Mokolabs (contributor) - -![gumgum](http://img.skitch.com/20080627-kc1weqsbkmxeqhwiyriq3n6g8k.jpg) - -* [http://gumgum.com](http://gumgum.com) Mattetti (Author) - -![http://img.skitch.com/20080627-n48j8pb2r7irsewfeh4yp3da12.jpg] - -* [http://feedflix.com/](http://feedflix.com/) [lifehacker article](http://lifehacker.com/395610/feedflix-creates-detailed-charts-from-your-netflix-use) - -* [California State University, Chico](http://www.csuchico.edu/) +http://chart.apis.google.com/chart?cht=p&chs=400x200&chd=s:YMSG9&chtt=SDRuby+Fu+level&chl=matt|rob|patrick|ryan|jordan \ No newline at end of file diff --git a/README.txt b/README.txt index fdfe9df..412aa74 100644 --- a/README.txt +++ b/README.txt @@ -1,9 +1,3 @@ CHECK README.markdown (open as a text file) -Or check: - - http://googlecharts.rubyforge.org - -and/or - - http://github.com/mattetti/googlecharts \ No newline at end of file +http://github.com/mattetti/googlecharts \ No newline at end of file diff --git a/Rakefile b/Rakefile index ed8e901..441aae2 100644 --- a/Rakefile +++ b/Rakefile @@ -1,20 +1 @@ -require 'rubygems' -require 'rake' - -begin - require 'jeweler' - Jeweler::Tasks.new do |gemspec| - gemspec.name = "googlecharts" - gemspec.summary = "Generate charts using Google API & Ruby" - gemspec.description = "Generate charts using Google API & Ruby" - gemspec.email = "[email protected]" - gemspec.homepage = "http://googlecharts.rubyforge.org/" - gemspec.authors = ["Matt Aimonetti"] - end - Jeweler::GemcutterTasks.new -rescue LoadError - puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com" -end - -Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext } - +require 'rubygems' \ No newline at end of file diff --git a/googlecharts.gemspec b/googlecharts.gemspec index 0c6a36e..9b9e14f 100644 --- a/googlecharts.gemspec +++ b/googlecharts.gemspec @@ -1,71 +1,20 @@ -# Generated by jeweler -# DO NOT EDIT THIS FILE DIRECTLY -# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- +$:.push File.expand_path("../lib", __FILE__) +require "gchart/version" Gem::Specification.new do |s| s.name = %q{googlecharts} - s.version = "1.6.5" - - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.version = GchartInfo::VERSION + s.platform = Gem::Platform::RUBY s.authors = ["Matt Aimonetti"] - s.date = %q{2011-05-16} + s.date = %q{2011-05-21} + s.summary = %q{Generate charts using Google API & Ruby} s.description = %q{Generate charts using Google API & Ruby} s.email = %q{[email protected]} - s.extra_rdoc_files = [ - "README", - "README.markdown", - "README.txt" - ] - s.files = [ - "History.txt", - "License.txt", - "Manifest.txt", - "README", - "README.markdown", - "README.txt", - "Rakefile", - "VERSION", - "config/hoe.rb", - "config/requirements.rb", - "googlecharts.gemspec", - "lib/gchart.rb", - "lib/gchart/aliases.rb", - "lib/gchart/theme.rb", - "lib/gchart/version.rb", - "lib/googlecharts.rb", - "lib/themes.yml", - "script/destroy", - "script/generate", - "script/txt2html", - "setup.rb", - "spec/fixtures/another_test_theme.yml", - "spec/fixtures/test_theme.yml", - "spec/gchart_spec.rb", - "spec/spec_helper.rb", - "spec/theme_spec.rb", - "tasks/deployment.rake", - "tasks/environment.rake", - "tasks/rspec.rake", - "tasks/website.rake", - "website/index.html", - "website/index.txt", - "website/javascripts/rounded_corners_lite.inc.js", - "website/stylesheets/screen.css", - "website/template.rhtml" - ] - s.homepage = %q{http://googlecharts.rubyforge.org/} - s.require_paths = ["lib"] - s.rubygems_version = %q{1.3.7} - s.summary = %q{Generate charts using Google API & Ruby} + s.homepage = %q{http://github.com/aderyabin/zendesk} - if s.respond_to? :specification_version then - s.specification_version = 3 - - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - else - end - else - end + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") + s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } + s.require_paths = ["lib"] end - diff --git a/lib/gchart/version.rb b/lib/gchart/version.rb index f2cbe72..62b747d 100644 --- a/lib/gchart/version.rb +++ b/lib/gchart/version.rb @@ -1,9 +1,3 @@ module GchartInfo #:nodoc: - module VERSION #:nodoc: - MAJOR = 1 - MINOR = 6 - TINY = 2 - - STRING = [MAJOR, MINOR, TINY].join('.') - end + VERSION = "1.6.5" end
mattetti/googlecharts
4d8cc16c545783b5ec57d23f8c0dc098e9565485
Version bump to 1.6.5
diff --git a/VERSION b/VERSION index 6463e95..49ebdd6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.6.4 \ No newline at end of file +1.6.5 \ No newline at end of file diff --git a/googlecharts.gemspec b/googlecharts.gemspec index 1080d20..0c6a36e 100644 --- a/googlecharts.gemspec +++ b/googlecharts.gemspec @@ -1,71 +1,71 @@ # Generated by jeweler # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = %q{googlecharts} - s.version = "1.6.4" + s.version = "1.6.5" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Matt Aimonetti"] - s.date = %q{2011-05-15} + s.date = %q{2011-05-16} s.description = %q{Generate charts using Google API & Ruby} s.email = %q{[email protected]} s.extra_rdoc_files = [ "README", "README.markdown", "README.txt" ] s.files = [ "History.txt", "License.txt", "Manifest.txt", "README", "README.markdown", "README.txt", "Rakefile", "VERSION", "config/hoe.rb", "config/requirements.rb", "googlecharts.gemspec", "lib/gchart.rb", "lib/gchart/aliases.rb", "lib/gchart/theme.rb", "lib/gchart/version.rb", "lib/googlecharts.rb", "lib/themes.yml", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "spec/fixtures/another_test_theme.yml", "spec/fixtures/test_theme.yml", "spec/gchart_spec.rb", "spec/spec_helper.rb", "spec/theme_spec.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/rspec.rake", "tasks/website.rake", "website/index.html", "website/index.txt", "website/javascripts/rounded_corners_lite.inc.js", "website/stylesheets/screen.css", "website/template.rhtml" ] s.homepage = %q{http://googlecharts.rubyforge.org/} s.require_paths = ["lib"] s.rubygems_version = %q{1.3.7} s.summary = %q{Generate charts using Google API & Ruby} if s.respond_to? :specification_version then s.specification_version = 3 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then else end else end end
mattetti/googlecharts
50c214e8c57700f1ca40731f31088702d361d7f8
Added SSL support. Closes #33
diff --git a/lib/gchart.rb b/lib/gchart.rb index a22848d..8ea4488 100644 --- a/lib/gchart.rb +++ b/lib/gchart.rb @@ -1,706 +1,714 @@ $:.unshift File.dirname(__FILE__) require 'gchart/version' require 'gchart/theme' require "net/http" +require "net/https" require "uri" require "cgi" require 'enumerator' class Gchart include GchartInfo - def self.url - "http://chart.apis.google.com/chart?" + def self.url(use_ssl = false) + if use_ssl + 'https://www.google.com/chart?' + else + 'http://chart.apis.google.com/chart?' + end end def self.types @types ||= ['line', 'line_xy', 'scatter', 'bar', 'venn', 'pie', 'pie_3d', 'jstize', 'sparkline', 'meter', 'map', 'radar'] end def self.simple_chars @simple_chars ||= ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a end def self.chars @chars ||= simple_chars + ['-', '.'] end def self.ext_pairs @ext_pairs ||= chars.map { |char_1| chars.map { |char_2| char_1 + char_2 } }.flatten end def self.default_filename 'chart.png' end attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :legend, :legend_position, :labels, :data, :encoding, :bar_colors, :title_color, :title_size, :custom, :axis_with_labels, :axis_labels, :bar_width_and_spacing, :id, :alt, :klass, :range_markers, :geographical_area, :map_colors, :country_codes, :axis_range, :filename, :min, :max, :colors, :usemap - attr_accessor :bg_type, :bg_color, :bg_angle, :chart_type, :chart_color, :chart_angle, :axis_range, :thickness, :new_markers, :grid_lines + attr_accessor :bg_type, :bg_color, :bg_angle, :chart_type, :chart_color, :chart_angle, :axis_range, :thickness, :new_markers, :grid_lines, :use_ssl attr_accessor :min_value, :max_value types.each do |type| instance_eval <<-DYNCLASSMETH def #{type}(options = {}) # Start with theme defaults if a theme is set theme = options[:theme] options = theme ? Chart::Theme.load(theme).to_options.merge(options) : options # # Extract the format and optional filename, then clean the hash format = options[:format] || 'url' options[:filename] ||= default_filename options.delete(:format) #update map_colors to become bar_colors options.update(:bar_colors => options[:map_colors]) if options.has_key?(:map_colors) chart = new(options.merge!({:type => "#{type}"})) chart.send(format) end DYNCLASSMETH end def self.version VERSION::STRING end def self.method_missing(m, options={}) raise NoMethodError, "#{m} is not a supported chart format. Please use one of the following: #{supported_types}." end def initialize(options={}) @type = options[:type] || 'line' @data = [] @width = 300 @height = 200 @curved = false @horizontal = false @grouped = false + @use_ssl = false @encoding = 'simple' # @max_value = 'auto' # @min_value defaults to nil meaning zero @filename = options[:filename] # Sets the alt tag when chart is exported as image tag @alt = 'Google Chart' # Sets the CSS id selector when chart is exported as image tag @id = false # Sets the CSS class selector when chart is exported as image tag @klass = options[:class] || false # set the options value if definable options.each do |attribute, value| send("#{attribute}=", value) if self.respond_to?("#{attribute}=") end end def self.supported_types self.types.join(' ') end # Defines the Graph size using the following format: # width X height def size=(size='300x200') @width, @height = size.split("x").map { |dimension| dimension.to_i } end def size "#{width}x#{height}" end def dimensions # TODO: maybe others? [:line_xy, :scatter].include?(type) ? 2 : 1 end # Sets the orientation of a bar graph def orientation=(orientation='h') if orientation == 'h' || orientation == 'horizontal' self.horizontal = true elsif orientation == 'v' || orientation == 'vertical' self.horizontal = false end end # Sets the bar graph presentation (stacked or grouped) def stacked=(option=true) @grouped = option ? false : true end def bg=(options) if options.is_a?(String) @bg_color = options elsif options.is_a?(Hash) @bg_color = options[:color] @bg_type = options[:type] @bg_angle = options[:angle] end end def graph_bg=(options) if options.is_a?(String) @chart_color = options elsif options.is_a?(Hash) @chart_color = options[:color] @chart_type = options[:type] @chart_angle = options[:angle] end end def max_value=(max_v) if max_v =~ /false/ @max_value = false else @max_value = max_v end end def min_value=(min_v) if min_v =~ /false/ @min_value = false else @min_value = min_v end end # returns the full data range as an array # it also sets the data range if not defined def full_data_range(ds) return if max_value == false ds.each_with_index do |mds, mds_index| mds[:min_value] ||= min_value mds[:max_value] ||= max_value if mds_index == 0 && type.to_s == 'bar' # TODO: unless you specify a zero line (using chp or chds), # the min_value of a bar chart is always 0. #mds[:min_value] ||= mds[:data].first.to_a.compact.min mds[:min_value] ||= 0 end if (mds_index == 0 && type.to_s == 'bar' && !grouped && mds[:data].first.is_a?(Array)) totals = [] mds[:data].each do |l| l.each_with_index do |v, index| next if v.nil? totals[index] ||= 0 totals[index] += v end end mds[:max_value] ||= totals.compact.max else all = mds[:data].flatten.compact # default min value should be 0 unless set to auto if mds[:min_value] == 'auto' mds[:min_value] = all.min else min = all.min mds[:min_value] ||= (min && min < 0 ? min : 0) end mds[:max_value] ||= all.max end end unless axis_range @calculated_axis_range = true @axis_range = ds.map{|mds| [mds[:min_value], mds[:max_value]]} if dimensions == 1 && (type.to_s != 'bar' || horizontal) tmp = axis_range.fetch(0, []) @axis_range[0] = axis_range.fetch(1, []) @axis_range[1] = tmp end end # return [min, max] unless (min.nil? || max.nil?) # @max = (max_value.nil? || max_value == 'auto') ? ds.compact.map{|mds| mds.compact.max}.max : max_value # # if min_value.nil? # min_ds_value = ds.compact.map{|mds| mds.compact.min}.min || 0 # @min = (min_ds_value < 0) ? min_ds_value : 0 # else # @min = min_value == 'auto' ? ds.compact.map{|mds| mds.compact.min}.min || 0 : min_value # end # @axis_range = [[min,max]] end def dataset if @dataset @dataset else @dataset = convert_dataset(data || []) full_data_range(@dataset) # unless axis_range @dataset end end # Sets of data to handle multiple sets def datasets datasets = [] dataset.each do |d| if d[:data].first.is_a?(Array) datasets += d[:data] else datasets << d[:data] end end datasets end def self.jstize(string) # See http://github.com/mattetti/googlecharts/issues#issue/27 #URI.escape( string ).gsub("%7C", "|") # See discussion: http://github.com/mattetti/googlecharts/commit/9b5cfb93aa51aae06611057668e631cd515ec4f3#comment_51347 string.gsub(' ', '+').gsub(/\[|\{|\}|\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} #string.gsub(' ', '+').gsub(/\[|\{|\}|\||\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} end # load all the custom aliases require 'gchart/aliases' # Returns the chart's generated PNG as a blob. (borrowed from John's gchart.rubyforge.org) def fetch - url = URI.parse(self.class.url) + url = URI.parse(self.class.url(use_ssl)) req = Net::HTTP::Post.new(url.path) req.body = query_builder req.content_type = 'application/x-www-form-urlencoded' - Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }.body + http = Net::HTTP.new(url.host, url.port) + http.use_ssl = use_ssl + http.start {|resp| resp.request(req) }.body end # Writes the chart's generated PNG to a file. (borrowed from John's gchart.rubyforge.org) def write io_or_file = filename || self.class.default_filename return io_or_file.write(fetch) if io_or_file.respond_to?(:write) open(io_or_file, "wb+") { |io| io.write(fetch) } end # Format def image_tag image = "<img" image += " id=\"#{id}\"" if id image += " class=\"#{klass}\"" if klass image += " src=\"#{url_builder(:html)}\"" image += " width=\"#{width}\"" image += " height=\"#{height}\"" image += " alt=\"#{alt}\"" image += " title=\"#{title}\"" if title image += " usemap=\"#{usemap}\"" if usemap image += " />" end alias_method :img_tag, :image_tag def url url_builder end def file write end # def jstize(string) self.class.jstize(string) end private # The title size cannot be set without specifying a color. # A dark key will be used for the title color if no color is specified def set_title title_params = "chtt=#{title}" unless (title_color.nil? && title_size.nil? ) title_params << "&chts=" + (color, size = (title_color || '454545'), title_size).compact.join(',') end title_params end def set_size "chs=#{size}" end def set_data data = send("#{@encoding}_encoding") "chd=#{data}" end def set_colors @bg_type = fill_type(bg_type) || 's' if bg_color @chart_type = fill_type(chart_type) || 's' if chart_color "chf=" + {'bg' => fill_for(bg_type, bg_color, bg_angle), 'c' => fill_for(chart_type, chart_color, chart_angle)}.map{|k,v| "#{k},#{v}" unless v.nil?}.compact.join('|') end # set bar, line colors def set_bar_colors @bar_colors = bar_colors.join(',') if bar_colors.is_a?(Array) "chco=#{bar_colors}" end def set_country_codes @country_codes = country_codes.join() if country_codes.is_a?(Array) "chld=#{country_codes}" end # set bar spacing # chbh= # <bar width in pixels>, # <optional space between bars in a group>, # <optional space between groups> def set_bar_width_and_spacing width_and_spacing_values = case bar_width_and_spacing when String bar_width_and_spacing when Array bar_width_and_spacing.join(',') when Hash width = bar_width_and_spacing[:width] || 23 spacing = bar_width_and_spacing[:spacing] || 4 group_spacing = bar_width_and_spacing[:group_spacing] || 8 [width,spacing,group_spacing].join(',') else bar_width_and_spacing.to_s end "chbh=#{width_and_spacing_values}" end def set_range_markers markers = case range_markers when Hash set_range_marker(range_markers) when Array range_markers.collect{|marker| set_range_marker(marker)}.join('|') end "chm=#{markers}" end def set_range_marker(options) orientation = ['vertical', 'Vertical', 'V', 'v', 'R'].include?(options[:orientation]) ? 'R' : 'r' "#{orientation},#{options[:color]},0,#{options[:start_position]},#{options[:stop_position]}#{',1' if options[:overlaid?]}" end def fill_for(type=nil, color='', angle=nil) unless type.nil? case type when 'lg' angle ||= 0 color = "#{color},0,ffffff,1" if color.split(',').size == 1 "#{type},#{angle},#{color}" when 'ls' angle ||= 90 color = "#{color},0.2,ffffff,0.2" if color.split(',').size == 1 "#{type},#{angle},#{color}" else "#{type},#{color}" end end end # A chart can have one or many legends. # Gchart.line(:legend => 'label') # or # Gchart.line(:legend => ['first label', 'last label']) def set_legend if type.to_s =~ /meter/ @labels = legend return set_labels end if legend.is_a?(Array) "chdl=#{@legend.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chdl=#{legend}" end end def set_legend_position case @legend_position.to_s when /(bottom|b)$/ "chdlp=b" when /(bottom_vertical|bv)$/ "chdlp=bv" when /(top|t)$/ "chdlp=t" when /(top_vertical|tv)$/ "chdlp=tv" when /(right|r)$/ "chdlp=r" when /(left|l)$/ "chdlp=l" end end def set_line_thickness "chls=#{thickness}" end def set_line_markers "chm=#{new_markers}" end def set_grid_lines "chg=#{grid_lines}" end def set_labels if labels.is_a?(Array) "chl=#{@labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chl=#{@labels}" end end def set_axis_with_labels @axis_with_labels = axis_with_labels.join(',') if @axis_with_labels.is_a?(Array) "chxt=#{axis_with_labels}" end def set_axis_labels if axis_labels.is_a?(Array) if RUBY_VERSION.to_f < 1.9 labels_arr = axis_labels.enum_with_index.map{|labels,index| [index,labels]} else labels_arr = axis_labels.map.with_index.map{|labels,index| [index,labels]} end elsif axis_labels.is_a?(Hash) labels_arr = axis_labels.to_a end labels_arr.map! do |index,labels| if labels.is_a?(Array) "#{index}:|#{labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "#{index}:|#{labels}" end end "chxl=#{labels_arr.join('|')}" end # http://code.google.com/apis/chart/labels.html#axis_range # Specify a range for axis labels def set_axis_range # a passed axis_range should look like: # [[10,100]] or [[10,100,4]] or [[10,100], [20,300]] # in the second example, 4 is the interval set = @calculated_axis_range ? datasets : axis_range || datasets return unless set && set.respond_to?(:each) && set.find {|o| o}.respond_to?(:each) 'chxr=' + set.enum_for(:each_with_index).map do |axis_range, index| next nil if axis_range.nil? # ignore this axis min, max, step = axis_range if axis_range.size > 3 || step && max && step > max # this is a full series max = axis_range.compact.max step = nil end [index, (min_value || min || 0), (max_value || max), step].compact.join(',') end.compact.join("|") end def set_geographical_area "chtm=#{geographical_area}" end def set_type 'cht=' + case type.to_s when 'line' then "lc" when 'line_xy' then "lxy" when 'pie_3d' then "p3" when 'pie' then "p" when 'venn' then "v" when 'scatter' then "s" when 'sparkline' then "ls" when 'meter' then "gom" when 'map' then "t" when 'radar' "r" + (curved? ? 's' : '') when 'bar' "b" + (horizontal? ? "h" : "v") + (grouped? ? "g" : "s") end end def fill_type(type) case type when 'solid' then 's' when 'gradient' then 'lg' when 'stripes' then 'ls' end end def number_visible n = 0 dataset.each do |mds| return n.to_s if mds[:invisible] == true if mds[:data].first.is_a?(Array) n += mds[:data].length else n += 1 end end "" end # Turns input into an array of axis hashes, dependent on the chart type def convert_dataset(ds) if dimensions == 2 # valid inputs include: # an array of >=2 arrays, or an array of >=2 hashes ds = ds.map do |d| d.is_a?(Hash) ? d : {:data => d} end elsif dimensions == 1 # valid inputs include: # a hash, an array of data, an array of >=1 array, or an array of >=1 hash if ds.is_a?(Hash) ds = [ds] elsif not ds.first.is_a?(Hash) ds = [{:data => ds}] end end ds end # just an alias def axis_set dataset end def convert_to_simple_value(number) if number.nil? "_" else value = self.class.simple_chars[number.to_i] value.nil? ? "_" : value end end def convert_to_extended_value(number) if number.nil? '__' else value = self.class.ext_pairs[number.to_i] value.nil? ? "__" : value end end def encode_scaled_dataset(chars, nil_char) dsets = [] dataset.each do |ds| if max_value != false range = ds[:max_value] - ds[:min_value] range = 1 if range == 0 end unless ds[:data].first.is_a?(Array) ldatasets = [ds[:data]] else ldatasets = ds[:data] end ldatasets.each do |l| dsets << l.map do |number| if number.nil? nil_char else unless range.nil? || range.zero? number = chars.size * (number - ds[:min_value]) / range.to_f number = [number, chars.size - 1].min end chars[number.to_i] end end.join end end dsets.join(',') end # http://code.google.com/apis/chart/#simple # Simple encoding has a resolution of 62 different values. # Allowing five pixels per data point, this is sufficient for line and bar charts up # to about 300 pixels. Simple encoding is suitable for all other types of chart regardless of size. def simple_encoding "s" + number_visible + ":" + encode_scaled_dataset(self.class.simple_chars, '_') end # http://code.google.com/apis/chart/#text # Text encoding with data scaling lets you specify arbitrary positive or # negative floating point numbers, in combination with a scaling parameter # that lets you specify a custom range for your chart. This chart is useful # when you don't want to worry about limiting your data to a specific range, # or do the calculations to scale your data down or up to fit nicely inside # a chart. # # Valid values range from (+/-)9.999e(+/-)100, and only four non-zero digits are supported (that is, 123400, 1234, 12.34, and 0.1234 are valid, but 12345, 123.45 and 123400.5 are not). # # This encoding is not available for maps. # def text_encoding chds = dataset.map{|ds| "#{ds[:min_value]},#{ds[:max_value]}" }.join(",") "t" + number_visible + ":" + datasets.map{ |ds| ds.map{|e|e||'_'}.join(',') }.join('|') + "&chds=" + chds end # http://code.google.com/apis/chart/#extended # Extended encoding has a resolution of 4,096 different values # and is best used for large charts where a large data range is required. def extended_encoding "e" + number_visible + ":" + encode_scaled_dataset(self.class.ext_pairs, '__') end def url_builder(options="") - self.class.url + query_builder(options) + self.class.url(use_ssl) + query_builder(options) end def query_builder(options="") query_params = instance_variables.sort.map do |var| case var.to_s when '@data' set_data unless data == [] # Set the graph size when '@width' set_size unless width.nil? || height.nil? when '@type' set_type when '@title' set_title unless title.nil? when '@legend' set_legend unless legend.nil? when '@labels' set_labels unless labels.nil? when '@legend_position' set_legend_position unless legend_position.nil? when '@thickness' set_line_thickness when '@new_markers' set_line_markers when '@bg_color' set_colors when '@chart_color' set_colors if bg_color.nil? when '@bar_colors' set_bar_colors when '@bar_width_and_spacing' set_bar_width_and_spacing when '@axis_with_labels' set_axis_with_labels when '@axis_labels' set_axis_labels when '@range_markers' set_range_markers when '@grid_lines' set_grid_lines when '@geographical_area' set_geographical_area when '@country_codes' set_country_codes when '@custom' custom end end.compact query_params << set_axis_range # Use ampersand as default delimiter unless options == :html delimiter = '&' # Escape ampersand for html image tags else delimiter = '&amp;' end jstize(query_params.join(delimiter)) end end diff --git a/spec/gchart_spec.rb b/spec/gchart_spec.rb index 7afbcb7..48624aa 100644 --- a/spec/gchart_spec.rb +++ b/spec/gchart_spec.rb @@ -154,512 +154,525 @@ describe "generating a default Gchart" do :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,16|1,0,16') # nil means ignore axis labeled_bar( :axis_range => [nil,[0,16]] ).should include('chxr=1,0,16') # empty array means take defaults labeled_bar( :max_value => 16, :axis_range => [[],[0,16]] ).should include('chxr=0,0,16|1,0,16') labeled_bar( :axis_range => [[],[0,16]] ).should include('chxr=0,0|1,0,16') Gchart.line( :data => [0,20, 40, 60, 140, 230, 60], :axis_with_labels => 'y').should include("chxr=0,0,230") end it "should take in consideration the max value when creating a range" do data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] url = Gchart.line(:data => data, :axis_with_labels => 'x,y', :axis_labels => [((1..24).to_a << 1)], :max_value => 700) url.should include('chxr=0,85,700') end it 'should generate different labels and legend' do Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three)).should(include('chdl=1|2|3') && include('chl=one|two|three')) end end describe "generating different type of charts" do it "should be able to generate a line chart" do Gchart.line.should be_an_instance_of(String) Gchart.line.include?('cht=lc').should be_true end it "should be able to generate a sparkline chart" do Gchart.sparkline.should be_an_instance_of(String) Gchart.sparkline.include?('cht=ls').should be_true end it "should be able to generate a line xy chart" do Gchart.line_xy.should be_an_instance_of(String) Gchart.line_xy.include?('cht=lxy').should be_true end it "should be able to generate a scatter chart" do Gchart.scatter.should be_an_instance_of(String) Gchart.scatter.include?('cht=s').should be_true end it "should be able to generate a bar chart" do Gchart.bar.should be_an_instance_of(String) Gchart.bar.include?('cht=bvs').should be_true end it "should be able to generate a Venn diagram" do Gchart.venn.should be_an_instance_of(String) Gchart.venn.include?('cht=v').should be_true end it "should be able to generate a Pie Chart" do Gchart.pie.should be_an_instance_of(String) Gchart.pie.include?('cht=p').should be_true end it "should be able to generate a Google-O-Meter" do Gchart.meter.should be_an_instance_of(String) Gchart.meter.include?('cht=gom').should be_true end it "should be able to generate a map chart" do Gchart.map.should be_an_instance_of(String) Gchart.map.include?('cht=t').should be_true end it "should not support other types" do msg = "sexy is not a supported chart format. Please use one of the following: #{Gchart.supported_types}." lambda{Gchart.sexy}.should raise_error(NoMethodError) end end describe "range markers" do it "should be able to generate given a hash of range-marker options" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}).include?('chm=r,ff0000,0,0.59,0.61').should be_true end it "should be able to generate given an array of range-marker hash options" do Gchart.line(:range_markers => [ {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}, {:start_position => 0, :stop_position => 0.6, :color => '666666'}, {:color => 'cccccc', :start_position => 0.6, :stop_position => 1} ]).include?(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1')).should be_true end it "should allow a :overlaid? to be set" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true}).include?('chm=r,ffffff,0,0.59,0.61,1').should be_true Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false}).include?('chm=r,ffffff,0,0.59,0.61').should be_true end describe "when setting the orientation option" do before(:each) do @options = {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'} end it "to vertical (R) if given a valid option" do Gchart.line(:range_markers => @options.merge(:orientation => 'v')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'V')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'R')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'vertical')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical')).include?('chm=R').should be_true end it "to horizontal (r) if given a valid option (actually anything other than the vertical options)" do Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal')).include?('chm=r').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'h')).include?('chm=r').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'etc')).include?('chm=r').should be_true end it "if left blank defaults to horizontal (r)" do Gchart.line(:range_markers => @options).include?('chm=r').should be_true end end end describe "a bar graph" do it "should have a default vertical orientation" do Gchart.bar.include?('cht=bvs').should be_true end it "should be able to have a different orientation" do Gchart.bar(:orientation => 'vertical').include?('cht=bvs').should be_true Gchart.bar(:orientation => 'v').include?('cht=bvs').should be_true Gchart.bar(:orientation => 'h').include?('cht=bhs').should be_true Gchart.bar(:orientation => 'horizontal').include?('cht=bhs').should be_true Gchart.bar(:horizontal => false).include?('cht=bvs').should be_true end it "should be set to be stacked by default" do Gchart.bar.include?('cht=bvs').should be_true end it "should be able to stacked or grouped" do Gchart.bar(:stacked => true).include?('cht=bvs').should be_true Gchart.bar(:stacked => false).include?('cht=bvg').should be_true Gchart.bar(:grouped => true).include?('cht=bvg').should be_true Gchart.bar(:grouped => false).include?('cht=bvs').should be_true end it "should be able to have different bar colors" do Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=').should be_true Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=efefef,00ffff').should be_true # alias Gchart.bar(:bar_color => 'efefef').include?('chco=efefef').should be_true end it "should be able to have different bar colors when using an array of colors" do Gchart.bar(:bar_colors => ['efefef','00ffff']).include?('chco=efefef,00ffff').should be_true end it 'should be able to accept a string of width and spacing options' do Gchart.bar(:bar_width_and_spacing => '25,6').include?('chbh=25,6').should be_true end it 'should be able to accept a single fixnum width and spacing option to set the bar width' do Gchart.bar(:bar_width_and_spacing => 25).include?('chbh=25').should be_true end it 'should be able to accept an array of width and spacing options' do Gchart.bar(:bar_width_and_spacing => [25,6,12]).include?('chbh=25,6,12').should be_true Gchart.bar(:bar_width_and_spacing => [25,6]).include?('chbh=25,6').should be_true Gchart.bar(:bar_width_and_spacing => [25]).include?('chbh=25').should be_true end describe "with a hash of width and spacing options" do before(:each) do @default_width = 23 @default_spacing = 4 @default_group_spacing = 8 end it 'should be able to have a custom bar width' do Gchart.bar(:bar_width_and_spacing => {:width => 19}).include?("chbh=19,#{@default_spacing},#{@default_group_spacing}").should be_true end it 'should be able to have custom spacing' do Gchart.bar(:bar_width_and_spacing => {:spacing => 19}).include?("chbh=#{@default_width},19,#{@default_group_spacing}").should be_true end it 'should be able to have custom group spacing' do Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19}).include?("chbh=#{@default_width},#{@default_spacing},19").should be_true end end end describe "a line chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @chart = Gchart.line(:title => @title, :legend => @legend) end it 'should be able have a chart title' do @chart.include?("chtt=Chart+Title").should be_true end it "should be able to a custom color and size title" do Gchart.line(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true Gchart.line(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true end it "should be able to have multiple legends" do @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true end it "should escape text values in url" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend) chart.include?(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")).should be_true end it "should be able to have one legend" do chart = Gchart.line(:legend => 'legend label') chart.include?("chdl=legend+label").should be_true end it "should be able to set the position of the legend" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend, :legend_position => :bottom_vertical) puts chart.inspect chart.include?("chdlp=bv").should be_true chart = Gchart.line(:title => title, :legend => legend, :legend_position => 'r') chart.include?("chdlp=r").should be_true end it "should be able to set the background fill" do Gchart.line(:bg => 'efefef').should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=bg,lg,90,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'}).should include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do Gchart.line(:graph_bg => 'efefef').should include("chf=c,s,efefef") Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true end it "should be able to set both a graph and a background fill" do Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true if RUBY_VERSION.to_f < 1.9 Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true else Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true end end it "should be able to have different line colors" do Gchart.line(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true Gchart.line(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true end it "should be able to render a graph where all the data values are 0" do Gchart.line(:data => [0, 0, 0]).should include("chd=s:AAA") end end describe "a sparkline chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [27,25,25,25,25,27,100,31,25,36,25,25,39,25,31,25,25,25,26,26,25,25,28,25,25,100,28,27,31,25,27,27,29,25,27,26,26,25,26,26,35,33,34,25,26,25,36,25,26,37,33,33,37,37,39,25,25,25,25] @chart = Gchart.sparkline(:title => @title, :data => @data, :legend => @legend) end it "should create a sparkline" do @chart.include?('cht=ls').should be_true end it 'should be able have a chart title' do @chart.include?("chtt=Chart+Title").should be_true end it "should be able to a custom color and size title" do Gchart.sparkline(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true Gchart.sparkline(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true end it "should be able to have multiple legends" do @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true end it "should be able to have one legend" do chart = Gchart.sparkline(:legend => 'legend label') chart.include?("chdl=legend+label").should be_true end it "should be able to set the background fill" do Gchart.sparkline(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=bg,lg,90,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'}).include?("chf=bg,ls,90,efefef,0.2,ffffff,0.2").should be_true end it "should be able to set a graph fill" do Gchart.sparkline(:graph_bg => 'efefef').include?("chf=c,s,efefef").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true end it "should be able to set both a graph and a background fill" do Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true if RUBY_VERSION.to_f < 1.9 Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true else Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true end end it "should be able to have different line colors" do Gchart.sparkline(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true Gchart.sparkline(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true end end describe "a 3d pie chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [12,8,40,15,5] @chart = Gchart.pie(:title => @title, :legend => @legend, :data => @data) end it "should create a pie" do @chart.include?('cht=p').should be_true end it "should be able to be in 3d" do Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data).include?('cht=p3').should be_true end end describe "a google-o-meter" do before(:each) do @data = [70] @legend = ['arrow points here'] @jstized_legend = Gchart.jstize(@legend.join('|')) @chart = Gchart.meter(:data => @data) end it "should create a meter" do @chart.include?('cht=gom').should be_true end it "should be able to set a solid background fill" do Gchart.meter(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true end it "should be able to set labels by using the legend or labesl accessor" do Gchart.meter(:title => @title, :labels => @legend, :data => @data).should include("chl=#{@jstized_legend}") Gchart.meter(:title => @title, :labels => @legend, :data => @data).should == Gchart.meter(:title => @title, :legend => @legend, :data => @data) end end describe "a map chart" do before(:each) do @data = [0,100,50,32] @geographical_area = 'usa' @map_colors = ['FFFFFF', 'FF0000', 'FFFF00', '00FF00'] @country_codes = ['MT', 'WY', "ID", 'SD'] @chart = Gchart.map(:data => @data, :encoding => 'text', :size => '400x300', :geographical_area => @geographical_area, :map_colors => @map_colors, :country_codes => @country_codes) end it "should create a map" do @chart.include?('cht=t').should be_true end it "should set the geographical area" do @chart.include?('chtm=usa').should be_true end it "should set the map colors" do @chart.include?('chco=FFFFFF,FF0000,FFFF00,00FF00').should be_true end it "should set the country/state codes" do @chart.include?('chld=MTWYIDSD').should be_true end it "should set the chart data" do @chart.include?('chd=t:0,100,50,32').should be_true end end describe 'exporting a chart' do it "should be available in the url format by default" do Gchart.line(:data => [0, 26], :format => 'url').should == Gchart.line(:data => [0, 26]) end it "should be available as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using img_tag alias" do Gchart.line(:data => [0, 26], :format => 'img_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom dimensions" do Gchart.line(:data => [0, 26], :format => 'image_tag', :size => '400x400').should match(/<img src=(.*) width="400" height="400" alt="Google Chart" \/>/) end it "should be available as an image tag using custom alt text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :alt => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Sexy chart" \/>/) end it "should be available as an image tag using custom title text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :title => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" title="Sexy chart" \/>/) end it "should be available as an image tag using custom css id selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :id => 'chart').should match(/<img id="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom css class selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should match(/<img class="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should use ampersands to separate key/value pairs in URLs by default" do Gchart.line(:data => [0, 26]).should satisfy {|chart| chart.include? "&" } Gchart.line(:data => [0, 26]).should_not satisfy {|chart| chart.include? "&amp;" } end it "should escape ampersands in URLs when used as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should satisfy {|chart| chart.include? "&amp;" } end it "should be available as a file" do File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file') File.exist?('chart.png').should be_true File.delete('chart.png') if File.exist?('chart.png') end it "should be available as a file using a custom file name" do File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') Gchart.line(:data => [0, 26], :format => 'file', :filename => 'custom_file_name.png') File.exist?('custom_file_name.png').should be_true File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') end it "should work even with multiple attrs" do File.delete('foo.png') if File.exist?('foo.png') Gchart.line(:size => '400x200', :data => [1,2,3,4,5], # :axis_labels => [[1,2,3,4, 5], %w[foo bar]], :axis_with_labels => 'x,r', :format => "file", :filename => "foo.png" ) File.exist?('foo.png').should be_true File.delete('foo.png') if File.exist?('foo.png') end end + +describe 'SSL support' do + it 'should change url if is presented' do + Gchart.line(:use_ssl => true).should include('https://www.google.com/chart?') + end + + it "should be available as a file" do + File.delete('chart.png') if File.exist?('chart.png') + Gchart.line(:data => [0, 26], :format => 'file', :use_ssl => true) + File.exist?('chart.png').should be_true + File.delete('chart.png') if File.exist?('chart.png') + end +end
mattetti/googlecharts
963884139519c8745024951f7fe0cbb06cd1cf7e
Version bump to 1.6.4
diff --git a/VERSION b/VERSION index f5d2a58..6463e95 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.6.3 \ No newline at end of file +1.6.4 \ No newline at end of file diff --git a/googlecharts.gemspec b/googlecharts.gemspec index e420d01..1080d20 100644 --- a/googlecharts.gemspec +++ b/googlecharts.gemspec @@ -1,71 +1,71 @@ # Generated by jeweler # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = %q{googlecharts} - s.version = "1.6.3" + s.version = "1.6.4" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Matt Aimonetti"] - s.date = %q{2011-05-05} + s.date = %q{2011-05-15} s.description = %q{Generate charts using Google API & Ruby} s.email = %q{[email protected]} s.extra_rdoc_files = [ "README", "README.markdown", "README.txt" ] s.files = [ "History.txt", "License.txt", "Manifest.txt", "README", "README.markdown", "README.txt", "Rakefile", "VERSION", "config/hoe.rb", "config/requirements.rb", "googlecharts.gemspec", "lib/gchart.rb", "lib/gchart/aliases.rb", "lib/gchart/theme.rb", "lib/gchart/version.rb", "lib/googlecharts.rb", "lib/themes.yml", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "spec/fixtures/another_test_theme.yml", "spec/fixtures/test_theme.yml", "spec/gchart_spec.rb", "spec/spec_helper.rb", "spec/theme_spec.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/rspec.rake", "tasks/website.rake", "website/index.html", "website/index.txt", "website/javascripts/rounded_corners_lite.inc.js", "website/stylesheets/screen.css", "website/template.rhtml" ] s.homepage = %q{http://googlecharts.rubyforge.org/} s.require_paths = ["lib"] s.rubygems_version = %q{1.3.7} s.summary = %q{Generate charts using Google API & Ruby} if s.respond_to? :specification_version then s.specification_version = 3 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then else end else end end
mattetti/googlecharts
b991a2f7ba49ca6cf234f50db9050ea5c72857f4
Fixed legend position value Fixed test
diff --git a/lib/gchart.rb b/lib/gchart.rb index f0cfa1b..a22848d 100644 --- a/lib/gchart.rb +++ b/lib/gchart.rb @@ -1,706 +1,706 @@ $:.unshift File.dirname(__FILE__) require 'gchart/version' require 'gchart/theme' require "net/http" require "uri" require "cgi" require 'enumerator' class Gchart include GchartInfo def self.url "http://chart.apis.google.com/chart?" end def self.types @types ||= ['line', 'line_xy', 'scatter', 'bar', 'venn', 'pie', 'pie_3d', 'jstize', 'sparkline', 'meter', 'map', 'radar'] end def self.simple_chars @simple_chars ||= ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a end def self.chars @chars ||= simple_chars + ['-', '.'] end def self.ext_pairs @ext_pairs ||= chars.map { |char_1| chars.map { |char_2| char_1 + char_2 } }.flatten end def self.default_filename 'chart.png' end attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :legend, :legend_position, :labels, :data, :encoding, :bar_colors, :title_color, :title_size, :custom, :axis_with_labels, :axis_labels, :bar_width_and_spacing, :id, :alt, :klass, :range_markers, :geographical_area, :map_colors, :country_codes, :axis_range, :filename, :min, :max, :colors, :usemap attr_accessor :bg_type, :bg_color, :bg_angle, :chart_type, :chart_color, :chart_angle, :axis_range, :thickness, :new_markers, :grid_lines attr_accessor :min_value, :max_value types.each do |type| instance_eval <<-DYNCLASSMETH def #{type}(options = {}) # Start with theme defaults if a theme is set theme = options[:theme] options = theme ? Chart::Theme.load(theme).to_options.merge(options) : options # # Extract the format and optional filename, then clean the hash format = options[:format] || 'url' options[:filename] ||= default_filename options.delete(:format) #update map_colors to become bar_colors options.update(:bar_colors => options[:map_colors]) if options.has_key?(:map_colors) chart = new(options.merge!({:type => "#{type}"})) chart.send(format) end DYNCLASSMETH end def self.version VERSION::STRING end def self.method_missing(m, options={}) raise NoMethodError, "#{m} is not a supported chart format. Please use one of the following: #{supported_types}." end def initialize(options={}) @type = options[:type] || 'line' @data = [] @width = 300 @height = 200 @curved = false @horizontal = false @grouped = false @encoding = 'simple' # @max_value = 'auto' # @min_value defaults to nil meaning zero @filename = options[:filename] # Sets the alt tag when chart is exported as image tag @alt = 'Google Chart' # Sets the CSS id selector when chart is exported as image tag @id = false # Sets the CSS class selector when chart is exported as image tag @klass = options[:class] || false # set the options value if definable options.each do |attribute, value| send("#{attribute}=", value) if self.respond_to?("#{attribute}=") end end def self.supported_types self.types.join(' ') end # Defines the Graph size using the following format: # width X height def size=(size='300x200') @width, @height = size.split("x").map { |dimension| dimension.to_i } end def size "#{width}x#{height}" end def dimensions # TODO: maybe others? [:line_xy, :scatter].include?(type) ? 2 : 1 end # Sets the orientation of a bar graph def orientation=(orientation='h') if orientation == 'h' || orientation == 'horizontal' self.horizontal = true elsif orientation == 'v' || orientation == 'vertical' self.horizontal = false end end # Sets the bar graph presentation (stacked or grouped) def stacked=(option=true) @grouped = option ? false : true end def bg=(options) if options.is_a?(String) @bg_color = options elsif options.is_a?(Hash) @bg_color = options[:color] @bg_type = options[:type] @bg_angle = options[:angle] end end def graph_bg=(options) if options.is_a?(String) @chart_color = options elsif options.is_a?(Hash) @chart_color = options[:color] @chart_type = options[:type] @chart_angle = options[:angle] end end def max_value=(max_v) if max_v =~ /false/ @max_value = false else @max_value = max_v end end def min_value=(min_v) if min_v =~ /false/ @min_value = false else @min_value = min_v end end # returns the full data range as an array # it also sets the data range if not defined def full_data_range(ds) return if max_value == false ds.each_with_index do |mds, mds_index| mds[:min_value] ||= min_value mds[:max_value] ||= max_value if mds_index == 0 && type.to_s == 'bar' # TODO: unless you specify a zero line (using chp or chds), # the min_value of a bar chart is always 0. #mds[:min_value] ||= mds[:data].first.to_a.compact.min mds[:min_value] ||= 0 end if (mds_index == 0 && type.to_s == 'bar' && !grouped && mds[:data].first.is_a?(Array)) totals = [] mds[:data].each do |l| l.each_with_index do |v, index| next if v.nil? totals[index] ||= 0 totals[index] += v end end mds[:max_value] ||= totals.compact.max else all = mds[:data].flatten.compact # default min value should be 0 unless set to auto if mds[:min_value] == 'auto' mds[:min_value] = all.min else min = all.min mds[:min_value] ||= (min && min < 0 ? min : 0) end mds[:max_value] ||= all.max end end unless axis_range @calculated_axis_range = true @axis_range = ds.map{|mds| [mds[:min_value], mds[:max_value]]} if dimensions == 1 && (type.to_s != 'bar' || horizontal) tmp = axis_range.fetch(0, []) @axis_range[0] = axis_range.fetch(1, []) @axis_range[1] = tmp end end # return [min, max] unless (min.nil? || max.nil?) # @max = (max_value.nil? || max_value == 'auto') ? ds.compact.map{|mds| mds.compact.max}.max : max_value # # if min_value.nil? # min_ds_value = ds.compact.map{|mds| mds.compact.min}.min || 0 # @min = (min_ds_value < 0) ? min_ds_value : 0 # else # @min = min_value == 'auto' ? ds.compact.map{|mds| mds.compact.min}.min || 0 : min_value # end # @axis_range = [[min,max]] end def dataset if @dataset @dataset else @dataset = convert_dataset(data || []) full_data_range(@dataset) # unless axis_range @dataset end end # Sets of data to handle multiple sets def datasets datasets = [] dataset.each do |d| if d[:data].first.is_a?(Array) datasets += d[:data] else datasets << d[:data] end end datasets end def self.jstize(string) # See http://github.com/mattetti/googlecharts/issues#issue/27 #URI.escape( string ).gsub("%7C", "|") # See discussion: http://github.com/mattetti/googlecharts/commit/9b5cfb93aa51aae06611057668e631cd515ec4f3#comment_51347 string.gsub(' ', '+').gsub(/\[|\{|\}|\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} #string.gsub(' ', '+').gsub(/\[|\{|\}|\||\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} end # load all the custom aliases require 'gchart/aliases' # Returns the chart's generated PNG as a blob. (borrowed from John's gchart.rubyforge.org) def fetch url = URI.parse(self.class.url) req = Net::HTTP::Post.new(url.path) req.body = query_builder req.content_type = 'application/x-www-form-urlencoded' Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }.body end # Writes the chart's generated PNG to a file. (borrowed from John's gchart.rubyforge.org) def write io_or_file = filename || self.class.default_filename return io_or_file.write(fetch) if io_or_file.respond_to?(:write) open(io_or_file, "wb+") { |io| io.write(fetch) } end # Format def image_tag image = "<img" image += " id=\"#{id}\"" if id image += " class=\"#{klass}\"" if klass image += " src=\"#{url_builder(:html)}\"" image += " width=\"#{width}\"" image += " height=\"#{height}\"" image += " alt=\"#{alt}\"" image += " title=\"#{title}\"" if title image += " usemap=\"#{usemap}\"" if usemap image += " />" end alias_method :img_tag, :image_tag def url url_builder end def file write end # def jstize(string) self.class.jstize(string) end private # The title size cannot be set without specifying a color. # A dark key will be used for the title color if no color is specified def set_title title_params = "chtt=#{title}" unless (title_color.nil? && title_size.nil? ) title_params << "&chts=" + (color, size = (title_color || '454545'), title_size).compact.join(',') end title_params end def set_size "chs=#{size}" end def set_data data = send("#{@encoding}_encoding") "chd=#{data}" end def set_colors @bg_type = fill_type(bg_type) || 's' if bg_color @chart_type = fill_type(chart_type) || 's' if chart_color "chf=" + {'bg' => fill_for(bg_type, bg_color, bg_angle), 'c' => fill_for(chart_type, chart_color, chart_angle)}.map{|k,v| "#{k},#{v}" unless v.nil?}.compact.join('|') end # set bar, line colors def set_bar_colors @bar_colors = bar_colors.join(',') if bar_colors.is_a?(Array) "chco=#{bar_colors}" end def set_country_codes @country_codes = country_codes.join() if country_codes.is_a?(Array) "chld=#{country_codes}" end # set bar spacing # chbh= # <bar width in pixels>, # <optional space between bars in a group>, # <optional space between groups> def set_bar_width_and_spacing width_and_spacing_values = case bar_width_and_spacing when String bar_width_and_spacing when Array bar_width_and_spacing.join(',') when Hash width = bar_width_and_spacing[:width] || 23 spacing = bar_width_and_spacing[:spacing] || 4 group_spacing = bar_width_and_spacing[:group_spacing] || 8 [width,spacing,group_spacing].join(',') else bar_width_and_spacing.to_s end "chbh=#{width_and_spacing_values}" end def set_range_markers markers = case range_markers when Hash set_range_marker(range_markers) when Array range_markers.collect{|marker| set_range_marker(marker)}.join('|') end "chm=#{markers}" end def set_range_marker(options) orientation = ['vertical', 'Vertical', 'V', 'v', 'R'].include?(options[:orientation]) ? 'R' : 'r' "#{orientation},#{options[:color]},0,#{options[:start_position]},#{options[:stop_position]}#{',1' if options[:overlaid?]}" end def fill_for(type=nil, color='', angle=nil) unless type.nil? case type when 'lg' angle ||= 0 color = "#{color},0,ffffff,1" if color.split(',').size == 1 "#{type},#{angle},#{color}" when 'ls' angle ||= 90 color = "#{color},0.2,ffffff,0.2" if color.split(',').size == 1 "#{type},#{angle},#{color}" else "#{type},#{color}" end end end # A chart can have one or many legends. # Gchart.line(:legend => 'label') # or # Gchart.line(:legend => ['first label', 'last label']) def set_legend if type.to_s =~ /meter/ @labels = legend return set_labels end if legend.is_a?(Array) "chdl=#{@legend.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chdl=#{legend}" end end def set_legend_position - case @legend_position - when :bottom + case @legend_position.to_s + when /(bottom|b)$/ "chdlp=b" - when :bottom_vertical + when /(bottom_vertical|bv)$/ "chdlp=bv" - when :top + when /(top|t)$/ "chdlp=t" - when :top_vertical + when /(top_vertical|tv)$/ "chdlp=tv" - when :right + when /(right|r)$/ "chdlp=r" - when :left + when /(left|l)$/ "chdlp=l" end end def set_line_thickness - "chls=#{thickness}" + "chls=#{thickness}" end - + def set_line_markers - "chm=#{new_markers}" + "chm=#{new_markers}" end - + def set_grid_lines - "chg=#{grid_lines}" + "chg=#{grid_lines}" end - + def set_labels if labels.is_a?(Array) "chl=#{@labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chl=#{@labels}" end end def set_axis_with_labels @axis_with_labels = axis_with_labels.join(',') if @axis_with_labels.is_a?(Array) "chxt=#{axis_with_labels}" end def set_axis_labels if axis_labels.is_a?(Array) if RUBY_VERSION.to_f < 1.9 labels_arr = axis_labels.enum_with_index.map{|labels,index| [index,labels]} else labels_arr = axis_labels.map.with_index.map{|labels,index| [index,labels]} end elsif axis_labels.is_a?(Hash) labels_arr = axis_labels.to_a end labels_arr.map! do |index,labels| if labels.is_a?(Array) "#{index}:|#{labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "#{index}:|#{labels}" end end "chxl=#{labels_arr.join('|')}" end # http://code.google.com/apis/chart/labels.html#axis_range # Specify a range for axis labels def set_axis_range # a passed axis_range should look like: # [[10,100]] or [[10,100,4]] or [[10,100], [20,300]] # in the second example, 4 is the interval set = @calculated_axis_range ? datasets : axis_range || datasets return unless set && set.respond_to?(:each) && set.find {|o| o}.respond_to?(:each) 'chxr=' + set.enum_for(:each_with_index).map do |axis_range, index| next nil if axis_range.nil? # ignore this axis min, max, step = axis_range if axis_range.size > 3 || step && max && step > max # this is a full series max = axis_range.compact.max step = nil end [index, (min_value || min || 0), (max_value || max), step].compact.join(',') end.compact.join("|") end def set_geographical_area "chtm=#{geographical_area}" end def set_type 'cht=' + case type.to_s when 'line' then "lc" when 'line_xy' then "lxy" when 'pie_3d' then "p3" when 'pie' then "p" when 'venn' then "v" when 'scatter' then "s" when 'sparkline' then "ls" when 'meter' then "gom" when 'map' then "t" when 'radar' "r" + (curved? ? 's' : '') when 'bar' "b" + (horizontal? ? "h" : "v") + (grouped? ? "g" : "s") end end def fill_type(type) case type when 'solid' then 's' when 'gradient' then 'lg' when 'stripes' then 'ls' end end def number_visible n = 0 dataset.each do |mds| return n.to_s if mds[:invisible] == true if mds[:data].first.is_a?(Array) n += mds[:data].length else n += 1 end end "" end # Turns input into an array of axis hashes, dependent on the chart type def convert_dataset(ds) if dimensions == 2 # valid inputs include: # an array of >=2 arrays, or an array of >=2 hashes ds = ds.map do |d| d.is_a?(Hash) ? d : {:data => d} end elsif dimensions == 1 # valid inputs include: # a hash, an array of data, an array of >=1 array, or an array of >=1 hash if ds.is_a?(Hash) ds = [ds] elsif not ds.first.is_a?(Hash) ds = [{:data => ds}] end end ds end # just an alias def axis_set dataset end def convert_to_simple_value(number) if number.nil? "_" else value = self.class.simple_chars[number.to_i] value.nil? ? "_" : value end end def convert_to_extended_value(number) if number.nil? '__' else value = self.class.ext_pairs[number.to_i] value.nil? ? "__" : value end end def encode_scaled_dataset(chars, nil_char) dsets = [] dataset.each do |ds| if max_value != false range = ds[:max_value] - ds[:min_value] range = 1 if range == 0 end unless ds[:data].first.is_a?(Array) ldatasets = [ds[:data]] else ldatasets = ds[:data] end ldatasets.each do |l| dsets << l.map do |number| if number.nil? nil_char else unless range.nil? || range.zero? number = chars.size * (number - ds[:min_value]) / range.to_f number = [number, chars.size - 1].min end chars[number.to_i] end end.join end end dsets.join(',') end # http://code.google.com/apis/chart/#simple # Simple encoding has a resolution of 62 different values. # Allowing five pixels per data point, this is sufficient for line and bar charts up # to about 300 pixels. Simple encoding is suitable for all other types of chart regardless of size. def simple_encoding "s" + number_visible + ":" + encode_scaled_dataset(self.class.simple_chars, '_') end # http://code.google.com/apis/chart/#text # Text encoding with data scaling lets you specify arbitrary positive or # negative floating point numbers, in combination with a scaling parameter # that lets you specify a custom range for your chart. This chart is useful # when you don't want to worry about limiting your data to a specific range, # or do the calculations to scale your data down or up to fit nicely inside # a chart. # # Valid values range from (+/-)9.999e(+/-)100, and only four non-zero digits are supported (that is, 123400, 1234, 12.34, and 0.1234 are valid, but 12345, 123.45 and 123400.5 are not). # # This encoding is not available for maps. # def text_encoding chds = dataset.map{|ds| "#{ds[:min_value]},#{ds[:max_value]}" }.join(",") "t" + number_visible + ":" + datasets.map{ |ds| ds.map{|e|e||'_'}.join(',') }.join('|') + "&chds=" + chds end # http://code.google.com/apis/chart/#extended # Extended encoding has a resolution of 4,096 different values # and is best used for large charts where a large data range is required. def extended_encoding "e" + number_visible + ":" + encode_scaled_dataset(self.class.ext_pairs, '__') end def url_builder(options="") self.class.url + query_builder(options) end def query_builder(options="") query_params = instance_variables.sort.map do |var| case var.to_s when '@data' set_data unless data == [] # Set the graph size when '@width' set_size unless width.nil? || height.nil? when '@type' set_type when '@title' set_title unless title.nil? when '@legend' set_legend unless legend.nil? when '@labels' set_labels unless labels.nil? when '@legend_position' set_legend_position unless legend_position.nil? when '@thickness' set_line_thickness when '@new_markers' set_line_markers when '@bg_color' set_colors when '@chart_color' set_colors if bg_color.nil? when '@bar_colors' set_bar_colors when '@bar_width_and_spacing' set_bar_width_and_spacing when '@axis_with_labels' set_axis_with_labels when '@axis_labels' set_axis_labels when '@range_markers' set_range_markers when '@grid_lines' set_grid_lines when '@geographical_area' set_geographical_area when '@country_codes' set_country_codes when '@custom' custom end end.compact query_params << set_axis_range # Use ampersand as default delimiter unless options == :html delimiter = '&' # Escape ampersand for html image tags else delimiter = '&amp;' end jstize(query_params.join(delimiter)) end end diff --git a/spec/gchart_spec.rb b/spec/gchart_spec.rb index 877c8a9..7afbcb7 100644 --- a/spec/gchart_spec.rb +++ b/spec/gchart_spec.rb @@ -1,660 +1,665 @@ require File.dirname(__FILE__) + '/spec_helper.rb' require File.dirname(__FILE__) + '/../lib/gchart' Chart::Theme.add_theme_file("#{File.dirname(__FILE__)}/fixtures/test_theme.yml") # Time to add your specs! # http://rspec.rubyforge.org/ describe "The Gchart class" do it "should show supported_types on error" do Gchart.supported_types.should match(/line/) end it "should return supported types" do Gchart.types.include?('line').should be_true end end describe "generating a default Gchart" do before(:each) do @chart = Gchart.line end it "should include the Google URL" do @chart.include?("http://chart.apis.google.com/chart?").should be_true end it "should have a default size" do @chart.should include('chs=300x200') end it "should be able to have a custom size" do Gchart.line(:size => '400x600').include?('chs=400x600').should be_true Gchart.line(:width => 400, :height => 600).include?('chs=400x600').should be_true end it "should have query parameters in predictable order" do Gchart.line(:axis_with_labels => 'x,y,r', :size => '400x600').should match(/chxt=.+cht=.+chs=/) end it "should have a type" do @chart.include?('cht=lc').should be_true end it 'should use theme defaults if theme is set' do Gchart.line(:theme=>:test).should include('chco=6886B4,FDD84E') if RUBY_VERSION.to_f < 1.9 Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=c,s,FFFFFF|bg,s,FFFFFF')) else Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=bg,s,FFFFFF|c,s,FFFFFF')) end end it "should use the simple encoding by default with auto max value" do # 9 is the max value in simple encoding, 26 being our max value the 2nd encoded value should be 9 Gchart.line(:data => [0, 26]).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => 26, :axis_with_labels => 'y').should include('chxr=0,0,26') end it "should support simple encoding with and without max_value" do Gchart.line(:data => [0, 26], :max_value => 26).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => false).should include('chd=s:Aa') end it "should support the extended encoding and encode properly" do Gchart.line(:data => [0, 10], :encoding => 'extended', :max_value => false).include?('chd=e:AA').should be_true Gchart.line(:encoding => 'extended', :max_value => false, :data => [[0,25,26,51,52,61,62,63], [64,89,90,115,4084]] ).include?('chd=e:AAAZAaAzA0A9A-A.,BABZBaBz.0').should be_true end it "should auto set the max value for extended encoding" do Gchart.line(:data => [0, 25], :encoding => 'extended', :max_value => false).should include('chd=e:AAAZ') # Extended encoding max value is '..' Gchart.line(:data => [0, 25], :encoding => 'extended').include?('chd=e:AA..').should be_true end it "should be able to have data with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,4,45,78') end it "should be able to have missing data points with text encoding" do Gchart.line(:data => [10, 5.2, nil, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,_,45,78') end it "should handle max and min values with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=0,78') end it "should automatically handle negative values with proper max/min limits when using text encoding" do Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=-10,78') end it "should handle negative values with manual max/min limits when using text encoding" do Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text', :min_value => -20, :max_value => 100).include?('chds=-20,100').should be_true end it "should set the proper axis values when using text encoding and negative values" do Gchart.bar( :data => [[-10], [100]], :encoding => 'text', :horizontal => true, :min_value => -20, :max_value => 100, :axis_with_labels => 'x', :bar_colors => ['FD9A3B', '4BC7DC']).should include("chxr=0,-20,100") end it "should be able to have multiple set of data with text encoding" do Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text').include?(Gchart.jstize('chd=t:10,5.2,4,45,78|20,40,70,15,99')).should be_true end it "should be able to receive a custom param" do Gchart.line(:custom => 'ceci_est_une_pipe').include?('ceci_est_une_pipe').should be_true end it "should be able to set label axis" do Gchart.line(:axis_with_labels => 'x,y,r').include?('chxt=x,y,r').should be_true Gchart.line(:axis_with_labels => ['x','y','r']).include?('chxt=x,y,r').should be_true end it "should be able to have axis labels" do Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true end def labeled_line(options = {}) Gchart.line({:data => @data, :axis_with_labels => 'x,y'}.merge(options)) end it "should display ranges properly" do @data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] labeled_line(:axis_labels => [((1..24).to_a << 1)]). should include('chxr=0,85,672') end def labeled_bar(options = {}) Gchart.bar({:data => @data, :axis_with_labels => 'x,y', :axis_labels => [(1..12).to_a], :encoding => "text" }.merge(options)) end it "should force the y range properly" do @data = [1,1,1,1,1,1,1,1,6,2,1,1] labeled_bar( :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,0|1,0,16') labeled_bar( :max_value => 16, :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,16|1,0,16') # nil means ignore axis labeled_bar( :axis_range => [nil,[0,16]] ).should include('chxr=1,0,16') # empty array means take defaults labeled_bar( :max_value => 16, :axis_range => [[],[0,16]] ).should include('chxr=0,0,16|1,0,16') labeled_bar( :axis_range => [[],[0,16]] ).should include('chxr=0,0|1,0,16') Gchart.line( :data => [0,20, 40, 60, 140, 230, 60], :axis_with_labels => 'y').should include("chxr=0,0,230") end it "should take in consideration the max value when creating a range" do data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] url = Gchart.line(:data => data, :axis_with_labels => 'x,y', :axis_labels => [((1..24).to_a << 1)], :max_value => 700) url.should include('chxr=0,85,700') end it 'should generate different labels and legend' do Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three)).should(include('chdl=1|2|3') && include('chl=one|two|three')) end end describe "generating different type of charts" do it "should be able to generate a line chart" do Gchart.line.should be_an_instance_of(String) Gchart.line.include?('cht=lc').should be_true end it "should be able to generate a sparkline chart" do Gchart.sparkline.should be_an_instance_of(String) Gchart.sparkline.include?('cht=ls').should be_true end it "should be able to generate a line xy chart" do Gchart.line_xy.should be_an_instance_of(String) Gchart.line_xy.include?('cht=lxy').should be_true end it "should be able to generate a scatter chart" do Gchart.scatter.should be_an_instance_of(String) Gchart.scatter.include?('cht=s').should be_true end it "should be able to generate a bar chart" do Gchart.bar.should be_an_instance_of(String) Gchart.bar.include?('cht=bvs').should be_true end it "should be able to generate a Venn diagram" do Gchart.venn.should be_an_instance_of(String) Gchart.venn.include?('cht=v').should be_true end it "should be able to generate a Pie Chart" do Gchart.pie.should be_an_instance_of(String) Gchart.pie.include?('cht=p').should be_true end it "should be able to generate a Google-O-Meter" do Gchart.meter.should be_an_instance_of(String) Gchart.meter.include?('cht=gom').should be_true end it "should be able to generate a map chart" do Gchart.map.should be_an_instance_of(String) Gchart.map.include?('cht=t').should be_true end it "should not support other types" do msg = "sexy is not a supported chart format. Please use one of the following: #{Gchart.supported_types}." lambda{Gchart.sexy}.should raise_error(NoMethodError) end end describe "range markers" do it "should be able to generate given a hash of range-marker options" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}).include?('chm=r,ff0000,0,0.59,0.61').should be_true end it "should be able to generate given an array of range-marker hash options" do Gchart.line(:range_markers => [ {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}, {:start_position => 0, :stop_position => 0.6, :color => '666666'}, {:color => 'cccccc', :start_position => 0.6, :stop_position => 1} ]).include?(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1')).should be_true end it "should allow a :overlaid? to be set" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true}).include?('chm=r,ffffff,0,0.59,0.61,1').should be_true Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false}).include?('chm=r,ffffff,0,0.59,0.61').should be_true end describe "when setting the orientation option" do before(:each) do @options = {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'} end it "to vertical (R) if given a valid option" do Gchart.line(:range_markers => @options.merge(:orientation => 'v')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'V')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'R')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'vertical')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical')).include?('chm=R').should be_true end it "to horizontal (r) if given a valid option (actually anything other than the vertical options)" do Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal')).include?('chm=r').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'h')).include?('chm=r').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'etc')).include?('chm=r').should be_true end it "if left blank defaults to horizontal (r)" do Gchart.line(:range_markers => @options).include?('chm=r').should be_true end end end describe "a bar graph" do it "should have a default vertical orientation" do Gchart.bar.include?('cht=bvs').should be_true end it "should be able to have a different orientation" do Gchart.bar(:orientation => 'vertical').include?('cht=bvs').should be_true Gchart.bar(:orientation => 'v').include?('cht=bvs').should be_true Gchart.bar(:orientation => 'h').include?('cht=bhs').should be_true Gchart.bar(:orientation => 'horizontal').include?('cht=bhs').should be_true Gchart.bar(:horizontal => false).include?('cht=bvs').should be_true end it "should be set to be stacked by default" do Gchart.bar.include?('cht=bvs').should be_true end it "should be able to stacked or grouped" do Gchart.bar(:stacked => true).include?('cht=bvs').should be_true Gchart.bar(:stacked => false).include?('cht=bvg').should be_true Gchart.bar(:grouped => true).include?('cht=bvg').should be_true Gchart.bar(:grouped => false).include?('cht=bvs').should be_true end it "should be able to have different bar colors" do Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=').should be_true Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=efefef,00ffff').should be_true # alias Gchart.bar(:bar_color => 'efefef').include?('chco=efefef').should be_true end it "should be able to have different bar colors when using an array of colors" do Gchart.bar(:bar_colors => ['efefef','00ffff']).include?('chco=efefef,00ffff').should be_true end it 'should be able to accept a string of width and spacing options' do Gchart.bar(:bar_width_and_spacing => '25,6').include?('chbh=25,6').should be_true end it 'should be able to accept a single fixnum width and spacing option to set the bar width' do Gchart.bar(:bar_width_and_spacing => 25).include?('chbh=25').should be_true end it 'should be able to accept an array of width and spacing options' do Gchart.bar(:bar_width_and_spacing => [25,6,12]).include?('chbh=25,6,12').should be_true Gchart.bar(:bar_width_and_spacing => [25,6]).include?('chbh=25,6').should be_true Gchart.bar(:bar_width_and_spacing => [25]).include?('chbh=25').should be_true end describe "with a hash of width and spacing options" do before(:each) do @default_width = 23 @default_spacing = 4 @default_group_spacing = 8 end it 'should be able to have a custom bar width' do Gchart.bar(:bar_width_and_spacing => {:width => 19}).include?("chbh=19,#{@default_spacing},#{@default_group_spacing}").should be_true end it 'should be able to have custom spacing' do Gchart.bar(:bar_width_and_spacing => {:spacing => 19}).include?("chbh=#{@default_width},19,#{@default_group_spacing}").should be_true end it 'should be able to have custom group spacing' do Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19}).include?("chbh=#{@default_width},#{@default_spacing},19").should be_true end end end describe "a line chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @chart = Gchart.line(:title => @title, :legend => @legend) end it 'should be able have a chart title' do @chart.include?("chtt=Chart+Title").should be_true end it "should be able to a custom color and size title" do Gchart.line(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true Gchart.line(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true end it "should be able to have multiple legends" do @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true end it "should escape text values in url" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend) chart.include?(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")).should be_true end it "should be able to have one legend" do chart = Gchart.line(:legend => 'legend label') chart.include?("chdl=legend+label").should be_true end it "should be able to set the position of the legend" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] + chart = Gchart.line(:title => title, :legend => legend, :legend_position => :bottom_vertical) - chart.include?("chdlp=bv") + puts chart.inspect + chart.include?("chdlp=bv").should be_true + + chart = Gchart.line(:title => title, :legend => legend, :legend_position => 'r') + chart.include?("chdlp=r").should be_true end it "should be able to set the background fill" do Gchart.line(:bg => 'efefef').should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=bg,lg,90,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'}).should include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do Gchart.line(:graph_bg => 'efefef').should include("chf=c,s,efefef") Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true end it "should be able to set both a graph and a background fill" do Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true if RUBY_VERSION.to_f < 1.9 Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true else Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true end end it "should be able to have different line colors" do Gchart.line(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true Gchart.line(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true end it "should be able to render a graph where all the data values are 0" do Gchart.line(:data => [0, 0, 0]).should include("chd=s:AAA") end end describe "a sparkline chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [27,25,25,25,25,27,100,31,25,36,25,25,39,25,31,25,25,25,26,26,25,25,28,25,25,100,28,27,31,25,27,27,29,25,27,26,26,25,26,26,35,33,34,25,26,25,36,25,26,37,33,33,37,37,39,25,25,25,25] @chart = Gchart.sparkline(:title => @title, :data => @data, :legend => @legend) end it "should create a sparkline" do @chart.include?('cht=ls').should be_true end it 'should be able have a chart title' do @chart.include?("chtt=Chart+Title").should be_true end it "should be able to a custom color and size title" do Gchart.sparkline(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true Gchart.sparkline(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true end it "should be able to have multiple legends" do @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true end it "should be able to have one legend" do chart = Gchart.sparkline(:legend => 'legend label') chart.include?("chdl=legend+label").should be_true end it "should be able to set the background fill" do Gchart.sparkline(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=bg,lg,90,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'}).include?("chf=bg,ls,90,efefef,0.2,ffffff,0.2").should be_true end it "should be able to set a graph fill" do Gchart.sparkline(:graph_bg => 'efefef').include?("chf=c,s,efefef").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true end it "should be able to set both a graph and a background fill" do Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true if RUBY_VERSION.to_f < 1.9 Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true else Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true end end it "should be able to have different line colors" do Gchart.sparkline(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true Gchart.sparkline(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true end end describe "a 3d pie chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [12,8,40,15,5] @chart = Gchart.pie(:title => @title, :legend => @legend, :data => @data) end it "should create a pie" do @chart.include?('cht=p').should be_true end it "should be able to be in 3d" do Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data).include?('cht=p3').should be_true end end describe "a google-o-meter" do before(:each) do @data = [70] @legend = ['arrow points here'] @jstized_legend = Gchart.jstize(@legend.join('|')) @chart = Gchart.meter(:data => @data) end it "should create a meter" do @chart.include?('cht=gom').should be_true end it "should be able to set a solid background fill" do Gchart.meter(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true end it "should be able to set labels by using the legend or labesl accessor" do Gchart.meter(:title => @title, :labels => @legend, :data => @data).should include("chl=#{@jstized_legend}") Gchart.meter(:title => @title, :labels => @legend, :data => @data).should == Gchart.meter(:title => @title, :legend => @legend, :data => @data) end end describe "a map chart" do before(:each) do @data = [0,100,50,32] @geographical_area = 'usa' @map_colors = ['FFFFFF', 'FF0000', 'FFFF00', '00FF00'] @country_codes = ['MT', 'WY', "ID", 'SD'] @chart = Gchart.map(:data => @data, :encoding => 'text', :size => '400x300', :geographical_area => @geographical_area, :map_colors => @map_colors, :country_codes => @country_codes) end it "should create a map" do @chart.include?('cht=t').should be_true end it "should set the geographical area" do @chart.include?('chtm=usa').should be_true end it "should set the map colors" do @chart.include?('chco=FFFFFF,FF0000,FFFF00,00FF00').should be_true end it "should set the country/state codes" do @chart.include?('chld=MTWYIDSD').should be_true end it "should set the chart data" do @chart.include?('chd=t:0,100,50,32').should be_true end end describe 'exporting a chart' do it "should be available in the url format by default" do Gchart.line(:data => [0, 26], :format => 'url').should == Gchart.line(:data => [0, 26]) end it "should be available as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using img_tag alias" do Gchart.line(:data => [0, 26], :format => 'img_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom dimensions" do Gchart.line(:data => [0, 26], :format => 'image_tag', :size => '400x400').should match(/<img src=(.*) width="400" height="400" alt="Google Chart" \/>/) end it "should be available as an image tag using custom alt text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :alt => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Sexy chart" \/>/) end it "should be available as an image tag using custom title text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :title => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" title="Sexy chart" \/>/) end it "should be available as an image tag using custom css id selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :id => 'chart').should match(/<img id="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom css class selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should match(/<img class="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should use ampersands to separate key/value pairs in URLs by default" do Gchart.line(:data => [0, 26]).should satisfy {|chart| chart.include? "&" } Gchart.line(:data => [0, 26]).should_not satisfy {|chart| chart.include? "&amp;" } end it "should escape ampersands in URLs when used as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should satisfy {|chart| chart.include? "&amp;" } end it "should be available as a file" do File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file') File.exist?('chart.png').should be_true File.delete('chart.png') if File.exist?('chart.png') end it "should be available as a file using a custom file name" do File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') Gchart.line(:data => [0, 26], :format => 'file', :filename => 'custom_file_name.png') File.exist?('custom_file_name.png').should be_true File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') end it "should work even with multiple attrs" do File.delete('foo.png') if File.exist?('foo.png') Gchart.line(:size => '400x200', :data => [1,2,3,4,5], # :axis_labels => [[1,2,3,4, 5], %w[foo bar]], :axis_with_labels => 'x,r', :format => "file", :filename => "foo.png" ) File.exist?('foo.png').should be_true File.delete('foo.png') if File.exist?('foo.png') end end
mattetti/googlecharts
42218d0dd2626afae665d44626e8faf21bc9a7a2
Add ability to set the legend position.
diff --git a/lib/gchart.rb b/lib/gchart.rb index c2f4d95..f0cfa1b 100644 --- a/lib/gchart.rb +++ b/lib/gchart.rb @@ -1,687 +1,706 @@ $:.unshift File.dirname(__FILE__) require 'gchart/version' require 'gchart/theme' require "net/http" require "uri" require "cgi" require 'enumerator' class Gchart include GchartInfo def self.url "http://chart.apis.google.com/chart?" end def self.types @types ||= ['line', 'line_xy', 'scatter', 'bar', 'venn', 'pie', 'pie_3d', 'jstize', 'sparkline', 'meter', 'map', 'radar'] end def self.simple_chars @simple_chars ||= ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a end def self.chars @chars ||= simple_chars + ['-', '.'] end def self.ext_pairs @ext_pairs ||= chars.map { |char_1| chars.map { |char_2| char_1 + char_2 } }.flatten end def self.default_filename 'chart.png' end - attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :legend, :labels, :data, :encoding, :bar_colors, + attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :legend, :legend_position, :labels, :data, :encoding, :bar_colors, :title_color, :title_size, :custom, :axis_with_labels, :axis_labels, :bar_width_and_spacing, :id, :alt, :klass, :range_markers, :geographical_area, :map_colors, :country_codes, :axis_range, :filename, :min, :max, :colors, :usemap attr_accessor :bg_type, :bg_color, :bg_angle, :chart_type, :chart_color, :chart_angle, :axis_range, :thickness, :new_markers, :grid_lines attr_accessor :min_value, :max_value types.each do |type| instance_eval <<-DYNCLASSMETH def #{type}(options = {}) # Start with theme defaults if a theme is set theme = options[:theme] options = theme ? Chart::Theme.load(theme).to_options.merge(options) : options # # Extract the format and optional filename, then clean the hash format = options[:format] || 'url' options[:filename] ||= default_filename options.delete(:format) #update map_colors to become bar_colors options.update(:bar_colors => options[:map_colors]) if options.has_key?(:map_colors) chart = new(options.merge!({:type => "#{type}"})) chart.send(format) end DYNCLASSMETH end def self.version VERSION::STRING end def self.method_missing(m, options={}) raise NoMethodError, "#{m} is not a supported chart format. Please use one of the following: #{supported_types}." end def initialize(options={}) @type = options[:type] || 'line' @data = [] @width = 300 @height = 200 @curved = false @horizontal = false @grouped = false @encoding = 'simple' # @max_value = 'auto' # @min_value defaults to nil meaning zero @filename = options[:filename] # Sets the alt tag when chart is exported as image tag @alt = 'Google Chart' # Sets the CSS id selector when chart is exported as image tag @id = false # Sets the CSS class selector when chart is exported as image tag @klass = options[:class] || false # set the options value if definable options.each do |attribute, value| send("#{attribute}=", value) if self.respond_to?("#{attribute}=") end end def self.supported_types self.types.join(' ') end # Defines the Graph size using the following format: # width X height def size=(size='300x200') @width, @height = size.split("x").map { |dimension| dimension.to_i } end def size "#{width}x#{height}" end def dimensions # TODO: maybe others? [:line_xy, :scatter].include?(type) ? 2 : 1 end # Sets the orientation of a bar graph def orientation=(orientation='h') if orientation == 'h' || orientation == 'horizontal' self.horizontal = true elsif orientation == 'v' || orientation == 'vertical' self.horizontal = false end end # Sets the bar graph presentation (stacked or grouped) def stacked=(option=true) @grouped = option ? false : true end def bg=(options) if options.is_a?(String) @bg_color = options elsif options.is_a?(Hash) @bg_color = options[:color] @bg_type = options[:type] @bg_angle = options[:angle] end end def graph_bg=(options) if options.is_a?(String) @chart_color = options elsif options.is_a?(Hash) @chart_color = options[:color] @chart_type = options[:type] @chart_angle = options[:angle] end end def max_value=(max_v) if max_v =~ /false/ @max_value = false else @max_value = max_v end end def min_value=(min_v) if min_v =~ /false/ @min_value = false else @min_value = min_v end end # returns the full data range as an array # it also sets the data range if not defined def full_data_range(ds) return if max_value == false ds.each_with_index do |mds, mds_index| mds[:min_value] ||= min_value mds[:max_value] ||= max_value if mds_index == 0 && type.to_s == 'bar' # TODO: unless you specify a zero line (using chp or chds), # the min_value of a bar chart is always 0. #mds[:min_value] ||= mds[:data].first.to_a.compact.min mds[:min_value] ||= 0 end if (mds_index == 0 && type.to_s == 'bar' && !grouped && mds[:data].first.is_a?(Array)) totals = [] mds[:data].each do |l| l.each_with_index do |v, index| next if v.nil? totals[index] ||= 0 totals[index] += v end end mds[:max_value] ||= totals.compact.max else all = mds[:data].flatten.compact # default min value should be 0 unless set to auto if mds[:min_value] == 'auto' mds[:min_value] = all.min else min = all.min mds[:min_value] ||= (min && min < 0 ? min : 0) end mds[:max_value] ||= all.max end end unless axis_range @calculated_axis_range = true @axis_range = ds.map{|mds| [mds[:min_value], mds[:max_value]]} if dimensions == 1 && (type.to_s != 'bar' || horizontal) tmp = axis_range.fetch(0, []) @axis_range[0] = axis_range.fetch(1, []) @axis_range[1] = tmp end end # return [min, max] unless (min.nil? || max.nil?) # @max = (max_value.nil? || max_value == 'auto') ? ds.compact.map{|mds| mds.compact.max}.max : max_value # # if min_value.nil? # min_ds_value = ds.compact.map{|mds| mds.compact.min}.min || 0 # @min = (min_ds_value < 0) ? min_ds_value : 0 # else # @min = min_value == 'auto' ? ds.compact.map{|mds| mds.compact.min}.min || 0 : min_value # end # @axis_range = [[min,max]] end def dataset if @dataset @dataset else @dataset = convert_dataset(data || []) full_data_range(@dataset) # unless axis_range @dataset end end # Sets of data to handle multiple sets def datasets datasets = [] dataset.each do |d| if d[:data].first.is_a?(Array) datasets += d[:data] else datasets << d[:data] end end datasets end def self.jstize(string) # See http://github.com/mattetti/googlecharts/issues#issue/27 #URI.escape( string ).gsub("%7C", "|") # See discussion: http://github.com/mattetti/googlecharts/commit/9b5cfb93aa51aae06611057668e631cd515ec4f3#comment_51347 string.gsub(' ', '+').gsub(/\[|\{|\}|\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} #string.gsub(' ', '+').gsub(/\[|\{|\}|\||\\|\^|\[|\]|\`|\]/) {|c| "%#{c[0].to_s.upcase}"} end # load all the custom aliases require 'gchart/aliases' # Returns the chart's generated PNG as a blob. (borrowed from John's gchart.rubyforge.org) def fetch url = URI.parse(self.class.url) req = Net::HTTP::Post.new(url.path) req.body = query_builder req.content_type = 'application/x-www-form-urlencoded' Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }.body end # Writes the chart's generated PNG to a file. (borrowed from John's gchart.rubyforge.org) def write io_or_file = filename || self.class.default_filename return io_or_file.write(fetch) if io_or_file.respond_to?(:write) open(io_or_file, "wb+") { |io| io.write(fetch) } end # Format def image_tag image = "<img" image += " id=\"#{id}\"" if id image += " class=\"#{klass}\"" if klass image += " src=\"#{url_builder(:html)}\"" image += " width=\"#{width}\"" image += " height=\"#{height}\"" image += " alt=\"#{alt}\"" image += " title=\"#{title}\"" if title image += " usemap=\"#{usemap}\"" if usemap image += " />" end alias_method :img_tag, :image_tag def url url_builder end def file write end # def jstize(string) self.class.jstize(string) end private # The title size cannot be set without specifying a color. # A dark key will be used for the title color if no color is specified def set_title title_params = "chtt=#{title}" unless (title_color.nil? && title_size.nil? ) title_params << "&chts=" + (color, size = (title_color || '454545'), title_size).compact.join(',') end title_params end def set_size "chs=#{size}" end def set_data data = send("#{@encoding}_encoding") "chd=#{data}" end def set_colors @bg_type = fill_type(bg_type) || 's' if bg_color @chart_type = fill_type(chart_type) || 's' if chart_color "chf=" + {'bg' => fill_for(bg_type, bg_color, bg_angle), 'c' => fill_for(chart_type, chart_color, chart_angle)}.map{|k,v| "#{k},#{v}" unless v.nil?}.compact.join('|') end # set bar, line colors def set_bar_colors @bar_colors = bar_colors.join(',') if bar_colors.is_a?(Array) "chco=#{bar_colors}" end def set_country_codes @country_codes = country_codes.join() if country_codes.is_a?(Array) "chld=#{country_codes}" end # set bar spacing # chbh= # <bar width in pixels>, # <optional space between bars in a group>, # <optional space between groups> def set_bar_width_and_spacing width_and_spacing_values = case bar_width_and_spacing when String bar_width_and_spacing when Array bar_width_and_spacing.join(',') when Hash width = bar_width_and_spacing[:width] || 23 spacing = bar_width_and_spacing[:spacing] || 4 group_spacing = bar_width_and_spacing[:group_spacing] || 8 [width,spacing,group_spacing].join(',') else bar_width_and_spacing.to_s end "chbh=#{width_and_spacing_values}" end def set_range_markers markers = case range_markers when Hash set_range_marker(range_markers) when Array range_markers.collect{|marker| set_range_marker(marker)}.join('|') end "chm=#{markers}" end def set_range_marker(options) orientation = ['vertical', 'Vertical', 'V', 'v', 'R'].include?(options[:orientation]) ? 'R' : 'r' "#{orientation},#{options[:color]},0,#{options[:start_position]},#{options[:stop_position]}#{',1' if options[:overlaid?]}" end def fill_for(type=nil, color='', angle=nil) unless type.nil? case type when 'lg' angle ||= 0 color = "#{color},0,ffffff,1" if color.split(',').size == 1 "#{type},#{angle},#{color}" when 'ls' angle ||= 90 color = "#{color},0.2,ffffff,0.2" if color.split(',').size == 1 "#{type},#{angle},#{color}" else "#{type},#{color}" end end end # A chart can have one or many legends. # Gchart.line(:legend => 'label') # or # Gchart.line(:legend => ['first label', 'last label']) def set_legend if type.to_s =~ /meter/ @labels = legend return set_labels end if legend.is_a?(Array) "chdl=#{@legend.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chdl=#{legend}" end end + def set_legend_position + case @legend_position + when :bottom + "chdlp=b" + when :bottom_vertical + "chdlp=bv" + when :top + "chdlp=t" + when :top_vertical + "chdlp=tv" + when :right + "chdlp=r" + when :left + "chdlp=l" + end + end + def set_line_thickness "chls=#{thickness}" end def set_line_markers "chm=#{new_markers}" end def set_grid_lines "chg=#{grid_lines}" end def set_labels if labels.is_a?(Array) "chl=#{@labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "chl=#{@labels}" end end def set_axis_with_labels @axis_with_labels = axis_with_labels.join(',') if @axis_with_labels.is_a?(Array) "chxt=#{axis_with_labels}" end def set_axis_labels if axis_labels.is_a?(Array) if RUBY_VERSION.to_f < 1.9 labels_arr = axis_labels.enum_with_index.map{|labels,index| [index,labels]} else labels_arr = axis_labels.map.with_index.map{|labels,index| [index,labels]} end elsif axis_labels.is_a?(Hash) labels_arr = axis_labels.to_a end labels_arr.map! do |index,labels| if labels.is_a?(Array) "#{index}:|#{labels.map{|label| "#{CGI::escape(label.to_s)}"}.join('|')}" else "#{index}:|#{labels}" end end "chxl=#{labels_arr.join('|')}" end # http://code.google.com/apis/chart/labels.html#axis_range # Specify a range for axis labels def set_axis_range # a passed axis_range should look like: # [[10,100]] or [[10,100,4]] or [[10,100], [20,300]] # in the second example, 4 is the interval set = @calculated_axis_range ? datasets : axis_range || datasets return unless set && set.respond_to?(:each) && set.find {|o| o}.respond_to?(:each) 'chxr=' + set.enum_for(:each_with_index).map do |axis_range, index| next nil if axis_range.nil? # ignore this axis min, max, step = axis_range if axis_range.size > 3 || step && max && step > max # this is a full series max = axis_range.compact.max step = nil end [index, (min_value || min || 0), (max_value || max), step].compact.join(',') end.compact.join("|") end def set_geographical_area "chtm=#{geographical_area}" end def set_type 'cht=' + case type.to_s when 'line' then "lc" when 'line_xy' then "lxy" when 'pie_3d' then "p3" when 'pie' then "p" when 'venn' then "v" when 'scatter' then "s" when 'sparkline' then "ls" when 'meter' then "gom" when 'map' then "t" when 'radar' "r" + (curved? ? 's' : '') when 'bar' "b" + (horizontal? ? "h" : "v") + (grouped? ? "g" : "s") end end def fill_type(type) case type when 'solid' then 's' when 'gradient' then 'lg' when 'stripes' then 'ls' end end def number_visible n = 0 dataset.each do |mds| return n.to_s if mds[:invisible] == true if mds[:data].first.is_a?(Array) n += mds[:data].length else n += 1 end end "" end # Turns input into an array of axis hashes, dependent on the chart type def convert_dataset(ds) if dimensions == 2 # valid inputs include: # an array of >=2 arrays, or an array of >=2 hashes ds = ds.map do |d| d.is_a?(Hash) ? d : {:data => d} end elsif dimensions == 1 # valid inputs include: # a hash, an array of data, an array of >=1 array, or an array of >=1 hash if ds.is_a?(Hash) ds = [ds] elsif not ds.first.is_a?(Hash) ds = [{:data => ds}] end end ds end # just an alias def axis_set dataset end def convert_to_simple_value(number) if number.nil? "_" else value = self.class.simple_chars[number.to_i] value.nil? ? "_" : value end end def convert_to_extended_value(number) if number.nil? '__' else value = self.class.ext_pairs[number.to_i] value.nil? ? "__" : value end end def encode_scaled_dataset(chars, nil_char) dsets = [] dataset.each do |ds| if max_value != false range = ds[:max_value] - ds[:min_value] range = 1 if range == 0 end unless ds[:data].first.is_a?(Array) ldatasets = [ds[:data]] else ldatasets = ds[:data] end ldatasets.each do |l| dsets << l.map do |number| if number.nil? nil_char else unless range.nil? || range.zero? number = chars.size * (number - ds[:min_value]) / range.to_f number = [number, chars.size - 1].min end chars[number.to_i] end end.join end end dsets.join(',') end # http://code.google.com/apis/chart/#simple # Simple encoding has a resolution of 62 different values. # Allowing five pixels per data point, this is sufficient for line and bar charts up # to about 300 pixels. Simple encoding is suitable for all other types of chart regardless of size. def simple_encoding "s" + number_visible + ":" + encode_scaled_dataset(self.class.simple_chars, '_') end # http://code.google.com/apis/chart/#text # Text encoding with data scaling lets you specify arbitrary positive or # negative floating point numbers, in combination with a scaling parameter # that lets you specify a custom range for your chart. This chart is useful # when you don't want to worry about limiting your data to a specific range, # or do the calculations to scale your data down or up to fit nicely inside # a chart. # # Valid values range from (+/-)9.999e(+/-)100, and only four non-zero digits are supported (that is, 123400, 1234, 12.34, and 0.1234 are valid, but 12345, 123.45 and 123400.5 are not). # # This encoding is not available for maps. # def text_encoding chds = dataset.map{|ds| "#{ds[:min_value]},#{ds[:max_value]}" }.join(",") "t" + number_visible + ":" + datasets.map{ |ds| ds.map{|e|e||'_'}.join(',') }.join('|') + "&chds=" + chds end # http://code.google.com/apis/chart/#extended # Extended encoding has a resolution of 4,096 different values # and is best used for large charts where a large data range is required. def extended_encoding "e" + number_visible + ":" + encode_scaled_dataset(self.class.ext_pairs, '__') end def url_builder(options="") self.class.url + query_builder(options) end def query_builder(options="") query_params = instance_variables.sort.map do |var| case var.to_s when '@data' set_data unless data == [] # Set the graph size when '@width' set_size unless width.nil? || height.nil? when '@type' set_type when '@title' set_title unless title.nil? when '@legend' set_legend unless legend.nil? when '@labels' set_labels unless labels.nil? + when '@legend_position' + set_legend_position unless legend_position.nil? when '@thickness' set_line_thickness when '@new_markers' set_line_markers when '@bg_color' set_colors when '@chart_color' set_colors if bg_color.nil? when '@bar_colors' set_bar_colors when '@bar_width_and_spacing' set_bar_width_and_spacing when '@axis_with_labels' set_axis_with_labels when '@axis_labels' set_axis_labels when '@range_markers' set_range_markers when '@grid_lines' set_grid_lines when '@geographical_area' set_geographical_area when '@country_codes' set_country_codes when '@custom' custom end end.compact query_params << set_axis_range # Use ampersand as default delimiter unless options == :html delimiter = '&' # Escape ampersand for html image tags else delimiter = '&amp;' end jstize(query_params.join(delimiter)) end end diff --git a/spec/gchart_spec.rb b/spec/gchart_spec.rb index 8f5ec4f..877c8a9 100644 --- a/spec/gchart_spec.rb +++ b/spec/gchart_spec.rb @@ -1,653 +1,660 @@ require File.dirname(__FILE__) + '/spec_helper.rb' require File.dirname(__FILE__) + '/../lib/gchart' Chart::Theme.add_theme_file("#{File.dirname(__FILE__)}/fixtures/test_theme.yml") # Time to add your specs! # http://rspec.rubyforge.org/ describe "The Gchart class" do it "should show supported_types on error" do Gchart.supported_types.should match(/line/) end it "should return supported types" do Gchart.types.include?('line').should be_true end end describe "generating a default Gchart" do before(:each) do @chart = Gchart.line end it "should include the Google URL" do @chart.include?("http://chart.apis.google.com/chart?").should be_true end it "should have a default size" do @chart.should include('chs=300x200') end it "should be able to have a custom size" do Gchart.line(:size => '400x600').include?('chs=400x600').should be_true Gchart.line(:width => 400, :height => 600).include?('chs=400x600').should be_true end it "should have query parameters in predictable order" do Gchart.line(:axis_with_labels => 'x,y,r', :size => '400x600').should match(/chxt=.+cht=.+chs=/) end it "should have a type" do @chart.include?('cht=lc').should be_true end it 'should use theme defaults if theme is set' do Gchart.line(:theme=>:test).should include('chco=6886B4,FDD84E') if RUBY_VERSION.to_f < 1.9 Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=c,s,FFFFFF|bg,s,FFFFFF')) else Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=bg,s,FFFFFF|c,s,FFFFFF')) end end it "should use the simple encoding by default with auto max value" do # 9 is the max value in simple encoding, 26 being our max value the 2nd encoded value should be 9 Gchart.line(:data => [0, 26]).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => 26, :axis_with_labels => 'y').should include('chxr=0,0,26') end it "should support simple encoding with and without max_value" do Gchart.line(:data => [0, 26], :max_value => 26).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => false).should include('chd=s:Aa') end it "should support the extended encoding and encode properly" do Gchart.line(:data => [0, 10], :encoding => 'extended', :max_value => false).include?('chd=e:AA').should be_true Gchart.line(:encoding => 'extended', :max_value => false, :data => [[0,25,26,51,52,61,62,63], [64,89,90,115,4084]] ).include?('chd=e:AAAZAaAzA0A9A-A.,BABZBaBz.0').should be_true end it "should auto set the max value for extended encoding" do Gchart.line(:data => [0, 25], :encoding => 'extended', :max_value => false).should include('chd=e:AAAZ') # Extended encoding max value is '..' Gchart.line(:data => [0, 25], :encoding => 'extended').include?('chd=e:AA..').should be_true end it "should be able to have data with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,4,45,78') end it "should be able to have missing data points with text encoding" do Gchart.line(:data => [10, 5.2, nil, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,_,45,78') end it "should handle max and min values with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=0,78') end it "should automatically handle negative values with proper max/min limits when using text encoding" do Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=-10,78') end it "should handle negative values with manual max/min limits when using text encoding" do Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text', :min_value => -20, :max_value => 100).include?('chds=-20,100').should be_true end it "should set the proper axis values when using text encoding and negative values" do Gchart.bar( :data => [[-10], [100]], :encoding => 'text', :horizontal => true, :min_value => -20, :max_value => 100, :axis_with_labels => 'x', :bar_colors => ['FD9A3B', '4BC7DC']).should include("chxr=0,-20,100") end it "should be able to have multiple set of data with text encoding" do Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text').include?(Gchart.jstize('chd=t:10,5.2,4,45,78|20,40,70,15,99')).should be_true end it "should be able to receive a custom param" do Gchart.line(:custom => 'ceci_est_une_pipe').include?('ceci_est_une_pipe').should be_true end it "should be able to set label axis" do Gchart.line(:axis_with_labels => 'x,y,r').include?('chxt=x,y,r').should be_true Gchart.line(:axis_with_labels => ['x','y','r']).include?('chxt=x,y,r').should be_true end it "should be able to have axis labels" do Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true end def labeled_line(options = {}) Gchart.line({:data => @data, :axis_with_labels => 'x,y'}.merge(options)) end it "should display ranges properly" do @data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] labeled_line(:axis_labels => [((1..24).to_a << 1)]). should include('chxr=0,85,672') end def labeled_bar(options = {}) Gchart.bar({:data => @data, :axis_with_labels => 'x,y', :axis_labels => [(1..12).to_a], :encoding => "text" }.merge(options)) end it "should force the y range properly" do @data = [1,1,1,1,1,1,1,1,6,2,1,1] labeled_bar( :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,0|1,0,16') labeled_bar( :max_value => 16, :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,16|1,0,16') # nil means ignore axis labeled_bar( :axis_range => [nil,[0,16]] ).should include('chxr=1,0,16') # empty array means take defaults labeled_bar( :max_value => 16, :axis_range => [[],[0,16]] ).should include('chxr=0,0,16|1,0,16') labeled_bar( :axis_range => [[],[0,16]] ).should include('chxr=0,0|1,0,16') Gchart.line( :data => [0,20, 40, 60, 140, 230, 60], :axis_with_labels => 'y').should include("chxr=0,0,230") end it "should take in consideration the max value when creating a range" do data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] url = Gchart.line(:data => data, :axis_with_labels => 'x,y', :axis_labels => [((1..24).to_a << 1)], :max_value => 700) url.should include('chxr=0,85,700') end it 'should generate different labels and legend' do Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three)).should(include('chdl=1|2|3') && include('chl=one|two|three')) end end describe "generating different type of charts" do it "should be able to generate a line chart" do Gchart.line.should be_an_instance_of(String) Gchart.line.include?('cht=lc').should be_true end it "should be able to generate a sparkline chart" do Gchart.sparkline.should be_an_instance_of(String) Gchart.sparkline.include?('cht=ls').should be_true end it "should be able to generate a line xy chart" do Gchart.line_xy.should be_an_instance_of(String) Gchart.line_xy.include?('cht=lxy').should be_true end it "should be able to generate a scatter chart" do Gchart.scatter.should be_an_instance_of(String) Gchart.scatter.include?('cht=s').should be_true end it "should be able to generate a bar chart" do Gchart.bar.should be_an_instance_of(String) Gchart.bar.include?('cht=bvs').should be_true end it "should be able to generate a Venn diagram" do Gchart.venn.should be_an_instance_of(String) Gchart.venn.include?('cht=v').should be_true end it "should be able to generate a Pie Chart" do Gchart.pie.should be_an_instance_of(String) Gchart.pie.include?('cht=p').should be_true end it "should be able to generate a Google-O-Meter" do Gchart.meter.should be_an_instance_of(String) Gchart.meter.include?('cht=gom').should be_true end it "should be able to generate a map chart" do Gchart.map.should be_an_instance_of(String) Gchart.map.include?('cht=t').should be_true end it "should not support other types" do msg = "sexy is not a supported chart format. Please use one of the following: #{Gchart.supported_types}." lambda{Gchart.sexy}.should raise_error(NoMethodError) end end describe "range markers" do it "should be able to generate given a hash of range-marker options" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}).include?('chm=r,ff0000,0,0.59,0.61').should be_true end it "should be able to generate given an array of range-marker hash options" do Gchart.line(:range_markers => [ {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}, {:start_position => 0, :stop_position => 0.6, :color => '666666'}, {:color => 'cccccc', :start_position => 0.6, :stop_position => 1} ]).include?(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1')).should be_true end it "should allow a :overlaid? to be set" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true}).include?('chm=r,ffffff,0,0.59,0.61,1').should be_true Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false}).include?('chm=r,ffffff,0,0.59,0.61').should be_true end describe "when setting the orientation option" do before(:each) do @options = {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'} end it "to vertical (R) if given a valid option" do Gchart.line(:range_markers => @options.merge(:orientation => 'v')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'V')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'R')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'vertical')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical')).include?('chm=R').should be_true end it "to horizontal (r) if given a valid option (actually anything other than the vertical options)" do Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal')).include?('chm=r').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'h')).include?('chm=r').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'etc')).include?('chm=r').should be_true end it "if left blank defaults to horizontal (r)" do Gchart.line(:range_markers => @options).include?('chm=r').should be_true end end end describe "a bar graph" do it "should have a default vertical orientation" do Gchart.bar.include?('cht=bvs').should be_true end it "should be able to have a different orientation" do Gchart.bar(:orientation => 'vertical').include?('cht=bvs').should be_true Gchart.bar(:orientation => 'v').include?('cht=bvs').should be_true Gchart.bar(:orientation => 'h').include?('cht=bhs').should be_true Gchart.bar(:orientation => 'horizontal').include?('cht=bhs').should be_true Gchart.bar(:horizontal => false).include?('cht=bvs').should be_true end it "should be set to be stacked by default" do Gchart.bar.include?('cht=bvs').should be_true end it "should be able to stacked or grouped" do Gchart.bar(:stacked => true).include?('cht=bvs').should be_true Gchart.bar(:stacked => false).include?('cht=bvg').should be_true Gchart.bar(:grouped => true).include?('cht=bvg').should be_true Gchart.bar(:grouped => false).include?('cht=bvs').should be_true end it "should be able to have different bar colors" do Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=').should be_true Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=efefef,00ffff').should be_true # alias Gchart.bar(:bar_color => 'efefef').include?('chco=efefef').should be_true end it "should be able to have different bar colors when using an array of colors" do Gchart.bar(:bar_colors => ['efefef','00ffff']).include?('chco=efefef,00ffff').should be_true end it 'should be able to accept a string of width and spacing options' do Gchart.bar(:bar_width_and_spacing => '25,6').include?('chbh=25,6').should be_true end it 'should be able to accept a single fixnum width and spacing option to set the bar width' do Gchart.bar(:bar_width_and_spacing => 25).include?('chbh=25').should be_true end it 'should be able to accept an array of width and spacing options' do Gchart.bar(:bar_width_and_spacing => [25,6,12]).include?('chbh=25,6,12').should be_true Gchart.bar(:bar_width_and_spacing => [25,6]).include?('chbh=25,6').should be_true Gchart.bar(:bar_width_and_spacing => [25]).include?('chbh=25').should be_true end describe "with a hash of width and spacing options" do before(:each) do @default_width = 23 @default_spacing = 4 @default_group_spacing = 8 end it 'should be able to have a custom bar width' do Gchart.bar(:bar_width_and_spacing => {:width => 19}).include?("chbh=19,#{@default_spacing},#{@default_group_spacing}").should be_true end it 'should be able to have custom spacing' do Gchart.bar(:bar_width_and_spacing => {:spacing => 19}).include?("chbh=#{@default_width},19,#{@default_group_spacing}").should be_true end it 'should be able to have custom group spacing' do Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19}).include?("chbh=#{@default_width},#{@default_spacing},19").should be_true end end end describe "a line chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @chart = Gchart.line(:title => @title, :legend => @legend) end it 'should be able have a chart title' do @chart.include?("chtt=Chart+Title").should be_true end it "should be able to a custom color and size title" do Gchart.line(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true Gchart.line(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true end it "should be able to have multiple legends" do @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true end it "should escape text values in url" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend) chart.include?(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")).should be_true end it "should be able to have one legend" do chart = Gchart.line(:legend => 'legend label') chart.include?("chdl=legend+label").should be_true end + + it "should be able to set the position of the legend" do + title = 'Chart & Title' + legend = ['first data & set label', 'n data set label'] + chart = Gchart.line(:title => title, :legend => legend, :legend_position => :bottom_vertical) + chart.include?("chdlp=bv") + end it "should be able to set the background fill" do Gchart.line(:bg => 'efefef').should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=bg,lg,90,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'}).should include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do Gchart.line(:graph_bg => 'efefef').should include("chf=c,s,efefef") Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true end it "should be able to set both a graph and a background fill" do Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true if RUBY_VERSION.to_f < 1.9 Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true else Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true end end it "should be able to have different line colors" do Gchart.line(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true Gchart.line(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true end it "should be able to render a graph where all the data values are 0" do Gchart.line(:data => [0, 0, 0]).should include("chd=s:AAA") end end describe "a sparkline chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [27,25,25,25,25,27,100,31,25,36,25,25,39,25,31,25,25,25,26,26,25,25,28,25,25,100,28,27,31,25,27,27,29,25,27,26,26,25,26,26,35,33,34,25,26,25,36,25,26,37,33,33,37,37,39,25,25,25,25] @chart = Gchart.sparkline(:title => @title, :data => @data, :legend => @legend) end it "should create a sparkline" do @chart.include?('cht=ls').should be_true end it 'should be able have a chart title' do @chart.include?("chtt=Chart+Title").should be_true end it "should be able to a custom color and size title" do Gchart.sparkline(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true Gchart.sparkline(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true end it "should be able to have multiple legends" do @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true end it "should be able to have one legend" do chart = Gchart.sparkline(:legend => 'legend label') chart.include?("chdl=legend+label").should be_true end it "should be able to set the background fill" do Gchart.sparkline(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=bg,lg,90,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'}).include?("chf=bg,ls,90,efefef,0.2,ffffff,0.2").should be_true end it "should be able to set a graph fill" do Gchart.sparkline(:graph_bg => 'efefef').include?("chf=c,s,efefef").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true end it "should be able to set both a graph and a background fill" do Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true if RUBY_VERSION.to_f < 1.9 Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true else Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true end end it "should be able to have different line colors" do Gchart.sparkline(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true Gchart.sparkline(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true end end describe "a 3d pie chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [12,8,40,15,5] @chart = Gchart.pie(:title => @title, :legend => @legend, :data => @data) end it "should create a pie" do @chart.include?('cht=p').should be_true end it "should be able to be in 3d" do Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data).include?('cht=p3').should be_true end end describe "a google-o-meter" do before(:each) do @data = [70] @legend = ['arrow points here'] @jstized_legend = Gchart.jstize(@legend.join('|')) @chart = Gchart.meter(:data => @data) end it "should create a meter" do @chart.include?('cht=gom').should be_true end it "should be able to set a solid background fill" do Gchart.meter(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true end it "should be able to set labels by using the legend or labesl accessor" do Gchart.meter(:title => @title, :labels => @legend, :data => @data).should include("chl=#{@jstized_legend}") Gchart.meter(:title => @title, :labels => @legend, :data => @data).should == Gchart.meter(:title => @title, :legend => @legend, :data => @data) end end describe "a map chart" do before(:each) do @data = [0,100,50,32] @geographical_area = 'usa' @map_colors = ['FFFFFF', 'FF0000', 'FFFF00', '00FF00'] @country_codes = ['MT', 'WY', "ID", 'SD'] @chart = Gchart.map(:data => @data, :encoding => 'text', :size => '400x300', :geographical_area => @geographical_area, :map_colors => @map_colors, :country_codes => @country_codes) end it "should create a map" do @chart.include?('cht=t').should be_true end it "should set the geographical area" do @chart.include?('chtm=usa').should be_true end it "should set the map colors" do @chart.include?('chco=FFFFFF,FF0000,FFFF00,00FF00').should be_true end it "should set the country/state codes" do @chart.include?('chld=MTWYIDSD').should be_true end it "should set the chart data" do @chart.include?('chd=t:0,100,50,32').should be_true end end describe 'exporting a chart' do it "should be available in the url format by default" do Gchart.line(:data => [0, 26], :format => 'url').should == Gchart.line(:data => [0, 26]) end it "should be available as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using img_tag alias" do Gchart.line(:data => [0, 26], :format => 'img_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom dimensions" do Gchart.line(:data => [0, 26], :format => 'image_tag', :size => '400x400').should match(/<img src=(.*) width="400" height="400" alt="Google Chart" \/>/) end it "should be available as an image tag using custom alt text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :alt => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Sexy chart" \/>/) end it "should be available as an image tag using custom title text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :title => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" title="Sexy chart" \/>/) end it "should be available as an image tag using custom css id selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :id => 'chart').should match(/<img id="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom css class selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should match(/<img class="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should use ampersands to separate key/value pairs in URLs by default" do Gchart.line(:data => [0, 26]).should satisfy {|chart| chart.include? "&" } Gchart.line(:data => [0, 26]).should_not satisfy {|chart| chart.include? "&amp;" } end it "should escape ampersands in URLs when used as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should satisfy {|chart| chart.include? "&amp;" } end it "should be available as a file" do File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file') File.exist?('chart.png').should be_true File.delete('chart.png') if File.exist?('chart.png') end it "should be available as a file using a custom file name" do File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') Gchart.line(:data => [0, 26], :format => 'file', :filename => 'custom_file_name.png') File.exist?('custom_file_name.png').should be_true File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') end it "should work even with multiple attrs" do File.delete('foo.png') if File.exist?('foo.png') Gchart.line(:size => '400x200', :data => [1,2,3,4,5], # :axis_labels => [[1,2,3,4, 5], %w[foo bar]], :axis_with_labels => 'x,r', :format => "file", :filename => "foo.png" ) File.exist?('foo.png').should be_true File.delete('foo.png') if File.exist?('foo.png') end end
mattetti/googlecharts
b59710fa679bff8cefafc3675cdfcb53065e410c
Version bump to 1.6.3
diff --git a/VERSION b/VERSION index fdd3be6..f5d2a58 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.6.2 +1.6.3 \ No newline at end of file
mattetti/googlecharts
110e39ea2b53ff26511faf3202aef1d6221463d8
clean up
diff --git a/spec/gchart_spec.rb b/spec/gchart_spec.rb index 3dc72fe..8f5ec4f 100644 --- a/spec/gchart_spec.rb +++ b/spec/gchart_spec.rb @@ -35,621 +35,619 @@ describe "generating a default Gchart" do end it "should have query parameters in predictable order" do Gchart.line(:axis_with_labels => 'x,y,r', :size => '400x600').should match(/chxt=.+cht=.+chs=/) end it "should have a type" do @chart.include?('cht=lc').should be_true end it 'should use theme defaults if theme is set' do Gchart.line(:theme=>:test).should include('chco=6886B4,FDD84E') if RUBY_VERSION.to_f < 1.9 Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=c,s,FFFFFF|bg,s,FFFFFF')) else Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=bg,s,FFFFFF|c,s,FFFFFF')) end end it "should use the simple encoding by default with auto max value" do # 9 is the max value in simple encoding, 26 being our max value the 2nd encoded value should be 9 Gchart.line(:data => [0, 26]).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => 26, :axis_with_labels => 'y').should include('chxr=0,0,26') end it "should support simple encoding with and without max_value" do Gchart.line(:data => [0, 26], :max_value => 26).should include('chd=s:A9') Gchart.line(:data => [0, 26], :max_value => false).should include('chd=s:Aa') end it "should support the extended encoding and encode properly" do Gchart.line(:data => [0, 10], :encoding => 'extended', :max_value => false).include?('chd=e:AA').should be_true Gchart.line(:encoding => 'extended', :max_value => false, :data => [[0,25,26,51,52,61,62,63], [64,89,90,115,4084]] ).include?('chd=e:AAAZAaAzA0A9A-A.,BABZBaBz.0').should be_true end it "should auto set the max value for extended encoding" do Gchart.line(:data => [0, 25], :encoding => 'extended', :max_value => false).should include('chd=e:AAAZ') # Extended encoding max value is '..' Gchart.line(:data => [0, 25], :encoding => 'extended').include?('chd=e:AA..').should be_true end it "should be able to have data with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,4,45,78') end it "should be able to have missing data points with text encoding" do Gchart.line(:data => [10, 5.2, nil, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,_,45,78') end it "should handle max and min values with text encoding" do Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=0,78') end it "should automatically handle negative values with proper max/min limits when using text encoding" do Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=-10,78') end it "should handle negative values with manual max/min limits when using text encoding" do Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text', :min_value => -20, :max_value => 100).include?('chds=-20,100').should be_true end it "should set the proper axis values when using text encoding and negative values" do Gchart.bar( :data => [[-10], [100]], :encoding => 'text', :horizontal => true, :min_value => -20, :max_value => 100, :axis_with_labels => 'x', :bar_colors => ['FD9A3B', '4BC7DC']).should include("chxr=0,-20,100") end it "should be able to have multiple set of data with text encoding" do Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text').include?(Gchart.jstize('chd=t:10,5.2,4,45,78|20,40,70,15,99')).should be_true end it "should be able to receive a custom param" do Gchart.line(:custom => 'ceci_est_une_pipe').include?('ceci_est_une_pipe').should be_true end it "should be able to set label axis" do Gchart.line(:axis_with_labels => 'x,y,r').include?('chxt=x,y,r').should be_true Gchart.line(:axis_with_labels => ['x','y','r']).include?('chxt=x,y,r').should be_true end it "should be able to have axis labels" do Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true end def labeled_line(options = {}) Gchart.line({:data => @data, :axis_with_labels => 'x,y'}.merge(options)) end it "should display ranges properly" do @data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] labeled_line(:axis_labels => [((1..24).to_a << 1)]). should include('chxr=0,85,672') end def labeled_bar(options = {}) Gchart.bar({:data => @data, :axis_with_labels => 'x,y', :axis_labels => [(1..12).to_a], :encoding => "text" }.merge(options)) end it "should force the y range properly" do @data = [1,1,1,1,1,1,1,1,6,2,1,1] labeled_bar( :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,0|1,0,16') labeled_bar( :max_value => 16, :axis_range => [[0,0],[0,16]] ).should include('chxr=0,0,16|1,0,16') # nil means ignore axis labeled_bar( :axis_range => [nil,[0,16]] ).should include('chxr=1,0,16') # empty array means take defaults labeled_bar( :max_value => 16, :axis_range => [[],[0,16]] ).should include('chxr=0,0,16|1,0,16') labeled_bar( :axis_range => [[],[0,16]] ).should include('chxr=0,0|1,0,16') Gchart.line( :data => [0,20, 40, 60, 140, 230, 60], :axis_with_labels => 'y').should include("chxr=0,0,230") end it "should take in consideration the max value when creating a range" do data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593] url = Gchart.line(:data => data, :axis_with_labels => 'x,y', :axis_labels => [((1..24).to_a << 1)], :max_value => 700) url.should include('chxr=0,85,700') end it 'should generate different labels and legend' do Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three)).should(include('chdl=1|2|3') && include('chl=one|two|three')) end end describe "generating different type of charts" do it "should be able to generate a line chart" do Gchart.line.should be_an_instance_of(String) Gchart.line.include?('cht=lc').should be_true end it "should be able to generate a sparkline chart" do Gchart.sparkline.should be_an_instance_of(String) Gchart.sparkline.include?('cht=ls').should be_true end it "should be able to generate a line xy chart" do Gchart.line_xy.should be_an_instance_of(String) Gchart.line_xy.include?('cht=lxy').should be_true end it "should be able to generate a scatter chart" do Gchart.scatter.should be_an_instance_of(String) Gchart.scatter.include?('cht=s').should be_true end it "should be able to generate a bar chart" do Gchart.bar.should be_an_instance_of(String) Gchart.bar.include?('cht=bvs').should be_true end it "should be able to generate a Venn diagram" do Gchart.venn.should be_an_instance_of(String) Gchart.venn.include?('cht=v').should be_true end it "should be able to generate a Pie Chart" do Gchart.pie.should be_an_instance_of(String) Gchart.pie.include?('cht=p').should be_true end it "should be able to generate a Google-O-Meter" do Gchart.meter.should be_an_instance_of(String) Gchart.meter.include?('cht=gom').should be_true end it "should be able to generate a map chart" do Gchart.map.should be_an_instance_of(String) Gchart.map.include?('cht=t').should be_true end it "should not support other types" do msg = "sexy is not a supported chart format. Please use one of the following: #{Gchart.supported_types}." lambda{Gchart.sexy}.should raise_error(NoMethodError) end end describe "range markers" do it "should be able to generate given a hash of range-marker options" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}).include?('chm=r,ff0000,0,0.59,0.61').should be_true end it "should be able to generate given an array of range-marker hash options" do Gchart.line(:range_markers => [ {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}, {:start_position => 0, :stop_position => 0.6, :color => '666666'}, {:color => 'cccccc', :start_position => 0.6, :stop_position => 1} ]).include?(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1')).should be_true end it "should allow a :overlaid? to be set" do Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true}).include?('chm=r,ffffff,0,0.59,0.61,1').should be_true Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false}).include?('chm=r,ffffff,0,0.59,0.61').should be_true end describe "when setting the orientation option" do before(:each) do @options = {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'} end it "to vertical (R) if given a valid option" do Gchart.line(:range_markers => @options.merge(:orientation => 'v')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'V')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'R')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'vertical')).include?('chm=R').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical')).include?('chm=R').should be_true end it "to horizontal (r) if given a valid option (actually anything other than the vertical options)" do Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal')).include?('chm=r').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'h')).include?('chm=r').should be_true Gchart.line(:range_markers => @options.merge(:orientation => 'etc')).include?('chm=r').should be_true end it "if left blank defaults to horizontal (r)" do Gchart.line(:range_markers => @options).include?('chm=r').should be_true end end end describe "a bar graph" do it "should have a default vertical orientation" do Gchart.bar.include?('cht=bvs').should be_true end it "should be able to have a different orientation" do Gchart.bar(:orientation => 'vertical').include?('cht=bvs').should be_true Gchart.bar(:orientation => 'v').include?('cht=bvs').should be_true Gchart.bar(:orientation => 'h').include?('cht=bhs').should be_true Gchart.bar(:orientation => 'horizontal').include?('cht=bhs').should be_true Gchart.bar(:horizontal => false).include?('cht=bvs').should be_true end it "should be set to be stacked by default" do Gchart.bar.include?('cht=bvs').should be_true end it "should be able to stacked or grouped" do Gchart.bar(:stacked => true).include?('cht=bvs').should be_true Gchart.bar(:stacked => false).include?('cht=bvg').should be_true Gchart.bar(:grouped => true).include?('cht=bvg').should be_true Gchart.bar(:grouped => false).include?('cht=bvs').should be_true end it "should be able to have different bar colors" do Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=').should be_true Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=efefef,00ffff').should be_true # alias Gchart.bar(:bar_color => 'efefef').include?('chco=efefef').should be_true end it "should be able to have different bar colors when using an array of colors" do Gchart.bar(:bar_colors => ['efefef','00ffff']).include?('chco=efefef,00ffff').should be_true end it 'should be able to accept a string of width and spacing options' do Gchart.bar(:bar_width_and_spacing => '25,6').include?('chbh=25,6').should be_true end it 'should be able to accept a single fixnum width and spacing option to set the bar width' do Gchart.bar(:bar_width_and_spacing => 25).include?('chbh=25').should be_true end it 'should be able to accept an array of width and spacing options' do Gchart.bar(:bar_width_and_spacing => [25,6,12]).include?('chbh=25,6,12').should be_true Gchart.bar(:bar_width_and_spacing => [25,6]).include?('chbh=25,6').should be_true Gchart.bar(:bar_width_and_spacing => [25]).include?('chbh=25').should be_true end describe "with a hash of width and spacing options" do before(:each) do @default_width = 23 @default_spacing = 4 @default_group_spacing = 8 end it 'should be able to have a custom bar width' do Gchart.bar(:bar_width_and_spacing => {:width => 19}).include?("chbh=19,#{@default_spacing},#{@default_group_spacing}").should be_true end it 'should be able to have custom spacing' do Gchart.bar(:bar_width_and_spacing => {:spacing => 19}).include?("chbh=#{@default_width},19,#{@default_group_spacing}").should be_true end it 'should be able to have custom group spacing' do Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19}).include?("chbh=#{@default_width},#{@default_spacing},19").should be_true end end end describe "a line chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @chart = Gchart.line(:title => @title, :legend => @legend) end it 'should be able have a chart title' do @chart.include?("chtt=Chart+Title").should be_true end it "should be able to a custom color and size title" do Gchart.line(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true Gchart.line(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true end it "should be able to have multiple legends" do @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true end it "should escape text values in url" do title = 'Chart & Title' legend = ['first data & set label', 'n data set label'] chart = Gchart.line(:title => title, :legend => legend) chart.include?(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")).should be_true end it "should be able to have one legend" do chart = Gchart.line(:legend => 'legend label') chart.include?("chdl=legend+label").should be_true end it "should be able to set the background fill" do Gchart.line(:bg => 'efefef').should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=bg,lg,90,efefef,0,ffffff,1") Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'}).should include("chf=bg,ls,90,efefef,0.2,ffffff,0.2") end it "should be able to set a graph fill" do Gchart.line(:graph_bg => 'efefef').should include("chf=c,s,efefef") Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true end it "should be able to set both a graph and a background fill" do Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true if RUBY_VERSION.to_f < 1.9 Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true else Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true end end it "should be able to have different line colors" do Gchart.line(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true Gchart.line(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true end it "should be able to render a graph where all the data values are 0" do Gchart.line(:data => [0, 0, 0]).should include("chd=s:AAA") end end describe "a sparkline chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [27,25,25,25,25,27,100,31,25,36,25,25,39,25,31,25,25,25,26,26,25,25,28,25,25,100,28,27,31,25,27,27,29,25,27,26,26,25,26,26,35,33,34,25,26,25,36,25,26,37,33,33,37,37,39,25,25,25,25] @chart = Gchart.sparkline(:title => @title, :data => @data, :legend => @legend) end it "should create a sparkline" do @chart.include?('cht=ls').should be_true end it 'should be able have a chart title' do @chart.include?("chtt=Chart+Title").should be_true end it "should be able to a custom color and size title" do Gchart.sparkline(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true Gchart.sparkline(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true end it "should be able to have multiple legends" do @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true end it "should be able to have one legend" do chart = Gchart.sparkline(:legend => 'legend label') chart.include?("chdl=legend+label").should be_true end it "should be able to set the background fill" do Gchart.sparkline(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=bg,lg,90,efefef,0,ffffff,1").should be_true Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'}).include?("chf=bg,ls,90,efefef,0.2,ffffff,0.2").should be_true end it "should be able to set a graph fill" do Gchart.sparkline(:graph_bg => 'efefef').include?("chf=c,s,efefef").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true end it "should be able to set both a graph and a background fill" do Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true if RUBY_VERSION.to_f < 1.9 Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true else Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true end end it "should be able to have different line colors" do Gchart.sparkline(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true Gchart.sparkline(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true end end describe "a 3d pie chart" do before(:each) do @title = 'Chart Title' @legend = ['first data set label', 'n data set label'] @jstized_legend = Gchart.jstize(@legend.join('|')) @data = [12,8,40,15,5] @chart = Gchart.pie(:title => @title, :legend => @legend, :data => @data) end it "should create a pie" do @chart.include?('cht=p').should be_true end it "should be able to be in 3d" do Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data).include?('cht=p3').should be_true end end describe "a google-o-meter" do before(:each) do @data = [70] @legend = ['arrow points here'] @jstized_legend = Gchart.jstize(@legend.join('|')) @chart = Gchart.meter(:data => @data) end it "should create a meter" do @chart.include?('cht=gom').should be_true end it "should be able to set a solid background fill" do Gchart.meter(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true end it "should be able to set labels by using the legend or labesl accessor" do Gchart.meter(:title => @title, :labels => @legend, :data => @data).should include("chl=#{@jstized_legend}") Gchart.meter(:title => @title, :labels => @legend, :data => @data).should == Gchart.meter(:title => @title, :legend => @legend, :data => @data) end - - end describe "a map chart" do before(:each) do @data = [0,100,50,32] @geographical_area = 'usa' @map_colors = ['FFFFFF', 'FF0000', 'FFFF00', '00FF00'] @country_codes = ['MT', 'WY', "ID", 'SD'] @chart = Gchart.map(:data => @data, :encoding => 'text', :size => '400x300', :geographical_area => @geographical_area, :map_colors => @map_colors, :country_codes => @country_codes) end it "should create a map" do @chart.include?('cht=t').should be_true end it "should set the geographical area" do @chart.include?('chtm=usa').should be_true end it "should set the map colors" do @chart.include?('chco=FFFFFF,FF0000,FFFF00,00FF00').should be_true end it "should set the country/state codes" do @chart.include?('chld=MTWYIDSD').should be_true end it "should set the chart data" do @chart.include?('chd=t:0,100,50,32').should be_true end end describe 'exporting a chart' do it "should be available in the url format by default" do Gchart.line(:data => [0, 26], :format => 'url').should == Gchart.line(:data => [0, 26]) end it "should be available as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using img_tag alias" do Gchart.line(:data => [0, 26], :format => 'img_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom dimensions" do Gchart.line(:data => [0, 26], :format => 'image_tag', :size => '400x400').should match(/<img src=(.*) width="400" height="400" alt="Google Chart" \/>/) end it "should be available as an image tag using custom alt text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :alt => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Sexy chart" \/>/) end it "should be available as an image tag using custom title text" do Gchart.line(:data => [0, 26], :format => 'image_tag', :title => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" title="Sexy chart" \/>/) end it "should be available as an image tag using custom css id selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :id => 'chart').should match(/<img id="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should be available as an image tag using custom css class selector" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should match(/<img class="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/) end it "should use ampersands to separate key/value pairs in URLs by default" do Gchart.line(:data => [0, 26]).should satisfy {|chart| chart.include? "&" } Gchart.line(:data => [0, 26]).should_not satisfy {|chart| chart.include? "&amp;" } end it "should escape ampersands in URLs when used as an image tag" do Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should satisfy {|chart| chart.include? "&amp;" } end it "should be available as a file" do File.delete('chart.png') if File.exist?('chart.png') Gchart.line(:data => [0, 26], :format => 'file') File.exist?('chart.png').should be_true File.delete('chart.png') if File.exist?('chart.png') end it "should be available as a file using a custom file name" do File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') Gchart.line(:data => [0, 26], :format => 'file', :filename => 'custom_file_name.png') File.exist?('custom_file_name.png').should be_true File.delete('custom_file_name.png') if File.exist?('custom_file_name.png') end it "should work even with multiple attrs" do File.delete('foo.png') if File.exist?('foo.png') Gchart.line(:size => '400x200', :data => [1,2,3,4,5], # :axis_labels => [[1,2,3,4, 5], %w[foo bar]], :axis_with_labels => 'x,r', :format => "file", :filename => "foo.png" ) File.exist?('foo.png').should be_true File.delete('foo.png') if File.exist?('foo.png') end end