Page 1 of 1

Feature: Unicode in shape names

Posted: Tue Nov 14, 2017 11:54 pm
by kipling
In https://contextfreeart.org/gallery2/#design/3878 I managed to use ♡ as a rule name, and it works — both in ContextFree.app (Mac OS X) and in the gallery. Is this intended? Will it behave nicely on other platforms?
If you decide that it is a feature, can we have ● and ■ and ▲ as synonyms for CIRCLE and SQUARE and TRIANGLE? (This is not just for code golf.)
If you decide that it is a bug, I'll have to go and edit that cfdg file. 🙁

Re: Feature: Unicode in shape names

Posted: Wed Nov 15, 2017 12:15 am
by kipling
Further experimentation:

Code: Select all

startshape 🖖

💩💩=.5
∡=120

shape 🖖{
	CIRCLE[]
	loop 3 [[ r ∡ ]] 🖖[s 💩💩 x 1 ]
	}

Re: Feature: Unicode in shape names

Posted: Wed Nov 15, 2017 12:22 am
by kipling

Code: Select all

startshape 🌳

■=SQUARE

ξ=sqrt(1.25)-.5 // mmm ... √(1.25)-.5 doesn't work.
θ=60

shape 🌳{
	■[[s .1 1 y .5]]
	loop 2 [[ f 90 ]] 🌳[[ y 1 r θ s ξ]]
	}

Re: Feature: Unicode in shape names

Posted: Wed Nov 15, 2017 12:56 am
by MtnViewJohn
It's not a bug! Unicode is allowed in shape names and in included/imported cfdg filenames. CFDG files are UTF-8 encoded. It's a bit of a hack because the parser library does not understand UTF-8. There are a few unicode tokens too: ≤, ≥, ≠, …, ±, ∞, and π. Pretty much any unicode character is allowed in a shape name except for these 6 (π is allowed in shape names). You can't name a shape '1', but you can name a shape ①,1,𝟏,𝟷,𝟭,𝟙,¹,₁,⑴,⒈,⓵, or ❶.

I suppose I should create a design Pile of Poop, 💩.

I like your idea for CIRCLE, SQUARE, and TRIANGLE synonyms. I could easily add them the same way that π is a synonym for 3.1416.

Re: Feature: Unicode in shape names

Posted: Wed Nov 15, 2017 2:14 am
by kipling
Yes I had previously caught that that ≠±∞≤≥π have meaning.
For the shapes, there is a macosx keystroke for • (⌥8), but there are also ●⚫️⬤⚫︎ which have no keystrokes.
There are no keystrokes for ◾️ or ▲ AFAIK.
However it is possible to have text input settings on an individual macosx computer so that something like \triangle gets converted to ▲.
Not sure that any of this is *that* useful.

Re: Feature: Unicode in shape names

Posted: Wed Nov 15, 2017 9:26 am
by MtnViewJohn
Not terribly useful, but fun. And it saves 3-5 bytes in code golf. I can add keyboard shortcuts for the three shapes, like I did for the other 7.

Re: Feature: Unicode in shape names

Posted: Thu Nov 16, 2017 5:38 am
by kipling
Fair enough.
I fully support your efforts for further CF glory on codegolf.stackexchange

Surely 💩 should be a primitive. 😄

Re: Feature: Unicode in shape names

Posted: Thu Nov 16, 2017 6:50 am
by kipling
Ideas for synonyms:

On Mac OS X keyboard √ ∆ % could have obvious meanings (oops — you've done %)
Other unicode symbols ⟦ ⟧ ⎡⎤⎣⎦ ⸬ ² ⅛ α could have obvious meaning.

further random ideas:

loop=∑ (⌥w) or Σ (Sigma) … since loop functions as "image summation".
shape=∫ (⌥b), or maybe ß (⌥s) however,
startshape=ß or § (save 9 bytes on all designs!)
rule=ρ (no keystroke) or ® (⌥r) or maybe → would look nice in v3 code
(sqrt(5)+1)/2=φ=ϕ
transform = τ, or 2*π=τ (no, don't start that argument)
skew=▱ or #
saturation=§
MOVETO=µ
LINETO=— (em-dash) or λ
CURVETO=~ (bezier curve - tilde) or κ
ARCTO=⌣ or α
STROKE=✎
FILL=Φ or paint bucket (can't find)

It seems that standard ternary •?•:• doesn't exist, but if(•,•,•) does. Is this a parsing issue? Could ¿•,•,•? be a synonym for if(…)? Is there a use for ‽?

Re: Feature: Unicode in shape names

Posted: Fri Nov 17, 2017 12:31 am
by MtnViewJohn
Let's not slide down this slippery slope.

The Bison parser is capable of parsing a ternary operator but the ternary operator can be ambiguous while the if function syntax is never ambiguous. If C had lazy function argument evaluation then they would never have bothered with the ternary operator.