<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Texturing on blog</title>
    <link>https://jpcharalambosh.co/tags/texturing/</link>
    <description>Recent content in Texturing on blog</description>
    <image>
      <title>blog</title>
      <url>https://jpcharalambosh.co/papermod-cover.png</url>
      <link>https://jpcharalambosh.co/papermod-cover.png</link>
    </image>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Wed, 05 Jun 2024 20:08:45 -0500</lastBuildDate>
    <atom:link href="https://jpcharalambosh.co/tags/texturing/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Platonic Cells</title>
      <link>https://jpcharalambosh.co/posts/platonic_cells/</link>
      <pubDate>Wed, 05 Jun 2024 20:08:45 -0500</pubDate>
      <guid>https://jpcharalambosh.co/posts/platonic_cells/</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This demo illustrates new capabilities of the WebGL mode in the &lt;a href=&#34;https://github.com/objetos/p5.quadrille.js/tree/next&#34;&gt;next&lt;/a&gt; major upcoming version of p5.quadrille.js, currently under development. It showcases how &lt;a href=&#34;https://jpcharalambosh.co/posts/platonic/&#34;&gt;Platonic solids&lt;/a&gt; can be stored in quadrille cells and rendered using either immediate or retained mode with the &lt;a href=&#34;https://github.com/VisualComputing/p5.platonic&#34;&gt;p5.platonic&lt;/a&gt; library.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id=&#34;platonic-cells&#34;&gt;Platonic Cells&lt;/h1&gt;
&lt;p&gt;Platonic cells are cell functions (&lt;code&gt;cellFn&lt;/code&gt;) that implement the filling of Platonic solid cells in a quadrille &lt;code&gt;game&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;retained-mode&#34;&gt;Retained Mode&lt;/h2&gt;
&lt;p&gt;(&lt;strong&gt;mouse&lt;/strong&gt; click to clear/add Platonic solids, drag to navigate; &lt;strong&gt;press&lt;/strong&gt; &lt;code&gt;s&lt;/code&gt; (or &lt;code&gt;c&lt;/code&gt;) to save)&lt;br&gt;














&lt;iframe
  id=&#34;&#34;
  style=&#34;width:525px; height:525px&#34;
  srcdoc=&#34;
        &lt;!DOCTYPE html&gt;
        &lt;html&gt;
          &lt;head&gt;
            &lt;script src=&#39;https://cdn.jsdelivr.net/npm/p5@1.11.10/lib/p5.min.js&#39;&gt;&lt;/script&gt;
            
            
            
            
            
            &lt;script src=https://cdn.jsdelivr.net/gh/VisualComputing/p5.platonic/p5.platonic.min.js&gt;&lt;/script&gt;
            &lt;script src=https://cdn.jsdelivr.net/gh/objetos/p5.quadrille.js/p5.quadrille.min.js&gt;&lt;/script&gt;
            
            
            
            &lt;script&gt;
              
`use strict`
let cnv
let game, solids
let font
let images = []
const r = 5, c = 5, l = Quadrille.cellLength

