Notebook - Welcome to Notebook

Contact/Report Bugs
You can contact me at: bkenwright@xbdev.net












D3 SVG Transforms The ability to transform SVG graphics enable you to manipulate elements on a higher level such as scaling rotating skewing and translating Introduction to SVG Transforms SVG transforms are set through the transform attribute The various transform options available include Rotation takes three options which refer to the position of rotation cx and cy and the angle If cx and cy are not specified the position of rotation is taken to be the origin of the shape that is the centre transform rotate 60 Translation takes two options the translation along the x and y axis The the options are referred to as tx and ty transform translate 20 50 Scale takes to options for the scaling along the x and y axis The options are sx and sy Skew skew is made of seperate SkewX and SkewY The skew option is a single number which refers to the skew angle transform skewx 10 Importantly the different transforms can be combined to form more complex transformations Also the order the transforms are conncatenated matters e g translation then rotation is not the same as rotation then translation HTML SVG Transform Examples Rotation Create a simple SVG rectangle and rotate it about 20 degrees DOCTYPE html html head script type text javascript src https d3js org d3 v7 min js script head body style height 50pt svg width 100 height 100 rect x 60 y 20 width 40 height 10 fill blue transform rotate 20 rect svg script script body html Translation Create a simple SVG rectangle and translate it by 20 pixels along the x axis and 10 pixels along the y axis Note if you translate the shape too far e g translate by 100 along the x axis it will leave the SVG container region and be clipped i e you won t see the rectangle DOCTYPE html html head script type text javascript src https d3js org d3 v7 min js script head body style height 50pt svg width 100 height 100 rect x 60 y 20 width 40 height 10 fill blue transform translate 20 10 rect svg script script body html Scale Create a simple SVG rectangle and scale it along the x and y axis DOCTYPE html html head script type text javascript src https d3js org d3 v7 min js script head body style height 100pt svg width 100 height 100 rect x 60 y 20 width 40 height 10 fill blue transform scale 1 3 rect svg script script body html Groups SVG elements can be grouped together using the g tag They essentially become a single shape that can be manipulated as one object So instead of manipulating lots of individual SVG elements a single group can be manipulated g rect x 60 y 20 width 40 height 10 fill blue rect rect x 160 y 10 width 20 height 10 fill green rect g You re able to apply transforms to groups and the transforms are applied to all of the contained elements DOCTYPE html html head script type text javascript src https d3js org d3 v7 min js script head body style height 100pt svg width 100 height 100 g transform scale 1 1 original group rect x 60 y 20 width 40 height 10 fill blue rect circle cx 10 cy 10 r 10 fill red g g transform scale 1 3 create copy but transform the group rect x 60 y 20 width 40 height 10 fill blue rect circle cx 10 cy 10 r 10 fill red g svg script script body html D3 SVG Transforms To apply a transform to one or more SVG elements with D3 you simply select the items for example using their tag name or ids You then set their transform attribute DOCTYPE html html head script type text javascript src https d3js org d3 v7 min js script head body style height 100pt svg width 200 height 200 svg script d3 select svg append rect attr x 30 attr y 20 attr width 100 attr height 50 attr fill green attr transform rotate 10 script body html DOCTYPE html html head script type text javascript src https d3js org d3 v7 min js script head body style height 100pt script d3 select body append svg attr width 300 attr height 300 append rect attr x 30 attr y 20 attr width 100 attr height 50 attr fill green attr transform rotate 10 script body html DOCTYPE html html head script type text javascript src https d3js org d3 v7 min js script head body style height 100pt script let svg d3 select body append svg attr width 300 attr height 300 let group svg append g attr transform translate 30 50 rotate 20 truncate transforms group append rect attr x 30 attr y 20 attr width 100 attr height 50 attr fill green group append circle attr cx 5 attr cy 5 attr r 30 attr fill blue script body html D3 Transform Library Due to the modular nature of D3 it also provides a seperate library to manage transform attributes The D3 transform library has methods for all types of transformations Some of the methods include transform translate scale and rotate To use the D3 transform library you need to include the d3 transform JavaScript library DOCTYPE html html head script type text javascript src https d3js org d3 v7 min js script script type text javascript src https cdnjs cloudflare com ajax libs d3 transform 1 0 4 d3 transform min js script head body style height 100pt script let svg d3 select body append svg attr width 300 attr height 300 let d3t d3Transform translate 20 10 scale 0 5 1 rotate 10 svg append rect attr x 30 attr y 20 attr width 100 attr height 50 attr fill pink attr transform d3t script body html To use the d3 transform you 1 include the JavaScript module d3 transform js or minimized version d3 transform min js 2 you construct a transform using the d3Transform method chain individual transforms onto the end 3 you apply the transform to the SVG by attaching the result from the d3Transform to the graphical element

