rubyvis 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +6 -1
- data/Manifest.txt +421 -1
- data/README.txt +12 -10
- data/examples/first.rb +2 -2
- data/examples/second.rb +6 -3
- data/lib/rubyvis.rb +18 -3
- data/lib/rubyvis/mark.rb +101 -83
- data/lib/rubyvis/mark/anchor.rb +5 -7
- data/lib/rubyvis/mark/area.rb +19 -17
- data/lib/rubyvis/mark/bar.rb +3 -10
- data/lib/rubyvis/mark/label.rb +3 -4
- data/lib/rubyvis/mark/line.rb +20 -4
- data/lib/rubyvis/mark/panel.rb +31 -6
- data/lib/rubyvis/mark/rule.rb +8 -4
- data/lib/rubyvis/property.rb +11 -0
- data/lib/rubyvis/scene/svg_label.rb +1 -1
- data/lib/rubyvis/scene/svg_scene.rb +2 -1
- data/lib/rubyvis/sceneelement.rb +2 -0
- data/spec/bar_spec.rb +50 -0
- data/spec/label_spec.rb +41 -0
- data/spec/mark_spec.rb +16 -0
- data/spec/panel_spec.rb +22 -4
- data/spec/spec_helper.rb +1 -0
- data/vendor/FUTURE +62 -0
- data/vendor/Makefile +138 -0
- data/vendor/TODO +22 -0
- data/vendor/examples/antibiotics/antibiotics-scatter.html +113 -0
- data/vendor/examples/antibiotics/antibiotics.html +140 -0
- data/vendor/examples/antibiotics/antibiotics.js +20 -0
- data/vendor/examples/barley/barley.html +102 -0
- data/vendor/examples/barley/barley.js +122 -0
- data/vendor/examples/cars/cars.html +90 -0
- data/vendor/examples/cars/cars.js +408 -0
- data/vendor/examples/clock/clock.html +91 -0
- data/vendor/examples/crimea/crimea-grouped-bar.html +65 -0
- data/vendor/examples/crimea/crimea-line.html +61 -0
- data/vendor/examples/crimea/crimea-stacked-area.html +61 -0
- data/vendor/examples/crimea/crimea-stacked-bar.html +60 -0
- data/vendor/examples/crimea/crimea.html +100 -0
- data/vendor/examples/crimea/crimea.js +33 -0
- data/vendor/examples/downloadify/LICENSE.txt +22 -0
- data/vendor/examples/downloadify/download.png +0 -0
- data/vendor/examples/downloadify/downloadify.html +57 -0
- data/vendor/examples/downloadify/downloadify.min.js +3 -0
- data/vendor/examples/downloadify/downloadify.swf +0 -0
- data/vendor/examples/downloadify/swfobject.js +4 -0
- data/vendor/examples/ex.css +17 -0
- data/vendor/examples/eyes/eyes.html +53 -0
- data/vendor/examples/eyes/matrix.html +44 -0
- data/vendor/examples/flowers/flowers.html +109 -0
- data/vendor/examples/flowers/flowers.js +154 -0
- data/vendor/examples/group-stack/group-stack.html +79 -0
- data/vendor/examples/group-stack/headcount.js +23 -0
- data/vendor/examples/hotel/hotel.html +76 -0
- data/vendor/examples/hotel/hotel.js +245 -0
- data/vendor/examples/jobs/jobs.html +71 -0
- data/vendor/examples/jobs/jobs.js +1024 -0
- data/vendor/examples/jquery-1.4.2.min.js +154 -0
- data/vendor/examples/nba/nba.html +83 -0
- data/vendor/examples/nba/nba.js +53 -0
- data/vendor/examples/nba/nba2.html +82 -0
- data/vendor/examples/sankey/gdp2009.js +184 -0
- data/vendor/examples/sankey/sankey.html +77 -0
- data/vendor/examples/slider/cell.html +112 -0
- data/vendor/examples/slider/cell.js +31 -0
- data/vendor/examples/slider/horizon.html +85 -0
- data/vendor/examples/slider/jquery-ui-1.8rc3.custom.min.js +71 -0
- data/vendor/examples/slider/slider.html +50 -0
- data/vendor/examples/slider/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/vendor/examples/slider/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/vendor/examples/slider/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/vendor/examples/slider/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/vendor/examples/slider/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/vendor/examples/slider/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/vendor/examples/slider/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/vendor/examples/slider/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/vendor/examples/slider/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/vendor/examples/slider/ui-lightness/images/ui-icons_222222_256x240.png +2 -0
- data/vendor/examples/slider/ui-lightness/images/ui-icons_228ef1_256x240.png +2 -0
- data/vendor/examples/slider/ui-lightness/images/ui-icons_ef8c08_256x240.png +2 -0
- data/vendor/examples/slider/ui-lightness/images/ui-icons_ffd27a_256x240.png +2 -0
- data/vendor/examples/slider/ui-lightness/images/ui-icons_ffffff_256x240.png +2 -0
- data/vendor/examples/slider/ui-lightness/jquery-ui-1.8rc3.custom.css +302 -0
- data/vendor/examples/tipsy/jquery.tipsy.js +198 -0
- data/vendor/examples/tipsy/tipsy-bar.html +65 -0
- data/vendor/examples/tipsy/tipsy-line.html +67 -0
- data/vendor/examples/tipsy/tipsy.css +12 -0
- data/vendor/examples/tipsy/tipsy.gif +0 -0
- data/vendor/examples/tipsy/tipsy.js +66 -0
- data/vendor/examples/weather/weather.html +86 -0
- data/vendor/examples/weather/weather.js +42 -0
- data/vendor/examples/wheat/wheat.html +130 -0
- data/vendor/examples/wheat/wheat.js +70 -0
- data/vendor/lib/google-compiler/COPYING +202 -0
- data/vendor/lib/google-compiler/README +224 -0
- data/vendor/lib/google-compiler/compiler-20100201.jar +0 -0
- data/vendor/protovis-d3.3.js +15726 -0
- data/vendor/protovis-r3.3.js +287 -0
- data/vendor/src/behavior/Behavior.js +32 -0
- data/vendor/src/behavior/Drag.js +112 -0
- data/vendor/src/behavior/Pan.js +110 -0
- data/vendor/src/behavior/Point.js +157 -0
- data/vendor/src/behavior/Resize.js +104 -0
- data/vendor/src/behavior/Select.js +100 -0
- data/vendor/src/behavior/Zoom.js +85 -0
- data/vendor/src/color/Color.js +598 -0
- data/vendor/src/color/Colors.js +135 -0
- data/vendor/src/color/Ramp.js +17 -0
- data/vendor/src/data/Arrays.js +277 -0
- data/vendor/src/data/Dom.js +380 -0
- data/vendor/src/data/Flatten.js +146 -0
- data/vendor/src/data/Histogram.js +120 -0
- data/vendor/src/data/LinearScale.js +54 -0
- data/vendor/src/data/LogScale.js +142 -0
- data/vendor/src/data/Nest.js +257 -0
- data/vendor/src/data/Numbers.js +313 -0
- data/vendor/src/data/Objects.js +78 -0
- data/vendor/src/data/OrdinalScale.js +267 -0
- data/vendor/src/data/QuantileScale.js +180 -0
- data/vendor/src/data/QuantitativeScale.js +440 -0
- data/vendor/src/data/RootScale.js +55 -0
- data/vendor/src/data/Scale.js +86 -0
- data/vendor/src/data/Transform.js +109 -0
- data/vendor/src/data/Tree.js +124 -0
- data/vendor/src/data/Vector.js +118 -0
- data/vendor/src/geo/Geo.js +5 -0
- data/vendor/src/geo/GeoScale.js +307 -0
- data/vendor/src/geo/LatLng.js +23 -0
- data/vendor/src/geo/Projection.js +43 -0
- data/vendor/src/geo/Projections.js +117 -0
- data/vendor/src/lang/Array.js +112 -0
- data/vendor/src/lang/init.js +26 -0
- data/vendor/src/layout/Arc.js +178 -0
- data/vendor/src/layout/Bullet.js +164 -0
- data/vendor/src/layout/Cluster.js +205 -0
- data/vendor/src/layout/Force.js +309 -0
- data/vendor/src/layout/Grid.js +119 -0
- data/vendor/src/layout/Hierarchy.js +249 -0
- data/vendor/src/layout/Horizon.js +159 -0
- data/vendor/src/layout/Indent.js +83 -0
- data/vendor/src/layout/Layout.js +56 -0
- data/vendor/src/layout/Matrix.js +177 -0
- data/vendor/src/layout/Network.js +302 -0
- data/vendor/src/layout/Pack.js +323 -0
- data/vendor/src/layout/Partition.js +203 -0
- data/vendor/src/layout/Rollup.js +203 -0
- data/vendor/src/layout/Stack.js +391 -0
- data/vendor/src/layout/Tree.js +282 -0
- data/vendor/src/layout/Treemap.js +347 -0
- data/vendor/src/mark/Anchor.js +81 -0
- data/vendor/src/mark/Area.js +268 -0
- data/vendor/src/mark/Bar.js +93 -0
- data/vendor/src/mark/Dot.js +212 -0
- data/vendor/src/mark/Ease.js +150 -0
- data/vendor/src/mark/Image.js +154 -0
- data/vendor/src/mark/Label.js +155 -0
- data/vendor/src/mark/Line.js +195 -0
- data/vendor/src/mark/Mark.js +1237 -0
- data/vendor/src/mark/Panel.js +273 -0
- data/vendor/src/mark/Rule.js +143 -0
- data/vendor/src/mark/Transient.js +7 -0
- data/vendor/src/mark/Transition.js +195 -0
- data/vendor/src/mark/Wedge.js +244 -0
- data/vendor/src/physics/BoundConstraint.js +75 -0
- data/vendor/src/physics/ChargeForce.js +184 -0
- data/vendor/src/physics/CollisionConstraint.js +113 -0
- data/vendor/src/physics/Constraint.js +26 -0
- data/vendor/src/physics/DragForce.js +49 -0
- data/vendor/src/physics/Force.js +25 -0
- data/vendor/src/physics/Particle.js +81 -0
- data/vendor/src/physics/PositionConstraint.js +72 -0
- data/vendor/src/physics/Quadtree.js +195 -0
- data/vendor/src/physics/Simulation.js +159 -0
- data/vendor/src/physics/SpringForce.js +141 -0
- data/vendor/src/pv-internals.js +154 -0
- data/vendor/src/pv.js +95 -0
- data/vendor/src/scene/SvgArea.js +172 -0
- data/vendor/src/scene/SvgBar.js +28 -0
- data/vendor/src/scene/SvgCurve.js +354 -0
- data/vendor/src/scene/SvgDot.js +81 -0
- data/vendor/src/scene/SvgImage.js +45 -0
- data/vendor/src/scene/SvgLabel.js +46 -0
- data/vendor/src/scene/SvgLine.js +159 -0
- data/vendor/src/scene/SvgPanel.js +126 -0
- data/vendor/src/scene/SvgRule.js +26 -0
- data/vendor/src/scene/SvgScene.js +185 -0
- data/vendor/src/scene/SvgWedge.js +66 -0
- data/vendor/src/text/DateFormat.js +262 -0
- data/vendor/src/text/Format.js +78 -0
- data/vendor/src/text/NumberFormat.js +227 -0
- data/vendor/src/text/TimeFormat.js +115 -0
- data/vendor/test1.html +30 -0
- data/vendor/tests/behavior/drag-events.html +47 -0
- data/vendor/tests/behavior/drag.html +32 -0
- data/vendor/tests/behavior/drag2.html +33 -0
- data/vendor/tests/behavior/point-area-stacked.html +73 -0
- data/vendor/tests/behavior/point-area-stacked2.html +70 -0
- data/vendor/tests/behavior/point-area.html +67 -0
- data/vendor/tests/behavior/point-bar.html +62 -0
- data/vendor/tests/behavior/point-dot.html +60 -0
- data/vendor/tests/behavior/point-line.html +62 -0
- data/vendor/tests/behavior/point-lines-grid.html +65 -0
- data/vendor/tests/behavior/point-lines.html +61 -0
- data/vendor/tests/behavior/point-wedge.html +43 -0
- data/vendor/tests/behavior/resize.html +69 -0
- data/vendor/tests/behavior/select.html +37 -0
- data/vendor/tests/bzr.js +62 -0
- data/vendor/tests/center.js +13 -0
- data/vendor/tests/data/deviation.html +54 -0
- data/vendor/tests/data/histogram-discrete.html +50 -0
- data/vendor/tests/data/histogram.html +56 -0
- data/vendor/tests/data/log-adjusted.html +48 -0
- data/vendor/tests/data/log-ceil.html +48 -0
- data/vendor/tests/data/log-floor.html +48 -0
- data/vendor/tests/data/log-symmetric.html +48 -0
- data/vendor/tests/data/log.html +48 -0
- data/vendor/tests/data/max-index.html +36 -0
- data/vendor/tests/data/max.html +36 -0
- data/vendor/tests/data/min-index.html +36 -0
- data/vendor/tests/data/min.html +36 -0
- data/vendor/tests/data/ordinal-split-banded.html +45 -0
- data/vendor/tests/data/ordinal-split-banded2.html +45 -0
- data/vendor/tests/data/ordinal-split-flush.html +51 -0
- data/vendor/tests/data/ordinal-split.html +51 -0
- data/vendor/tests/data/range.html +105 -0
- data/vendor/tests/data/scale-date.html +46 -0
- data/vendor/tests/data/scale-date2.html +38 -0
- data/vendor/tests/data/scale-date3.html +38 -0
- data/vendor/tests/data/scale-date4.html +38 -0
- data/vendor/tests/data/scale-degenerate.html +143 -0
- data/vendor/tests/data/scale-linear.html +59 -0
- data/vendor/tests/data/scale-log.html +60 -0
- data/vendor/tests/data/scale-log2.html +60 -0
- data/vendor/tests/data/scale-log3.html +60 -0
- data/vendor/tests/data/scale-log4.html +60 -0
- data/vendor/tests/data/scale-log5.html +60 -0
- data/vendor/tests/data/scale-log6.html +60 -0
- data/vendor/tests/data/scale-quantile.html +47 -0
- data/vendor/tests/data/scale-quantile2.html +50 -0
- data/vendor/tests/data/scale-quantile3.html +48 -0
- data/vendor/tests/data/scale-root.html +60 -0
- data/vendor/tests/data/scale-root2.html +39 -0
- data/vendor/tests/data/scale-tick-format.html +54 -0
- data/vendor/tests/data/scale-ticks.html +45 -0
- data/vendor/tests/data/sum.html +42 -0
- data/vendor/tests/data/variance.html +42 -0
- data/vendor/tests/diamond.js +40 -0
- data/vendor/tests/flare-imports.js +222 -0
- data/vendor/tests/flare.js +284 -0
- data/vendor/tests/geo/countries-hires.js +257 -0
- data/vendor/tests/geo/countries-lores.js +197 -0
- data/vendor/tests/geo/population.js +250 -0
- data/vendor/tests/geo/scale-aitoff.html +58 -0
- data/vendor/tests/geo/scale-gall-peters.html +56 -0
- data/vendor/tests/geo/scale-hammer.html +58 -0
- data/vendor/tests/geo/scale-identity.html +56 -0
- data/vendor/tests/geo/scale-mercator.html +56 -0
- data/vendor/tests/geo/scale-sinusoidal.html +57 -0
- data/vendor/tests/geo/scale-smart-domain.html +58 -0
- data/vendor/tests/geo/scale.html +55 -0
- data/vendor/tests/geo/scale2.html +40 -0
- data/vendor/tests/geo/us-states.js +61 -0
- data/vendor/tests/heatmap.js +63 -0
- data/vendor/tests/lang/globals.html +41 -0
- data/vendor/tests/lang/init.html +31 -0
- data/vendor/tests/layers.js +28 -0
- data/vendor/tests/layout/arc-directed.html +33 -0
- data/vendor/tests/layout/arc-radial.html +36 -0
- data/vendor/tests/layout/arc-undirected.html +32 -0
- data/vendor/tests/layout/arc.html +33 -0
- data/vendor/tests/layout/arc2.html +32 -0
- data/vendor/tests/layout/bullet-multiples.html +60 -0
- data/vendor/tests/layout/bullet.html +45 -0
- data/vendor/tests/layout/bullets.js +37 -0
- data/vendor/tests/layout/cluster-fill-group.html +24 -0
- data/vendor/tests/layout/cluster-fill.html +28 -0
- data/vendor/tests/layout/cluster-partition-radial-fill.html +43 -0
- data/vendor/tests/layout/cluster-radial-fill-radius.html +26 -0
- data/vendor/tests/layout/cluster-radial-fill.html +29 -0
- data/vendor/tests/layout/cluster-radial-group-fill.html +30 -0
- data/vendor/tests/layout/cluster-radial-radius.html +30 -0
- data/vendor/tests/layout/cluster-radial.html +28 -0
- data/vendor/tests/layout/cluster-radial2.html +33 -0
- data/vendor/tests/layout/cluster.html +34 -0
- data/vendor/tests/layout/cluster2.html +32 -0
- data/vendor/tests/layout/force-toggle.html +46 -0
- data/vendor/tests/layout/force.html +45 -0
- data/vendor/tests/layout/force2.html +58 -0
- data/vendor/tests/layout/force3.html +41 -0
- data/vendor/tests/layout/force4.html +45 -0
- data/vendor/tests/layout/force5.html +53 -0
- data/vendor/tests/layout/grid-cols.html +31 -0
- data/vendor/tests/layout/grid-heatmap.html +25 -0
- data/vendor/tests/layout/grid-rows.html +31 -0
- data/vendor/tests/layout/grid.html +34 -0
- data/vendor/tests/layout/horizon-color.html +31 -0
- data/vendor/tests/layout/horizon.html +31 -0
- data/vendor/tests/layout/indent-toggle.html +62 -0
- data/vendor/tests/layout/indent.html +25 -0
- data/vendor/tests/layout/indent2.html +33 -0
- data/vendor/tests/layout/matrix-sort.html +28 -0
- data/vendor/tests/layout/matrix.html +35 -0
- data/vendor/tests/layout/network.html +43 -0
- data/vendor/tests/layout/pack-bubble.html +45 -0
- data/vendor/tests/layout/pack.html +26 -0
- data/vendor/tests/layout/pack2.html +32 -0
- data/vendor/tests/layout/partition-fill.html +27 -0
- data/vendor/tests/layout/partition-fill2.html +22 -0
- data/vendor/tests/layout/partition-fill3.html +27 -0
- data/vendor/tests/layout/partition-radial-fill-radius.html +25 -0
- data/vendor/tests/layout/partition-radial-fill.html +26 -0
- data/vendor/tests/layout/partition-radial-fill2.html +23 -0
- data/vendor/tests/layout/partition-radial-fill3.html +29 -0
- data/vendor/tests/layout/partition-radial-radius.html +29 -0
- data/vendor/tests/layout/partition-radial.html +30 -0
- data/vendor/tests/layout/partition-radial2.html +33 -0
- data/vendor/tests/layout/partition.html +33 -0
- data/vendor/tests/layout/partition2.html +32 -0
- data/vendor/tests/layout/rollup.html +50 -0
- data/vendor/tests/layout/stack-empty.html +27 -0
- data/vendor/tests/layout/stack-expand.html +41 -0
- data/vendor/tests/layout/stack-reverse.html +42 -0
- data/vendor/tests/layout/stack-right.html +42 -0
- data/vendor/tests/layout/stack-rule.html +61 -0
- data/vendor/tests/layout/stack-visible.html +43 -0
- data/vendor/tests/layout/stack.html +53 -0
- data/vendor/tests/layout/tree-radial.html +31 -0
- data/vendor/tests/layout/tree-radial2.html +34 -0
- data/vendor/tests/layout/tree-toggle.html +36 -0
- data/vendor/tests/layout/tree.html +31 -0
- data/vendor/tests/layout/tree2.html +35 -0
- data/vendor/tests/layout/treemap-hierarchy.html +40 -0
- data/vendor/tests/layout/treemap-margin.html +26 -0
- data/vendor/tests/layout/treemap-round.html +40 -0
- data/vendor/tests/layout/treemap-slice.html +34 -0
- data/vendor/tests/layout/treemap.html +37 -0
- data/vendor/tests/life.js +212 -0
- data/vendor/tests/mark/anchor.html +25 -0
- data/vendor/tests/mark/area-anchor-chain.html +42 -0
- data/vendor/tests/mark/area-anchor-line.html +57 -0
- data/vendor/tests/mark/area-anchor-stack.html +35 -0
- data/vendor/tests/mark/area-anchor.html +43 -0
- data/vendor/tests/mark/area-anchor2.html +33 -0
- data/vendor/tests/mark/area-cardinal.html +57 -0
- data/vendor/tests/mark/area-monotone.html +57 -0
- data/vendor/tests/mark/area-segmented-basis.html +30 -0
- data/vendor/tests/mark/area-segmented-cardinal.html +30 -0
- data/vendor/tests/mark/area-segmented-monotone.html +30 -0
- data/vendor/tests/mark/area-segmented-step.html +44 -0
- data/vendor/tests/mark/area-segmented.html +29 -0
- data/vendor/tests/mark/area-stacked-cardinal.html +54 -0
- data/vendor/tests/mark/area-stacked-monotone.html +54 -0
- data/vendor/tests/mark/area-stacked.html +53 -0
- data/vendor/tests/mark/area-step.html +43 -0
- data/vendor/tests/mark/area-zero.html +32 -0
- data/vendor/tests/mark/area.html +57 -0
- data/vendor/tests/mark/bar-anchor-stack.html +51 -0
- data/vendor/tests/mark/bar-anchor.html +44 -0
- data/vendor/tests/mark/bar-column-grouped.html +63 -0
- data/vendor/tests/mark/bar-column-stacked.html +56 -0
- data/vendor/tests/mark/bar-column.html +54 -0
- data/vendor/tests/mark/bar-grouped.html +63 -0
- data/vendor/tests/mark/bar-stacked.html +57 -0
- data/vendor/tests/mark/bar.html +54 -0
- data/vendor/tests/mark/cursor.html +41 -0
- data/vendor/tests/mark/def-type.html +23 -0
- data/vendor/tests/mark/dot-anchor.html +33 -0
- data/vendor/tests/mark/dot-radius.html +22 -0
- data/vendor/tests/mark/dot-stroke.html +43 -0
- data/vendor/tests/mark/dot.html +52 -0
- data/vendor/tests/mark/dot2.html +61 -0
- data/vendor/tests/mark/ease.html +90 -0
- data/vendor/tests/mark/event-dblclick.html +30 -0
- data/vendor/tests/mark/event-prototype.html +45 -0
- data/vendor/tests/mark/event-render.html +45 -0
- data/vendor/tests/mark/event.html +24 -0
- data/vendor/tests/mark/image-color-inherit.html +33 -0
- data/vendor/tests/mark/image-color.html +35 -0
- data/vendor/tests/mark/image-color2.html +35 -0
- data/vendor/tests/mark/image-heatmap.html +29 -0
- data/vendor/tests/mark/image.html +32 -0
- data/vendor/tests/mark/label-break.html +54 -0
- data/vendor/tests/mark/label-decoration.html +22 -0
- data/vendor/tests/mark/label-events.html +32 -0
- data/vendor/tests/mark/line-anchor.html +42 -0
- data/vendor/tests/mark/line-basis.html +54 -0
- data/vendor/tests/mark/line-brownian.html +57 -0
- data/vendor/tests/mark/line-cardinal.html +77 -0
- data/vendor/tests/mark/line-catmull-rom.html +78 -0
- data/vendor/tests/mark/line-curve.html +65 -0
- data/vendor/tests/mark/line-eccentricity.html +39 -0
- data/vendor/tests/mark/line-fill.html +24 -0
- data/vendor/tests/mark/line-join.html +51 -0
- data/vendor/tests/mark/line-monotone-non-monotone.html +53 -0
- data/vendor/tests/mark/line-monotone-two-way.html +61 -0
- data/vendor/tests/mark/line-monotone.html +53 -0
- data/vendor/tests/mark/line-polar.html +36 -0
- data/vendor/tests/mark/line-segmented-basis.html +57 -0
- data/vendor/tests/mark/line-segmented-cardinal.html +80 -0
- data/vendor/tests/mark/line-segmented-join.html +52 -0
- data/vendor/tests/mark/line-segmented-monotone.html +56 -0
- data/vendor/tests/mark/line-segmented-polar.html +30 -0
- data/vendor/tests/mark/line-segmented-step.html +41 -0
- data/vendor/tests/mark/line-segmented-step2.html +32 -0
- data/vendor/tests/mark/line-segmented.html +30 -0
- data/vendor/tests/mark/line-step.html +39 -0
- data/vendor/tests/mark/line-tension.html +59 -0
- data/vendor/tests/mark/line.html +51 -0
- data/vendor/tests/mark/panel-anchor.html +37 -0
- data/vendor/tests/mark/panel-anchor2.html +31 -0
- data/vendor/tests/mark/panel-anchor3.html +22 -0
- data/vendor/tests/mark/panel-anchor4.html +28 -0
- data/vendor/tests/mark/panel-anchor5.html +28 -0
- data/vendor/tests/mark/panel-append.html +29 -0
- data/vendor/tests/mark/panel-canvas.html +107 -0
- data/vendor/tests/mark/panel-fill.html +50 -0
- data/vendor/tests/mark/panel-mouse.html +53 -0
- data/vendor/tests/mark/panel-transform.html +67 -0
- data/vendor/tests/mark/property-cast.html +24 -0
- data/vendor/tests/mark/render-partial.html +42 -0
- data/vendor/tests/mark/rule-anchor.html +29 -0
- data/vendor/tests/mark/title.html +41 -0
- data/vendor/tests/mark/transition-anchor.html +47 -0
- data/vendor/tests/mark/transition-wedge.html +47 -0
- data/vendor/tests/mark/transition.html +106 -0
- data/vendor/tests/mark/wedge-donut.html +35 -0
- data/vendor/tests/mark/wedge-implied.html +42 -0
- data/vendor/tests/mark/wedge-pie.html +37 -0
- data/vendor/tests/mark/wedge-ring.html +27 -0
- data/vendor/tests/miserables.js +348 -0
- data/vendor/tests/physics/dorling.html +70 -0
- data/vendor/tests/physics/simulation.html +56 -0
- data/vendor/tests/social.js +28 -0
- data/vendor/tests/stanford.png +0 -0
- data/vendor/tests/style.css +5 -0
- data/vendor/tests/testify.css +29 -0
- data/vendor/tests/testify.js +16 -0
- data/vendor/tests/text/format-number.html +75 -0
- data/web/first.svg +1 -0
- data/web/index.html +48 -0
- metadata +434 -31
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -2
@@ -0,0 +1,113 @@
|
|
1
|
+
/**
|
2
|
+
* Constructs a new collision constraint. The default search radius is 10, and
|
3
|
+
* the default repeat count is 1. A radius function must be specified to compute
|
4
|
+
* the radius of particles.
|
5
|
+
*
|
6
|
+
* @class Constraints circles to avoid overlap. Each particle is treated as a
|
7
|
+
* circle, with the radius of the particle computed using a specified function.
|
8
|
+
* For example, if the particle has an <tt>r</tt> attribute storing the radius,
|
9
|
+
* the radius <tt>function(d) d.r</tt> specifies a collision constraint using
|
10
|
+
* this radius. The radius function is passed each {@link pv.Particle} as the
|
11
|
+
* first argument.
|
12
|
+
*
|
13
|
+
* <p>To accelerate collision detection, this implementation uses a quadtree and
|
14
|
+
* a search radius. The search radius is computed as the maximum radius of all
|
15
|
+
* particles in the simulation.
|
16
|
+
*
|
17
|
+
* @see pv.Constraint
|
18
|
+
* @param {function} radius the radius function.
|
19
|
+
*/
|
20
|
+
pv.Constraint.collision = function(radius) {
|
21
|
+
var n = 1, // number of times to repeat the constraint
|
22
|
+
r1,
|
23
|
+
px1,
|
24
|
+
py1,
|
25
|
+
px2,
|
26
|
+
py2,
|
27
|
+
constraint = {};
|
28
|
+
|
29
|
+
if (!arguments.length) r1 = 10; // default search radius
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Sets or gets the repeat count. If the repeat count is greater than 1, the
|
33
|
+
* constraint will be applied repeatedly; this is a form of the Gauss-Seidel
|
34
|
+
* method for constraints relaxation. Repeating the collision constraint makes
|
35
|
+
* the constraint have more of an effect when there is a potential for many
|
36
|
+
* co-occurring collisions.
|
37
|
+
*
|
38
|
+
* @function
|
39
|
+
* @name pv.Constraint.collision.prototype.repeat
|
40
|
+
* @param {number} x the number of times to repeat this constraint.
|
41
|
+
* @returns {pv.Constraint.collision} this.
|
42
|
+
*/
|
43
|
+
constraint.repeat = function(x) {
|
44
|
+
if (arguments.length) {
|
45
|
+
n = Number(x);
|
46
|
+
return constraint;
|
47
|
+
}
|
48
|
+
return n;
|
49
|
+
};
|
50
|
+
|
51
|
+
/** @private */
|
52
|
+
function constrain(n, p, x1, y1, x2, y2) {
|
53
|
+
if (!n.leaf) {
|
54
|
+
var sx = (x1 + x2) * .5,
|
55
|
+
sy = (y1 + y2) * .5,
|
56
|
+
top = sy > py1,
|
57
|
+
bottom = sy < py2,
|
58
|
+
left = sx > px1,
|
59
|
+
right = sx < px2;
|
60
|
+
if (top) {
|
61
|
+
if (n.c1 && left) constrain(n.c1, p, x1, y1, sx, sy);
|
62
|
+
if (n.c2 && right) constrain(n.c2, p, sx, y1, x2, sy);
|
63
|
+
}
|
64
|
+
if (bottom) {
|
65
|
+
if (n.c3 && left) constrain(n.c3, p, x1, sy, sx, y2);
|
66
|
+
if (n.c4 && right) constrain(n.c4, p, sx, sy, x2, y2);
|
67
|
+
}
|
68
|
+
}
|
69
|
+
if (n.p && (n.p != p)) {
|
70
|
+
var dx = p.x - n.p.x,
|
71
|
+
dy = p.y - n.p.y,
|
72
|
+
l = Math.sqrt(dx * dx + dy * dy),
|
73
|
+
d = r1 + radius(n.p);
|
74
|
+
if (l < d) {
|
75
|
+
var k = (l - d) / l * .5;
|
76
|
+
dx *= k;
|
77
|
+
dy *= k;
|
78
|
+
p.x -= dx;
|
79
|
+
p.y -= dy;
|
80
|
+
n.p.x += dx;
|
81
|
+
n.p.y += dy;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
/**
|
87
|
+
* Applies this constraint to the specified particles.
|
88
|
+
*
|
89
|
+
* @function
|
90
|
+
* @name pv.Constraint.collision.prototype.apply
|
91
|
+
* @param {pv.Particle} particles particles to which to apply this constraint.
|
92
|
+
* @param {pv.Quadtree} q a quadtree for spatial acceleration.
|
93
|
+
*/
|
94
|
+
constraint.apply = function(particles, q) {
|
95
|
+
var p, r, max = -Infinity;
|
96
|
+
for (p = particles; p; p = p.next) {
|
97
|
+
r = radius(p);
|
98
|
+
if (r > max) max = r;
|
99
|
+
}
|
100
|
+
for (var i = 0; i < n; i++) {
|
101
|
+
for (p = particles; p; p = p.next) {
|
102
|
+
r = (r1 = radius(p)) + max;
|
103
|
+
px1 = p.x - r;
|
104
|
+
px2 = p.x + r;
|
105
|
+
py1 = p.y - r;
|
106
|
+
py2 = p.y + r;
|
107
|
+
constrain(q.root, p, q.xMin, q.yMin, q.xMax, q.yMax);
|
108
|
+
}
|
109
|
+
}
|
110
|
+
};
|
111
|
+
|
112
|
+
return constraint;
|
113
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/**
|
2
|
+
* Abstract; see an implementing class.
|
3
|
+
*
|
4
|
+
* @class Represents a constraint that acts on particles. Note that this
|
5
|
+
* interface does not specify how to bind a constraint to specific particles; in
|
6
|
+
* general, constraints are applied globally to all particles. However, some
|
7
|
+
* constraints may be applied to specific particles or between particles, such
|
8
|
+
* as position constraints, through additional specialization.
|
9
|
+
*
|
10
|
+
* @see pv.Simulation
|
11
|
+
* @see pv.Particle
|
12
|
+
* @see pv.Constraint.bound
|
13
|
+
* @see pv.Constraint.collision
|
14
|
+
* @see pv.Constraint.position
|
15
|
+
*/
|
16
|
+
pv.Constraint = {};
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Applies this constraint to the specified particles.
|
20
|
+
*
|
21
|
+
* @function
|
22
|
+
* @name pv.Constraint.prototype.apply
|
23
|
+
* @param {pv.Particle} particles particles to which to apply this constraint.
|
24
|
+
* @param {pv.Quadtree} q a quadtree for spatial acceleration.
|
25
|
+
* @returns {pv.Constraint} this.
|
26
|
+
*/
|
@@ -0,0 +1,49 @@
|
|
1
|
+
/**
|
2
|
+
* Constructs a new drag force with the specified constant.
|
3
|
+
*
|
4
|
+
* @class Implements a drag force, simulating friction. The drag force is
|
5
|
+
* applied in the opposite direction of the particle's velocity. Since Position
|
6
|
+
* Verlet integration does not track velocities explicitly, the error term with
|
7
|
+
* this estimate of velocity is fairly high, so the drag force may be
|
8
|
+
* inaccurate.
|
9
|
+
*
|
10
|
+
* @extends pv.Force
|
11
|
+
* @param {number} k the drag constant.
|
12
|
+
* @see #constant
|
13
|
+
*/
|
14
|
+
pv.Force.drag = function(k) {
|
15
|
+
var force = {};
|
16
|
+
|
17
|
+
if (!arguments.length) k = .1; // default drag constant
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Sets or gets the drag constant, in the range [0,1]. The default drag
|
21
|
+
* constant is 0.1. The drag forces scales linearly with the particle's
|
22
|
+
* velocity based on the given drag constant.
|
23
|
+
*
|
24
|
+
* @function
|
25
|
+
* @name pv.Force.drag.prototype.constant
|
26
|
+
* @param {number} x the new drag constant.
|
27
|
+
* @returns {pv.Force.drag} this, or the current drag constant.
|
28
|
+
*/
|
29
|
+
force.constant = function(x) {
|
30
|
+
if (arguments.length) { k = x; return force; }
|
31
|
+
return k;
|
32
|
+
};
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Applies this force to the specified particles.
|
36
|
+
*
|
37
|
+
* @function
|
38
|
+
* @name pv.Force.drag.prototype.apply
|
39
|
+
* @param {pv.Particle} particles particles to which to apply this force.
|
40
|
+
*/
|
41
|
+
force.apply = function(particles) {
|
42
|
+
if (k) for (var p = particles; p; p = p.next) {
|
43
|
+
p.fx -= k * p.vx;
|
44
|
+
p.fy -= k * p.vy;
|
45
|
+
}
|
46
|
+
};
|
47
|
+
|
48
|
+
return force;
|
49
|
+
};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
/**
|
2
|
+
* Abstract; see an implementing class.
|
3
|
+
*
|
4
|
+
* @class Represents a force that acts on particles. Note that this interface
|
5
|
+
* does not specify how to bind a force to specific particles; in general,
|
6
|
+
* forces are applied globally to all particles. However, some forces may be
|
7
|
+
* applied to specific particles or between particles, such as spring forces,
|
8
|
+
* through additional specialization.
|
9
|
+
*
|
10
|
+
* @see pv.Simulation
|
11
|
+
* @see pv.Particle
|
12
|
+
* @see pv.Force.charge
|
13
|
+
* @see pv.Force.drag
|
14
|
+
* @see pv.Force.spring
|
15
|
+
*/
|
16
|
+
pv.Force = {};
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Applies this force to the specified particles.
|
20
|
+
*
|
21
|
+
* @function
|
22
|
+
* @name pv.Force.prototype.apply
|
23
|
+
* @param {pv.Particle} particles particles to which to apply this force.
|
24
|
+
* @param {pv.Quadtree} q a quadtree for spatial acceleration.
|
25
|
+
*/
|
@@ -0,0 +1,81 @@
|
|
1
|
+
/**
|
2
|
+
* Abstract; not implemented. There is no explicit constructor; this class
|
3
|
+
* merely serves to document the attributes that are used on particles in
|
4
|
+
* physics simulations.
|
5
|
+
*
|
6
|
+
* @class A weighted particle that can participate in a force simulation.
|
7
|
+
*
|
8
|
+
* @name pv.Particle
|
9
|
+
*/
|
10
|
+
|
11
|
+
/**
|
12
|
+
* The next particle in the simulation. Particles form a singly-linked list.
|
13
|
+
*
|
14
|
+
* @field
|
15
|
+
* @type pv.Particle
|
16
|
+
* @name pv.Particle.prototype.next
|
17
|
+
*/
|
18
|
+
|
19
|
+
/**
|
20
|
+
* The <i>x</i>-position of the particle.
|
21
|
+
*
|
22
|
+
* @field
|
23
|
+
* @type number
|
24
|
+
* @name pv.Particle.prototype.x
|
25
|
+
*/
|
26
|
+
|
27
|
+
/**
|
28
|
+
* The <i>y</i>-position of the particle.
|
29
|
+
*
|
30
|
+
* @field
|
31
|
+
* @type number
|
32
|
+
* @name pv.Particle.prototype.y
|
33
|
+
*/
|
34
|
+
|
35
|
+
/**
|
36
|
+
* The <i>x</i>-velocity of the particle.
|
37
|
+
*
|
38
|
+
* @field
|
39
|
+
* @type number
|
40
|
+
* @name pv.Particle.prototype.vx
|
41
|
+
*/
|
42
|
+
|
43
|
+
/**
|
44
|
+
* The <i>y</i>-velocity of the particle.
|
45
|
+
*
|
46
|
+
* @field
|
47
|
+
* @type number
|
48
|
+
* @name pv.Particle.prototype.vy
|
49
|
+
*/
|
50
|
+
|
51
|
+
/**
|
52
|
+
* The <i>x</i>-position of the particle at -dt.
|
53
|
+
*
|
54
|
+
* @field
|
55
|
+
* @type number
|
56
|
+
* @name pv.Particle.prototype.px
|
57
|
+
*/
|
58
|
+
|
59
|
+
/**
|
60
|
+
* The <i>y</i>-position of the particle at -dt.
|
61
|
+
*
|
62
|
+
* @field
|
63
|
+
* @type number
|
64
|
+
* @name pv.Particle.prototype.py
|
65
|
+
*/
|
66
|
+
|
67
|
+
/**
|
68
|
+
* The <i>x</i>-force on the particle.
|
69
|
+
*
|
70
|
+
* @field
|
71
|
+
* @type number
|
72
|
+
* @name pv.Particle.prototype.fx
|
73
|
+
*/
|
74
|
+
|
75
|
+
/**
|
76
|
+
* The <i>y</i>-force on the particle.
|
77
|
+
*
|
78
|
+
* @field
|
79
|
+
* @type number
|
80
|
+
* @name pv.Particle.prototype.fy
|
81
|
+
*/
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/**
|
2
|
+
* Constructs a default position constraint using the <tt>fix</tt> attribute.
|
3
|
+
* An optional position function can be specified to determine how the fixed
|
4
|
+
* position per-particle is determined.
|
5
|
+
*
|
6
|
+
* @class Constraints particles to a fixed position. The fixed position per
|
7
|
+
* particle is determined using a given position function, which defaults to
|
8
|
+
* <tt>function(d) d.fix</tt>.
|
9
|
+
*
|
10
|
+
* <p>If the position function returns null, then no position constraint is
|
11
|
+
* applied to the given particle. Otherwise, the particle's position is set to
|
12
|
+
* the returned position, as expressed by a {@link pv.Vector}. (Note: the
|
13
|
+
* position does not need to be an instance of <tt>pv.Vector</tt>, but simply an
|
14
|
+
* object with <tt>x</tt> and <tt>y</tt> attributes.)
|
15
|
+
*
|
16
|
+
* <p>This constraint also supports a configurable alpha parameter, which
|
17
|
+
* defaults to 1. If the alpha parameter is in the range [0,1], then rather than
|
18
|
+
* setting the particle's new position directly to the position returned by the
|
19
|
+
* supplied position function, the particle's position is interpolated towards
|
20
|
+
* the fixed position. This results is a smooth (exponential) drift towards the
|
21
|
+
* fixed position, which can increase the stability of the physics simulation.
|
22
|
+
* In addition, the alpha parameter can be decayed over time, relaxing the
|
23
|
+
* position constraint, which helps to stabilize on an optimal solution.
|
24
|
+
*
|
25
|
+
* @param {function} [f] the position function.
|
26
|
+
*/
|
27
|
+
pv.Constraint.position = function(f) {
|
28
|
+
var a = 1, // default alpha
|
29
|
+
constraint = {};
|
30
|
+
|
31
|
+
if (!arguments.length) /** @ignore */ f = function(p) { return p.fix; };
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Sets or gets the alpha parameter for position interpolation. If the alpha
|
35
|
+
* parameter is in the range [0,1], then rather than setting the particle's
|
36
|
+
* new position directly to the position returned by the supplied position
|
37
|
+
* function, the particle's position is interpolated towards the fixed
|
38
|
+
* position.
|
39
|
+
*
|
40
|
+
* @function
|
41
|
+
* @name pv.Constraint.position.prototype.alpha
|
42
|
+
* @param {number} x the new alpha parameter, in the range [0,1].
|
43
|
+
* @returns {pv.Constraint.position} this.
|
44
|
+
*/
|
45
|
+
constraint.alpha = function(x) {
|
46
|
+
if (arguments.length) {
|
47
|
+
a = Number(x);
|
48
|
+
return constraint;
|
49
|
+
}
|
50
|
+
return a;
|
51
|
+
};
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Applies this constraint to the specified particles.
|
55
|
+
*
|
56
|
+
* @function
|
57
|
+
* @name pv.Constraint.position.prototype.apply
|
58
|
+
* @param {pv.Particle} particles particles to which to apply this constraint.
|
59
|
+
*/
|
60
|
+
constraint.apply = function(particles) {
|
61
|
+
for (var p = particles; p; p = p.next) {
|
62
|
+
var v = f(p);
|
63
|
+
if (v) {
|
64
|
+
p.x += (v.x - p.x) * a;
|
65
|
+
p.y += (v.y - p.y) * a;
|
66
|
+
p.fx = p.fy = p.vx = p.vy = 0;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
};
|
70
|
+
|
71
|
+
return constraint;
|
72
|
+
};
|
@@ -0,0 +1,195 @@
|
|
1
|
+
/**
|
2
|
+
* Constructs a new quadtree for the specified array of particles.
|
3
|
+
*
|
4
|
+
* @class Represents a quadtree: a two-dimensional recursive spatial
|
5
|
+
* subdivision. This particular implementation uses square partitions, dividing
|
6
|
+
* each square into four equally-sized squares. Each particle exists in a unique
|
7
|
+
* node; if multiple particles are in the same position, some particles may be
|
8
|
+
* stored on internal nodes rather than leaf nodes.
|
9
|
+
*
|
10
|
+
* <p>This quadtree can be used to accelerate various spatial operations, such
|
11
|
+
* as the Barnes-Hut approximation for computing n-body forces, or collision
|
12
|
+
* detection.
|
13
|
+
*
|
14
|
+
* @see pv.Force.charge
|
15
|
+
* @see pv.Constraint.collision
|
16
|
+
* @param {pv.Particle} particles the linked list of particles.
|
17
|
+
*/
|
18
|
+
pv.Quadtree = function(particles) {
|
19
|
+
var p;
|
20
|
+
|
21
|
+
/* Compute bounds. */
|
22
|
+
var x1 = Number.POSITIVE_INFINITY, y1 = x1,
|
23
|
+
x2 = Number.NEGATIVE_INFINITY, y2 = x2;
|
24
|
+
for (p = particles; p; p = p.next) {
|
25
|
+
if (p.x < x1) x1 = p.x;
|
26
|
+
if (p.y < y1) y1 = p.y;
|
27
|
+
if (p.x > x2) x2 = p.x;
|
28
|
+
if (p.y > y2) y2 = p.y;
|
29
|
+
}
|
30
|
+
|
31
|
+
/* Squarify the bounds. */
|
32
|
+
var dx = x2 - x1, dy = y2 - y1;
|
33
|
+
if (dx > dy) y2 = y1 + dx;
|
34
|
+
else x2 = x1 + dy;
|
35
|
+
this.xMin = x1;
|
36
|
+
this.yMin = y1;
|
37
|
+
this.xMax = x2;
|
38
|
+
this.yMax = y2;
|
39
|
+
|
40
|
+
/**
|
41
|
+
* @ignore Recursively inserts the specified particle <i>p</i> at the node
|
42
|
+
* <i>n</i> or one of its descendants. The bounds are defined by [<i>x1</i>,
|
43
|
+
* <i>x2</i>] and [<i>y1</i>, <i>y2</i>].
|
44
|
+
*/
|
45
|
+
function insert(n, p, x1, y1, x2, y2) {
|
46
|
+
if (isNaN(p.x) || isNaN(p.y)) return; // ignore invalid particles
|
47
|
+
if (n.leaf) {
|
48
|
+
if (n.p) {
|
49
|
+
/*
|
50
|
+
* If the particle at this leaf node is at the same position as the new
|
51
|
+
* particle we are adding, we leave the particle associated with the
|
52
|
+
* internal node while adding the new particle to a child node. This
|
53
|
+
* avoids infinite recursion.
|
54
|
+
*/
|
55
|
+
if ((Math.abs(n.p.x - p.x) + Math.abs(n.p.y - p.y)) < .01) {
|
56
|
+
insertChild(n, p, x1, y1, x2, y2);
|
57
|
+
} else {
|
58
|
+
var v = n.p;
|
59
|
+
n.p = null;
|
60
|
+
insertChild(n, v, x1, y1, x2, y2);
|
61
|
+
insertChild(n, p, x1, y1, x2, y2);
|
62
|
+
}
|
63
|
+
} else {
|
64
|
+
n.p = p;
|
65
|
+
}
|
66
|
+
} else {
|
67
|
+
insertChild(n, p, x1, y1, x2, y2);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
/**
|
72
|
+
* @ignore Recursively inserts the specified particle <i>p</i> into a
|
73
|
+
* descendant of node <i>n</i>. The bounds are defined by [<i>x1</i>,
|
74
|
+
* <i>x2</i>] and [<i>y1</i>, <i>y2</i>].
|
75
|
+
*/
|
76
|
+
function insertChild(n, p, x1, y1, x2, y2) {
|
77
|
+
/* Compute the split point, and the quadrant in which to insert p. */
|
78
|
+
var sx = (x1 + x2) * .5,
|
79
|
+
sy = (y1 + y2) * .5,
|
80
|
+
right = p.x >= sx,
|
81
|
+
bottom = p.y >= sy;
|
82
|
+
|
83
|
+
/* Recursively insert into the child node. */
|
84
|
+
n.leaf = false;
|
85
|
+
switch ((bottom << 1) + right) {
|
86
|
+
case 0: n = n.c1 || (n.c1 = new pv.Quadtree.Node()); break;
|
87
|
+
case 1: n = n.c2 || (n.c2 = new pv.Quadtree.Node()); break;
|
88
|
+
case 2: n = n.c3 || (n.c3 = new pv.Quadtree.Node()); break;
|
89
|
+
case 3: n = n.c4 || (n.c4 = new pv.Quadtree.Node()); break;
|
90
|
+
}
|
91
|
+
|
92
|
+
/* Update the bounds as we recurse. */
|
93
|
+
if (right) x1 = sx; else x2 = sx;
|
94
|
+
if (bottom) y1 = sy; else y2 = sy;
|
95
|
+
insert(n, p, x1, y1, x2, y2);
|
96
|
+
}
|
97
|
+
|
98
|
+
/* Insert all particles. */
|
99
|
+
this.root = new pv.Quadtree.Node();
|
100
|
+
for (p = particles; p; p = p.next) insert(this.root, p, x1, y1, x2, y2);
|
101
|
+
};
|
102
|
+
|
103
|
+
/**
|
104
|
+
* The root node of the quadtree.
|
105
|
+
*
|
106
|
+
* @type pv.Quadtree.Node
|
107
|
+
* @name pv.Quadtree.prototype.root
|
108
|
+
*/
|
109
|
+
|
110
|
+
/**
|
111
|
+
* The minimum x-coordinate value of all contained particles.
|
112
|
+
*
|
113
|
+
* @type number
|
114
|
+
* @name pv.Quadtree.prototype.xMin
|
115
|
+
*/
|
116
|
+
|
117
|
+
/**
|
118
|
+
* The maximum x-coordinate value of all contained particles.
|
119
|
+
*
|
120
|
+
* @type number
|
121
|
+
* @name pv.Quadtree.prototype.xMax
|
122
|
+
*/
|
123
|
+
|
124
|
+
/**
|
125
|
+
* The minimum y-coordinate value of all contained particles.
|
126
|
+
*
|
127
|
+
* @type number
|
128
|
+
* @name pv.Quadtree.prototype.yMin
|
129
|
+
*/
|
130
|
+
|
131
|
+
/**
|
132
|
+
* The maximum y-coordinate value of all contained particles.
|
133
|
+
*
|
134
|
+
* @type number
|
135
|
+
* @name pv.Quadtree.prototype.yMax
|
136
|
+
*/
|
137
|
+
|
138
|
+
/**
|
139
|
+
* Constructs a new node.
|
140
|
+
*
|
141
|
+
* @class A node in a quadtree.
|
142
|
+
*
|
143
|
+
* @see pv.Quadtree
|
144
|
+
*/
|
145
|
+
pv.Quadtree.Node = function() {
|
146
|
+
/*
|
147
|
+
* Prepopulating all attributes significantly increases performance! Also,
|
148
|
+
* letting the language interpreter manage garbage collection was moderately
|
149
|
+
* faster than creating a cache pool.
|
150
|
+
*/
|
151
|
+
this.leaf = true;
|
152
|
+
this.c1 = null;
|
153
|
+
this.c2 = null;
|
154
|
+
this.c3 = null;
|
155
|
+
this.c4 = null;
|
156
|
+
this.p = null;
|
157
|
+
};
|
158
|
+
|
159
|
+
/**
|
160
|
+
* True if this node is a leaf node; i.e., it has no children. Note that both
|
161
|
+
* leaf nodes and non-leaf (internal) nodes may have associated particles. If
|
162
|
+
* this is a non-leaf node, then at least one of {@link #c1}, {@link #c2},
|
163
|
+
* {@link #c3} or {@link #c4} is guaranteed to be non-null.
|
164
|
+
*
|
165
|
+
* @type boolean
|
166
|
+
* @name pv.Quadtree.Node.prototype.leaf
|
167
|
+
*/
|
168
|
+
|
169
|
+
/**
|
170
|
+
* The particle associated with this node, if any.
|
171
|
+
*
|
172
|
+
* @type pv.Particle
|
173
|
+
* @name pv.Quadtree.Node.prototype.p
|
174
|
+
*/
|
175
|
+
|
176
|
+
/**
|
177
|
+
* The child node for the second quadrant, if any.
|
178
|
+
*
|
179
|
+
* @type pv.Quadtree.Node
|
180
|
+
* @name pv.Quadtree.Node.prototype.c2
|
181
|
+
*/
|
182
|
+
|
183
|
+
/**
|
184
|
+
* The child node for the third quadrant, if any.
|
185
|
+
*
|
186
|
+
* @type pv.Quadtree.Node
|
187
|
+
* @name pv.Quadtree.Node.prototype.c3
|
188
|
+
*/
|
189
|
+
|
190
|
+
/**
|
191
|
+
* The child node for the fourth quadrant, if any.
|
192
|
+
*
|
193
|
+
* @type pv.Quadtree.Node
|
194
|
+
* @name pv.Quadtree.Node.prototype.c4
|
195
|
+
*/
|