function preload() {
  font = loadFont(&amp;#39;noto_sans.ttf&amp;#39;)
  for (let i = 1; i &amp;lt;= 10; i&amp;#43;&amp;#43;) {
    images.push(loadImage(`p${i}.jpg`))
  }
}

function setup() {
  cnv = createCanvas(r * l, c * l, WEBGL)
  solids = createQuadrille(r, c)
  const args = [l / 2, true, [&amp;#39;yellow&amp;#39;, &amp;#39;blue&amp;#39;, &amp;#39;red&amp;#39;,
                              &amp;#39;cyan&amp;#39;, &amp;#39;magenta&amp;#39;, &amp;#39;yellow&amp;#39;]]
  visitQuadrille(solids, (row, col) =&amp;gt; solids.fill(row, col,
                                       platonicGeometry(...args)))
  game = createQuadrille(5, 5)
  visitQuadrille(game, (row, col) =&amp;gt; game.fill(row, col, random(images)))
  game.rand(15).rand(10, cellFn)
}

function draw() {
  background(&amp;#39;Gold&amp;#39;)
  drawQuadrille(game, {
    textFont: font,
    origin: CORNER,
    options: { origin: CENTER }
  })
}

function cellFn({ row, col }) {
  push()
  background(&amp;#39;black&amp;#39;)
  stroke(&amp;#39;lime&amp;#39;)
  fill(&amp;#39;blue&amp;#39;)
  rotateX(millis() * 0.001)
  rotateY(millis() * 0.001)
  rotateZ(millis() * 0.001)
  model(solids.read(row, col))
  pop()
}

function mouseClicked() {
  const row = game.mouseRow
  const col = game.mouseCol
  game.isEmpty(row, col) ? game.fill(row, col, cellFn) : game.clear(row, col)
}

function keyPressed() {
  key === &amp;#39;s&amp;#39; &amp;amp;&amp;amp; game.toImage(&amp;#39;game.png&amp;#39;, {
    textFont: font,
    origin: CORNER,
    options: { origin: CENTER }
  })
  key === &amp;#39;c&amp;#39; &amp;amp;&amp;amp; save(cnv, &amp;#39;platonic_cells.png&amp;#39;)
}

const mouseWheel = () =&amp;gt; false

            &lt;/script&gt;
          &lt;/head&gt;
          &lt;body&gt;
          &lt;/body&gt;
        &lt;/html&gt;
      &#34;
&gt;&lt;/iframe&gt;
&lt;/p&gt;</description>
    </item>
    <item>
      <title>Game of Life Texturing</title>
      <link>https://jpcharalambosh.co/posts/game_of_life/</link>
      <pubDate>Sun, 08 Oct 2023 15:46:53 -0500</pubDate>
      <guid>https://jpcharalambosh.co/posts/game_of_life/</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Before diving into development, thoroughly reading the &lt;a href=&#34;https://objetos.github.io/p5.quadrille.js/&#34;&gt;Quadrille API documentation&lt;/a&gt; is key to efficient coding, preventing mistakes, and ensuring optimal performance. By acquainting yourself with the API&amp;rsquo;s nuances, you set the stage for informed decision-making, seamless collaboration, and a smoother development journey.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The following demo illustrates the &lt;a href=&#34;https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life&#34;&gt;game of life&lt;/a&gt; using a &lt;a href=&#34;https://conwaylife.com/wiki/Pentadecathlon&#34;&gt;pentadecathlon&lt;/a&gt; pattern as its initial seed, rendered as a surface texture on p5 &lt;a href=&#34;https://p5js.org/reference/#group-Shape&#34;&gt;3D shapes&lt;/a&gt; in &lt;a href=&#34;https://p5js.org/reference/#/p5/WEBGL&#34;&gt;WEBGL&lt;/a&gt; mode:&lt;/p&gt;
&lt;p&gt;(mouse drag to navigate; [1..7] keys change shape, other keys reset)&lt;br&gt;














&lt;iframe
  id=&#34;&#34;
  style=&#34;width:425px; height:425px&#34;
  srcdoc=&#34;
        &lt;!DOCTYPE html&gt;
        &lt;html&gt;
          &lt;head&gt;
            &lt;script src=&#39;https://cdn.jsdelivr.net/npm/p5@1.11.10/lib/p5.min.js&#39;&gt;&lt;/script&gt;
            
            
            
            
            
            &lt;script src=https://cdn.jsdelivr.net/gh/objetos/p5.quadrille.js/p5.quadrille.min.js&gt;&lt;/script&gt;
            
            
            
            
            &lt;script&gt;
              
`use strict`;
Quadrille.cellLength = 20
let game, pattern
let life
let graphics
let mode = 1
const shapes = {
  1: () =&amp;gt; plane(width, height),
  2: () =&amp;gt; sphere(100),
  3: () =&amp;gt; torus(100, 50),
  4: () =&amp;gt; box(200),
  5: () =&amp;gt; cylinder(100, 200, 24, 1, false, false),
  6: () =&amp;gt; cone(100, 200, 24, 1, false),
  7: () =&amp;gt; ellipsoid(100, 180)
}

function setup() {
  game = createQuadrille(20, 20)
  life = color(&amp;#39;lime&amp;#39;)
  pattern = createQuadrille(3, 16252911n, life)
  game = Quadrille.or(game, pattern, 6, 8)
  createCanvas(game.width  * Quadrille.cellLength,
               game.height * Quadrille.cellLength,
               WEBGL)
  graphics = createGraphics(game.width  * Quadrille.cellLength,
                            game.height * Quadrille.cellLength)
  update()
}

function draw() {
  background(&amp;#39;yellow&amp;#39;)
  orbitControl()
  frameCount % 20 === 0 &amp;amp;&amp;amp; update()
  noStroke()
  shapes[mode] ? shapes[mode]() : shapes[1]()
}

function update() {
  const next = game.clone()
  visitQuadrille(game, (row, col) =&amp;gt; {
                       const order = game.ring(row, col).order
                       game.isFilled(row, col) ?
                       (order &amp;lt; 3 || order &amp;gt; 4) &amp;amp;&amp;amp; next.clear(row, col) :
                       order === 3 &amp;amp;&amp;amp; next.fill(row, col, life) })
  game = next
  graphics.background(&amp;#39;blue&amp;#39;)
  drawQuadrille(game, { graphics, outline: &amp;#39;magenta&amp;#39; })
  texture(graphics)
}

function keyPressed() {
  mode = &amp;#43;key
  game.clear()
  game = Quadrille.or(game, pattern, 6, 8)
}

            &lt;/script&gt;
          &lt;/head&gt;
          &lt;body&gt;
          &lt;/body&gt;
        &lt;/html&gt;
      &#34;
&gt;&lt;/iframe&gt;
&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