circle cx 10 cy 10 r 10 fill red g g transform scale 1 3 create copy but transform the group rect x 60 y 20 width 40 height 10 fill blue rect circle cx 10 cy 10 r 10 fill red g svg script script body html D3 SVG Transforms To apply a transform to one or more SVG elements with D3 you simply select the items for example using their tag name or ids You then set their transform attribute DOCTYPE html html head script type text javascript src https d3js org d3 v7 min js script head body style height 100pt svg width 200 height 200 svg script d3 select svg append rect attr x 30 attr y 20 attr width 100 attr height 50 attr fill green attr transform rotate 10 script body html DOCTYPE html html head script type text javascript src https d3js org d3 v7 min js script head body style height 100pt script d3 select body append svg attr width 300 attr height 300 append rect attr x 30 attr y 20 attr width 100 attr height 50 attr fill green attr transform rotate 10 script body html DOCTYPE html html head script type text javascript src https d3js org d3 v7 min js script head body style height 100pt script let svg d3 select body append svg attr width 300 attr height 300 let group svg append g attr transform translate 30 50 rotate 20 truncate transforms group append rect attr x 30 attr y 20 attr width 100 attr height 50 attr fill green group append circle attr cx 5 attr cy 5 attr r 30 attr fill blue script body html D3 Transform Library Due to the modular nature of D3 it also provides a seperate library to manage transform attributes The D3 transform library has methods for all types of transformations Some of the methods include transform translate scale and rotate To use the D3 transform library you need to include the d3 transform JavaScript library DOCTYPE html html head script type text javascript src https d3js org d3 v7 min js script script type text javascript src https cdnjs cloudflare com ajax libs d3 transform 1 0 4 d3 transform min js script head body style height 100pt script let svg d3 select body append svg attr width 300 attr height 300 let d3t d3Transform translate 20 10 scale 0 5 1 rotate 10 svg append rect attr x 30 attr y 20 attr width 100 attr height 50 attr fill pink attr transform d3t script body html To use the d3 transform you 1 include the JavaScript module d3 transform js or minimized version d3 transform min js 2 you construct a transform using the d3Transform method chain individual transforms onto the end 3 you apply the transform to the SVG by attaching the result from the d3Transform to the graphical element

