2011年8月18日木曜日

OpenGL/GLUT for PHP5.3 exe tarball v0.0.1 (experimental)

OpenGL/GLUT for PHP5.3 exe tarball v0.0.1 (experimental)

i release zip archive of OpenGL PHP for Windows, it runnable so
http://diary.awm.jp/~yoya/data/2011/08/17/php53opengl-0.0.1.zip

i checked it on Microsoft Windows Vista and 7 32bits version.

i reported sourceforge.net の phpopengl forum



Dear all.
Windows binary PHP5.3 with OpenGL/GLUT extension for you.

source repos.


↓original source, it runnable on php4
- http://phpopengl.sourceforge.net/

↓my php5 migration and costomize code
- https://github.com/yoya/phpopengl/

usage



php -c php.ini samples\contrib\gears.php

[f:id:yoya:20110818025231p:image]

problem


  • OpenGL 1.2 version because Windows SDK 7.1 's default.

  • GLUT callback is not stable so maybe not runnable sample under.
    • samples\examples\movelight.php
    • samples\glut\glut_example.php
    • samples\redbook\bezmesh.php
  • msvcr100.dll
    • attached in zip. I'm trying to enbeded into exe file.

2011年2月13日日曜日

SWF Shape reducer

* SWF Shape reducer


** code
** size compare

- before
magic=CWS  version=8  file_length=3166474
 rect=(0, 0)-(550, 300) (f_size=15)

- after
magic=CWS  version=8  file_length=3166366
 rect=(0, 0)-(550, 300) (f_size=15)

** detail


swf defineshape vector data has length field at first, and following data has  concrete value.


- sample

+------------------------------+
| numBits |  deltaX  | deltaY  |
+------------------------------+
<4or5 bits><-numBits-><-numBits->


i can reduce size for rebuild swf binary.


** notes

- numBits 0 is OK
- styleChangeRecord x, y is not delta value.
- new style not add table but replace it.

** TODO

- deforme vector.

SWF DefineShape parser

SWF DefineShape parser in PHP.

