Transparency in CLJS

16 views
Skip to first unread message

mmb90

unread,
Jul 17, 2017, 12:09:51 PM7/17/17
to clj-processing
Trying to fill a shape with alpha in clojurescript. Here’s my attempt that doesn’t work, what am I doing wrong?


(ns my.core
 
(:require [quil.core :as q :include-macros true]
           
[quil.middleware :as m]))


(defn setup []
 
(q/frame-rate 30)
 
{:graphic (q/create-graphics 500 500)})


(defn draw-state [state]
 
(q/with-graphics (:graphic state)
   
(q/background 240)
   
;; With the 0.5 the shape has no fill. Remove the 0.5 and it is a solid color
   
(q/fill 100 140 255 0.5)
   
(q/ellipse 100 100 100 100))
   
(q/image (:graphic state) 0 0))


(q/defsketch my
 
:host "host"
 
:size [500 500]
 
:setup setup
 
:draw draw-state
 
:middleware [m/fun-mode])


mmb90

unread,
Jul 18, 2017, 10:57:24 AM7/18/17
to clj-processing
Turns out the opacity is given with a range of 0-255 where I assumed it would be 0-1.0. So I don't want 0.5 I want 127. Works great.
Reply all
Reply to author
Forward
0 new messages