2dracecargame
3dplot
a4print
about
acecustomkeywords
acecustomkeywords2
acejs
acejs2
acejs3
aessecurity
angularjs
animbackgroundimage
aseformat
assert
asteroidsjs
backgrounds01
backgrounds02
backgrounds03
barnsleyfern
base26
base64
bib
binary
bodypix
bouncy
box2dweb
breakoutjs
browserversion
buslanes
busybutton
bvhreader
calendar
candycrush
candycrush2
canvas
canvas2
canvas3
canvasmandelbrot
canvasmandelbrot2
canvasnumbers
canvaszoom
capsule
car2dsimulationphysics
car2dsimulationphysics2
changingimages
chaosgame
chaosrandom
chaosrandomhisto
chaosrandomhisto2
chatgptusingopenai
chatgptusingopenai2
chatgptusingopenai3
checkboxtoggle
chinesetiles
classes
classfeatures
clipboardbutton
clonenode
codedropdown
codemirror
codemirror2
collada
colorpick
columnresizer
contextmenu
convnet
cookiebanner
countdown
countdown2
countdown3
crop
css3dbarchart
css3dbarchart2
css3dbook
css3dscene
csscube
csscube2
csscube3
csscubevideos
cssfilelist
csshas
csspulse
cssresizeaspect
cssspin
csszooming
csvtoarray
curleffect
customcheckbox
d3datamap
d3js
d3js10
d3js11
d3js2
d3js3
d3js4
d3js5
d3js6
d3js7
d3js8
d3js9
d3jsanimatedgrid
d3jsarctransition
d3jsarctransition2
d3jsaxis
d3jsaxischanging
d3jsbars
d3jsbrushing
d3jsbuslanes
d3jsbuslanes2
d3jscalendar
d3jscheat
d3jsclock
d3jscloudmap
d3jscogs
d3jscolors
d3jscovid
d3jscovid2
d3jscovid3
d3jsdashboard
d3jsdashboard2
d3jsdashboard3
d3jsdatakeyfunction
d3jsdensity
d3jsdragresizing
d3jsdragresizing2
d3jseach
d3jsease
d3jsevents
d3jsflower
d3jsforcegroups
d3jsforces
d3jsforces2
d3jsfractaltree
d3jsgeo
d3jsgroupbars
d3jsgroups
d3jsheatmap
d3jshex
d3jshierarchies
d3jshierarchies2
d3jshistogram
d3jshistogram2
d3jshistogram3
d3jshistogram4
d3jsinterpolate
d3jsjoin
d3jskmean
d3jskmean2
d3jsline
d3jsline2
d3jsline3
d3jsline4
d3jslinetransition
d3jslinetransition0
d3jslinetransition2
d3jsmaplocations
d3jsmaps
d3jsmaps2
d3jsmaps3
d3jsmisc
d3jsmisc2
d3jsmodule
d3jsmodulecolor
d3jsmultistyles
d3jsnobel
d3jsoverlappinggraphs
d3jspanel
d3jspie
d3jspieinterpolate
d3jssankey
d3jssankey2
d3jsscatter
d3jsshapes
d3jsslider
d3jsspending
d3jsspending2
d3jsspiralplot
d3jsspirograph
d3jssquare
d3jsstack
d3jsstackedbar
d3jsstackedbar2
d3jssunburst
d3jssunmoon
d3jssvglines
d3jssymbols
d3jstimelines
d3jsuk
d3jsvoronoi
d3scatterplot
d3timeline
d3timeline2
datalist
datamuse
date
dblclickhighlight
deviceorientation
dictionaryapi
dockermenu
doodlepad
downloadgif
dragdroplistitems
dragrotateresizediv
dragrotateresizediv2
dragrotateresizediv3
dragrotateresizediv4
dragrotateresizefontsize
dragselectbrush
drawlinesdiv
dropdown
dualquaternionimages
dynamicgrid
easefunctions
easeinterpolate3dplots
echart
echart2
echart3
encapsulation
epubviewer
errorstack
excalidraw
excalidraw2
excalidraw3
excalidraw5
expandable
faker
fetchplus
fileupload
fixedtopbar
fluiddynamics
fluiddynamics2
fluiddynamics3
fluidgaswatergl
fluidsmokedynamics
fluidsmokedynamics2
fonts
fonts2
footerbar
fractalmaze
fractalmaze2
fractalnoiseimage
fractals
fractals2
fractaltree
freesvg
fresnel
froggerjs
gantt
gifgiphyapi
gifhex
gltffromscratch
gradients
griditems
griditems2
griditems3
griditems4
gridworms
happyfont
heat
hexview
hexview2
highlight
icons
icons2
iframes
ik
imagetracertosvg
imgur
inputfile
invadersjs
ipynb
ipynb2
ipynb3
ipynb4
isbn13
isbn2
jpghex
jquery
jquery2
jqueryui
jqueryui2
jsdraganddrop
jsfire
jslint
jsobfuscate
jsraytracer
jstree
jstree2
jszip
jszipimages
jszipread
keyframes
l2dwidget
lcpsolverrigidbodies
lda
leftmenu
less
less2
lineargradientimage
linenumbers
loadimagefromfile
makepdf
maps
markdown
markdown2
markdown3
markdownalerts
markdownalerts2
markdownbookmarks
markovimage
markovpixelblocks
mathjax
matrices
matsandvects
mazegamejs
md2tex
metrotiles
metrowindows
milestones
minkowski2dboxes
misc
misc2
modules
myipdetails
mymodplotly
neataptic
networkstructures
networkstructures2
neural_network_drawshape
neural_network_plot_in_vs_out
neuralnetworkarrays
neuralnetworkblocks
neuralnetworksinewave
neuralnetworksnolibs
neuralnetworkvisualization
noiseflowfield
noiseflowfield2
noiseflowfield3
noiseflowfield4
noiseflowfield5
noiseflowfield6
number
obj
objtojson
openaiimages
opencv
opencv2
opencv3
opencv4
opencv5
outline
p2
p5fractalleaf
p5fractalshape
p5js
p5js2
p5js3
p5jsanimatedcover
p5mengercube
p5snowflakes
palindrome
panel
parallax
paste
paste2
pasteimgfromurl
pdfjs
pdfjs2
pdfkit
pdfkit2
pdfkit3
pdfkit4
pdfkit5
pdfkit6
pdfmake
pdfmake2
pdfmake3
pdfmake4
pdfmake5
pdfmake6
perlin
perlin2
perlin3
perspective
pexels
pixelgridpattern
playground
plotly
plotlynoise
plotlyranddist
plyloader
plyloader2
pngtxtencoder
pongjs
pptxgenjs
prettycode
prism
prn
problems
progress
pseudorandom
px2svg
python
quotes
racergame
random
randomcalcpie
randomgenerator
randomprofilepatterns
randomsinhistogram
randomstring
rating
rayambient
raymonte
raymonteprogressive
raymonteprogressive2
raymontewarmstart
reexpcross
reexpcross2
regex
regexbib
regexpfixbib
regexpmultiline
repeatwordsregexp
resizabletable
resizabletable2
revealjs
revealjs2
revealjsmulti
rigidbodyspheres2d
rigidbodyspheres3
rigidbodysphereslopetangent
ritalanguage
ritalanguage2
ritalanguage3
rotateimg
rough
rsapublicprivatekeys
rss
rss2
sankey
scrappingsvg
scrolltext
scrolltext2
scrollwidth
sdf2dcanvas
sdfboxinboxtwist
sdfchessbishop
sdfchessking
sdfchessknight
sdfchesspawn
sdfchessqueen
sdfchessrook
sdfhollowbox
setintervalexception
shareurl
shuffle
sidecomment
similarity
simplehighlighter
simpleplatformgamejs
sinecanvas
sliderpopout
slides
smileys
snowfall
snowman
sound
soundsignal
sphererayintersection
springs
sqljs
steganography
stereogram
stringmatching
sudoku
sudoku2
sudoku3
svg
svgchaos
svgdragresize
svgdragresize2
svgdragresize3
svgdragrotate
svgdrawing
svglines
svglines2
svglines3
svglines4
svglines5
svglinesmandelbrot
svgpathsdragrotate
svgpathsdragrotateresize
svgpie
svgpie2
svgpie3
svgpiepath
svgpiepath2
svgrandomfaces
symbols
synaptic
synaptic2
synonyms
tablerotatecells
tablerotatecells2
tablerotatecells3
tablerotatecells3b
tablerotatecells4
tables
tablezebra
tabularjs
tabularjs2
tabulatordownload
tagcanvas
tensorflowgan
tensorflowjs
tensorflowjsbasic
tensorflowjscnn
tensorflowjssinewave
tensorflowjssound
tensorflowmobilenet
tetrahedronfractal
tetrahedronfractalfolding
tetris
textarea
textareaauto
textareadiv
textareadiv2
textmaskimage
theirorthere
thesaurus
threejs
threejs2
threejs3
threejs4
threejsgltf
threejstokyo
tiles
toaster
tooltip
transition
transitionexpandabledropdown
treeview
treeview2
tricks
tshirt
tshirt2
tshirt3
turningpages
unsplash
urlblob
urlblob2
userdefinepoints
vector
videos
videos2
visualsort
vue
w2ui
w2uientertextdialog
webcam
webgl
webgl2
webgl3
webgl4
webgl5
webglbasic1
webglbasic2
webglcube
webglfov
webglfrustum
webgljson
webglleaves
webgllighting
webglorthographic
webglpoints1
webglpoints2
webglpoints3
webglsquare
webgltexture1
webgltexture2
webgltexture3
webgltransforms
webgltriangle
webgpu
webgpu10
webgpu11
webgpu12
webgpu13
webgpu14
webgpu15
webgpu16
webgpu17
webgpu2
webgpu3
webgpu4
webgpu5
webgpu6
webgpu7
webgpu8
webgpu9
webgpubars
webgpubuffers
webgpubuffers2
webgpucellnoise
webgpuclouds
webgpuclydescope
webgpucompute
webgpucubemap
webgpucubemap2
webgpudeferred
webgpudepth
webgpudof
webgpudrops
webgpuetha
webgpufire
webgpufractalcubes
webgpuglassrain
webgpugltf
webgpugltf2
webgpugrass
webgpugrid
webgpukernel
webgpukleinian
webgpulabupdates
webgpulighting
webgpumandelbrot
webgpumeta3d
webgpumetaballs
webgpumouse
webgpunoise
webgpunormalmapping
webgpuobj
webgpuparallax
webgpuparallax2
webgpuparallax3
webgpuparallaxshadow
webgpuparallaxshadow2
webgpupixel
webgpuquad
webgpuray1
webgpuraytracing
webgpuraytracing2
webgpushadowmaps
webgpushadowmaps2
webgpusierpinski2d
webgpusierpinski3d
webgpusinusoid
webgpussao
webgpustadiumobj
webgpuswirl
webgputestpipe3
webgputoon
webgputopology
webgputt
webgpuvolcloud
webgpuwater
webgpuwireframe
webgpuwireframe2
webpcanvas
webworkers
webxr
webxr2
wiggly
wikipedia