** essence




  • http://openpear.org/package/IO_SWF/src/trunk/IO/SWF/Shape.php






  • $this->_shapeBounds = IO_SWF_Type::parseRECT($reader);
    $this->_parseFILLSTYLEARRAY($reader);
    $this->_parseLINESTYLEARRAY($reader);
    $reader->byteAlign();
    $numFillBits = $reader->getUIBits(4);
    $numLineBits = $reader->getUIBits(4);
    while ($done === false) {
        $typeFlag = $reader->getUIBit();
        if ($typeFlag == 0) {
            $endOfShape = $reader->getUIBits(5);
            if ($endOfShape == 0) {
                $done = true;
            } else {
                // StyleChangeRecord
                ...
            }
        } else {
            $straightFlag = $reader->getUIBit();
            if ($straightFlag) {
                 // StraightEdgeRecord
                 ...
                $stateNewStyles = $reader->getUIBit();
                if ($stateNewStyles) {
                    $this->_parseFILLSTYLEARRAY($reader);
                    $this->_parseLINESTYLEARRAY($reader);
                    $reader->byteAlign();
    $numFillBits = $reader->getUIBits(4);
                    $numLineBits = $reader->getUIBits(4);
                }
            } else {
                 // CurvedEdgeRecord
                 ...
            }
        }
    }
    
    ** ready

    pear channel-discover openpear.org
    pear install openpear/IO_Bit
    pear install openpear/IO_SWF
    

    ** go

    ShapeId: 1
    ShapeBounds:
            (-7.75, -7.75) - (7.75, 7.75)
    FillStyles:
            solid fill: #0066ff
    LineStyles:
    ShapeRecords:
            ChangeStyle: MoveTo: (-7.75, -7.75)  FillStyle: 0|1  LineStyle: 0
            StraightEdge: MoveTo: (7.75, -7.75)
            StraightEdge: MoveTo: (7.75, 7.75)
            StraightEdge: MoveTo: (-7.75, 7.75)
            StraightEdge: MoveTo: (-7.75, -7.75)
    

    ** TODO

    i want convert to SVG for shape display.




    2011年2月12日土曜日

    Challenge to FizzBuzz

    I challenged to fizzbuzz because i had watched "fizzbuzz" in Twitter timeline.
    It takes 5 minutes for take1,2,3. so good.

    - reference
    --    http://www.aoky.net/articles/jeff_atwood/why_cant_programmers_program.htm

    * subject

    Let's programming 1 to 100 number print out.
    but if number is multiple of three then print "Fizz",
    ,multiple of five then print "Buzz", and
    multiple of three and file then print "FizzBuzz".

    * take1

    simple and  stupidly honest.

    <?php
    foreach (range(1, 100) as $n) {
        if ($n % 3 == 0)  {
            if ($n % 5 == 0)  {
              echo "FizzBuzz\n";
            } else {
              echo "Fizz\n";
            }
        } elseif ($n % 5 == 0)  {
              echo "Buzz\n";
        } else {
            echo "$n\n";
        }
    }
    

    * take2

    aggregate %5 routine.

    <?php
    foreach (range(1, 100) as $n) {
        $d = '';
        if ($n % 3 == 0)  {
            $d .= "Fizz";
        }
        if ($n % 5 == 0)  {
            $d .= "Buzz";
        }
        if ($d === '') {
            $d = $n;
        }
        echo "$d\n";
    }

    * take2'

    ternary operand

    <?php
    foreach (range(1, 100) as $n) {
        $d = ($n % 3)?'':"Fizz";
        $d .= ($n % 5)?'':"Buzz";
        echo ($d?$d:$n)."\n";
    }
    

    i don't want to use ternary operand nesting.

    * take3

    flag programming. clearly but long code.

    <?php
    foreach (range(1, 100) as $n) {
        $b3 = ($n % 3)?0:1;
        $b5 = ($n % 5)?0:2;
        switch ($b3 | $b5) {
            case 0:
                 echo "$n\n";
                 break;
            case 1:
                 echo "Fizz\n";
                 break;
            case 2:
                 echo "Buzz\n";
                 break;
            case 3:
                 echo "FizzBuzz\n";
                 break;
        }
    }
    

    * take3

    printf programming.

    $fmt = array('%d', 'Fizz', 'Buzz', 'FizzBuzz');
    foreach (range(1, 100) as $n) {
        $b3 = ($n % 3)?0:1;
        $b5 = ($n % 5)?0:2;
        printf($fmt[$b3 | $b5]."\n", $n);
    }
    
    * perl

    foreach (1 .. 100) {
        $_ = ($_, 'Fizz', 'Buzz', 'FizzBuzz')[2 * !($_ % 3) + !($_ % 5)]."\n"; print
    }
    

    very simple....


    2011年1月25日火曜日

    What spoken at Zynga Japan

    I've spoken at Zynga Japan.
    I can speak about Flash SWF only, and wrote down blog.

    ** SWF review

    - header structure and control tag and display list.
    - base acknowledgement for gordon.js leaning.

    ** about gordon.js

    - flush v1 player, powered by javascript and SVG.
    - animation by SVG node addttion and removal to DOM.
    - Javascript mouse, button event handle to flush event.
    - multi-timeline by Worker thread. but not works.

    ** gordon.js remix

    - contents repository
    - deformer shape edge.
    - image pre filter (reverse pre-mutilipried alpha channel)
    - actionbytecode to javascript converter.

    ** SWFEditor

    - setActionVariables
    - setShapeAdjustMode
      -  http://d.hatena.ne.jp/yoya/20101027/swfed
    - applyShapeMatrixFactor

    ** etc...

    - Flush Lite Study. Im waiting it enjoyment.
    - ZendEngine Study. Thank you for your presentation.
    - I want to come again.

    2011年1月15日土曜日

    Zend Engine study ATND drafts

    We can't make drafts at ATND service so i wrote it here.
    Mayby, not enought of examination. need check it.

    TITLE: ZendEngine Study at Tokyo
    SubTITLE: Recommend to PHP extention
    Contents:...
    DateTime: 2011/2/16 20:00-23:00
    MemberMax:100
    Hall: Gree Inc, Seminor room.
    Address: Tokyo Minato-ku Roppongi 6-10-1 Roppongi-Hills Mori Tower.
    URL: http://groups.google.com/group/php-zendengine
    Questionnaire: ...

    **Contents

    I have plan to Zend Engine study for mainly PHP extension.

    - ZendEngine study at Tokyo

    - Schedule.
      - 19:30 open hall
      - 20:00 study start
      - 22:00 after party.
      - 23:00 close

    - Reqruitment Presenter

    2011年1月12日水曜日

    Zend Engine study hall reservation

    I reserved the seminar room of GREE, 2011/2/16(Wed).

    I'm designing outline of study meeting, referring to roppongi.st.
    Wait a moment, please.

    * derived from roppingi.st (member increase)

    - DateTime: 2011/2/16(Wed) 20:00 to 23:00 JST
    - Member LIMIT: 100 persons.
    - Hall: GREE Inc (TOKYO, Minato-ku Roppongi 6-10-1 Roppongi-Hills Mori-Tower)
    - After Party fee: \2,000 (Arbitrary join)
    - Presentation Wanted: Reguler(10,20,30,40mins)、LightningTalk(5,10mins)
    - Entrance management: member's realname is required. Inquiry by business card (or Warrant card  someting)

    * TODO

    I want to understand following items.

    - flow of guide to hall.
    - process of hall building.
    - Catering procedure
    - presentation recruitment.
    - realname management. (privacy data is risky)
    - hall management. (guide, timekeeper, ustream, etc...)

    2011年1月1日土曜日

    FreeBSD ports graphics php5-swfed

    SWF Editor for PHP, my product, was commited for ports of FreeBSD.

    http://www.freebsd.org/cgi/cvsweb.cgi/ports/graphics/php5-swfed/

    I hope it was included FreeBSD next version 8.2 RELEASE.

    swfed-0.28 release - jpeg chunk fault

    SWFEditor 0.28 was released.

    - http://sourceforge.jp/projects/swfed/releases/

    This release is mainly correspondence to the matter that seg.fault by the environment.

    - Seg.fault corrected case SWF including the JPEG tag is processed.
    (no intended free when specific chunk was deleted from the JPEG data was processed.)
    - It remodels it with setActionVariables behind the Protect tag the inserted DoAction tag of the location.
    - Remodeling of debugging code.