Jump to content

  • Log In with Google      Sign In   
  • Create Account


TheComet

Member Since 02 Oct 2013
Online Last Active Today, 07:11 AM

Topics I've Started

Colour Cycling - An Old School Technique

20 August 2014 - 01:27 PM

Seize the Day was a calendar program made by in 1994 by Buena Vista software. It features graphics that at the time, were revolutionary because of the way they handled color cycling. These images were static bitmaps, but by changing color values, they appear animated. What is also impressive about these images is that they had full day night cycles built in, rendered also through color cycling. A few years ago, a html5 version was made. A copy was uncovered online and there is a way to use the program through DOSbox. As well, one of the original programmers for the project, Iam Gilman, has thought of the idea of remaking it, open sourced, for modern machines.

 
This popped up on my blog today and I wanted to share it with you all. The HTML5 demo can be played here:
http://www.effectgames.com/demos/canvascycle/
 
Make sure to play around with the settings on the right. The guy who implemented the HTML5 canvas program mentions that he improved on the technique by linearly blending the cycling colours to produce smoother transitions.
 
Here are the results of what can be done with colour cycling:
 
tumblr_n4w85syp811s559q7o1_500.gif
 
tumblr_n4w85syp811s559q7o2_500.gif
 
tumblr_n4w85syp811s559q7o4_500.gif
 
tumblr_n4w85syp811s559q7o3_500.gif
 
tumblr_n4w85syp811s559q7o6_500.gif
 
tumblr_n4w85syp811s559q7o5_500.gif
 
tumblr_n4w85syp811s559q7o7_500.gif
 
tumblr_n4w85syp811s559q7o8_500.gif
 
tumblr_n4w85syp811s559q7o9_500.gif

PyQt4 - takeAt() returning a QWidgetItem?

20 August 2014 - 08:32 AM

Hi,
 
I've discovered some very strange behaviour when trying to delete a QWidget from a QGridLayout. The following code demonstrates this behaviour:
 
>>> from PyQt4 import QtGui
>>> import sys
>>> app = QtGui.QApplication(sys.argv)
>>> grid_layout = QtGui.QGridLayout()
>>> grid_layout.addWidget(QtGui.QWidget())
>>> item = grid_layout.takeAt(0)
>>> item.deleteLater()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'QWidgetItem' object has no attribute 'deleteLater'
 
I swear this has worked before.
 
This makes no sense to me whatsoever. Firstly, why is it returning a QWidgetItem when I inserted a QWidget to begin with? Secondly, every Qt object derives from QObject, and deleteLater() is a method of QObject, so that method should exist. What's going on here?
 
Additional info:
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2

CMake (some random questions)

15 August 2014 - 11:02 AM

Assume the following project tree for all of my questions:

some_project
├── another_library
│   ├── CMakeLists.txt
│   ├── include
│   │   └── another_library
│   │       └── another_library.hpp
│   └── src
│       └── another_library.cpp
├── app
│   ├── CMakeLists.txt
│   ├── include
│   │   └── app
│   └── src
│       └── main.cpp
├── CMakeLists.txt
└── library
    ├── CMakeLists.txt
    ├── include
    │   └── library
    │       └── library.hpp
    └── src
        └── library.cpp

Where app is an executable and depends on the shared object another_library and another_library depends on another shared object library.

 

 

Question 1

 

Since another_library needs to include header files from library, is it ok for another_library/CMakeLists.txt to include the directories by using the following?

include_directories ("${CMAKE_SOURCE_DIR}/library/include")

It feels a little wrong to be assuming things about where the top library folder is placed. Moving it to another location (in a subdirectory somewhere for example) would mean having to edit another_library/CMakeLists.txt to include the new location of library.

 

 

Question 2

 

app is the executable, and I've seen a lot of people configure their executable directly in the top level CMakeLists.txt rather than doing it in app/CMakeListst.txt. What are the pros/cons of either technique?

 

 

Question 3

 

How and were do I install resource files (such as images, config files, etc.)?

 


Multiverse theory

13 July 2014 - 03:52 AM

If the multiverse theory is true, then there exists a universe in which it isn't


urllib2 - Website loads fine in browser but not in Python

08 July 2014 - 05:20 AM

I'm trying to download a page from this website: http://www.digikey.de

If I click on the link from within Firefox, it loads fine.

 

If I try to download the page using urllib2, I keep getting this message:

    <span id="ctl00_mainContentPlaceHolder_lblInvalidRequest"><H2>There was a pr
oblem with your request.</H2>

We are unable to process your request.<br/> Please return to the previous page t
o try again or contact <a href="mailto:webmaster@digikey.com?subject=Incident Nu
mber: 18&#46;ce969d50&#46;1404818243&#46;20b8e71">Digi-Key Webmaster</a> if you
feel that you have received this message in error. Please reference the followin
g incident number so we may assist you with this error.
<br/><br/

Here's the code:

import urllib2
import sys

if __name__ == '__main__':

    # optional proxy
    if len(sys.argv) > 1:
        proxy = {'http': str(sys.argv[1])}
        proxy = urllib2.ProxyHandler(proxy)
        opener = urllib2.build_opener(proxy)
        urllib2.install_opener(opener)

    html = urllib2.urlopen('http://www.digikey.de').read()
    error = html.find('request')
    if not error == -1:
        print html[error-400:error+400]
    else:
        print 'success'

Can anyone explain to me why it's doing this and how I can fix it?


PARTNERS