Hi all,
While getting ready to get rid of an old computer of mine, I came across
this transform that I wrote a few years ago (around 2002 I think). I did
it just to prove that it could be done, so the more mathematically
inclined will no doubt find better ways to do this.
I thought some of you might get a kick out of it.
Do this:
1) Run it trough your favorite XSLT 1.0 processor, output to file. I
recommend a really fast processor, such as SAXON. The transform does not
depend on any input source, so you can use whatever you have lying
around. Wait for it...
2) Open the result in a browser. Wait for it...
Here is the transform:
-- begin mandel.xsl --
<?xml version="1.0" encoding="utf-8"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"
indent="yes"
encoding="iso-8859-1"/>
<!-- The area to calculate -->
<xsl:param name="minX" select="-2"/>
<xsl:param name="maxX" select="1.25"/>
<xsl:param name="minY" select="-1.25"/>
<xsl:param name="maxY" select="1.75"/>
<!-- Maximum number of iterations -->
<xsl:param name="maxIterat ions" select="100"/>
<!-- Cell size -->
<xsl:param name="cellSize" select="1"/>
<!-- Number of rows -->
<xsl:param name="rowsMax" select="300"/>
<xsl:variable name="dy" select="($maxY - $minY) div $rowsMax"/>
<xsl:variable name="cellsMax" select="($maxX - $minX) div $dy"/>
<xsl:variable name="dx" select="($maxX - $minX) div $cellsMax"/>
<xsl:template match="/">
<html>
<head>
<title>XSLT Mandelbrot Set</title>
</head>
<body>
<table cellspacing="0"
cellpadding="0"
border="0"
bgcolor="black" >
<xsl:call-template name="Rows"/>
</table>
</body>
</html>
</xsl:template>
<xsl:template name="Rows">
<xsl:param name="rowNumber " select="0"/>
<xsl:if test="$rowNumbe r < $rowsMax">
<xsl:message>
<xsl:value-of select="concat( 'Row ', $rowNumber + 1, ' of ',
$rowsMax)"/>
</xsl:message>
<tr>
<xsl:call-template name="Cells">
<xsl:with-param name="rowNumber " select="$rowNum ber"/>
</xsl:call-template>
</tr>
<xsl:call-template name="Rows">
<xsl:with-param name="rowNumber " select="$rowNum ber + 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="Cells">
<xsl:param name="cellNumbe r" select="0"/>
<xsl:param name="rowNumber "/>
<xsl:if test="$cellNumb er < $cellsMax">
<td width="{$cellSi ze}" height="{$cellS ize}">
<xsl:call-template name="CellColor ">
<xsl:with-param name="cx" select="$minX + ($cellNumber * $dx)"/>
<xsl:with-param name="cy" select="$minY + ($rowNumber * $dy)"/>
</xsl:call-template>
</td>
<xsl:call-template name="Cells">
<xsl:with-param name="cellNumbe r" select="$cellNu mber + 1"/>
<xsl:with-param name="rowNumber " select="$rowNum ber"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="CellColor ">
<xsl:param name="iteration " select="0"/>
<xsl:param name="cx"/>
<xsl:param name="cy"/>
<xsl:param name="a0" select="0"/>
<xsl:param name="b0" select="0"/>
<xsl:variable name="a1" select="($a0 * $a0) - ($b0 * $b0) + $cx"/>
<xsl:variable name="b1" select="2 * ($a0 * $b0) + $cy"/>
<xsl:variable name="zLength" select="($a1 * $a1) + ($b1 * $b1)"/>
<xsl:if test="$zLength > 4">
<xsl:variable name="color">
<xsl:call-template name="Dec2Hex">
<xsl:with-param name="dec" select="round(( 16777215 div
$maxIterations) * $iteration)"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="padding"
select="6 - string-length($color)"/>
<xsl:variable name="paddedCol or"
select="concat( substring('0000 00',1,$padding) , $color)"/>
<xsl:attribut e name="bgcolor">
<xsl:value-of select="concat( '#',$paddedColo r)"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$iteratio n < $maxIterations and $zLength <= 4">
<xsl:call-template name="CellColor ">
<xsl:with-param name="iteration " select="$iterat ion + 1"/>
<xsl:with-param name="cx" select="$cx"/>
<xsl:with-param name="cy" select="$cy"/>
<xsl:with-param name="a0" select="$a1"/>
<xsl:with-param name="b0" select="$b1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="Dec2Hex">
<xsl:param name="dec" select="0"/>
<xsl:variable name="div" select="floor($ dec div 16)"/>
<xsl:variable name="rem" select="$dec - ($div * 16)"/>
<xsl:choose>
<xsl:when test="$dec = 0">0</xsl:when>
<xsl:when test="$dec = 1">1</xsl:when>
<xsl:when test="$dec = 2">2</xsl:when>
<xsl:when test="$dec = 3">3</xsl:when>
<xsl:when test="$dec = 4">4</xsl:when>
<xsl:when test="$dec = 5">5</xsl:when>
<xsl:when test="$dec = 6">6</xsl:when>
<xsl:when test="$dec = 7">7</xsl:when>
<xsl:when test="$dec = 8">8</xsl:when>
<xsl:when test="$dec = 9">9</xsl:when>
<xsl:when test="$dec = 10">A</xsl:when>
<xsl:when test="$dec = 11">B</xsl:when>
<xsl:when test="$dec = 12">C</xsl:when>
<xsl:when test="$dec = 13">D</xsl:when>
<xsl:when test="$dec = 14">E</xsl:when>
<xsl:when test="$dec = 15">F</xsl:when>
<xsl:otherwis e>
<xsl:call-template name="Dec2Hex">
<xsl:with-param name="dec" select="$div"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$div">
<xsl:call-template name="Dec2Hex">
<xsl:with-param name="dec" select="$rem"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
-- end mandel.xsl --
Other mildly interesting values of the parameters are:
minX = 0.2
maxX = 0.4
minY = 0.5
maxY = 0.7
and
minX = 0.3
maxX = 0.4
minY = 0.5
maxY = 0.6
and
minX = 0.32
maxX = 0.35
minY = 0.52
maxY = 0.55
The smaller the area, the longer it will take. For really small areas it
seems like the processor gets stuck.
// Magnus 3 1470
And I thought merely solving the eight-queens problem in XSLT was a
terrifying concept... <grin/>
Are you willing to officially put that into the public domain so we can
pass it around?
Joseph Kesselman wrote:
And I thought merely solving the eight-queens problem in XSLT was a
terrifying concept... <grin/>
Are you willing to officially put that into the public domain so we can
pass it around?
I hereby abandon any property rights to the XSLT code in message
eh**********@ne ws.al.sw.ericss on.se.
// Magnus
Magnus Henriksson wrote:
[XSLT Mandelbrot Set Explorer]
I thought some of you might get a kick out of it.
I sure did.
1) Run it trough your favorite XSLT 1.0 processor, output
to file. I recommend a really fast processor, such as
SAXON.
libxslt-based PHP5 module worked well enough for me. (And I
didn't even have to juggle the files around - my web-based
toolkit handles that for me and displays the transformation
result in an iframe.)
I guess this post is a bit pointless, but I just wanted to
say that this is wonderful stuff. Hats off.
--
roy axenov This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: StinkFinger |
last post by:
Hello all,
After enabling sessions for my website I have approx. 785 files in my
sessiondata folder. Now, I know what these are, however, I don't know
when/how is the best way to clean them (besides running a weekly delete
batch file).
Once the users leaves and closes the browser, the session is essential dead,
right ? So, why would I need to keep these files around ? I looked in
PHP.INI but I could not find any "cleaning" settings to...
|
by: Ellen K. |
last post by:
What tools has everyone used for cleaning name and address data
(including identifying not-immediately-obvious duplicates) in
connection with a CRM project or the Customer dimension of a data
warehouse? What did you like/dislike about the tool you used? How
customizable was the tool you used?
|
by: Matej Cepl |
last post by:
Hi,
can anybody help me with the cleaning of really messy HTML from
the news site into really clean XHTML, which I would like to
then analyze with some qualitative analysis (probably exporting
to plain ASCII in meantime, but not necessarily). I can do some
little cleaning by hand, but when there some hundreds of
webpages, I hoped that I could create some XSL stylesheet for
conversion.
|
by: Jaans |
last post by:
I have a problem that relates to running "cleanup" code when an application
is forcibly ended using the "End Process" of "Task Manager" (Please note that
this is very different from "End Task" since end task sends a message to the
application, requesting it to close)
My real problem is that our application makes entries into a database when
the application starts, and then corresponding entries when the application
closes ("cleanup")....
|
by: sheffdog |
last post by:
Hello,
I often find myself cleaning up strings like the following:
setAttr ".ftn" -type "string" /assets/chars/
/boya/geo/textures/lod1/ppbhat.tga";
Using regular expressions, the best I can do so far is using the re.sub
command but it still takes two lines. Can I do this in one line? Or
should I be approaching this differently? All I want to end up with is
| |
by: Pierre Saint-Jacques |
last post by:
DB2 V8.2 has a new envir. var.
DB2_USE_ALTERNATE_PAGE_CLEANING=YES
The docs. mention that this will make DB2 ignore chngpgs_thresh and use
softmax to even the rate of writing out of the bp's.
What agent process then takes over.
On a workload of 10000 trans./min., I get over 9000 bp's writes out of
my snapshot. However, LSAN Gap Cleaners, Thereshold Cleansers and
Victim Page Cleaners are all = 0
|
by: jadionne |
last post by:
I have a new instalation that I am ironing out the wrinkles in. In the
process I have had a few crashes and now my SQLlib\DB2 Dir is full of
..0 and .000 files. What is the best way to clean up this Dir without
damaging anything permanatly?
|
by: Mikey |
last post by:
Do NativeWindows get destroyed when the app shuts down?
While my app is running I can Spy++ and see my NativeWindow handle.
After app shutdown it's no longer there.
But this is confusing because if I Spy++ on the messages, and do a
DestroyHandle, I see a WM_DESTROY, but do not see this message when
the app shuts down. I presume the window has indeed been destroyed,
because Spy++ doesn't pick it up.
|
by: Foodbank |
last post by:
Hi,
Has anyone ever hashed a text file to disk before? I'm trying to
convert an in-memory hash to disk hash and I can't find any relevant
information to help me. Also, I'd like to use lseek, read, write, and
fd if anyone is familiar with them. Any info would be greatly helpful.
Thanks,
James
|
by: Now You Know |
last post by:
Carpet Cleaners Los Angeles Home Carpet Rug Upholstery Cleaning
Phone 1 310 925 1720 OR 1-818-386-1022
Local Call California Wide
We offer carpet cleaning services such as; Steam Cleaning, Dry
Cleaning, Fabric Lounge Suite Cleaning, Leather Lounge Suite Cleaning,
Tile & Grout Cleaning, Mattress Cleaning, Wet Carpet / Water Damage
Restoration for: offices, homes, restaurants, clubs and hotels
http://carpetcleanersorangecounty.blogspot.com/...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |